From 9941aa5607c4ee257944f60ecd978551ac21b03c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Jan 2006 21:40:18 +0000 Subject: [PATCH] removed fixnum<< vop since it was buggy and afforded no performance gain, and also simplified some code --- library/collections/namespaces.factor | 9 +++-- library/compiler/intrinsics.factor | 47 +++++------------------- library/compiler/ppc/fixnum.factor | 25 ------------- library/compiler/stack.factor | 14 +++---- library/compiler/vops.factor | 8 +--- library/compiler/x86/fixnum.factor | 25 ------------- library/inference/branches.factor | 4 +- library/inference/call-optimizers.factor | 8 ++-- library/inference/class-infer.factor | 24 ++++++------ library/inference/dataflow.factor | 19 +++++----- library/inference/inference.factor | 9 +++-- library/inference/kill-literals.factor | 2 +- library/inference/known-words.factor | 2 +- library/inference/optimizer.factor | 4 +- library/inference/print-dataflow.factor | 6 +-- library/inference/words.factor | 2 +- library/test/compiler/optimizer.factor | 4 +- library/tools/annotations.factor | 2 - 18 files changed, 67 insertions(+), 147 deletions(-) diff --git a/library/collections/namespaces.factor b/library/collections/namespaces.factor index c6f5ecb9fb..3997289df6 100644 --- a/library/collections/namespaces.factor +++ b/library/collections/namespaces.factor @@ -23,15 +23,16 @@ sequences strings vectors words ; : change ( var quot -- quot: old -- new ) >r dup get r> rot slip set ; inline -: inc ( var -- ) [ 1+ ] change ; inline +: +@ ( n var -- ) [ [ 0 ] unless* + ] change ; -: counter ( var -- n ) - global [ [ [ 0 ] unless* dup 1+ >fixnum ] change ] bind ; +: inc ( var -- ) 1 swap +@ ; inline -: dec ( var -- ) [ 1- ] change ; inline +: dec ( var -- ) -1 swap +@ ; inline : bind ( namespace quot -- ) swap >n call n> drop ; inline +: counter ( var -- n ) global [ dup inc get ] bind ; + : make-hash ( quot -- hash ) H{ } clone >n call n> ; inline : with-scope ( quot -- ) make-hash drop ; inline diff --git a/library/compiler/intrinsics.factor b/library/compiler/intrinsics.factor index 6225d319e9..d896923674 100644 --- a/library/compiler/intrinsics.factor +++ b/library/compiler/intrinsics.factor @@ -22,8 +22,8 @@ namespaces sequences words ; : slot@ ( node -- n/f ) #! Compute slot offset. - dup node-in-d reverse-slice dup first dup literal? [ - literal-value cells swap second + dup node-in-d reverse-slice dup first dup value? [ + value-literal cells swap second rot value-tag dup [ - ] [ 2drop f ] if ] [ 3drop f @@ -90,7 +90,7 @@ namespaces sequences words ; \ getenv [ -1 %inc-d , - node-peek literal-value 0 swap %getenv , + node-peek value-literal 0 swap %getenv , 1 %inc-d , out-1 ] "intrinsic" set-word-prop @@ -98,7 +98,7 @@ namespaces sequences words ; \ setenv [ -1 %inc-d , in-1 - node-peek literal-value 0 swap %setenv , + node-peek value-literal 0 swap %setenv , -1 %inc-d , ] "intrinsic" set-word-prop @@ -118,13 +118,13 @@ namespaces sequences words ; >r binary-inputs dup -1 %inc-d , r> execute , out-1 ; inline : binary-imm ( node -- in1 in2 ) - -1 %inc-d , in-1 node-peek literal-value 0 ; + -1 %inc-d , in-1 node-peek value-literal 0 ; : binary-op-imm ( node op -- ) >r binary-imm dup r> execute , out-1 ; inline : literal-immediate? ( value -- ? ) - dup literal? [ literal-value immediate? ] [ drop f ] if ; + dup value? [ value-literal immediate? ] [ drop f ] if ; : binary-op-imm? ( node -- ? ) fixnum-imm? >r node-peek literal-immediate? r> and ; @@ -197,25 +197,8 @@ namespaces sequences words ; out-1 ] "intrinsic" set-word-prop -: fast-fixnum* ( n -- ) - -1 %inc-d , - in-1 - log2 0 0 %fixnum<< , - out-1 ; - -: slow-fixnum* ( node -- ) \ %fixnum* binary-op-reg ; - \ fixnum* [ - ! Turn multiplication by a power of two into a left shift. - dup node-peek dup literal-immediate? [ - literal-value dup power-of-2? [ - nip fast-fixnum* - ] [ - drop slow-fixnum* - ] if - ] [ - drop slow-fixnum* - ] if + \ %fixnum* binary-op-reg ] "intrinsic" set-word-prop : slow-shift ( -- ) \ fixnum-shift %call , ; @@ -231,16 +214,6 @@ namespaces sequences words ; out-1 ] if ; -: positive-shift ( n -- ) - dup cell-bits tag-bits - <= [ - -1 %inc-d , - in-1 - 0 0 %fixnum<< , - out-1 - ] [ - drop slow-shift - ] if ; - : fast-shift ( n -- ) dup 0 = [ -1 %inc-d , @@ -249,13 +222,13 @@ namespaces sequences words ; dup 0 < [ negative-shift ] [ - positive-shift + drop slow-shift ] if ] if ; \ fixnum-shift [ - node-peek dup literal? [ - literal-value fast-shift + node-peek dup value? [ + value-literal fast-shift ] [ drop slow-shift ] if diff --git a/library/compiler/ppc/fixnum.factor b/library/compiler/ppc/fixnum.factor index dee016ed7d..0aeadb66ba 100644 --- a/library/compiler/ppc/fixnum.factor +++ b/library/compiler/ppc/fixnum.factor @@ -111,31 +111,6 @@ M: %fixnum-bitnot generate-node ( vop -- ) drop dest/src NOT 0 output-operand dup untag ; -M: %fixnum<< generate-node ( vop -- ) - ! This has specific register requirements. - drop -