Fixes and a small optiimization

db4
Slava Pestov 2008-07-12 22:27:28 -05:00
parent f1879cb337
commit 16b85df5db
13 changed files with 46 additions and 53 deletions

View File

@ -119,6 +119,7 @@ SYMBOL: jit-primitive
SYMBOL: jit-word-jump SYMBOL: jit-word-jump
SYMBOL: jit-word-call SYMBOL: jit-word-call
SYMBOL: jit-push-literal SYMBOL: jit-push-literal
SYMBOL: jit-push-immediate
SYMBOL: jit-if-word SYMBOL: jit-if-word
SYMBOL: jit-if-jump SYMBOL: jit-if-jump
SYMBOL: jit-dispatch-word SYMBOL: jit-dispatch-word
@ -149,6 +150,7 @@ SYMBOL: undefined-quot
{ jit-epilog 33 } { jit-epilog 33 }
{ jit-return 34 } { jit-return 34 }
{ jit-profiling 35 } { jit-profiling 35 }
{ jit-push-immediate 36 }
{ jit-declare-word 42 } { jit-declare-word 42 }
{ undefined-quot 60 } { undefined-quot 60 }
} at header-size + ; } at header-size + ;
@ -438,6 +440,7 @@ M: quotation '
jit-word-jump jit-word-jump
jit-word-call jit-word-call
jit-push-literal jit-push-literal
jit-push-immediate
jit-if-word jit-if-word
jit-if-jump jit-if-jump
jit-dispatch-word jit-dispatch-word

View File

@ -40,6 +40,12 @@ big-endian off
ds-reg [] arg0 MOV ! store literal on datastack ds-reg [] arg0 MOV ! store literal on datastack
] rc-absolute-cell rt-literal 1 rex-length + jit-push-literal jit-define ] rc-absolute-cell rt-literal 1 rex-length + jit-push-literal jit-define
[
arg0 0 MOV ! load literal
ds-reg bootstrap-cell ADD ! increment datastack pointer
ds-reg [] arg0 MOV ! store literal on datastack
] rc-absolute-cell rt-immediate 1 rex-length + jit-push-immediate jit-define
[ [
arg0 0 MOV ! load XT arg0 0 MOV ! load XT
arg1 stack-reg MOV ! pass callstack pointer as arg 2 arg1 stack-reg MOV ! pass callstack pointer as arg 2

View File

@ -72,6 +72,7 @@ SYMBOL: label-table
: rt-xt 4 ; : rt-xt 4 ;
: rt-here 5 ; : rt-here 5 ;
: rt-label 6 ; : rt-label 6 ;
: rt-immediate 7 ;
TUPLE: label-fixup label class ; TUPLE: label-fixup label class ;

View File

@ -1,9 +1,9 @@
! Copyright (C) 2006, 2008 Slava Pestov. ! Copyright (C) 2006, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel generic sequences prettyprint io words arrays
summary effects debugger assocs accessors inference.backend
inference.dataflow ;
IN: inference.errors IN: inference.errors
USING: inference.backend inference.dataflow kernel generic
sequences prettyprint io words arrays summary effects debugger
assocs accessors ;
M: inference-error error-help error>> error-help ; M: inference-error error-help error>> error-help ;

View File

@ -1,8 +1,7 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: namespaces assocs sequences inference.dataflow USING: namespaces assocs sequences kernel generic assocs classes
inference.backend kernel generic assocs classes vectors vectors accessors combinators inference.dataflow inference.backend ;
accessors combinators ;
IN: optimizer.def-use IN: optimizer.def-use
SYMBOL: def-use SYMBOL: def-use

View File

@ -1,15 +1,15 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien arrays generic hashtables definitions USING: accessors alien arrays generic hashtables definitions
inference.dataflow inference.state inference.class kernel assocs kernel assocs math math.order math.private kernel.private
math math.order math.private kernel.private sequences words sequences words parser vectors strings sbufs io namespaces
parser vectors strings sbufs io namespaces assocs quotations assocs quotations sequences.private io.binary io.streams.string
sequences.private io.binary io.streams.string layouts splitting layouts splitting math.intervals math.floats.private
math.intervals math.floats.private classes.tuple classes.predicate classes.tuple classes.predicate classes.tuple.private classes
classes.tuple.private classes classes.algebra optimizer.def-use classes.algebra sequences.private combinators byte-arrays
optimizer.backend optimizer.pattern-match optimizer.inlining byte-vectors slots.private inference.dataflow inference.state
sequences.private combinators byte-arrays byte-vectors inference.class optimizer.def-use optimizer.backend
slots.private ; optimizer.pattern-match optimizer.inlining ;
IN: optimizer.known-words IN: optimizer.known-words
{ <tuple> <tuple-boa> (tuple) } [ { <tuple> <tuple-boa> (tuple) } [

View File

@ -2,10 +2,10 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: effects alien alien.accessors arrays generic hashtables USING: effects alien alien.accessors arrays generic hashtables
kernel assocs math math.libm math.private kernel.private kernel assocs math math.libm math.private kernel.private
sequences words parser inference.class inference.dataflow sequences words parser vectors strings sbufs io namespaces
vectors strings sbufs io namespaces assocs quotations assocs quotations math.intervals sequences.private combinators
math.intervals sequences.private combinators splitting layouts splitting layouts math.parser classes classes.algebra
math.parser classes classes.algebra generic.math generic.math inference.class inference.dataflow
optimizer.pattern-match optimizer.backend optimizer.def-use optimizer.pattern-match optimizer.backend optimizer.def-use
optimizer.inlining optimizer.math.partial generic.standard optimizer.inlining optimizer.math.partial generic.standard
system accessors ; system accessors ;

View File

@ -1,8 +1,9 @@
! Copyright (C) 2007 Slava Pestov. ! Copyright (C) 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences namespaces generic
combinators classes classes.algebra
inference inference.dataflow ;
IN: optimizer.pattern-match IN: optimizer.pattern-match
USING: kernel sequences inference namespaces generic
combinators classes classes.algebra inference.dataflow ;
! Funny pattern matching ! Funny pattern matching
SYMBOL: @ SYMBOL: @

View File

@ -1,10 +1,10 @@
! Copyright (C) 2006, 2008 Slava Pestov. ! Copyright (C) 2006, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: classes inference inference.dataflow io kernel USING: classes io kernel kernel.private math.parser namespaces
kernel.private math.parser namespaces optimizer prettyprint optimizer prettyprint prettyprint.backend sequences words arrays
prettyprint.backend sequences words arrays match macros match macros assocs sequences.private generic combinators
assocs sequences.private optimizer.specializers generic sorting math quotations accessors inference inference.dataflow
combinators sorting math quotations accessors ; optimizer.specializers ;
IN: optimizer.debugger IN: optimizer.debugger
! A simple tool for turning dataflow IR into quotations, for ! A simple tool for turning dataflow IR into quotations, for

View File

@ -63,6 +63,8 @@ INLINE CELL compute_code_rel(F_REL *rel,
return (CELL)get_rel_symbol(rel,literals_start); return (CELL)get_rel_symbol(rel,literals_start);
case RT_LITERAL: case RT_LITERAL:
return CREF(literals_start,REL_ARGUMENT(rel)); return CREF(literals_start,REL_ARGUMENT(rel));
case RT_IMMEDIATE:
return get(CREF(literals_start,REL_ARGUMENT(rel)));
case RT_XT: case RT_XT:
return (CELL)untag_word(get(CREF(literals_start,REL_ARGUMENT(rel))))->xt; return (CELL)untag_word(get(CREF(literals_start,REL_ARGUMENT(rel))))->xt;
case RT_HERE: case RT_HERE:

View File

@ -12,7 +12,9 @@ typedef enum {
/* current offset */ /* current offset */
RT_HERE, RT_HERE,
/* a local label */ /* a local label */
RT_LABEL RT_LABEL,
/* immeditae literal */
RT_IMMEDIATE
} F_RELTYPE; } F_RELTYPE;
typedef enum { typedef enum {

View File

@ -30,9 +30,8 @@ push the array and immediately drop it after.
in the VM. They are open-coded and no subroutine call is generated. This in the VM. They are open-coded and no subroutine call is generated. This
includes stack shufflers, some fixnum arithmetic words, and words such as tag, includes stack shufflers, some fixnum arithmetic words, and words such as tag,
slot and eq?. A primitive call is relatively expensive (two subroutine calls) slot and eq?. A primitive call is relatively expensive (two subroutine calls)
so this results in a big speedup for relatively little effort. so this results in a big speedup for relatively little effort. */
*/
bool jit_primitive_call_p(F_ARRAY *array, CELL i) bool jit_primitive_call_p(F_ARRAY *array, CELL i)
{ {
return (i + 2) == array_capacity(array) return (i + 2) == array_capacity(array)
@ -253,7 +252,7 @@ void jit_compile(CELL quot, bool relocate)
} }
default: default:
GROWABLE_ARRAY_ADD(literals,obj); GROWABLE_ARRAY_ADD(literals,obj);
EMIT(userenv[JIT_PUSH_LITERAL],literals_count - 1); EMIT(userenv[immediate_p(obj) ? JIT_PUSH_IMMEDIATE : JIT_PUSH_LITERAL],literals_count - 1);
break; break;
} }
} }

View File

@ -47,29 +47,9 @@ typedef enum {
JIT_EPILOG, JIT_EPILOG,
JIT_RETURN, JIT_RETURN,
JIT_PROFILING, JIT_PROFILING,
JIT_TAG, JIT_PUSH_IMMEDIATE,
JIT_TAG_WORD,
JIT_EQP, JIT_DECLARE_WORD = 42,
JIT_EQP_WORD,
JIT_SLOT,
JIT_SLOT_WORD,
JIT_DECLARE_WORD,
JIT_DROP,
JIT_DROP_WORD,
JIT_DUP,
JIT_DUP_WORD,
JIT_TO_R,
JIT_TO_R_WORD,
JIT_FROM_R,
JIT_FROM_R_WORD,
JIT_SWAP,
JIT_SWAP_WORD,
JIT_OVER,
JIT_OVER_WORD,
JIT_FIXNUM_MINUS,
JIT_FIXNUM_MINUS_WORD,
JIT_FIXNUM_GE,
JIT_FIXNUM_GE_WORD,
STACK_TRACES_ENV = 59, STACK_TRACES_ENV = 59,