|
@@ -316,7 +316,7 @@ struct jit_ctx {
|
|
# ifdef HL_DEBUG
|
|
# ifdef HL_DEBUG
|
|
# define error_i64() jit_error("i64-32")
|
|
# define error_i64() jit_error("i64-32")
|
|
# else
|
|
# else
|
|
-void error_i64() {
|
|
|
|
|
|
+void error_i64() {
|
|
printf("The module you are loading is using 64 bit ints that are not supported by the HL32.\nPlease run using HL64 or compile with -D hl-legacy32");
|
|
printf("The module you are loading is using 64 bit ints that are not supported by the HL32.\nPlease run using HL64 or compile with -D hl-legacy32");
|
|
jit_exit();
|
|
jit_exit();
|
|
}
|
|
}
|
|
@@ -607,12 +607,12 @@ static void op( jit_ctx *ctx, CpuOp o, preg *a, preg *b, bool mode64 ) {
|
|
int_val cval = b->holds ? (int_val)b->holds : b->id;
|
|
int_val cval = b->holds ? (int_val)b->holds : b->id;
|
|
// short byte form
|
|
// short byte form
|
|
if( f->r_i8 && IS_SBYTE(cval) ) {
|
|
if( f->r_i8 && IS_SBYTE(cval) ) {
|
|
- if( (f->r_i8&FLAG_DUAL) && a->id > 7 ) r64 |= 4;
|
|
|
|
|
|
+ if( (f->r_i8&FLAG_DUAL) && a->id > 7 ) r64 |= 4;
|
|
OP(f->r_i8);
|
|
OP(f->r_i8);
|
|
if( (f->r_i8&FLAG_DUAL) ) MOD_RM(3,a->id,a->id); else MOD_RM(3,GET_RM(f->r_i8)-1,a->id);
|
|
if( (f->r_i8&FLAG_DUAL) ) MOD_RM(3,a->id,a->id); else MOD_RM(3,GET_RM(f->r_i8)-1,a->id);
|
|
B((int)cval);
|
|
B((int)cval);
|
|
} else if( GET_RM(f->r_const) > 0 || (f->r_const&FLAG_DUAL) ) {
|
|
} else if( GET_RM(f->r_const) > 0 || (f->r_const&FLAG_DUAL) ) {
|
|
- if( (f->r_i8&FLAG_DUAL) && a->id > 7 ) r64 |= 4;
|
|
|
|
|
|
+ if( (f->r_i8&FLAG_DUAL) && a->id > 7 ) r64 |= 4;
|
|
OP(f->r_const&0xFF);
|
|
OP(f->r_const&0xFF);
|
|
if( (f->r_i8&FLAG_DUAL) ) MOD_RM(3,a->id,a->id); else MOD_RM(3,GET_RM(f->r_const)-1,a->id);
|
|
if( (f->r_i8&FLAG_DUAL) ) MOD_RM(3,a->id,a->id); else MOD_RM(3,GET_RM(f->r_const)-1,a->id);
|
|
if( mode64 && IS_64 && o == MOV ) W64(cval); else W((int)cval);
|
|
if( mode64 && IS_64 && o == MOV ) W64(cval); else W((int)cval);
|
|
@@ -1073,7 +1073,7 @@ static preg *fetch32( jit_ctx *ctx, vreg *r ) {
|
|
return fetch(r);
|
|
return fetch(r);
|
|
}
|
|
}
|
|
|
|
|
|
-// make sure higher bits are zeroes
|
|
|
|
|
|
+// make sure higher bits are zeroes
|
|
static preg *alloc_cpu64( jit_ctx *ctx, vreg *r, bool andLoad ) {
|
|
static preg *alloc_cpu64( jit_ctx *ctx, vreg *r, bool andLoad ) {
|
|
# ifndef HL_64
|
|
# ifndef HL_64
|
|
return alloc_cpu(ctx,r,andLoad);
|
|
return alloc_cpu(ctx,r,andLoad);
|
|
@@ -2417,7 +2417,7 @@ static void jit_c2hl( jit_ctx *ctx ) {
|
|
op64(ctx,MOV,PEBP,PESP);
|
|
op64(ctx,MOV,PEBP,PESP);
|
|
|
|
|
|
# ifdef HL_64
|
|
# ifdef HL_64
|
|
-
|
|
|
|
|
|
+
|
|
fptr = REG_AT(R10);
|
|
fptr = REG_AT(R10);
|
|
stack = PEAX;
|
|
stack = PEAX;
|
|
stend = REG_AT(R11);
|
|
stend = REG_AT(R11);
|
|
@@ -2554,7 +2554,7 @@ static void jit_hl2c( jit_ctx *ctx ) {
|
|
// case HF32: case HF64: return jit_wrapper_d(arg0,&args);
|
|
// case HF32: case HF64: return jit_wrapper_d(arg0,&args);
|
|
// default: return jit_wrapper_ptr(arg0,&args);
|
|
// default: return jit_wrapper_ptr(arg0,&args);
|
|
// }
|
|
// }
|
|
- if( !IS_64 )
|
|
|
|
|
|
+ if( !IS_64 )
|
|
op64(ctx,MOV,cl,pmem(&p,Ebp,HL_WSIZE*2)); // load arg0
|
|
op64(ctx,MOV,cl,pmem(&p,Ebp,HL_WSIZE*2)); // load arg0
|
|
op64(ctx,MOV,tmp,pmem(&p,cl->id,0)); // ->t
|
|
op64(ctx,MOV,tmp,pmem(&p,cl->id,0)); // ->t
|
|
op64(ctx,MOV,tmp,pmem(&p,tmp->id,HL_WSIZE)); // ->fun
|
|
op64(ctx,MOV,tmp,pmem(&p,tmp->id,HL_WSIZE)); // ->fun
|
|
@@ -2566,7 +2566,7 @@ static void jit_hl2c( jit_ctx *ctx ) {
|
|
op32(ctx,CMP,tmp,pconst(&p,HF32));
|
|
op32(ctx,CMP,tmp,pconst(&p,HF32));
|
|
XJump_small(JEq,jfloat2);
|
|
XJump_small(JEq,jfloat2);
|
|
|
|
|
|
- // 64 bits : ESP + EIP (+WIN64PAD)
|
|
|
|
|
|
+ // 64 bits : ESP + EIP (+WIN64PAD)
|
|
// 32 bits : ESP + EIP + PARAM0
|
|
// 32 bits : ESP + EIP + PARAM0
|
|
int args_pos = IS_64 ? ((IS_WINCALL64 ? 32 : 0) + HL_WSIZE * 2) : (HL_WSIZE*3);
|
|
int args_pos = IS_64 ? ((IS_WINCALL64 ? 32 : 0) + HL_WSIZE * 2) : (HL_WSIZE*3);
|
|
|
|
|
|
@@ -2897,7 +2897,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
vreg *r = R(i);
|
|
vreg *r = R(i);
|
|
int creg = select_call_reg(&cregs,r->t,i);
|
|
int creg = select_call_reg(&cregs,r->t,i);
|
|
if( creg < 0 || IS_WINCALL64 ) {
|
|
if( creg < 0 || IS_WINCALL64 ) {
|
|
- // use existing stack storage
|
|
|
|
|
|
+ // use existing stack storage
|
|
r->stackPos = argsSize + HL_WSIZE * 2;
|
|
r->stackPos = argsSize + HL_WSIZE * 2;
|
|
argsSize += stack_size(r->t);
|
|
argsSize += stack_size(r->t);
|
|
} else {
|
|
} else {
|
|
@@ -3050,7 +3050,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
preg *pb = alloc_cpu(ctx,ra,true);
|
|
preg *pb = alloc_cpu(ctx,ra,true);
|
|
op64(ctx,XOR,pa,pa);
|
|
op64(ctx,XOR,pa,pa);
|
|
op64(ctx,SUB,pa,pb);
|
|
op64(ctx,SUB,pa,pb);
|
|
- store(ctx,dst,pa,true);
|
|
|
|
|
|
+ store(ctx,dst,pa,true);
|
|
# else
|
|
# else
|
|
error_i64();
|
|
error_i64();
|
|
# endif
|
|
# endif
|
|
@@ -3313,7 +3313,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
ctx->calls = j;
|
|
ctx->calls = j;
|
|
|
|
|
|
set_native_arg(ctx,pconst64(&p,RESERVE_ADDRESS));
|
|
set_native_arg(ctx,pconst64(&p,RESERVE_ADDRESS));
|
|
- set_native_arg(ctx,pconst64(&p,(int_val)m->code->functions[m->functions_indexes[o->p2]].type));
|
|
|
|
|
|
+ set_native_arg(ctx,pconst64(&p,(int_val)m->code->functions[m->functions_indexes[o->p2]].type));
|
|
call_native(ctx,hl_alloc_closure_ptr,size);
|
|
call_native(ctx,hl_alloc_closure_ptr,size);
|
|
store(ctx,dst,PEAX,true);
|
|
store(ctx,dst,PEAX,true);
|
|
}
|
|
}
|
|
@@ -3403,7 +3403,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
{
|
|
{
|
|
int regids[64];
|
|
int regids[64];
|
|
preg *pc = REG_AT(CALL_REGS[0]);
|
|
preg *pc = REG_AT(CALL_REGS[0]);
|
|
- vreg *sc = R(f->nregs); // scratch register that we temporary rebind
|
|
|
|
|
|
+ vreg *sc = R(f->nregs); // scratch register that we temporary rebind
|
|
if( o->p3 >= 63 ) jit_error("assert");
|
|
if( o->p3 >= 63 ) jit_error("assert");
|
|
memcpy(regids + 1, o->extra, o->p3 * sizeof(int));
|
|
memcpy(regids + 1, o->extra, o->p3 * sizeof(int));
|
|
regids[0] = f->nregs;
|
|
regids[0] = f->nregs;
|
|
@@ -3442,7 +3442,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
error_i64();
|
|
error_i64();
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-# endif
|
|
|
|
|
|
+# endif
|
|
switch( ra->t->kind ) {
|
|
switch( ra->t->kind ) {
|
|
case HOBJ:
|
|
case HOBJ:
|
|
case HSTRUCT:
|
|
case HSTRUCT:
|
|
@@ -3707,7 +3707,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
|
|
// keep o->value in R(f->nregs)
|
|
// keep o->value in R(f->nregs)
|
|
int regids[64];
|
|
int regids[64];
|
|
preg *pc = alloc_reg(ctx,RCPU_CALL);
|
|
preg *pc = alloc_reg(ctx,RCPU_CALL);
|
|
- vreg *sc = R(f->nregs); // scratch register that we temporary rebind
|
|
|
|
|
|
+ vreg *sc = R(f->nregs); // scratch register that we temporary rebind
|
|
if( o->p3 >= 63 ) jit_error("assert");
|
|
if( o->p3 >= 63 ) jit_error("assert");
|
|
memcpy(regids, o->extra, o->p3 * sizeof(int));
|
|
memcpy(regids, o->extra, o->p3 * sizeof(int));
|
|
regids[0] = f->nregs;
|
|
regids[0] = f->nregs;
|