commit b498214c3223d7ba2c8a40d4f0ef3f8e7530ca3b
parent b680be0787e73207b0b38ebe53ab07a5e7972747
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sun, 26 Feb 2023 14:45:05 -0500
comp/c: move constarray compilation to common vm
Diffstat:
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/fs/comp/c/vm/commonhi.fs b/fs/comp/c/vm/commonhi.fs
@@ -63,7 +63,15 @@ ARIOPCNT wordtbl constops ( n n -- n )
TYPE_INT to vmop type
else 1 ( - ) _ariop, then ;
-: _assignop, vmop :isconst? not _assert assignop, ;
+: _movarray, \ special case, we have a {1, 2, 3} assign
+ vmop loc VM_STACKFRAME = _assert
+ vmop^ arg vmop^ :init @+ ( a sz )
+ swap litn RSP>A, vmop arg A+, A>, litn \ on compiled PS: src dst len
+ compile move ;
+
+: _assignop, ( opid -- )
+ vmop :isconst? not _assert
+ vmop^ loc VM_CONSTARRAY = if 10 = _assert _movarray, else assignop, then ;
: assignop doer , does> @ _assignop, ;
2 assignop vm*=, 3 assignop vm/=,
4 assignop vm%=, 5 assignop vm&=, 6 assignop vm|=, 7 assignop vm^=,
diff --git a/fs/comp/c/vm/forth.fs b/fs/comp/c/vm/forth.fs
@@ -135,16 +135,9 @@ ARIOPCNT 1+ ( for = ) wordtbl _tbl
\ Copy the contents of op2 in the memory address pointed out by op1 and deinit
\ op2. In other words, perform a AST_ASSIGN with the right part as op2
\ and the left part as op1.
-: _movarray, \ special case, we have a {1, 2, 3} assign
- vmop loc VM_STACKFRAME = _assert
- vmop^ arg vmop^ :init @+ ( a sz )
- swap litn vmop :compile litn \ on compiled PS: src dst len
- compile move PS- ;
-
\ an assignop, is like a unop in the sense that it operates directly on op1, but
\ with the participation of op2.
: assignop, ( opid -- )
- vmop^ loc VM_CONSTARRAY = if drop _movarray, exit then
vmop type typesize ( opid sz ) vmop :compile&
compile dup PS+ dup sz! compilesz @ vmop^ :compile$ ( opid sz )
swap _tbl swap wexec, PS- ( sz ) \ result on TOS
diff --git a/fs/comp/c/vm/i386.fs b/fs/comp/c/vm/i386.fs
@@ -231,15 +231,7 @@ ASSIGNOPCNT wordtbl _tbl
vmop :compilesz vmop^ :compile
_tbl swap wexec vmop^ :init ;
-: _movarray
- vmop loc VM_STACKFRAME = _assert
- vmop :>reg vmop^ arg vmop^ :init @+ ( a sz )
- cx i) mov, si i) mov, di vmop :compile mov,
- rep, movsb, ;
-
: assignop, ( opid -- )
- vmop^ loc VM_CONSTARRAY = if \ special case, we have a {1, 2, 3} assign
- ( opid ) 10 = _assert _movarray exit then
dup _mulop? if _mulop exit then
dup _shcl? if _shcl exit then
vmop :?>simple vmop :compilesz vmop^ :hasop# vmop^ :compile