]> gitweb.factorcode.org Git - factor.git/commitdiff
set-context and start-context primitives can now pass parameters around
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 27 Mar 2010 12:13:57 +0000 (08:13 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 27 Mar 2010 12:13:57 +0000 (08:13 -0400)
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/bootstrap.factor
basis/stack-checker/known-words/known-words.factor
core/bootstrap/primitives.factor

index 6fab8769d533c7b61f8002f8dcbfe2cdfe8ada62..dde800760e95a0a582ba83f6c4d83e7171cee175 100644 (file)
@@ -269,12 +269,11 @@ IN: bootstrap.x86
     ESP [] vm-reg MOV
     "new_context" jit-call
 
-    ! Save pointer to quotation and parameter, pop them off the
-    ! datastack
+    ! Save pointer to quotation and parameter
     EBX ds-reg MOV
     ds-reg 8 SUB
 
-    ! Make the new context the active context
+    ! Make the new context active
     EAX jit-set-context
 
     ! Push parameter
@@ -288,16 +287,21 @@ IN: bootstrap.x86
 ] \ (start-context) define-sub-primitive
 
 [
-    ! Load context from datastack
+    ! Load context and parameter from datastack
     EAX ds-reg [] 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
 
     ! Twiddle stack for return
     ESP 4 ADD
+
+    ! Store parameter to datastack
+    ds-reg 4 ADD
+    ds-reg [] EBX MOV
 ] \ (set-context) define-sub-primitive
 
 << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
index e8fa026a4985f104d1695c3b039fb966be07c231..9eb59e2c86ec4ddf782c28b78696cfb274904343 100644 (file)
@@ -242,15 +242,12 @@ IN: bootstrap.x86
     arg1 vm-reg MOV
     "new_context" jit-call
 
-    ! Load quotation from datastack
+    ! Load quotation and parameter from datastack
     arg1 ds-reg [] MOV
-
-    ! Load parameter from datastack
     arg2 ds-reg -8 [+] MOV
-
     ds-reg 16 SUB
 
-    ! Make the new context the active context
+    ! Make the new context active
     return-reg jit-set-context
 
     ! Push parameter
@@ -262,16 +259,21 @@ IN: bootstrap.x86
 ] \ (start-context) define-sub-primitive
 
 [
-    ! Load context from datastack
+    ! Load context and parameter from datastack
     temp0 ds-reg [] 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
 
     ! Twiddle stack for return
     RSP 8 ADD
+
+    ! Store parameter to datastack
+    ds-reg 8 ADD
+    ds-reg [] temp1 MOV
 ] \ (set-context) define-sub-primitive
 
 << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
index a625eedb3a8a66844028e9cc78843694be5d12ab..a95456cdc6a42ae7c7f9c53984d2ec76e972063b 100644 (file)
@@ -513,9 +513,9 @@ M: bad-executable summary
 
 \ 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 make-flushable
index 9971c00e1dc63b0580205b48a27569514336c8d6..38e1a380ee193d880f5b2bbc53ff0af72a7d68f7 100644 (file)
@@ -369,8 +369,8 @@ tuple
     { "fixnum<=" "math.private" (( x y -- z )) }
     { "fixnum>" "math.private" (( x y -- ? )) }
     { "fixnum>=" "math.private" (( x y -- ? )) }
-    { "(set-context)" "threads.private" (( context -- )) }
-    { "(start-context)" "threads.private" (( obj quot -- )) }
+    { "(set-context)" "threads.private" (( obj context -- obj' )) }
+    { "(start-context)" "threads.private" (( obj quot -- obj' )) }
 } [ first3 make-sub-primitive ] each
 
 ! Primitive words