[ add-dlsym-parameters ] dip rt-dlsym rel-fixup ;
: rel-word ( word class -- )
- [ add-literal ] dip rt-xt rel-fixup ;
+ [ add-literal ] dip rt-entry-point rel-fixup ;
: rel-word-pic ( word class -- )
- [ add-literal ] dip rt-xt-pic rel-fixup ;
+ [ add-literal ] dip rt-entry-point-pic rel-fixup ;
: rel-word-pic-tail ( word class -- )
- [ add-literal ] dip rt-xt-pic-tail rel-fixup ;
+ [ add-literal ] dip rt-entry-point-pic-tail rel-fixup ;
: rel-primitive ( word class -- )
[ def>> first add-parameter ] dip rt-primitive rel-fixup ;
: alien-offset ( -- n ) 4 alien type-number slot-offset ; inline
: underlying-alien-offset ( -- n ) 1 alien type-number slot-offset ; inline
: tuple-class-offset ( -- n ) 1 tuple type-number slot-offset ; inline
-: word-xt-offset ( -- n ) 10 \ word type-number slot-offset ; inline
-: quot-xt-offset ( -- n ) 4 quotation type-number slot-offset ; inline
+: word-entry-point-offset ( -- n ) 10 \ word type-number slot-offset ; inline
+: quot-entry-point-offset ( -- n ) 4 quotation type-number slot-offset ; inline
: word-code-offset ( -- n ) 11 \ word type-number slot-offset ; inline
: array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
: compiled-header-size ( -- n ) 4 bootstrap-cells ; inline
! Relocation types
CONSTANT: rt-primitive 0
CONSTANT: rt-dlsym 1
-CONSTANT: rt-dispatch 2
-CONSTANT: rt-xt 3
-CONSTANT: rt-xt-pic 4
-CONSTANT: rt-xt-pic-tail 5
-CONSTANT: rt-here 6
-CONSTANT: rt-this 7
-CONSTANT: rt-literal 8
-CONSTANT: rt-context 9
-CONSTANT: rt-untagged 10
-CONSTANT: rt-megamorphic-cache-hits 11
-CONSTANT: rt-vm 12
-CONSTANT: rt-cards-offset 13
-CONSTANT: rt-decks-offset 14
+CONSTANT: rt-entry-point 2
+CONSTANT: rt-entry-point-pic 3
+CONSTANT: rt-entry-point-pic-tail 4
+CONSTANT: rt-here 5
+CONSTANT: rt-this 6
+CONSTANT: rt-literal 7
+CONSTANT: rt-untagged 8
+CONSTANT: rt-megamorphic-cache-hits 9
+CONSTANT: rt-vm 10
+CONSTANT: rt-cards-offset 11
+CONSTANT: rt-decks-offset 12
: rc-absolute? ( n -- ? )
${ rc-absolute-ppc-2/2 rc-absolute-cell rc-absolute } member? ;
! Copyright (C) 2007, 2010 Slava Pestov.\r
! See http://factorcode.org/license.txt for BSD license.\r
USING: bootstrap.image.private kernel kernel.private namespaces\r
-system cpu.ppc.assembler compiler.codegen.fixup compiler.units\r
-compiler.constants math math.private math.ranges layouts words vocabs\r
-slots.private locals locals.backend generic.single.private fry\r
-sequences ;\r
+system cpu.ppc.assembler compiler.units compiler.constants math\r
+math.private math.ranges layouts words vocabs slots.private\r
+locals locals.backend generic.single.private fry sequences ;\r
FROM: cpu.ppc.assembler => B ;\r
IN: bootstrap.ppc\r
\r
\r
0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel\r
\r
- 0 2 LOAD32 rc-absolute-ppc-2/2 rt-xt jit-rel\r
+ 0 2 LOAD32 rc-absolute-ppc-2/2 rt-entry-point jit-rel\r
2 MTLR\r
BLRL\r
\r
jit-restore-context\r
] jit-primitive jit-define\r
\r
-[ 0 BL rc-relative-ppc-3 rt-xt-pic jit-rel ] jit-word-call jit-define\r
+[ 0 BL rc-relative-ppc-3 rt-entry-point-pic jit-rel ] jit-word-call jit-define\r
\r
[\r
0 6 LOAD32 rc-absolute-ppc-2/2 rt-here jit-rel\r
- 0 B rc-relative-ppc-3 rt-xt-pic-tail jit-rel\r
+ 0 B rc-relative-ppc-3 rt-entry-point-pic-tail jit-rel\r
] jit-word-jump jit-define\r
\r
[\r
3 ds-reg 0 LWZ\r
ds-reg dup 4 SUBI\r
0 3 \ f type-number CMPI\r
- [ BEQ ] [ 0 B rc-relative-ppc-3 rt-xt jit-rel ] jit-conditional*\r
- 0 B rc-relative-ppc-3 rt-xt jit-rel\r
+ [ BEQ ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*\r
+ 0 B rc-relative-ppc-3 rt-entry-point jit-rel\r
] jit-if jit-define\r
\r
: jit->r ( -- )\r
\r
[\r
jit->r\r
- 0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+ 0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
jit-r>\r
] jit-dip jit-define\r
\r
[\r
jit-2>r\r
- 0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+ 0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
jit-2r>\r
] jit-2dip jit-define\r
\r
[\r
jit-3>r\r
- 0 BL rc-relative-ppc-3 rt-xt jit-rel\r
+ 0 BL rc-relative-ppc-3 rt-entry-point jit-rel\r
jit-3r>\r
] jit-3dip jit-define\r
\r
] pic-check-tuple jit-define\r
\r
[\r
- [ BNE ] [ 0 B rc-relative-ppc-3 rt-xt jit-rel ] jit-conditional*\r
+ [ BNE ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*\r
] pic-hit jit-define\r
\r
! Inline cache miss entry points\r
5 4 0 STW\r
! ... goto get(cache + 4)\r
3 3 4 LWZ\r
- 3 3 word-xt-offset LWZ\r
+ 3 3 word-entry-point-offset LWZ\r
3 MTCTR\r
BCTR\r
]\r
[\r
3 ds-reg 0 LWZ\r
ds-reg dup 4 SUBI\r
- 5 3 quot-xt-offset LWZ\r
+ 5 3 quot-entry-point-offset LWZ\r
]\r
[ 5 MTLR BLRL ]\r
[ 5 MTCTR BCTR ] \ (call) define-combinator-primitive\r
[\r
3 ds-reg 0 LWZ\r
ds-reg dup 4 SUBI\r
- 4 3 word-xt-offset LWZ\r
+ 4 3 word-entry-point-offset LWZ\r
]\r
[ 4 MTLR BLRL ]\r
[ 4 MTCTR BCTR ] \ (execute) define-combinator-primitive\r
[\r
3 ds-reg 0 LWZ\r
ds-reg dup 4 SUBI\r
- 4 3 word-xt-offset LWZ\r
+ 4 3 word-entry-point-offset LWZ\r
4 MTCTR BCTR\r
] jit-execute jit-define\r
\r
! Save ctx->callstack_bottom\r
1 ctx-reg context-callstack-bottom-offset STW\r
! Call quotation\r
- 5 3 quot-xt-offset LWZ\r
+ 5 3 quot-entry-point-offset LWZ\r
5 MTLR\r
BLRL\r
jit-save-context\r
0 MTLR\r
\r
! Call quotation\r
- 4 3 quot-xt-offset LWZ\r
+ 4 3 quot-entry-point-offset LWZ\r
4 MTCTR\r
BCTR\r
] \ unwind-native-frames define-sub-primitive\r
0 2 LOAD32 "lazy_jit_compile" f rc-absolute-ppc-2/2 jit-dlsym\r
2 MTLR\r
BLRL\r
- 5 3 quot-xt-offset LWZ\r
+ 5 3 quot-entry-point-offset LWZ\r
]\r
[ 5 MTLR BLRL ]\r
[ 5 MTCTR BCTR ]\r
HOOK: reserved-area-size os ( -- n )
! The start of the stack frame contains the size of this frame
-! as well as the currently executing XT
+! as well as the currently executing code block
: factor-area-size ( -- n ) 2 cells ; foldable
: next-save ( n -- i ) cell - ; foldable
: xt-save ( n -- i ) 2 cells - ; foldable
M: ppc %alien-callback ( quot -- )
3 4 %restore-context
3 swap %load-reference
- 4 3 quot-xt-offset LWZ
+ 4 3 quot-entry-point-offset LWZ
4 MTLR
BLRL
3 4 %save-context ;
M: x86.32 %alien-callback ( quot -- )
EAX EDX %restore-context
EAX swap %load-reference
- EAX quot-xt-offset [+] CALL
+ EAX quot-entry-point-offset [+] CALL
EAX EDX %save-context ;
M: x86.32 %callback-value ( ctype -- )
[
! save stack frame size
stack-frame-size PUSH
- ! push XT
+ ! push entry point
0 PUSH rc-absolute-cell rt-this jit-rel
! alignment
ESP stack-frame-size 3 bootstrap-cells - SUB
EDX stack-reg stack-frame-size 4 - [+] LEA
ctx-reg context-callstack-bottom-offset [+] EDX MOV
! call the quotation
- EAX quot-xt-offset [+] CALL
+ EAX quot-entry-point-offset [+] CALL
! save ds, rs registers
jit-save-context
] \ c-to-factor define-sub-primitive
EAX ds-reg [] MOV
ds-reg bootstrap-cell SUB
]
-[ EAX quot-xt-offset [+] CALL ]
-[ EAX quot-xt-offset [+] JMP ]
+[ EAX quot-entry-point-offset [+] CALL ]
+[ EAX quot-entry-point-offset [+] JMP ]
\ (call) define-combinator-primitive
[
jit-restore-context
! Call quotation
- EAX quot-xt-offset [+] JMP
+ EAX quot-entry-point-offset [+] JMP
] \ unwind-native-frames define-sub-primitive
[
! Call VM
0 CALL "lazy_jit_compile" f rc-relative jit-dlsym
]
-[ EAX quot-xt-offset [+] CALL ]
-[ EAX quot-xt-offset [+] JMP ]
+[ EAX quot-entry-point-offset [+] CALL ]
+[ EAX quot-entry-point-offset [+] JMP ]
\ lazy-jit-compile define-combinator-primitive
! Inline cache miss entry points
M: x86.64 %alien-callback ( quot -- )
param-reg-0 param-reg-1 %restore-context
param-reg-0 swap %load-reference
- param-reg-0 quot-xt-offset [+] CALL
+ param-reg-0 quot-entry-point-offset [+] CALL
param-reg-0 param-reg-1 %save-context ;
M: x86.64 %callback-value ( ctype -- )
: rex-length ( -- n ) 1 ;
[
- ! load XT
+ ! load entry point
safe-reg 0 MOV rc-absolute-cell rt-this jit-rel
! save stack frame size
stack-frame-size PUSH
- ! push XT
+ ! push entry point
safe-reg PUSH
! alignment
RSP stack-frame-size 3 bootstrap-cells - SUB
safe-reg stack-reg stack-frame-size 8 - [+] LEA
ctx-reg context-callstack-bottom-offset [+] safe-reg MOV
! call the quotation
- arg1 quot-xt-offset [+] CALL
+ arg1 quot-entry-point-offset [+] CALL
jit-save-context
] \ c-to-factor define-sub-primitive
arg1 ds-reg [] MOV
ds-reg bootstrap-cell SUB
]
-[ arg1 quot-xt-offset [+] CALL ]
-[ arg1 quot-xt-offset [+] JMP ]
+[ arg1 quot-entry-point-offset [+] CALL ]
+[ arg1 quot-entry-point-offset [+] JMP ]
\ (call) define-combinator-primitive
[
jit-restore-context
! Call quotation
- arg1 quot-xt-offset [+] JMP
+ arg1 quot-entry-point-offset [+] JMP
] \ unwind-native-frames define-sub-primitive
[
safe-reg 0 MOV "lazy_jit_compile" f rc-absolute-cell jit-dlsym
safe-reg CALL
]
-[ return-reg quot-xt-offset [+] CALL ]
-[ return-reg quot-xt-offset [+] JMP ]
+[ return-reg quot-entry-point-offset [+] CALL ]
+[ return-reg quot-entry-point-offset [+] JMP ]
\ lazy-jit-compile define-combinator-primitive
! Inline cache miss entry points
vm-reg 0 MOV rc-absolute-cell rt-vm jit-rel
! Call into Factor code
- safe-reg 0 MOV rc-absolute-cell rt-xt jit-rel
+ safe-reg 0 MOV rc-absolute-cell rt-entry-point jit-rel
safe-reg CALL
! Tear down register shadow area
temp0 profile-count-offset [+] 1 tag-fixnum ADD
! Load word->code
temp0 temp0 word-code-offset [+] MOV
- ! Compute word XT
+ ! Compute word entry point
temp0 compiled-header-size ADD
- ! Jump to XT
+ ! Jump to entry point
temp0 JMP
] jit-profiling jit-define
[
temp3 0 MOV rc-absolute-cell rt-here jit-rel
- 0 JMP rc-relative rt-xt-pic-tail jit-rel
+ 0 JMP rc-relative rt-entry-point-pic-tail jit-rel
] jit-word-jump jit-define
[
- 0 CALL rc-relative rt-xt-pic jit-rel
+ 0 CALL rc-relative rt-entry-point-pic jit-rel
] jit-word-call jit-define
[
! compare boolean with f
temp0 \ f type-number CMP
! jump to true branch if not equal
- 0 JNE rc-relative rt-xt jit-rel
+ 0 JNE rc-relative rt-entry-point jit-rel
! jump to false branch if equal
- 0 JMP rc-relative rt-xt jit-rel
+ 0 JMP rc-relative rt-entry-point jit-rel
] jit-if jit-define
: jit->r ( -- )
[
jit->r
- 0 CALL rc-relative rt-xt jit-rel
+ 0 CALL rc-relative rt-entry-point jit-rel
jit-r>
] jit-dip jit-define
[
jit-2>r
- 0 CALL rc-relative rt-xt jit-rel
+ 0 CALL rc-relative rt-entry-point jit-rel
jit-2r>
] jit-2dip jit-define
[
jit-3>r
- 0 CALL rc-relative rt-xt jit-rel
+ 0 CALL rc-relative rt-entry-point jit-rel
jit-3r>
] jit-3dip jit-define
! pop stack
ds-reg bootstrap-cell SUB
]
-[ temp0 word-xt-offset [+] CALL ]
-[ temp0 word-xt-offset [+] JMP ]
+[ temp0 word-entry-point-offset [+] CALL ]
+[ temp0 word-entry-point-offset [+] JMP ]
\ (execute) define-combinator-primitive
[
temp0 ds-reg [] MOV
ds-reg bootstrap-cell SUB
- temp0 word-xt-offset [+] JMP
+ temp0 word-entry-point-offset [+] JMP
] jit-execute jit-define
[
temp1 temp2 CMP
] pic-check-tuple jit-define
-[ 0 JE rc-relative rt-xt jit-rel ] pic-hit jit-define
+[ 0 JE rc-relative rt-entry-point jit-rel ] pic-hit jit-define
! ! ! Megamorphic caches
temp1 [] 1 ADD
! goto get(cache + bootstrap-cell)
temp0 temp0 bootstrap-cell [+] MOV
- temp0 word-xt-offset [+] JMP
+ temp0 word-entry-point-offset [+] JMP
! fall-through on miss
] mega-lookup jit-define
\ (word) { object object object } { word } define-primitive
\ (word) make-flushable
-\ word-xt { word } { integer integer } define-primitive
-\ word-xt make-flushable
+\ word-code { word } { integer integer } define-primitive
+\ word-code make-flushable
\ special-object { fixnum } { object } define-primitive
\ special-object make-flushable
\ array>quotation { array } { quotation } define-primitive
\ array>quotation make-flushable
-\ quotation-xt { quotation } { integer } define-primitive
-\ quotation-xt make-flushable
+\ quotation-code { quotation } { integer integer } define-primitive
+\ quotation-code make-flushable
\ <tuple> { tuple-layout } { tuple } define-primitive
\ <tuple> make-flushable
GENERIC: disassemble ( obj -- )
+<PRIVATE
+
SYMBOL: disassembler-backend
HOOK: disassemble* disassembler-backend ( from to -- lines )
TR: tabs>spaces "\t" "\s" ;
+PRIVATE>
+
M: byte-array disassemble
[
[ malloc-byte-array &free alien-address dup ]
M: pair disassemble first2 disassemble* [ tabs>spaces print ] each ;
-M: word disassemble word-xt 2array disassemble ;
+M: word disassemble word-code 2array disassemble ;
M: quotation disassemble [ dup infer define-temp ] with-compilation-unit disassemble ;
-! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
+! Copyright (C) 2008, 2010 Slava Pestov, Jorge Acereda Macia.
! See http://factorcode.org/license.txt for BSD license.
USING: io.files io.files.temp io words alien kernel math.parser
-alien.syntax io.launcher assocs arrays sequences
-namespaces make system math io.encodings.ascii
-accessors tools.disassembler ;
+alien.syntax io.launcher assocs arrays sequences namespaces make
+system math io.encodings.ascii accessors tools.disassembler
+tools.disassembler.private ;
IN: tools.disassembler.gdb
SINGLETON: gdb-disassembler
-! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
+! Copyright (C) 2008, 2010 Slava Pestov, Jorge Acereda Macia.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.disassembler namespaces combinators
alien alien.syntax alien.c-types lexer parser kernel
sequences layouts math math.order alien.libraries
math.parser system make fry arrays libc destructors
-tools.disassembler.utils splitting alien.data
-classes.struct ;
+tools.disassembler.utils tools.disassembler.private splitting
+alien.data classes.struct ;
IN: tools.disassembler.udis
<<
dup UD_SYN_INTEL ud_set_syntax ;
: with-ud ( quot: ( ud -- ) -- )
- [ [ [ <ud> ] dip call ] with-destructors ] with-words-xt ; inline
+ [ [ [ <ud> ] dip call ] with-destructors ] with-word-entry-points ; inline
SINGLETON: udis-disassembler
math.parser namespaces sequences sorting splitting vectors vocabs words ;
IN: tools.disassembler.utils
-SYMBOL: words-xt
+SYMBOL: word-entry-points
SYMBOL: smallest-xt
SYMBOL: greatest-xt
-: (words-xt) ( -- assoc )
- vocabs [ words ] map concat [ [ word-xt ] keep 3array ] map
- [ [ first ] bi@ <=> ] sort >vector ;
+: (word-entry-points) ( -- assoc )
+ vocabs [ words ] map concat [ [ word-code ] keep 3array ] map
+ [ first ] sort-with ;
: complete-address ( n seq -- str )
[ first - ] [ third name>> ] bi
dup [ smallest-xt get < ] [ greatest-xt get > ] bi or [
drop f
] [
- words-xt get over [ swap first <=> ] curry search nip
+ word-entry-points get over [ swap first <=> ] curry search nip
2dup second <= [
[ complete-address ] [ drop f ] if*
] [
: resolve-call ( str -- str' )
"0x" split1-last [ resolve-xt "0x" glue ] when* ;
-: with-words-xt ( quot -- )
- [ (words-xt)
- [ words-xt set ]
- [ first first smallest-xt set ]
- [ last second greatest-xt set ] tri
- ] prepose with-scope ; inline
+: with-word-entry-points ( quot -- )
+ [
+ (word-entry-points)
+ [ word-entry-points set ]
+ [ first first smallest-xt set ]
+ [ last second greatest-xt set ] tri
+ call
+ ] with-scope ; inline
{ "float-u>" "math.private" (( x y -- ? )) }
{ "float-u>=" "math.private" (( x y -- ? )) }
{ "(word)" "words.private" (( name vocab -- word )) }
- { "word-xt" "words" (( word -- start end )) }
+ { "word-code" "words" (( word -- start end )) }
{ "special-object" "kernel.private" (( n -- obj )) }
{ "set-special-object" "kernel.private" (( obj n -- )) }
{ "(exists?)" "io.files.private" (( path -- ? )) }
{ "(clone)" "kernel" (( obj -- newobj )) }
{ "<string>" "strings" (( n ch -- string )) }
{ "array>quotation" "quotations.private" (( array -- quot )) }
- { "quotation-xt" "quotations" (( quot -- xt )) }
+ { "quotation-code" "quotations" (( quot -- start end )) }
{ "<tuple>" "classes.tuple.private" (( layout -- tuple )) }
{ "profiling" "tools.profiler.private" (( ? -- )) }
{ "become" "kernel.private" (( old new -- )) }
IN: quotations
ARTICLE: "quotations" "Quotations"
-"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called. Quotations are delimited by square brackets (" { $snippet "[ ]" } "); see " { $link "syntax-quots" } " for details on their syntax."
+"A quotation is an anonymous function (a value denoting a snippet of code) which can be used as a value and called using the " { $link "call" } "."
+$nl
+"Quotation literals appearing in source code are delimited by square brackets, for example " { $snippet "[ 2 + ]" } "; see " { $link "syntax-quots" } " for details on their syntax."
$nl
"Quotations form a class of objects:"
{ $subsections
ARTICLE: "word.private" "Word implementation details"
"The " { $snippet "def" } " slot of a word holds a " { $link quotation } " instance that is called when the word is executed."
$nl
-"An " { $emphasis "XT" } " (execution token) is the machine code address of a word:"
-{ $subsections word-xt } ;
+"A primitive to get the memory range storing the machine code for a word:"
+{ $subsections word-code } ;
ARTICLE: "words.introspection" "Word introspection"
"Word introspection facilities and implementation details are found in the " { $vocab-link "words" } " vocabulary."
{ $description "Removes a word property, so future lookups will output " { $link f } " until it is set again. Word property names are conventionally strings." }
{ $side-effects "word" } ;
-HELP: word-xt ( word -- start end )
+HELP: word-code ( word -- start end )
{ $values { "word" word } { "start" "the word's start address" } { "end" "the word's end address" } }
-{ $description "Outputs the machine code address of the word's definition." } ;
+{ $description "Outputs the memory range containing the word's machine code." } ;
HELP: define
{ $values { "word" word } { "def" quotation } }
] map harvest
] unit-test
-[ "hi" word-xt ] must-fail
+[ "hi" word-code ] must-fail
void callback_heap::update(code_block *stub)
{
- store_callback_operand(stub,1,(cell)callback_xt(stub));
+ store_callback_operand(stub,1,(cell)callback_entry_point(stub));
stub->flush_icache();
}
stub->parameters = false_object;
stub->relocation = false_object;
- memcpy(stub->xt(),insns->data<void>(),size);
+ memcpy(stub->entry_point(),insns->data<void>(),size);
/* Store VM pointer */
store_callback_operand(stub,0,(cell)parent);
tagged<word> w(ctx->pop());
w.untag_check(this);
- ctx->push(allot_alien(callbacks->add(w.value(),return_rewind)->xt()));
+ ctx->push(allot_alien(callbacks->add(w.value(),return_rewind)->entry_point()));
}
}
/* The callback heap is used to store the machine code that alien-callbacks
actually jump to when C code invokes them.
-The callback heap has entries that look like code_blocks from the code heap,
-but callback heap entries are allocated contiguously, never deallocated, and all
+The callback heap has entries that look like code_blocks from the code heap, but
+callback heap entries are allocated contiguously, never deallocated, and all
fields but the owner are set to false_object. The owner points to the callback
-bottom word, whose XT is the callback body itself, generated by the optimizing
-compiler. The machine code that follows a callback stub consists of a single
-CALLBACK_STUB machine code template, which performs a jump to a "far" address
-(on PowerPC and x86-64, its loaded into a register first).
+bottom word, whose entry point is the callback body itself, generated by the
+optimizing compiler. The machine code that follows a callback stub consists of a
+single CALLBACK_STUB machine code template, which performs a jump to a "far"
+address (on PowerPC and x86-64, its loaded into a register first).
GC updates the CALLBACK_STUB code if the code block of the callback bottom word
is ever moved. The callback stub itself won't move, though, and is never
explicit callback_heap(cell size, factor_vm *parent);
~callback_heap();
- void *callback_xt(code_block *stub)
+ void *callback_entry_point(code_block *stub)
{
word *w = (word *)UNTAG(stub->owner);
- return w->xt;
+ return w->entry_point;
}
void store_callback_operand(code_block *stub, cell index, cell value);
void factor_vm::check_frame(stack_frame *frame)
{
#ifdef FACTOR_DEBUG
- check_code_pointer((cell)frame->xt);
+ check_code_pointer((cell)frame->entry_point);
assert(frame->size != 0);
#endif
}
code_block *factor_vm::frame_code(stack_frame *frame)
{
check_frame(frame);
- return (code_block *)frame->xt - 1;
+ return (code_block *)frame->entry_point - 1;
}
code_block_type factor_vm::frame_type(stack_frame *frame)
if(obj.type_p(QUOTATION_TYPE))
{
char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame,this);
- char *quot_xt = (char *)(frame_code(frame) + 1);
+ char *quot_entry_point = (char *)(frame_code(frame) + 1);
return tag_fixnum(quot_code_offset_to_scan(
- obj.value(),(cell)(return_addr - quot_xt)));
+ obj.value(),(cell)(return_addr - quot_entry_point)));
}
else
return false_object;
jit_compile_quot(quot.value(),true);
stack_frame *inner = innermost_stack_frame(callstack.untagged());
- cell offset = (char *)FRAME_RETURN_ADDRESS(inner,this) - (char *)inner->xt;
- inner->xt = quot->xt;
- FRAME_RETURN_ADDRESS(inner,this) = (char *)quot->xt + offset;
+ cell offset = (char *)FRAME_RETURN_ADDRESS(inner,this) - (char *)inner->entry_point;
+ inner->entry_point = quot->entry_point;
+ FRAME_RETURN_ADDRESS(inner,this) = (char *)quot->entry_point + offset;
}
}
void operator()(stack_frame *frame)
{
- cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt;
+ cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->entry_point;
code_block *new_block = visitor(parent->frame_code(frame));
- frame->xt = new_block->xt();
+ frame->entry_point = new_block->entry_point();
- FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset);
+ FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->entry_point + offset);
}
};
if(w->profiling)
w->profiling = visitor(w->profiling);
- parent->update_word_xt(w);
+ parent->update_word_entry_point(w);
break;
}
case QUOTATION_TYPE:
{
quotation *q = (quotation *)obj;
if(q->code)
- parent->set_quot_xt(q,visitor(q->code));
+ parent->set_quot_entry_point(q,visitor(q->code));
break;
}
case CALLSTACK_TYPE:
void operator()(instruction_operand op)
{
relocation_type type = op.rel_type();
- if(type == RT_XT || type == RT_XT_PIC || type == RT_XT_PIC_TAIL)
+ if(type == RT_ENTRY_POINT
+ || type == RT_ENTRY_POINT_PIC
+ || type == RT_ENTRY_POINT_PIC_TAIL)
op.store_code_block(visitor(op.load_code_block()));
}
};
namespace factor
{
-cell factor_vm::compute_xt_address(cell obj)
+cell factor_vm::compute_entry_point_address(cell obj)
{
switch(tagged<object>(obj).type())
{
case WORD_TYPE:
- return (cell)untag<word>(obj)->xt;
+ return (cell)untag<word>(obj)->entry_point;
case QUOTATION_TYPE:
- return (cell)untag<quotation>(obj)->xt;
+ return (cell)untag<quotation>(obj)->entry_point;
default:
critical_error("Expected word or quotation",obj);
return 0;
}
}
-cell factor_vm::compute_xt_pic_address(word *w, cell tagged_quot)
+cell factor_vm::compute_entry_point_pic_address(word *w, cell tagged_quot)
{
if(!to_boolean(tagged_quot) || max_pic_size == 0)
- return (cell)w->xt;
+ return (cell)w->entry_point;
else
{
quotation *quot = untag<quotation>(tagged_quot);
if(quot_compiled_p(quot))
- return (cell)quot->xt;
+ return (cell)quot->entry_point;
else
- return (cell)w->xt;
+ return (cell)w->entry_point;
}
}
-cell factor_vm::compute_xt_pic_address(cell w_)
+cell factor_vm::compute_entry_point_pic_address(cell w_)
{
tagged<word> w(w_);
- return compute_xt_pic_address(w.untagged(),w->pic_def);
+ return compute_entry_point_pic_address(w.untagged(),w->pic_def);
}
-cell factor_vm::compute_xt_pic_tail_address(cell w_)
+cell factor_vm::compute_entry_point_pic_tail_address(cell w_)
{
tagged<word> w(w_);
- return compute_xt_pic_address(w.untagged(),w->pic_tail_def);
+ return compute_entry_point_pic_address(w.untagged(),w->pic_tail_def);
}
cell factor_vm::code_block_owner(code_block *compiled)
{
switch(op.rel_type())
{
- case RT_XT:
+ case RT_ENTRY_POINT:
{
code_block *compiled = op.load_code_block();
cell owner = compiled->owner;
- if(to_boolean(owner)) op.store_value(parent->compute_xt_address(owner));
+ if(to_boolean(owner))
+ op.store_value(parent->compute_entry_point_address(owner));
break;
}
- case RT_XT_PIC:
+ case RT_ENTRY_POINT_PIC:
{
code_block *compiled = op.load_code_block();
cell owner = parent->code_block_owner(compiled);
- if(to_boolean(owner)) op.store_value(parent->compute_xt_pic_address(owner));
+ if(to_boolean(owner))
+ op.store_value(parent->compute_entry_point_pic_address(owner));
break;
}
- case RT_XT_PIC_TAIL:
+ case RT_ENTRY_POINT_PIC_TAIL:
{
code_block *compiled = op.load_code_block();
cell owner = parent->code_block_owner(compiled);
- if(to_boolean(owner)) op.store_value(parent->compute_xt_pic_tail_address(owner));
+ if(to_boolean(owner))
+ op.store_value(parent->compute_entry_point_pic_tail_address(owner));
break;
}
default:
initialize_code_block(compiled);
/* update_word_references() is always applied to every block in
the code heap. Since it resets all call sites to point to
- their canonical XT (cold entry point for non-tail calls,
+ their canonical entry point (cold entry point for non-tail calls,
standard entry point for tail calls), it means that no PICs
are referenced after this is done. So instead of polluting
the code heap with dead PICs that will be freed on the next
}
}
-cell factor_vm::compute_context_address()
-{
- return (cell)&ctx;
-}
-
cell factor_vm::compute_vm_address(cell arg)
{
return (cell)this + untag_fixnum(arg);
op.store_value(compute_dlsym_address(parameters,index));
break;
case RT_THIS:
- op.store_value((cell)compiled->xt());
- break;
- case RT_CONTEXT:
- op.store_value(compute_context_address());
+ op.store_value((cell)compiled->entry_point());
break;
case RT_MEGAMORPHIC_CACHE_HITS:
op.store_value((cell)&dispatch_stats.megamorphic_cache_hits);
cell factor_vm::compute_here_address(cell arg, cell offset, code_block *compiled)
{
fixnum n = untag_fixnum(arg);
- return n >= 0 ? ((cell)compiled->xt() + offset + n) : ((cell)compiled->xt() - n);
+ if(n >= 0)
+ return (cell)compiled->entry_point() + offset + n;
+ else
+ return (cell)compiled->entry_point() - n;
}
struct initial_code_block_visitor {
case RT_LITERAL:
op.store_value(next_literal());
break;
- case RT_XT:
- op.store_value(parent->compute_xt_address(next_literal()));
+ case RT_ENTRY_POINT:
+ op.store_value(parent->compute_entry_point_address(next_literal()));
break;
- case RT_XT_PIC:
- op.store_value(parent->compute_xt_pic_address(next_literal()));
+ case RT_ENTRY_POINT_PIC:
+ op.store_value(parent->compute_entry_point_pic_address(next_literal()));
break;
- case RT_XT_PIC_TAIL:
- op.store_value(parent->compute_xt_pic_tail_address(next_literal()));
+ case RT_ENTRY_POINT_PIC_TAIL:
+ op.store_value(parent->compute_entry_point_pic_tail_address(next_literal()));
break;
case RT_HERE:
op.store_value(parent->compute_here_address(next_literal(),op.rel_offset(),op.parent_code_block()));
relocation_entry new_entry(RT_HERE,rel_class,offset);
instruction_operand op(new_entry,compiled,0);
- op.store_value(target + (cell)compiled->xt());
+ op.store_value(target + (cell)compiled->entry_point());
}
}
return size;
}
- void *xt() const
+ void *entry_point() const
{
return (void *)(this + 1);
}
break;
}
- update_word_xt(word.untagged());
+ update_word_entry_point(word.untagged());
}
update_code_heap_words();
void operator()(instruction_operand op)
{
- cell old_offset = op.rel_offset() + (cell)old_address->xt();
+ cell old_offset = op.rel_offset() + (cell)old_address->entry_point();
switch(op.rel_type())
{
case RT_LITERAL:
op.store_value(slot_forwarder.visit_pointer(op.load_value(old_offset)));
break;
- case RT_XT:
- case RT_XT_PIC:
- case RT_XT_PIC_TAIL:
+ case RT_ENTRY_POINT:
+ case RT_ENTRY_POINT_PIC:
+ case RT_ENTRY_POINT_PIC_TAIL:
op.store_code_block(code_forwarder.visit_code_block(op.load_code_block(old_offset)));
break;
case RT_HERE:
std::cout << std::hex << (cell)parent->frame_executing(frame) << std::dec;
std::cout << std::endl;
std::cout << "word/quot xt: ";
- std::cout << std::hex << (cell)frame->xt << std::dec;
+ std::cout << std::hex << (cell)frame->entry_point << std::dec;
std::cout << std::endl;
std::cout << "return address: ";
std::cout << std::hex << (cell)FRAME_RETURN_ADDRESS(frame,parent) << std::dec;
{
tagged<word> c_to_factor_word(special_objects[C_TO_FACTOR_WORD]);
code_block *c_to_factor_block = callbacks->add(c_to_factor_word.value(),0);
- c_to_factor_func = (c_to_factor_func_type)c_to_factor_block->xt();
+ c_to_factor_func = (c_to_factor_func_type)c_to_factor_block->entry_point();
}
c_to_factor_func(quot);
void factor_vm::unwind_native_frames(cell quot, stack_frame *to)
{
tagged<word> unwind_native_frames_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]);
- unwind_native_frames_func_type unwind_native_frames_func = (unwind_native_frames_func_type)unwind_native_frames_word->xt;
+ unwind_native_frames_func_type unwind_native_frames_func = (unwind_native_frames_func_type)unwind_native_frames_word->entry_point;
unwind_native_frames_func(quot,to);
}
void operator()(instruction_operand op)
{
code_block *compiled = op.parent_code_block();
- cell old_offset = op.rel_offset() + (cell)compiled->xt() - code_offset;
+ cell old_offset = op.rel_offset() + (cell)compiled->entry_point() - code_offset;
switch(op.rel_type())
{
case RT_LITERAL:
op.store_value(data_visitor.visit_pointer(op.load_value(old_offset)));
break;
- case RT_XT:
- case RT_XT_PIC:
- case RT_XT_PIC_TAIL:
+ case RT_ENTRY_POINT:
+ case RT_ENTRY_POINT_PIC:
+ case RT_ENTRY_POINT_PIC_TAIL:
op.store_code_block(code_visitor(op.load_code_block(old_offset)));
break;
case RT_HERE:
void factor_vm::deallocate_inline_cache(cell return_address)
{
/* Find the call target. */
- void *old_xt = get_call_target(return_address);
- check_code_pointer((cell)old_xt);
+ void *old_entry_point = get_call_target(return_address);
+ check_code_pointer((cell)old_entry_point);
- code_block *old_block = (code_block *)old_xt - 1;
+ code_block *old_block = (code_block *)old_entry_point - 1;
/* Free the old PIC since we know its unreachable */
if(old_block->pic_p())
/* A generic word's definition performs general method lookup. */
void *factor_vm::megamorphic_call_stub(cell generic_word)
{
- return untag<word>(generic_word)->xt;
+ return untag<word>(generic_word)->entry_point;
}
cell factor_vm::inline_cache_size(cell cache_entries)
generic_word.value(),
methods.value(),
new_cache_entries.value(),
- tail_call_site)->xt();
+ tail_call_site)->entry_point();
}
/* Install the new stub. */
{
instruction_operand::instruction_operand(relocation_entry rel_, code_block *compiled_, cell index_) :
- rel(rel_), compiled(compiled_), index(index_), pointer((cell)compiled_->xt() + rel_.rel_offset()) {}
+ rel(rel_), compiled(compiled_), index(index_), pointer((cell)compiled_->entry_point() + rel_.rel_offset()) {}
/* Load a 32-bit value from a PowerPC LIS/ORI sequence */
fixnum instruction_operand::load_value_2_2()
void instruction_operand::store_code_block(code_block *compiled)
{
- store_value((cell)compiled->xt());
+ store_value((cell)compiled->entry_point());
}
}
RT_PRIMITIVE,
/* arg is a literal table index, holding an array pair (symbol/dll) */
RT_DLSYM,
- /* a pointer to a compiled word reference */
- RT_DISPATCH,
/* a word or quotation's general entry point */
- RT_XT,
+ RT_ENTRY_POINT,
/* a word's PIC entry point */
- RT_XT_PIC,
+ RT_ENTRY_POINT_PIC,
/* a word's tail-call PIC entry point */
- RT_XT_PIC_TAIL,
+ RT_ENTRY_POINT_PIC_TAIL,
/* current offset */
RT_HERE,
/* current code block */
RT_THIS,
/* data heap literal */
RT_LITERAL,
- /* address of ctx var */
- RT_CONTEXT,
/* untagged fixnum literal */
RT_UNTAGGED,
/* address of megamorphic_cache_hits var */
return 1;
case RT_DLSYM:
return 2;
- case RT_XT:
- case RT_XT_PIC:
- case RT_XT_PIC_TAIL:
+ case RT_ENTRY_POINT:
+ case RT_ENTRY_POINT_PIC:
+ case RT_ENTRY_POINT_PIC_TAIL:
case RT_LITERAL:
case RT_HERE:
case RT_UNTAGGED:
case RT_THIS:
- case RT_CONTEXT:
case RT_MEGAMORPHIC_CACHE_HITS:
case RT_CARDS_OFFSET:
case RT_DECKS_OFFSET:
cell counter;
/* TAGGED machine code for sub-primitive */
cell subprimitive;
- /* UNTAGGED execution token: jump here to execute word */
- void *xt;
+ /* UNTAGGED entry point: jump here to execute word */
+ void *entry_point;
/* UNTAGGED compiled code block */
code_block *code;
/* UNTAGGED profiler stub */
cell cached_effect;
/* tagged */
cell cache_counter;
- /* UNTAGGED */
- void *xt;
+ /* UNTAGGED entry point; jump here to call quotation */
+ void *entry_point;
/* UNTAGGED compiled code block */
code_block *code;
};
};
struct stack_frame {
- void *xt;
+ /* Updated by procedure prologue with procedure start address */
+ void *entry_point;
/* Frame size in bytes */
cell size;
};
PRIMITIVE_FORWARD(float_greater)
PRIMITIVE_FORWARD(float_greatereq)
PRIMITIVE_FORWARD(word)
-PRIMITIVE_FORWARD(word_xt)
+PRIMITIVE_FORWARD(word_code)
PRIMITIVE_FORWARD(special_object)
PRIMITIVE_FORWARD(set_special_object)
PRIMITIVE_FORWARD(existsp)
PRIMITIVE_FORWARD(clone)
PRIMITIVE_FORWARD(string)
PRIMITIVE_FORWARD(array_to_quotation)
-PRIMITIVE_FORWARD(quotation_xt)
+PRIMITIVE_FORWARD(quotation_code)
PRIMITIVE_FORWARD(tuple)
PRIMITIVE_FORWARD(profiling)
PRIMITIVE_FORWARD(become)
primitive_float_greater,
primitive_float_greatereq,
primitive_word,
- primitive_word_xt,
+ primitive_word_code,
primitive_special_object,
primitive_set_special_object,
primitive_existsp,
primitive_clone,
primitive_string,
primitive_array_to_quotation,
- primitive_quotation_xt,
+ primitive_quotation_code,
primitive_tuple,
primitive_profiling,
primitive_become,
word->counter = tag_fixnum(0);
}
- update_word_xt(word.untagged());
+ update_word_entry_point(word.untagged());
}
update_code_heap_words();
}
}
-void factor_vm::set_quot_xt(quotation *quot, code_block *code)
+void factor_vm::set_quot_entry_point(quotation *quot, code_block *code)
{
quot->code = code;
- quot->xt = code->xt();
+ quot->entry_point = code->entry_point();
}
/* Allocates memory */
if(!quot_compiled_p(quot.untagged()))
{
code_block *compiled = jit_compile_quot(quot.value(),quot.value(),relocating);
- set_quot_xt(quot.untagged(),compiled);
+ set_quot_entry_point(quot.untagged(),compiled);
}
}
quot->array = ctx->peek();
quot->cached_effect = false_object;
quot->cache_counter = false_object;
- set_quot_xt(quot,lazy_jit_compile_block());
+ set_quot_entry_point(quot,lazy_jit_compile_block());
ctx->replace(tag<quotation>(quot));
}
-void factor_vm::primitive_quotation_xt()
+void factor_vm::primitive_quotation_code()
{
- quotation *quot = untag_check<quotation>(ctx->peek());
- ctx->replace(allot_cell((cell)quot->xt));
+ quotation *quot = untag_check<quotation>(ctx->pop());
+
+ ctx->push(allot_cell((cell)quot->code->entry_point()));
+ ctx->push(allot_cell((cell)quot->code + quot->code->size()));
}
/* Allocates memory */
{
data_root<quotation> quot(array_nth(quotations.untagged(),i),this);
if(!quot->code)
- set_quot_xt(quot.untagged(),lazy_jit_compile_block());
+ set_quot_entry_point(quot.untagged(),lazy_jit_compile_block());
}
}
//words
word *allot_word(cell name_, cell vocab_, cell hashcode_);
void primitive_word();
- void primitive_word_xt();
- void update_word_xt(word *w_);
+ void primitive_word_code();
+ void update_word_entry_point(word *w_);
void primitive_optimized_p();
void primitive_wrapper();
void jit_compile_word(cell word_, cell def_, bool relocating);
void primitive_fclose();
//code_block
- cell compute_xt_address(cell obj);
- cell compute_xt_pic_address(word *w, cell tagged_quot);
- cell compute_xt_pic_address(cell w_);
- cell compute_xt_pic_tail_address(cell w_);
+ cell compute_entry_point_address(cell obj);
+ cell compute_entry_point_pic_address(word *w, cell tagged_quot);
+ cell compute_entry_point_pic_address(cell w_);
+ cell compute_entry_point_pic_tail_address(cell w_);
cell code_block_owner(code_block *compiled);
void update_word_references(code_block *compiled);
void check_code_address(cell address);
cell compute_primitive_address(cell arg);
void undefined_symbol();
cell compute_dlsym_address(array *literals, cell index);
- cell compute_context_address();
cell compute_vm_address(cell arg);
void store_external_address(instruction_operand op);
cell compute_here_address(cell arg, cell offset, code_block *compiled);
void primitive_jit_compile();
code_block *lazy_jit_compile_block();
void primitive_array_to_quotation();
- void primitive_quotation_xt();
- void set_quot_xt(quotation *quot, code_block *code);
+ void primitive_quotation_code();
+ void set_quot_entry_point(quotation *quot, code_block *code);
code_block *jit_compile_quot(cell owner_, cell quot_, bool relocating);
void jit_compile_quot(cell quot_, bool relocating);
fixnum quot_code_offset_to_scan(cell quot_, cell offset);
if(!word->code || !word->code->optimized_p())
jit_compile_word(word.value(),word->def,false);
- update_word_xt(word.untagged());
+ update_word_entry_point(word.untagged());
}
}
initialize_code_block(new_word->profiling);
}
- update_word_xt(new_word.untagged());
+ update_word_entry_point(new_word.untagged());
return new_word.untagged();
}
ctx->push(tag<word>(allot_word(name,vocab,hashcode)));
}
-/* word-xt ( word -- start end ) */
-void factor_vm::primitive_word_xt()
+/* word-code ( word -- start end ) */
+void factor_vm::primitive_word_code()
{
data_root<word> w(ctx->pop(),this);
w.untag_check(this);
if(profiling_p)
{
- ctx->push(allot_cell((cell)w->profiling->xt()));
+ ctx->push(allot_cell((cell)w->profiling->entry_point()));
ctx->push(allot_cell((cell)w->profiling + w->profiling->size()));
}
else
{
- ctx->push(allot_cell((cell)w->code->xt()));
+ ctx->push(allot_cell((cell)w->code->entry_point()));
ctx->push(allot_cell((cell)w->code + w->code->size()));
}
}
-void factor_vm::update_word_xt(word *w)
+void factor_vm::update_word_entry_point(word *w)
{
if(profiling_p && w->profiling)
- w->xt = w->profiling->xt();
+ w->entry_point = w->profiling->entry_point();
else
- w->xt = w->code->xt();
+ w->entry_point = w->code->entry_point();
}
void factor_vm::primitive_optimized_p()