]> gitweb.factorcode.org Git - factor.git/commitdiff
arm: try to call begin_callback from asm
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 10 Jan 2022 02:42:46 +0000 (20:42 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 17 Jun 2022 22:16:14 +0000 (17:16 -0500)
basis/bootstrap/assembler/arm.64.factor
basis/cpu/arm/assembler/assembler.factor
vm/contexts.cpp

index bcd886e3a640270fc10c6ecc6fb559c4f4214e02..85ee1e3b32576d349bf36f01ca537f7c21a9fc2f 100644 (file)
@@ -89,7 +89,7 @@ big-endian off
 
 ! rc-absolute-cell is just CONSTANT: 0
 : jit-call ( name -- )
-    0 X0 MOVwi64
+    0 X0 MOVwi64
     f rc-absolute-cell rel-dlsym
     X0 BR ;
     ! RAX 0 MOV f rc-absolute-cell rel-dlsym
@@ -286,6 +286,7 @@ big-endian off
 
     ! ## Entry points
     { c-to-factor [
+        ! dst src MOV
         ! arg2 arg1 MOV
         ! vm-reg "begin_callback" jit-call-1arg
 
@@ -295,7 +296,17 @@ big-endian off
 
         ! vm-reg "end_callback" jit-call-1arg
 
-        BL
+        [
+            ! Rn Rd MOVr64
+            arg1 arg2 MOVr64
+            vm-reg "begin_callback" jit-call-1arg
+
+            return-reg arg1 MOVr64 ! arg1 is return
+            jit-call-quot
+
+            vm-reg "end_callback" jit-call-1arg
+
+        ] assemble-arm %
 
     ] }
     ! { unwind-native-frames [ ] }
index de463c66a76aee2872c75d962ee8f1f14c270c18..623e598d167871732158559635303c69fbc48180 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2020 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators cpu.arm.assembler.opcodes kernel
-math math.bitwise namespaces sequences ;
+USING: accessors combinators combinators.extras
+cpu.arm.assembler.opcodes io.binary kernel math
+math.bitwise namespaces sequences ;
 IN: cpu.arm.assembler
 
 ! pre-index mode: computed addres is the base-register + offset
@@ -106,6 +107,8 @@ ERROR: imm-out-of-range imm n ;
 : LSRi32 ( imm6 Rn Rd -- ) LSRi32-encode >out ;
 : LSRi64 ( imm6 Rn Rd -- ) LSRi64-encode >out ;
 
+: SVC ( imm16 -- ) SVC-encode >out ;
+
 : with-new-arm64-offset ( offset quot -- arm64-assembler )
     [ <arm64-assembler> \ arm64-assembler ] dip
     '[ @ \ arm64-assembler get ] with-variable ; inline
@@ -114,6 +117,9 @@ ERROR: imm-out-of-range imm n ;
     [ 0 <arm64-assembler> \ arm64-assembler ] dip
     '[ @ \ arm64-assembler get ] with-variable ; inline
 
+: assemble-arm ( quot -- bytes )
+    with-new-arm64 out>> [ 4 >le ] map concat ; inline
+
 : offset-test-arm64 ( offset quot -- instuctions )
     with-new-arm64-offset out>> ; inline
 
index 48afadaa279556b99e9a1ecced1151e89474d5f9..d087bc3364327f8f7e2a78cde2ab57c8630a49d1 100644 (file)
@@ -160,6 +160,7 @@ cell factor_vm::begin_callback(cell quot_) {
 
 // Allocates memory
 cell begin_callback(factor_vm* parent, cell quot) {
+  cout << "begin_callback called" << endl;
   return parent->begin_callback(quot);
 }