set-context and start-context primitives can now pass parameters around

release
Slava Pestov 2010-03-27 08:13:57 -04:00
parent b5f7e91bdc
commit b6dfdcb909
4 changed files with 24 additions and 18 deletions

View File

@ -269,12 +269,11 @@ IN: bootstrap.x86
ESP [] vm-reg MOV ESP [] vm-reg MOV
"new_context" jit-call "new_context" jit-call
! Save pointer to quotation and parameter, pop them off the ! Save pointer to quotation and parameter
! datastack
EBX ds-reg MOV EBX ds-reg MOV
ds-reg 8 SUB ds-reg 8 SUB
! Make the new context the active context ! Make the new context active
EAX jit-set-context EAX jit-set-context
! Push parameter ! Push parameter
@ -288,16 +287,21 @@ IN: bootstrap.x86
] \ (start-context) define-sub-primitive ] \ (start-context) define-sub-primitive
[ [
! Load context from datastack ! Load context and parameter from datastack
EAX ds-reg [] MOV EAX ds-reg [] MOV
EAX EAX alien-offset [+] MOV EAX EAX alien-offset [+] MOV
ds-reg 4 SUB EBX ds-reg -4 [+] MOV
ds-reg 8 SUB
! Make it the active context ! Make the new context active
EAX jit-set-context EAX jit-set-context
! Twiddle stack for return ! Twiddle stack for return
ESP 4 ADD ESP 4 ADD
! Store parameter to datastack
ds-reg 4 ADD
ds-reg [] EBX MOV
] \ (set-context) define-sub-primitive ] \ (set-context) define-sub-primitive
<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>

View File

@ -242,15 +242,12 @@ IN: bootstrap.x86
arg1 vm-reg MOV arg1 vm-reg MOV
"new_context" jit-call "new_context" jit-call
! Load quotation from datastack ! Load quotation and parameter from datastack
arg1 ds-reg [] MOV arg1 ds-reg [] MOV
! Load parameter from datastack
arg2 ds-reg -8 [+] MOV arg2 ds-reg -8 [+] MOV
ds-reg 16 SUB ds-reg 16 SUB
! Make the new context the active context ! Make the new context active
return-reg jit-set-context return-reg jit-set-context
! Push parameter ! Push parameter
@ -262,16 +259,21 @@ IN: bootstrap.x86
] \ (start-context) define-sub-primitive ] \ (start-context) define-sub-primitive
[ [
! Load context from datastack ! Load context and parameter from datastack
temp0 ds-reg [] MOV temp0 ds-reg [] MOV
temp0 temp0 alien-offset [+] MOV temp0 temp0 alien-offset [+] MOV
ds-reg 8 SUB temp1 ds-reg -8 [+] MOV
ds-reg 16 SUB
! Make it the active context ! Make the new context active
temp0 jit-set-context temp0 jit-set-context
! Twiddle stack for return ! Twiddle stack for return
RSP 8 ADD RSP 8 ADD
! Store parameter to datastack
ds-reg 8 ADD
ds-reg [] temp1 MOV
] \ (set-context) define-sub-primitive ] \ (set-context) define-sub-primitive
<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >> << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>

View File

@ -513,9 +513,9 @@ M: bad-executable summary
\ delete-context { c-ptr } { } define-primitive \ delete-context { c-ptr } { } define-primitive
\ (start-context) { object quotation } { } define-primitive \ (start-context) { object quotation } { object } define-primitive
\ (set-context) { alien } { } define-primitive \ (set-context) { object alien } { object } define-primitive
\ special-object { fixnum } { object } define-primitive \ special-object { fixnum } { object } define-primitive
\ special-object make-flushable \ special-object make-flushable

View File

@ -369,8 +369,8 @@ tuple
{ "fixnum<=" "math.private" (( x y -- z )) } { "fixnum<=" "math.private" (( x y -- z )) }
{ "fixnum>" "math.private" (( x y -- ? )) } { "fixnum>" "math.private" (( x y -- ? )) }
{ "fixnum>=" "math.private" (( x y -- ? )) } { "fixnum>=" "math.private" (( x y -- ? )) }
{ "(set-context)" "threads.private" (( context -- )) } { "(set-context)" "threads.private" (( obj context -- obj' )) }
{ "(start-context)" "threads.private" (( obj quot -- )) } { "(start-context)" "threads.private" (( obj quot -- obj' )) }
} [ first3 make-sub-primitive ] each } [ first3 make-sub-primitive ] each
! Primitive words ! Primitive words