From f0f1e73337fd3cbe2ff201543d986c106fe0ff3f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 13 Mar 2021 18:18:16 -0600 Subject: [PATCH] arm: try to call begin_callback from asm --- basis/bootstrap/assembler/arm.64.factor | 15 +++++++++++++-- basis/cpu/arm/assembler/assembler.factor | 9 +++++++-- vm/contexts.cpp | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/basis/bootstrap/assembler/arm.64.factor b/basis/bootstrap/assembler/arm.64.factor index a682ddd3da..1d5ed0b083 100644 --- a/basis/bootstrap/assembler/arm.64.factor +++ b/basis/bootstrap/assembler/arm.64.factor @@ -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 [ ] } diff --git a/basis/cpu/arm/assembler/assembler.factor b/basis/cpu/arm/assembler/assembler.factor index 4f686e3ae6..98208ac3a4 100644 --- a/basis/cpu/arm/assembler/assembler.factor +++ b/basis/cpu/arm/assembler/assembler.factor @@ -1,7 +1,7 @@ ! 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 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 +106,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-output-variable ( value variable quot -- value ) over [ get ] curry compose with-variable ; inline @@ -115,6 +117,9 @@ ERROR: imm-out-of-range imm n ; : with-new-arm64 ( quot -- arm64-assembler ) [ 0 \ arm64-assembler ] dip with-output-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 diff --git a/vm/contexts.cpp b/vm/contexts.cpp index 48afadaa27..d087bc3364 100644 --- a/vm/contexts.cpp +++ b/vm/contexts.cpp @@ -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); } -- 2.34.1