]> gitweb.factorcode.org Git - factor.git/commitdiff
Non-optimizing compiler doesn't need to optimize 'dispatch' primitive anymore since...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 00:42:08 +0000 (19:42 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 00:42:08 +0000 (19:42 -0500)
basis/bootstrap/image/image.factor
basis/cpu/ppc/bootstrap.factor
basis/cpu/x86/bootstrap.factor
vm/quotations.c
vm/run.h

index fe1677a7a0410b6d83c0895d80e1774c8c5e0df8..cad40b63848fda7dd99be8c01a1fbc3f0765c477 100644 (file)
@@ -144,8 +144,6 @@ SYMBOL: jit-push-immediate
 SYMBOL: jit-if-word
 SYMBOL: jit-if-1
 SYMBOL: jit-if-2
-SYMBOL: jit-dispatch-word
-SYMBOL: jit-dispatch
 SYMBOL: jit-dip-word
 SYMBOL: jit-dip
 SYMBOL: jit-2dip-word
@@ -158,7 +156,6 @@ SYMBOL: jit-execute-call
 SYMBOL: jit-epilog
 SYMBOL: jit-return
 SYMBOL: jit-profiling
-SYMBOL: jit-declare-word
 SYMBOL: jit-save-stack
 
 ! PIC stubs
@@ -192,13 +189,10 @@ SYMBOL: undefined-quot
         { jit-if-word 28 }
         { jit-if-1 29 }
         { jit-if-2 30 }
-        { jit-dispatch-word 31 }
-        { jit-dispatch 32 }
         { jit-epilog 33 }
         { jit-return 34 }
         { jit-profiling 35 }
         { jit-push-immediate 36 }
-        { jit-declare-word 37 }
         { jit-save-stack 38 }
         { jit-dip-word 39 }
         { jit-dip 40 }
@@ -524,9 +518,7 @@ M: quotation '
 
 : emit-jit-data ( -- )
     \ if jit-if-word set
-    \ dispatch jit-dispatch-word set
     \ do-primitive jit-primitive-word set
-    \ declare jit-declare-word set
     \ dip jit-dip-word set
     \ 2dip jit-2dip-word set
     \ 3dip jit-3dip-word set
@@ -545,8 +537,6 @@ M: quotation '
         jit-if-word
         jit-if-1
         jit-if-2
-        jit-dispatch-word
-        jit-dispatch
         jit-dip-word
         jit-dip
         jit-2dip-word
@@ -559,7 +549,6 @@ M: quotation '
         jit-epilog
         jit-return
         jit-profiling
-        jit-declare-word
         jit-save-stack
         pic-load
         pic-tag
index 1f86bf6a0ddb94159193919129b3cf076d151999..7278fd20929f7e0a6d8fcca4878e7972e7288bfb 100644 (file)
@@ -74,21 +74,6 @@ CONSTANT: rs-reg 30
     0 B rc-relative-ppc-3 rt-xt jit-rel\r
 ] jit-if-2 jit-define\r
 \r
-: jit-jump-quot ( -- )\r
-    4 3 quot-xt-offset LWZ\r
-    4 MTCTR\r
-    BCTR ;\r
-\r
-[\r
-    0 3 LOAD32 rc-absolute-ppc-2/2 rt-immediate jit-rel\r
-    6 ds-reg 0 LWZ\r
-    6 6 1 SRAWI\r
-    3 3 6 ADD\r
-    3 3 array-start-offset LWZ\r
-    ds-reg dup 4 SUBI\r
-    jit-jump-quot\r
-] jit-dispatch jit-define\r
-\r
 : jit->r ( -- )\r
     4 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
@@ -167,7 +152,9 @@ CONSTANT: rs-reg 30
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
-    jit-jump-quot\r
+    4 3 quot-xt-offset LWZ\r
+    4 MTCTR\r
+    BCTR\r
 ] \ (call) define-sub-primitive\r
 \r
 [\r
index 337c3ae57597fe39877943f0fbdf339769e63dd7..4fe5e5cd33b2f5fcb1a0381645b3a14f7b27392f 100644 (file)
@@ -65,24 +65,6 @@ big-endian off
     f JMP rc-relative rt-xt jit-rel
 ] jit-if-2 jit-define
 
-[
-    ! load dispatch table
-    temp1 0 MOV rc-absolute-cell rt-immediate jit-rel
-    ! load index
-    temp0 ds-reg [] MOV
-    ! turn it into an array offset
-    fixnum>slot@
-    ! pop index
-    ds-reg bootstrap-cell SUB
-    ! compute quotation location
-    temp0 temp1 ADD
-    ! load quotation
-    arg temp0 array-start-offset [+] MOV
-    ! execute branch. the quot must be in arg, since it might
-    ! not be compiled yet
-    arg quot-xt-offset [+] JMP
-] jit-dispatch jit-define
-
 : jit->r ( -- )
     rs-reg bootstrap-cell ADD
     temp0 ds-reg [] MOV
index 909bba501e5c3426aeb1ce9daeedee0f7025d1ba..2e0d5ed248a5a3d51cafea4b3c797445d321e7be 100755 (executable)
@@ -53,13 +53,6 @@ static bool jit_fast_if_p(F_ARRAY *array, CELL i)
                && array_nth(array,i + 2) == userenv[JIT_IF_WORD];
 }
 
-static bool jit_fast_dispatch_p(F_ARRAY *array, CELL i)
-{
-       return (i + 2) == array_capacity(array)
-               && type_of(array_nth(array,i)) == ARRAY_TYPE
-               && array_nth(array,i + 1) == userenv[JIT_DISPATCH_WORD];
-}
-
 static bool jit_fast_dip_p(F_ARRAY *array, CELL i)
 {
        return (i + 2) <= array_capacity(array)
@@ -81,13 +74,6 @@ static bool jit_fast_3dip_p(F_ARRAY *array, CELL i)
                && array_nth(array,i + 1) == userenv[JIT_3DIP_WORD];
 }
 
-static bool jit_ignore_declare_p(F_ARRAY *array, CELL i)
-{
-       return (i + 1) < array_capacity(array)
-               && type_of(array_nth(array,i)) == ARRAY_TYPE
-               && array_nth(array,i + 1) == userenv[JIT_DECLARE_WORD];
-}
-
 static bool jit_mega_lookup_p(F_ARRAY *array, CELL i)
 {
        return (i + 3) < array_capacity(array)
@@ -108,7 +94,7 @@ static bool jit_stack_frame_p(F_ARRAY *array)
                if(type_of(obj) == WORD_TYPE)
                {
                        F_WORD *word = untag_object(obj);
-                       if(word->subprimitive == F && obj != userenv[JIT_DECLARE_WORD])
+                       if(word->subprimitive == F)
                                return true;
                }
                else if(type_of(obj) == QUOTATION_TYPE)
@@ -190,6 +176,7 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
                        jit_push(jit,wrapper->object);
                        break;
                case FIXNUM_TYPE:
+                       /* Primitive calls */
                        if(jit_primitive_call_p(untag_object(array),i))
                        {
                                jit_emit(jit,userenv[JIT_SAVE_STACK]);
@@ -201,7 +188,7 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
                                break;
                        }
                case QUOTATION_TYPE:
-                       /* if preceeded by two literal quotations (this is why if and ? are
+                       /* 'if' preceeded by two literal quotations (this is why if and ? are
                           mutually recursive in the library, but both still work) */
                        if(jit_fast_if_p(untag_object(array),i))
                        {
@@ -248,23 +235,8 @@ static void jit_iterate_quotation(F_JIT *jit, CELL array, CELL compiling, CELL r
                                break;
                        }
                case ARRAY_TYPE:
-                       /* Jump tables */
-                       if(jit_fast_dispatch_p(untag_object(array),i))
-                       {
-                               TAIL_CALL;
-                               jit_emit_with(jit,userenv[JIT_DISPATCH],obj);
-
-                               i++;
-                               break;
-                       }
-                       /* Non-optimizing compiler ignores declarations */
-                       else if(jit_ignore_declare_p(untag_object(array),i))
-                       {
-                               i++;
-                               break;
-                       }
                        /* Method dispatch */
-                       else if(jit_mega_lookup_p(untag_object(array),i))
+                       if(jit_mega_lookup_p(untag_object(array),i))
                        {
                                jit_emit_mega_cache_lookup(jit,
                                        array_nth(untag_object(array),i),
index d32a91e67afdc15ac5721e9b7d7a8672b077c6c2..b31fc3a2e17b2dc9de1b43f5bc9c6632138167ae 100755 (executable)
--- a/vm/run.h
+++ b/vm/run.h
@@ -41,14 +41,11 @@ typedef enum {
        JIT_IF_WORD,
        JIT_IF_1,
        JIT_IF_2,
-       JIT_DISPATCH_WORD,
-       JIT_DISPATCH,
-       JIT_EPILOG,
+       JIT_EPILOG          = 33,
        JIT_RETURN,
        JIT_PROFILING,
        JIT_PUSH_IMMEDIATE,
-       JIT_DECLARE_WORD,
-       JIT_SAVE_STACK,
+       JIT_SAVE_STACK = 38,
        JIT_DIP_WORD,
        JIT_DIP,
        JIT_2DIP_WORD,