x64: Add LJ_GC64 mode interpreter.

Enable this mode with: make XCFLAGS=-DLUAJIT_ENABLE_GC64
master
Mike Pall 2015-05-04 06:30:57 +02:00
parent 5caf53d502
commit a92e730233
8 changed files with 4906 additions and 5 deletions

View File

@ -428,7 +428,7 @@ LJLIB_CF(dofile)
LJLIB_CF(gcinfo)
{
setintV(L->top++, (G(L)->gc.total >> 10));
setintV(L->top++, (int32_t)(G(L)->gc.total >> 10));
return 1;
}

View File

@ -158,6 +158,9 @@
#define LJ_TARGET_MASKROT 1
#define LJ_TARGET_UNALIGNED 1
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL
#ifdef LUAJIT_ENABLE_GC64
#define LJ_TARGET_GC64 1
#endif
#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM

View File

@ -35,7 +35,7 @@
#elif LJ_TARGET_X86ORX64
#define CALLBACK_MCODE_HEAD (LJ_64 ? 8 : 0)
#define CALLBACK_MCODE_GROUP (-2+1+2+5+(LJ_64 ? 6 : 5))
#define CALLBACK_MCODE_GROUP (-2+1+2+(LJ_GC64 ? 10 : 5)+(LJ_64 ? 6 : 5))
#define CALLBACK_SLOT2OFS(slot) \
(CALLBACK_MCODE_HEAD + CALLBACK_MCODE_GROUP*((slot)/32) + 4*(slot))
@ -120,8 +120,13 @@ static void callback_mcode_init(global_State *g, uint8_t *page)
/* push ebp/rbp; mov ah, slot>>8; mov ebp, &g. */
*p++ = XI_PUSH + RID_EBP;
*p++ = XI_MOVrib | (RID_EAX+4); *p++ = (uint8_t)(slot >> 8);
#if LJ_GC64
*p++ = 0x48; *p++ = XI_MOVri | RID_EBP;
*(uint64_t *)p = (uint64_t)(g); p += 8;
#else
*p++ = XI_MOVri | RID_EBP;
*(int32_t *)p = i32ptr(g); p += 4;
#endif
#if LJ_64
/* jmp [rip-pageofs] where lj_vm_ffi_callback is stored. */
*p++ = XI_GROUP5; *p++ = XM_OFS0 + (XOg_JMP<<3) + RID_EBP;

View File

@ -121,7 +121,12 @@ collect_attrib:
idx = (ptrdiff_t)intV(key);
goto integer_key;
} else if (tvisnum(key)) { /* Numeric key. */
idx = LJ_64 ? (ptrdiff_t)numV(key) : (ptrdiff_t)lj_num2int(numV(key));
#ifdef _MSC_VER
/* Workaround for MSVC bug. */
volatile
#endif
lua_Number n = numV(key);
idx = LJ_64 ? (ptrdiff_t)n : (ptrdiff_t)lj_num2int(n);
integer_key:
if (ctype_ispointer(ct->info)) {
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */

View File

@ -127,21 +127,37 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
#elif LJ_TARGET_X64
#if LJ_ABI_WIN
#define CFRAME_OFS_PREV (13*8)
#if LJ_GC64
#define CFRAME_OFS_PC (12*8)
#define CFRAME_OFS_L (11*8)
#define CFRAME_OFS_ERRF (21*4)
#define CFRAME_OFS_NRES (20*4)
#define CFRAME_OFS_MULTRES (8*4)
#else
#define CFRAME_OFS_PC (25*4)
#define CFRAME_OFS_L (24*4)
#define CFRAME_OFS_ERRF (23*4)
#define CFRAME_OFS_NRES (22*4)
#define CFRAME_OFS_MULTRES (21*4)
#endif
#define CFRAME_SIZE (10*8)
#define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8)
#define CFRAME_SHIFT_MULTRES 0
#else
#define CFRAME_OFS_PREV (4*8)
#if LJ_GC64
#define CFRAME_OFS_PC (3*8)
#define CFRAME_OFS_L (2*8)
#define CFRAME_OFS_ERRF (3*4)
#define CFRAME_OFS_NRES (2*4)
#define CFRAME_OFS_MULTRES (0*4)
#else
#define CFRAME_OFS_PC (7*4)
#define CFRAME_OFS_L (6*4)
#define CFRAME_OFS_ERRF (5*4)
#define CFRAME_OFS_NRES (4*4)
#define CFRAME_OFS_MULTRES (1*4)
#endif
#define CFRAME_SIZE (10*8)
#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16)
#define CFRAME_SHIFT_MULTRES 0

View File

@ -556,8 +556,8 @@ static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx)
DB(DW_CFA_offset|DW_REG_15); DUV(4);
DB(DW_CFA_offset|DW_REG_14); DUV(5);
/* Extra registers saved for JIT-compiled code. */
DB(DW_CFA_offset|DW_REG_13); DUV(9);
DB(DW_CFA_offset|DW_REG_12); DUV(10);
DB(DW_CFA_offset|DW_REG_13); DUV(LJ_GC64 ? 10 : 9);
DB(DW_CFA_offset|DW_REG_12); DUV(LJ_GC64 ? 11 : 10);
#elif LJ_TARGET_ARM
{
int i;

View File

@ -132,7 +132,11 @@ enum {
#define SPS_FIXED (4*2)
#define SPS_FIRST (4*2) /* Don't use callee register save area. */
#else
#if LJ_GC64
#define SPS_FIXED 2
#else
#define SPS_FIXED 4
#endif
#define SPS_FIRST 2
#endif
#else

4868
src/vm_x64.dasc Normal file

File diff suppressed because it is too large Load Diff