int.select fix

extensions
Steven Massey 5 years ago
parent 0c8b9eab5c
commit adba7ff482

@ -1212,7 +1212,7 @@ _ (Pop (o));
_ (PreserveRegisterIfOccupied (o, type));
}
EmitOp (o, selectOps [type] [opIndex]);
EmitOp (o, selectOps [type - 1] [opIndex]);
for (u32 i = 0; i < 3; i++)
{
@ -1355,7 +1355,7 @@ const M3OpInfo c_operations [] =
M3OP( "br_if", -1, none, d_emptyOpList(), Compile_Branch ), // 0x0d
M3OP( "br_table", -1, none, d_singleOp (op_BranchTable), Compile_BranchTable ), // 0x0e
M3OP( "return", 0, any, d_emptyOpList(), Compile_Return ), // 0x0f
M3OP( "call", 0, any, d_emptyOpList(), Compile_Call ), // 0x10
M3OP( "call", 0, any, d_singleOp (op_Call), Compile_Call ), // 0x10
M3OP( "call_indirect", 0, any, d_emptyOpList(), Compile_CallIndirect ), // 0x11
M3OP( "return_call", 0, any, d_emptyOpList(), Compile_Call ), // 0x12 TODO: Optimize
M3OP( "return_call_indirect",0, any, d_emptyOpList(), Compile_CallIndirect ), // 0x13
@ -1558,7 +1558,6 @@ const M3OpInfo c_operations [] =
M3OP( "Entry", 0, none, op_Entry ),
M3OP( "unreachable", 0, none, op_Unreachable ),
M3OP( "Call", 0, none, op_Call),
M3OP( "Compile", 0, none, op_Compile),
M3OP( "SetGlobal_s", 0, none, op_SetGlobal_s),

@ -35,6 +35,7 @@ enum
c_waOp_branch = 0x0c,
c_waOp_branchTable = 0x0e,
c_waOp_branchIf = 0x0d,
c_waOp_call = 0x10,
c_waOp_getLocal = 0x20,
c_waOp_setLocal = 0x21,
c_waOp_teeLocal = 0x22,

@ -38,10 +38,10 @@ d_m3OpDef (Call)
m3ret_t r = Call (callPC, sp, _mem, d_m3OpDefaultArgs);
if (r != 0)
if (r == 0)
return nextOp ();
else
return r;
return nextOp ();
}
@ -175,7 +175,7 @@ d_m3OpDef (Compile)
d_m3OpDef (Entry)
{
IM3Function function = immediate (IM3Function);
function->hits++; m3log (exec, " enter > %s %s", function->name, SPrintFunctionArgList (function, _sp));
function->hits++; m3log (exec, " enter %p > %s %s", _pc - 2, function->name, SPrintFunctionArgList (function, _sp));
u32 numLocals = function->numLocals;

@ -160,12 +160,32 @@ OpInfo FindOperationInfo (IM3Operation i_operation)
}
#define fetch2(TYPE) (*(TYPE *) ((*o_pc)++))
void Decode_Call (char * o_string, u8 i_opcode, IM3OpInfo i_opInfo, pc_t * o_pc)
{
void * function = fetch2 (void *);
u16 stackOffset = fetch2 (u16);
sprintf (o_string, "%p; stack-offset: %d", function, stackOffset);
}
void Decode_Entry (char * o_string, u8 i_opcode, IM3OpInfo i_opInfo, pc_t * o_pc)
{
IM3Function function = fetch2 (IM3Function);
sprintf (o_string, "%s", function->name);
}
#undef fetch
#define fetch(TYPE) (*(TYPE *) (pc++))
void DecodeOperation (char * o_string, u8 i_opcode, IM3OpInfo i_opInfo, pc_t * o_pc)
{
pc_t pc = * o_pc;
#undef fetch
#define fetch(TYPE) (*(TYPE *) (pc++))
i32 offset;
@ -191,6 +211,12 @@ void DecodeOperation (char * o_string, u8 i_opcode, IM3OpInfo i_opInfo, pc_t *
u64 value = fetch (u64); offset = fetch (i32);
sprintf (o_string, " slot [%d] = %" PRIu64, offset, value);
}
else if (i_opcode == 0xc1) // entry
{
Decode_Entry (o_string, i_opcode, i_opInfo, o_pc);
}
else if (i_opcode == c_waOp_call)
Decode_Call (o_string, i_opcode, i_opInfo, o_pc);
#undef fetch

Loading…
Cancel
Save