|
@@ -15,6 +15,70 @@
|
|
|
|
|
|
|
|
|//-----------------------------------------------------------------------
|
|
|//-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
+|// Fixed register assignments for the interpreter.
|
|
|
|
+|
|
|
|
|
+|// The following must be C callee-save (but BASE is often refetched).
|
|
|
|
+|.define BASE, r4 // Base of current Lua stack frame.
|
|
|
|
+|.define KBASE, r5 // Constants of current Lua function.
|
|
|
|
+|.define PC, r6 // Next PC.
|
|
|
|
+|.define DISPATCH, r7 // Opcode dispatch table.
|
|
|
|
+|.define LREG, r8 // Register holding lua_State (also in SAVE_L).
|
|
|
|
+|.define MASKR8, r9 // 255*8 constant for fast bytecode decoding.
|
|
|
|
+|
|
|
|
|
+|// The following temporaries are not saved across C calls, except for RA/RC.
|
|
|
|
+|.define RA, r10 // Callee-save.
|
|
|
|
+|.define RC, r11 // Callee-save.
|
|
|
|
+|.define RB, r12
|
|
|
|
+|.define OP, r12 // Overlaps RB, must not be lr.
|
|
|
|
+|.define INS, lr
|
|
|
|
+|
|
|
|
|
+|// Calling conventions. Also used as temporaries.
|
|
|
|
+|.define CARG1, r0
|
|
|
|
+|.define CARG2, r1
|
|
|
|
+|.define CARG3, r2
|
|
|
|
+|.define CARG4, r3
|
|
|
|
+|.define CARG12, r0 // For 1st soft-fp double.
|
|
|
|
+|.define CARG34, r2 // For 2nd soft-fp double.
|
|
|
|
+|
|
|
|
|
+|.define CRET1, r0
|
|
|
|
+|.define CRET2, r1
|
|
|
|
+|
|
|
|
|
+|// Stack layout while in interpreter. Must match with lj_frame.h.
|
|
|
|
+|.define CFRAME_SPACE, #28
|
|
|
|
+|.define SAVE_ERRF, [sp, #24]
|
|
|
|
+|.define SAVE_NRES, [sp, #20]
|
|
|
|
+|.define SAVE_CFRAME, [sp, #16]
|
|
|
|
+|.define SAVE_L, [sp, #12]
|
|
|
|
+|.define SAVE_PC, [sp, #8]
|
|
|
|
+|.define SAVE_MULTRES, [sp, #4]
|
|
|
|
+|.define ARG5, [sp]
|
|
|
|
+|
|
|
|
|
+|.macro saveregs
|
|
|
|
+| push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
|
|
|
|
+| sub sp, sp, CFRAME_SPACE
|
|
|
|
+|.endmacro
|
|
|
|
+|.macro restoreregs_ret
|
|
|
|
+| add sp, sp, CFRAME_SPACE
|
|
|
|
+| pop {r4, r5, r6, r7, r8, r9, r10, r11, pc}
|
|
|
|
+|.endmacro
|
|
|
|
+|
|
|
|
|
+|// Type definitions. Some of these are only used for documentation.
|
|
|
|
+|.type L, lua_State, LREG
|
|
|
|
+|.type GL, global_State
|
|
|
|
+|.type TVALUE, TValue
|
|
|
|
+|.type GCOBJ, GCobj
|
|
|
|
+|.type STR, GCstr
|
|
|
|
+|.type TAB, GCtab
|
|
|
|
+|.type LFUNC, GCfuncL
|
|
|
|
+|.type CFUNC, GCfuncC
|
|
|
|
+|.type PROTO, GCproto
|
|
|
|
+|.type UPVAL, GCupval
|
|
|
|
+|.type NODE, Node
|
|
|
|
+|.type NARGS8, int
|
|
|
|
+|.type TRACE, GCtrace
|
|
|
|
+|
|
|
|
|
+|//-----------------------------------------------------------------------
|
|
|
|
+|
|
|
|// Trap for not-yet-implemented parts.
|
|
|// Trap for not-yet-implemented parts.
|
|
|.macro NYI; ud; .endmacro
|
|
|.macro NYI; ud; .endmacro
|
|
|
|
|
|
|