From b458d58b91b7c15c31104e99f34967c1943fecf4 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 25 Apr 2006 22:25:39 +0000 Subject: [PATCH] Fixing some bugs, with-template argument order reversed --- library/compiler/intrinsics.factor | 92 +++++++++++++++--------------- library/compiler/linearizer.factor | 13 ++--- library/compiler/templates.factor | 44 ++++++-------- 3 files changed, 69 insertions(+), 80 deletions(-) diff --git a/library/compiler/intrinsics.factor b/library/compiler/intrinsics.factor index f1c77dc471..34a998abe1 100644 --- a/library/compiler/intrinsics.factor +++ b/library/compiler/intrinsics.factor @@ -6,65 +6,65 @@ inference kernel kernel-internals lists math math-internals namespaces sequences words ; \ slot [ - H{ - { +input { { f "obj" } { f "n" } } } - { +output { "obj" } } - } [ + [ "obj" get %untag , "n" get "obj" get %slot , - ] with-template + ] H{ + { +input { { f "obj" } { f "n" } } } + { +output { "obj" } } + } with-template ] "intrinsic" set-word-prop \ set-slot [ - H{ - { +input { { f "val" } { f "obj" } { f "slot" } } } - { +clobber { "obj" } } - } [ + [ "obj" get %untag , "val" get "obj" get "slot" get %set-slot , finalize-contents "obj" get %write-barrier , - ] with-template + ] H{ + { +input { { f "val" } { f "obj" } { f "slot" } } } + { +clobber { "obj" } } + } with-template ] "intrinsic" set-word-prop \ char-slot [ - H{ + [ + "n" get "str" get %char-slot , + ] H{ { +input { { f "n" } { f "str" } } } { +output { "str" } } - } [ - "n" get "str" get %char-slot , - ] with-template + } with-template ] "intrinsic" set-word-prop \ set-char-slot [ - H{ - { +input { { f "ch" } { f "n" } { f "str" } } } - } [ + [ "ch" get "str" get "n" get %set-char-slot , - ] with-template + ] H{ + { +input { { f "ch" } { f "n" } { f "str" } } } + } with-template ] "intrinsic" set-word-prop \ type [ - H{ + [ finalize-contents "in" get %type , ] H{ { +input { { f "in" } } } { +output { "in" } } - } [ finalize-contents "in" get %type , ] with-template + } with-template ] "intrinsic" set-word-prop \ tag [ - H{ + [ "in" get %tag , ] H{ { +input { { f "in" } } } { +output { "in" } } - } [ "in" get %tag , ] with-template + } with-template ] "intrinsic" set-word-prop : binary-op ( op -- ) - H{ + [ + finalize-contents >r "y" get "x" get dup r> execute , + ] H{ { +input { { 0 "x" } { 1 "y" } } } { +output { "x" } } - } [ - finalize-contents >r "y" get "x" get dup r> execute , - ] with-template ; inline + } with-template ; inline { { fixnum+ %fixnum+ } @@ -77,12 +77,12 @@ namespaces sequences words ; ] each : binary-op-fast ( op -- ) - H{ + [ + >r "y" get "x" get dup r> execute , + ] H{ { +input { { f "x" } { f "y" } } } { +output { "x" } } - } [ - >r "y" get "x" get dup r> execute , - ] with-template ; inline + } with-template ; inline { { fixnum-bitand %fixnum-bitand } @@ -96,11 +96,11 @@ namespaces sequences words ; ] each : binary-jump ( label op -- ) - H{ - { +input { { f "x" } { f "y" } } } - } [ + [ end-basic-block >r >r "y" get "x" get r> r> execute , - ] with-template ; inline + ] H{ + { +input { { f "x" } { f "y" } } } + } with-template ; inline { { fixnum<= %jump-fixnum<= } @@ -117,33 +117,33 @@ namespaces sequences words ; ! This is not clever. Because of x86, %fixnum-mod is ! hard-coded to put its output in vreg 2, which happends to ! be EDX there. - H{ - { +input { { 0 "x" } { 1 "y" } } } - { +output { "out" } } - } [ + [ finalize-contents T{ vreg f 2 } "out" set "y" get "x" get "out" get %fixnum-mod , - ] with-template + ] H{ + { +input { { 0 "x" } { 1 "y" } } } + { +output { "out" } } + } with-template ] "intrinsic" set-word-prop \ fixnum/mod [ ! See the remark on fixnum-mod for vreg usage - H{ - { +input { { 0 "x" } { 1 "y" } } } - { +output { "quo" "rem" } } - } [ + [ finalize-contents T{ vreg f 0 } "quo" set T{ vreg f 2 } "rem" set "y" get "x" get 2array "rem" get "quo" get 2array %fixnum/mod , - ] with-template + ] H{ + { +input { { 0 "x" } { 1 "y" } } } + { +output { "quo" "rem" } } + } with-template ] "intrinsic" set-word-prop \ fixnum-bitnot [ - H{ + [ "x" get dup %fixnum-bitnot , ] H{ { +input { { f "x" } } } { +output { "x" } } - } [ "x" get dup %fixnum-bitnot , ] with-template + } with-template ] "intrinsic" set-word-prop diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index 1913736b8f..d36e214473 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -99,19 +99,18 @@ M: #call-label linearize* ( node -- next ) node-param renamed-label linearize-call ; M: #if linearize* ( node -- next ) - H{ - { +input { { 0 "flag" } } } - } [ + [ end-basic-block