Stop wearing monocle and use the term "entry point" instead of "XT" throughout VM and compiler; also remove two unused relocation types
parent
41082b5b12
commit
637a77c018
|
@ -62,13 +62,13 @@ MEMO: cached-string>symbol ( symbol -- obj ) string>symbol ;
|
|||
[ 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 ;
|
||||
|
|
|
@ -20,8 +20,8 @@ CONSTANT: deck-bits 18
|
|||
: 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
|
||||
|
@ -49,19 +49,17 @@ CONSTANT: rc-absolute-2 10
|
|||
! 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? ;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
! Copyright (C) 2007, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel kernel.private namespaces
|
||||
system cpu.ppc.assembler compiler.codegen.fixup compiler.units
|
||||
compiler.constants math math.private math.ranges layouts words vocabs
|
||||
slots.private locals locals.backend generic.single.private fry
|
||||
sequences ;
|
||||
system cpu.ppc.assembler compiler.units compiler.constants math
|
||||
math.private math.ranges layouts words vocabs slots.private
|
||||
locals locals.backend generic.single.private fry sequences ;
|
||||
FROM: cpu.ppc.assembler => B ;
|
||||
IN: bootstrap.ppc
|
||||
|
||||
|
@ -66,7 +65,7 @@ CONSTANT: ctx-reg 16
|
|||
|
||||
0 vm-reg LOAD32 rc-absolute-ppc-2/2 rt-vm jit-rel
|
||||
|
||||
0 2 LOAD32 rc-absolute-ppc-2/2 rt-xt jit-rel
|
||||
0 2 LOAD32 rc-absolute-ppc-2/2 rt-entry-point jit-rel
|
||||
2 MTLR
|
||||
BLRL
|
||||
|
||||
|
@ -132,19 +131,19 @@ CONSTANT: ctx-reg 16
|
|||
jit-restore-context
|
||||
] jit-primitive jit-define
|
||||
|
||||
[ 0 BL rc-relative-ppc-3 rt-xt-pic jit-rel ] jit-word-call jit-define
|
||||
[ 0 BL rc-relative-ppc-3 rt-entry-point-pic jit-rel ] jit-word-call jit-define
|
||||
|
||||
[
|
||||
0 6 LOAD32 rc-absolute-ppc-2/2 rt-here jit-rel
|
||||
0 B rc-relative-ppc-3 rt-xt-pic-tail jit-rel
|
||||
0 B rc-relative-ppc-3 rt-entry-point-pic-tail jit-rel
|
||||
] jit-word-jump jit-define
|
||||
|
||||
[
|
||||
3 ds-reg 0 LWZ
|
||||
ds-reg dup 4 SUBI
|
||||
0 3 \ f type-number CMPI
|
||||
[ BEQ ] [ 0 B rc-relative-ppc-3 rt-xt jit-rel ] jit-conditional*
|
||||
0 B rc-relative-ppc-3 rt-xt jit-rel
|
||||
[ BEQ ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*
|
||||
0 B rc-relative-ppc-3 rt-entry-point jit-rel
|
||||
] jit-if jit-define
|
||||
|
||||
: jit->r ( -- )
|
||||
|
@ -195,19 +194,19 @@ CONSTANT: ctx-reg 16
|
|||
|
||||
[
|
||||
jit->r
|
||||
0 BL rc-relative-ppc-3 rt-xt jit-rel
|
||||
0 BL rc-relative-ppc-3 rt-entry-point jit-rel
|
||||
jit-r>
|
||||
] jit-dip jit-define
|
||||
|
||||
[
|
||||
jit-2>r
|
||||
0 BL rc-relative-ppc-3 rt-xt jit-rel
|
||||
0 BL rc-relative-ppc-3 rt-entry-point jit-rel
|
||||
jit-2r>
|
||||
] jit-2dip jit-define
|
||||
|
||||
[
|
||||
jit-3>r
|
||||
0 BL rc-relative-ppc-3 rt-xt jit-rel
|
||||
0 BL rc-relative-ppc-3 rt-entry-point jit-rel
|
||||
jit-3r>
|
||||
] jit-3dip jit-define
|
||||
|
||||
|
@ -256,7 +255,7 @@ CONSTANT: ctx-reg 16
|
|||
] pic-check-tuple jit-define
|
||||
|
||||
[
|
||||
[ BNE ] [ 0 B rc-relative-ppc-3 rt-xt jit-rel ] jit-conditional*
|
||||
[ BNE ] [ 0 B rc-relative-ppc-3 rt-entry-point jit-rel ] jit-conditional*
|
||||
] pic-hit jit-define
|
||||
|
||||
! Inline cache miss entry points
|
||||
|
@ -308,7 +307,7 @@ CONSTANT: ctx-reg 16
|
|||
5 4 0 STW
|
||||
! ... goto get(cache + 4)
|
||||
3 3 4 LWZ
|
||||
3 3 word-xt-offset LWZ
|
||||
3 3 word-entry-point-offset LWZ
|
||||
3 MTCTR
|
||||
BCTR
|
||||
]
|
||||
|
@ -322,7 +321,7 @@ CONSTANT: ctx-reg 16
|
|||
[
|
||||
3 ds-reg 0 LWZ
|
||||
ds-reg dup 4 SUBI
|
||||
5 3 quot-xt-offset LWZ
|
||||
5 3 quot-entry-point-offset LWZ
|
||||
]
|
||||
[ 5 MTLR BLRL ]
|
||||
[ 5 MTCTR BCTR ] \ (call) define-combinator-primitive
|
||||
|
@ -330,7 +329,7 @@ CONSTANT: ctx-reg 16
|
|||
[
|
||||
3 ds-reg 0 LWZ
|
||||
ds-reg dup 4 SUBI
|
||||
4 3 word-xt-offset LWZ
|
||||
4 3 word-entry-point-offset LWZ
|
||||
]
|
||||
[ 4 MTLR BLRL ]
|
||||
[ 4 MTCTR BCTR ] \ (execute) define-combinator-primitive
|
||||
|
@ -338,7 +337,7 @@ CONSTANT: ctx-reg 16
|
|||
[
|
||||
3 ds-reg 0 LWZ
|
||||
ds-reg dup 4 SUBI
|
||||
4 3 word-xt-offset LWZ
|
||||
4 3 word-entry-point-offset LWZ
|
||||
4 MTCTR BCTR
|
||||
] jit-execute jit-define
|
||||
|
||||
|
@ -348,7 +347,7 @@ CONSTANT: ctx-reg 16
|
|||
! Save ctx->callstack_bottom
|
||||
1 ctx-reg context-callstack-bottom-offset STW
|
||||
! Call quotation
|
||||
5 3 quot-xt-offset LWZ
|
||||
5 3 quot-entry-point-offset LWZ
|
||||
5 MTLR
|
||||
BLRL
|
||||
jit-save-context
|
||||
|
@ -370,7 +369,7 @@ CONSTANT: ctx-reg 16
|
|||
0 MTLR
|
||||
|
||||
! Call quotation
|
||||
4 3 quot-xt-offset LWZ
|
||||
4 3 quot-entry-point-offset LWZ
|
||||
4 MTCTR
|
||||
BCTR
|
||||
] \ unwind-native-frames define-sub-primitive
|
||||
|
@ -409,7 +408,7 @@ CONSTANT: ctx-reg 16
|
|||
0 2 LOAD32 "lazy_jit_compile" f rc-absolute-ppc-2/2 jit-dlsym
|
||||
2 MTLR
|
||||
BLRL
|
||||
5 3 quot-xt-offset LWZ
|
||||
5 3 quot-entry-point-offset LWZ
|
||||
]
|
||||
[ 5 MTLR BLRL ]
|
||||
[ 5 MTCTR BCTR ]
|
||||
|
|
|
@ -81,7 +81,7 @@ M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
|
|||
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
|
||||
|
@ -702,7 +702,7 @@ M: ppc %alien-invoke ( symbol dll -- )
|
|||
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 ;
|
||||
|
|
|
@ -244,7 +244,7 @@ M: x86.32 %alien-indirect ( -- )
|
|||
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 -- )
|
||||
|
|
|
@ -30,7 +30,7 @@ IN: bootstrap.x86
|
|||
[
|
||||
! 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
|
||||
|
@ -74,7 +74,7 @@ IN: bootstrap.x86
|
|||
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
|
||||
|
@ -83,8 +83,8 @@ IN: bootstrap.x86
|
|||
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
|
||||
|
||||
[
|
||||
|
@ -108,7 +108,7 @@ IN: bootstrap.x86
|
|||
jit-restore-context
|
||||
|
||||
! Call quotation
|
||||
EAX quot-xt-offset [+] JMP
|
||||
EAX quot-entry-point-offset [+] JMP
|
||||
] \ unwind-native-frames define-sub-primitive
|
||||
|
||||
[
|
||||
|
@ -150,8 +150,8 @@ IN: bootstrap.x86
|
|||
! 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
|
||||
|
|
|
@ -234,7 +234,7 @@ M: x86.64 %alien-indirect ( -- )
|
|||
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 -- )
|
||||
|
|
|
@ -27,11 +27,11 @@ IN: bootstrap.x86
|
|||
: 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
|
||||
|
@ -67,7 +67,7 @@ IN: bootstrap.x86
|
|||
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
|
||||
|
||||
|
@ -75,8 +75,8 @@ IN: bootstrap.x86
|
|||
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
|
||||
|
||||
[
|
||||
|
@ -97,7 +97,7 @@ IN: bootstrap.x86
|
|||
jit-restore-context
|
||||
|
||||
! Call quotation
|
||||
arg1 quot-xt-offset [+] JMP
|
||||
arg1 quot-entry-point-offset [+] JMP
|
||||
] \ unwind-native-frames define-sub-primitive
|
||||
|
||||
[
|
||||
|
@ -133,8 +133,8 @@ IN: bootstrap.x86
|
|||
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
|
||||
|
|
|
@ -34,7 +34,7 @@ big-endian off
|
|||
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
|
||||
|
@ -61,9 +61,9 @@ big-endian off
|
|||
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
|
||||
|
||||
|
@ -78,11 +78,11 @@ big-endian off
|
|||
|
||||
[
|
||||
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
|
||||
|
||||
[
|
||||
|
@ -93,9 +93,9 @@ big-endian off
|
|||
! 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 ( -- )
|
||||
|
@ -148,19 +148,19 @@ big-endian off
|
|||
|
||||
[
|
||||
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
|
||||
|
||||
|
@ -170,14 +170,14 @@ big-endian off
|
|||
! 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
|
||||
|
||||
[
|
||||
|
@ -224,7 +224,7 @@ big-endian off
|
|||
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
|
||||
|
||||
|
@ -248,7 +248,7 @@ big-endian off
|
|||
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
|
||||
|
||||
|
|
|
@ -486,8 +486,8 @@ M: bad-executable summary
|
|||
\ (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
|
||||
|
@ -662,8 +662,8 @@ M: bad-executable summary
|
|||
\ 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
|
||||
|
|
|
@ -7,12 +7,16 @@ IN: tools.disassembler
|
|||
|
||||
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 ]
|
||||
|
@ -22,7 +26,7 @@ M: byte-array disassemble
|
|||
|
||||
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 ;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
! 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
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
! 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
|
||||
|
||||
<<
|
||||
|
@ -105,7 +105,7 @@ FUNCTION: char* ud_lookup_mnemonic ( int c ) ;
|
|||
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
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ USING: accessors arrays binary-search kernel math math.order
|
|||
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
|
||||
|
@ -18,7 +18,7 @@ SYMBOL: greatest-xt
|
|||
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*
|
||||
] [
|
||||
|
@ -33,9 +33,11 @@ SYMBOL: greatest-xt
|
|||
: 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
|
||||
|
|
|
@ -420,7 +420,7 @@ tuple
|
|||
{ "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 -- ? )) }
|
||||
|
@ -496,7 +496,7 @@ tuple
|
|||
{ "(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 -- )) }
|
||||
|
|
|
@ -3,7 +3,9 @@ vectors kernel combinators ;
|
|||
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
|
||||
|
|
|
@ -133,8 +133,8 @@ $nl
|
|||
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."
|
||||
|
@ -209,9 +209,9 @@ HELP: remove-word-prop
|
|||
{ $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 } }
|
||||
|
|
|
@ -127,4 +127,4 @@ DEFER: x
|
|||
] map harvest
|
||||
] unit-test
|
||||
|
||||
[ "hi" word-xt ] must-fail
|
||||
[ "hi" word-code ] must-fail
|
||||
|
|
|
@ -38,7 +38,7 @@ void callback_heap::store_callback_operand(code_block *stub, cell index, cell va
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ code_block *callback_heap::add(cell owner, cell return_rewind)
|
|||
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);
|
||||
|
@ -99,7 +99,7 @@ void factor_vm::primitive_callback()
|
|||
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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace factor
|
|||
/* 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
|
||||
|
@ -32,10 +32,10 @@ struct callback_heap {
|
|||
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);
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace factor
|
|||
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
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void factor_vm::primitive_callstack()
|
|||
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)
|
||||
|
@ -105,10 +105,10 @@ cell factor_vm::frame_scan(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;
|
||||
|
@ -190,9 +190,9 @@ void factor_vm::primitive_set_innermost_stack_frame_quot()
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ struct call_frame_code_block_visitor {
|
|||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -64,14 +64,14 @@ void code_block_visitor<Visitor>::visit_object_code_block(object *obj)
|
|||
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:
|
||||
|
@ -93,7 +93,9 @@ struct embedded_code_pointers_visitor {
|
|||
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()));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,44 +3,44 @@
|
|||
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)
|
||||
|
@ -74,25 +74,28 @@ struct update_word_references_relocation_visitor {
|
|||
{
|
||||
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:
|
||||
|
@ -111,7 +114,7 @@ void factor_vm::update_word_references(code_block *compiled)
|
|||
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
|
||||
|
@ -193,11 +196,6 @@ cell factor_vm::compute_dlsym_address(array *literals, cell index)
|
|||
}
|
||||
}
|
||||
|
||||
cell factor_vm::compute_context_address()
|
||||
{
|
||||
return (cell)&ctx;
|
||||
}
|
||||
|
||||
cell factor_vm::compute_vm_address(cell arg)
|
||||
{
|
||||
return (cell)this + untag_fixnum(arg);
|
||||
|
@ -218,10 +216,7 @@ void factor_vm::store_external_address(instruction_operand op)
|
|||
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);
|
||||
|
@ -244,7 +239,10 @@ void factor_vm::store_external_address(instruction_operand op)
|
|||
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 {
|
||||
|
@ -267,14 +265,14 @@ 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()));
|
||||
|
@ -320,7 +318,7 @@ void factor_vm::fixup_labels(array *labels, code_block *compiled)
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ struct code_block
|
|||
return size;
|
||||
}
|
||||
|
||||
void *xt() const
|
||||
void *entry_point() const
|
||||
{
|
||||
return (void *)(this + 1);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ void factor_vm::primitive_modify_code_heap()
|
|||
break;
|
||||
}
|
||||
|
||||
update_word_xt(word.untagged());
|
||||
update_word_entry_point(word.untagged());
|
||||
}
|
||||
|
||||
update_code_heap_words();
|
||||
|
|
|
@ -104,16 +104,16 @@ struct code_block_compaction_relocation_visitor {
|
|||
|
||||
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:
|
||||
|
|
|
@ -171,7 +171,7 @@ struct stack_frame_printer {
|
|||
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;
|
||||
|
|
|
@ -13,7 +13,7 @@ void factor_vm::c_to_factor(cell quot)
|
|||
{
|
||||
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);
|
||||
|
@ -22,7 +22,7 @@ void factor_vm::c_to_factor(cell 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,16 +178,16 @@ struct code_block_fixup_relocation_visitor {
|
|||
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:
|
||||
|
|
|
@ -11,10 +11,10 @@ void factor_vm::init_inline_caching(int max_size)
|
|||
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())
|
||||
|
@ -148,7 +148,7 @@ code_block *factor_vm::compile_inline_cache(fixnum index,
|
|||
/* 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)
|
||||
|
@ -226,7 +226,7 @@ void *factor_vm::inline_cache_miss(cell return_address_)
|
|||
generic_word.value(),
|
||||
methods.value(),
|
||||
new_cache_entries.value(),
|
||||
tail_call_site)->xt();
|
||||
tail_call_site)->entry_point();
|
||||
}
|
||||
|
||||
/* Install the new stub. */
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace factor
|
|||
{
|
||||
|
||||
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()
|
||||
|
@ -132,7 +132,7 @@ void instruction_operand::store_value(fixnum absolute_value)
|
|||
|
||||
void instruction_operand::store_code_block(code_block *compiled)
|
||||
{
|
||||
store_value((cell)compiled->xt());
|
||||
store_value((cell)compiled->entry_point());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,22 +6,18 @@ enum relocation_type {
|
|||
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 */
|
||||
|
@ -102,14 +98,13 @@ struct relocation_entry {
|
|||
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:
|
||||
|
|
|
@ -232,8 +232,8 @@ struct word : public object {
|
|||
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 */
|
||||
|
@ -266,8 +266,8 @@ struct quotation : public object {
|
|||
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;
|
||||
};
|
||||
|
@ -302,7 +302,8 @@ struct dll : public object {
|
|||
};
|
||||
|
||||
struct stack_frame {
|
||||
void *xt;
|
||||
/* Updated by procedure prologue with procedure start address */
|
||||
void *entry_point;
|
||||
/* Frame size in bytes */
|
||||
cell size;
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ PRIMITIVE_FORWARD(float_lesseq)
|
|||
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)
|
||||
|
@ -98,7 +98,7 @@ PRIMITIVE_FORWARD(wrapper)
|
|||
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)
|
||||
|
@ -181,7 +181,7 @@ const primitive_type primitives[] = {
|
|||
primitive_float_greater,
|
||||
primitive_float_greatereq,
|
||||
primitive_word,
|
||||
primitive_word_xt,
|
||||
primitive_word_code,
|
||||
primitive_special_object,
|
||||
primitive_set_special_object,
|
||||
primitive_existsp,
|
||||
|
@ -257,7 +257,7 @@ const primitive_type primitives[] = {
|
|||
primitive_clone,
|
||||
primitive_string,
|
||||
primitive_array_to_quotation,
|
||||
primitive_quotation_xt,
|
||||
primitive_quotation_code,
|
||||
primitive_tuple,
|
||||
primitive_profiling,
|
||||
primitive_become,
|
||||
|
|
|
@ -52,7 +52,7 @@ void factor_vm::set_profiling(bool profiling)
|
|||
word->counter = tag_fixnum(0);
|
||||
}
|
||||
|
||||
update_word_xt(word.untagged());
|
||||
update_word_entry_point(word.untagged());
|
||||
}
|
||||
|
||||
update_code_heap_words();
|
||||
|
|
|
@ -267,10 +267,10 @@ void quotation_jit::iterate_quotation()
|
|||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
|
@ -296,7 +296,7 @@ void factor_vm::jit_compile_quot(cell quot_, bool relocating)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,15 +318,17 @@ void factor_vm::primitive_array_to_quotation()
|
|||
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 */
|
||||
|
@ -381,7 +383,7 @@ void factor_vm::initialize_all_quotations()
|
|||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
vm/vm.hpp
17
vm/vm.hpp
|
@ -393,8 +393,8 @@ struct factor_vm
|
|||
//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);
|
||||
|
@ -503,17 +503,16 @@ struct factor_vm
|
|||
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);
|
||||
|
@ -600,8 +599,8 @@ struct factor_vm
|
|||
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);
|
||||
|
|
18
vm/words.cpp
18
vm/words.cpp
|
@ -33,7 +33,7 @@ void factor_vm::compile_all_words()
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
|
|||
initialize_code_block(new_word->profiling);
|
||||
}
|
||||
|
||||
update_word_xt(new_word.untagged());
|
||||
update_word_entry_point(new_word.untagged());
|
||||
|
||||
return new_word.untagged();
|
||||
}
|
||||
|
@ -78,30 +78,30 @@ void factor_vm::primitive_word()
|
|||
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()
|
||||
|
|
Loading…
Reference in New Issue