From 0dab9c7f9dab742f924f56dd02b6d00c2de88795 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 5 May 2010 02:03:53 -0400 Subject: [PATCH 1/6] compiler.cfg.intrinsics.allot: intrinsic was writing past the end of the array and this was causing problems for scheduling --- basis/compiler/cfg/intrinsics/allot/allot.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/compiler/cfg/intrinsics/allot/allot.factor b/basis/compiler/cfg/intrinsics/allot/allot.factor index 31a8a898bc..47f5be962e 100644 --- a/basis/compiler/cfg/intrinsics/allot/allot.factor +++ b/basis/compiler/cfg/intrinsics/allot/allot.factor @@ -78,5 +78,5 @@ IN: compiler.cfg.intrinsics.allot :> len 0 ^^load-literal :> elt len emit-allot-byte-array :> reg - len reg elt byte-array store-initial-element + len cell align cell /i reg elt byte-array store-initial-element ] [ drop node emit-primitive ] if ; From aaa706dd297e5fdb3c31595b9dbf0515ca9ceb67 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 5 May 2010 02:54:48 -0400 Subject: [PATCH 2/6] cpu.x86.32: fix load error --- basis/cpu/x86/32/32.factor | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 6d81d50691..d7c95ff15e 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -5,10 +5,11 @@ arrays kernel fry math namespaces sequences system layouts io vocabs.loader accessors init classes.struct combinators command-line make words compiler compiler.units compiler.constants compiler.alien compiler.codegen -compiler.codegen.fixup compiler.cfg.instructions -compiler.cfg.builder compiler.cfg.intrinsics -compiler.cfg.stack-frame cpu.x86.assembler -cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ; +compiler.codegen.alien compiler.codegen.fixup +compiler.cfg.instructions compiler.cfg.builder +compiler.cfg.intrinsics compiler.cfg.stack-frame +cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 +cpu.architecture vm ; FROM: layouts => cell ; IN: cpu.x86.32 @@ -358,7 +359,7 @@ M: x86.32 dummy-fp-params? f ; ! Dreadful M: struct-c-type flatten-c-type stack-params (flatten-c-type) ; M: long-long-type flatten-c-type stack-params (flatten-c-type) ; -M: c-type flatten-c-type dup rep>> int-rep? int-rep stack-params ? (flatten-c-type)) ; +M: c-type flatten-c-type dup rep>> int-rep? int-rep stack-params ? (flatten-c-type) ; M: x86.32 struct-return-pointer-type os linux? void* (stack-value) ? ; From 07092df20bffda5f1c703c6a76e52e1ea9ded55a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 5 May 2010 13:17:20 -0400 Subject: [PATCH 3/6] compiler.cfg.intrinsics.allot: fix intrinsic for real. Don't ever check in code without testing it --- basis/compiler/cfg/intrinsics/allot/allot.factor | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/compiler/cfg/intrinsics/allot/allot.factor b/basis/compiler/cfg/intrinsics/allot/allot.factor index 47f5be962e..dd3288cec3 100644 --- a/basis/compiler/cfg/intrinsics/allot/allot.factor +++ b/basis/compiler/cfg/intrinsics/allot/allot.factor @@ -4,7 +4,8 @@ USING: kernel math math.order sequences accessors arrays byte-arrays layouts classes.tuple.private fry locals compiler.tree.propagation.info compiler.cfg.hats compiler.cfg.instructions compiler.cfg.stacks -compiler.cfg.utilities compiler.cfg.builder.blocks ; +compiler.cfg.utilities compiler.cfg.builder.blocks +compiler.constants cpu.architecture alien.c-types ; IN: compiler.cfg.intrinsics.allot : ##set-slots ( regs obj class -- ) @@ -73,10 +74,16 @@ IN: compiler.cfg.intrinsics.allot dup node-input-infos first literal>> dup expand-(byte-array)? [ nip emit-allot-byte-array drop ] [ drop emit-primitive ] if ; +:: zero-byte-array ( len reg -- ) + 0 ^^load-literal :> elt + reg ^^tagged>integer :> reg + len 3 + 4 /i iota [ + [ elt reg ] dip 4 * byte-array-offset + int-rep uint ##store-memory-imm + ] each ; + :: emit- ( node -- ) node node-input-infos first literal>> dup expand-? [ :> len - 0 ^^load-literal :> elt len emit-allot-byte-array :> reg - len cell align cell /i reg elt byte-array store-initial-element + len reg zero-byte-array ] [ drop node emit-primitive ] if ; From 32ab6ca8d8cd3b8d4c5dc8b08f5a0b22389c963e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 5 May 2010 13:23:00 -0400 Subject: [PATCH 4/6] compiler.cfg.intrinsics: may as well use cell-size stores instead of 32-bit stores when initializing byte arrays --- basis/compiler/cfg/intrinsics/allot/allot.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/compiler/cfg/intrinsics/allot/allot.factor b/basis/compiler/cfg/intrinsics/allot/allot.factor index dd3288cec3..ff4c28a488 100644 --- a/basis/compiler/cfg/intrinsics/allot/allot.factor +++ b/basis/compiler/cfg/intrinsics/allot/allot.factor @@ -77,8 +77,8 @@ IN: compiler.cfg.intrinsics.allot :: zero-byte-array ( len reg -- ) 0 ^^load-literal :> elt reg ^^tagged>integer :> reg - len 3 + 4 /i iota [ - [ elt reg ] dip 4 * byte-array-offset + int-rep uint ##store-memory-imm + len cell align cell /i iota [ + [ elt reg ] dip cells byte-array-offset + int-rep f ##store-memory-imm ] each ; :: emit- ( node -- ) From 020c011d0049164ad6c6099f74266ae7986e2ba1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 5 May 2010 13:37:25 -0400 Subject: [PATCH 5/6] cpu.ppc: add missing cases to ##load/store-memory instructions --- basis/cpu/ppc/ppc.factor | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index d0571337c2..7e23a0b9c1 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -373,6 +373,9 @@ M:: ppc %box-displaced-alien ( dst displacement base temp base-class -- ) "end" resolve-label ] with-scope ; +: (%memory) ( val base displacement scale offset rep c-type -- base val displacement rep c-type ) + [ [ 0 assert= ] bi@ swapd ] 2dip ; inline + M: ppc %load-memory-imm ( dst base offset rep c-type -- ) [ { @@ -380,6 +383,8 @@ M: ppc %load-memory-imm ( dst base offset rep c-type -- ) { c:uchar [ LBZ ] } { c:short [ LHA ] } { c:ushort [ LHZ ] } + { c:int [ LWZ ] } + { c:uint [ LWZ ] } } case ] [ { @@ -389,9 +394,6 @@ M: ppc %load-memory-imm ( dst base offset rep c-type -- ) } case ] ?if ; -: (%memory) ( val base displacement scale offset rep c-type -- base val displacement rep c-type ) - [ [ 0 assert= ] bi@ swapd ] 2dip ; inline - M: ppc %load-memory ( dst base displacement scale offset rep c-type -- ) (%memory) [ { @@ -399,6 +401,8 @@ M: ppc %load-memory ( dst base displacement scale offset rep c-type -- ) { c:uchar [ LBZX ] } { c:short [ LHAX ] } { c:ushort [ LHZX ] } + { c:int [ LWZX ] } + { c:uint [ LWZX ] } } case ] [ { @@ -415,6 +419,8 @@ M: ppc %store-memory-imm ( src base offset rep c-type -- ) { c:uchar [ STB ] } { c:short [ STH ] } { c:ushort [ STH ] } + { c:int [ STW ] } + { c:uint [ STW ] } } case ] [ { @@ -431,6 +437,8 @@ M: ppc %store-memory ( src base displacement scale offset rep c-type -- ) { c:uchar [ STBX ] } { c:short [ STHX ] } { c:ushort [ STHX ] } + { c:int [ STWX ] } + { c:uint [ STWX ] } } case ] [ { From 23b353505398af82057ac69c26615699530bfab8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 5 May 2010 02:06:03 -0500 Subject: [PATCH 6/6] Fix typo in between? stack effect docs --- core/math/order/order-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/order/order-docs.factor b/core/math/order/order-docs.factor index 418107fcd1..4c5bc381cc 100644 --- a/core/math/order/order-docs.factor +++ b/core/math/order/order-docs.factor @@ -58,7 +58,7 @@ HELP: clamp { $description "Outputs " { $snippet "x" } " if contained in the interval " { $snippet "[min,max]" } " or else outputs one of the endpoints." } ; HELP: between? -{ $values { "x" object } { "y" object } { "z" real } { "?" "a boolean" } } +{ $values { "x" object } { "y" object } { "z" object } { "?" "a boolean" } } { $description "Tests if " { $snippet "x" } " is in the interval " { $snippet "[y,z]" } "." } { $notes "As per the closed interval notation, the end-points are included in the interval." } ;