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

View File

@ -40,6 +40,12 @@ big-endian off
ds-reg [] arg0 MOV ! store literal on datastack
] 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
arg1 stack-reg MOV ! pass callstack pointer as arg 2

View File

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

View File

@ -1,9 +1,9 @@
! Copyright (C) 2006, 2008 Slava Pestov.
! 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
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 ;

View File

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

View File

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

View File

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

View File

@ -1,8 +1,9 @@
! Copyright (C) 2007 Slava Pestov.
! 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
USING: kernel sequences inference namespaces generic
combinators classes classes.algebra inference.dataflow ;
! Funny pattern matching
SYMBOL: @

View File

@ -1,10 +1,10 @@
! Copyright (C) 2006, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: classes inference inference.dataflow io kernel
kernel.private math.parser namespaces optimizer prettyprint
prettyprint.backend sequences words arrays match macros
assocs sequences.private optimizer.specializers generic
combinators sorting math quotations accessors ;
USING: classes io kernel kernel.private math.parser namespaces
optimizer prettyprint prettyprint.backend sequences words arrays
match macros assocs sequences.private generic combinators
sorting math quotations accessors inference inference.dataflow
optimizer.specializers ;
IN: optimizer.debugger
! 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);
case RT_LITERAL:
return CREF(literals_start,REL_ARGUMENT(rel));
case RT_IMMEDIATE:
return get(CREF(literals_start,REL_ARGUMENT(rel)));
case RT_XT:
return (CELL)untag_word(get(CREF(literals_start,REL_ARGUMENT(rel))))->xt;
case RT_HERE:

View File

@ -12,7 +12,9 @@ typedef enum {
/* current offset */
RT_HERE,
/* a local label */
RT_LABEL
RT_LABEL,
/* immeditae literal */
RT_IMMEDIATE
} F_RELTYPE;
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
includes stack shufflers, some fixnum arithmetic words, and words such as tag,
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)
{
return (i + 2) == array_capacity(array)
@ -253,7 +252,7 @@ void jit_compile(CELL quot, bool relocate)
}
default:
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;
}
}

View File

@ -47,29 +47,9 @@ typedef enum {
JIT_EPILOG,
JIT_RETURN,
JIT_PROFILING,
JIT_TAG,
JIT_TAG_WORD,
JIT_EQP,
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,
JIT_PUSH_IMMEDIATE,
JIT_DECLARE_WORD = 42,
STACK_TRACES_ENV = 59,