]> Nishi Git Mirror - gwion.git/commitdiff
:art: VM clean
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 1 Mar 2020 18:04:45 +0000 (19:04 +0100)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 1 Mar 2020 18:04:45 +0000 (19:04 +0100)
include/opcode.h
opcode.txt
src/vm/vm.c

index 7d0df98bd321057fc1050d4de269a8632fc7b66e..e85a433dc8b95bda271fe9c3f8427ac1d0d287f5 100644 (file)
@@ -118,15 +118,11 @@ enum {
   eCastF2I,
   eTime_Advance,
   eSetCode,
-  eFuncPtr,
-  eFuncMember,
-  eFuncUsr,
   eRegPop,
   eRegPush,
   eReg2Mem,
   eReg2Mem4,
   eOverflow,
-  eNext,
   eFuncUsrEnd,
   eFuncMemberEnd,
   eSporkIni,
@@ -295,15 +291,11 @@ enum {
 #define  CastF2I             (f_instr)eCastF2I
 #define  Time_Advance        (f_instr)eTime_Advance
 #define  SetCode             (f_instr)eSetCode
-#define  FuncPtr             (f_instr)eFuncPtr
-#define  FuncMember          (f_instr)eFuncMember
-#define  FuncUsr             (f_instr)eFuncUsr
 #define  RegPop              (f_instr)eRegPop
 #define  RegPush             (f_instr)eRegPush
 #define  Reg2Mem             (f_instr)eReg2Mem
 #define  Reg2Mem4            (f_instr)eReg2Mem4
 #define  Overflow            (f_instr)eOverflow
-#define  Next                (f_instr)eNext
 #define  FuncUsrEnd          (f_instr)eFuncUsrEnd
 #define  FuncMemberEnd       (f_instr)eFuncMemberEnd
 #define  SporkIni            (f_instr)eSporkIni
index db75fbd5fe6e17f719ab1a532695e328c1c9b7cf..2c4015892ac8e6435b01793778fac47c6539d0a7 100644 (file)
@@ -115,15 +115,11 @@ CastI2F
 CastF2I
 Time_Advance
 SetCode
-FuncPtr
-FuncMember
-FuncUsr
 RegPop
 RegPush
 Reg2Mem
 Reg2Mem4
 Overflow
-Next
 FuncUsrEnd
 FuncMemberEnd
 SporkIni
index b6be206bcc44ada9aa89cb15858220c0bfcb29d0..fdc31543e9d3d983dc0917323d275f6551745e58 100644 (file)
@@ -330,8 +330,8 @@ ANN void vm_run(const VM* vm) { // lgtm [cpp/use-of-goto]
     &&firassign, &&firadd, &&firsub, &&firmul, &&firdiv,
     &&itof, &&ftoi,
     &&timeadv,
-    &&setcode, &&funcptr, &&funcmember,
-    &&funcusr, &&regpop, &&regpush, &&regtomem, &&regtomemother, &&overflow, &&next, &&funcusrend, &&funcmemberend,
+    &&setcode,
+    &&regpop, &&regpush, &&regtomem, &&regtomemother, &&overflow, &&funcusrend, &&funcmemberend,
     &&sporkini, &&sporkfunc, &&sporkmemberfptr, &&sporkexp, &&forkend, &&sporkend,
     &&brancheqint, &&branchneint, &&brancheqfloat, &&branchnefloat,
     &&arrayappend, &&autoloop, &&autoloopptr, &&autoloopcount, &&arraytop, &&arrayaccess, &&arrayget, &&arrayaddr, &&arrayvalid,
@@ -603,28 +603,22 @@ timeadv:
   VM_OUT
   break;
 setcode:
-  a.code = *(VM_Code*)(reg-SZ_INT);
-funcptr:
 PRAGMA_PUSH()
   reg -= SZ_INT;
   a.code = *(VM_Code*)reg;
-  if(!GET_FLAG((VM_Code)a.code, builtin))
-    goto funcusr;
+  if(!GET_FLAG((VM_Code)a.code, builtin)) {
+    register const m_uint push = *(m_uint*)(reg + SZ_INT) + *(m_uint*)(mem-SZ_INT);
+    mem += push;
+    *(m_uint*)  mem = push;mem += SZ_INT;
+    *(VM_Code*) mem = code; mem += SZ_INT;
+    *(m_uint*)  mem = PC + VAL2; mem += SZ_INT;
+    *(m_uint*) mem = a.code->stack_depth; mem += SZ_INT;
+    next = eFuncUsrEnd;
+  } else {
+    mem += *(m_uint*)(reg + SZ_INT);
+    next = eFuncMemberEnd;
+  }
 PRAGMA_POP()
-funcmember:
-  mem += *(m_uint*)(reg + SZ_INT);
-  next = eFuncMemberEnd;
-  goto regpop;
-funcusr:
-{
-  register const m_uint push = *(m_uint*)(reg + SZ_INT) + *(m_uint*)(mem-SZ_INT);
-  mem += push;
-  *(m_uint*)  mem = push;mem += SZ_INT;
-  *(VM_Code*) mem = code; mem += SZ_INT;
-  *(m_uint*)  mem = PC + VAL2; mem += SZ_INT;
-  *(m_uint*) mem = a.code->stack_depth; mem += SZ_INT;
-  next = eFuncUsrEnd;
-}
 regpop:
   reg -= VAL;
   DISPATCH();
@@ -643,7 +637,6 @@ overflow:
     exception(shred, "StackOverflow");
     continue;
   }
-next:
 PRAGMA_PUSH()
   goto *dispatch[next];
 PRAGMA_POP()