|
|
|
@ -477,8 +477,7 @@ M3Result Push (IM3Compilation o, u8 i_type, u16 i_slot)
|
|
|
|
|
|
|
|
|
|
M3Result PushRegister (IM3Compilation o, u8 i_type)
|
|
|
|
|
{
|
|
|
|
|
M3Result result = m3Err_none; d_m3Assert ((u16) d_m3Reg0SlotAlias > (u16) d_m3MaxFunctionSlots and
|
|
|
|
|
(u16) d_m3Fp0SlotAlias > (u16) d_m3MaxFunctionSlots);
|
|
|
|
|
M3Result result = m3Err_none; d_m3Assert ((u16) d_m3Reg0SlotAlias > (u16) d_m3MaxFunctionSlots);
|
|
|
|
|
u16 slot = IsFpType (i_type) ? d_m3Fp0SlotAlias : d_m3Reg0SlotAlias; d_m3Assert (i_type or IsStackPolymorphic (o));
|
|
|
|
|
|
|
|
|
|
_ (Push (o, i_type, slot));
|
|
|
|
@ -1150,8 +1149,6 @@ M3Result Compile_ExtendedOpcode (IM3Compilation o, m3opcode_t i_opcode)
|
|
|
|
|
{
|
|
|
|
|
M3Result result;
|
|
|
|
|
|
|
|
|
|
i32 value;
|
|
|
|
|
|
|
|
|
|
u8 opcode;
|
|
|
|
|
_ (Read_u8 (& opcode, & o->wasm, o->wasmEnd)); m3log (compile, d_indent " (FC: %" PRIi32 ")", get_indention_string (o), opcode);
|
|
|
|
|
|
|
|
|
@ -1160,7 +1157,7 @@ _ (Read_u8 (& opcode, & o->wasm, o->wasmEnd)); m3log (compile, d_i
|
|
|
|
|
//printf("Extended opcode: 0x%x\n", i_opcode);
|
|
|
|
|
|
|
|
|
|
M3Compiler compiler = GetOpInfo (i_opcode)->compiler;
|
|
|
|
|
_throwifnull (m3Err_noCompiler, compiler);
|
|
|
|
|
_throwif (m3Err_noCompiler, not compiler);
|
|
|
|
|
|
|
|
|
|
_ ((* compiler) (o, i_opcode));
|
|
|
|
|
|
|
|
|
@ -1816,25 +1813,22 @@ _ (ReadBlockType (o, & blockType));
|
|
|
|
|
d_m3Assert (numValues >= numParams);
|
|
|
|
|
if (numValues >= numParams)
|
|
|
|
|
{
|
|
|
|
|
u16 stackTop = GetStackTopIndex (o);
|
|
|
|
|
for (u16 i = 0; i < numParams; ++i)
|
|
|
|
|
u16 stackTop = GetStackTopIndex (o) + 1;
|
|
|
|
|
|
|
|
|
|
for (u16 i = stackTop - numParams; i < stackTop; ++i)
|
|
|
|
|
{
|
|
|
|
|
u16 stackIndex = stackTop - i;
|
|
|
|
|
u16 slot = GetSlotForStackIndex (o, stackIndex);
|
|
|
|
|
u8 type = GetStackTypeFromBottom (o, stackIndex);
|
|
|
|
|
u16 slot = GetSlotForStackIndex (o, i);
|
|
|
|
|
u8 type = GetStackTypeFromBottom (o, i);
|
|
|
|
|
|
|
|
|
|
if (IsConstantSlot (o, slot))
|
|
|
|
|
{
|
|
|
|
|
u16 newSlot;
|
|
|
|
|
_ (AllocateSlots (o, & newSlot, type));
|
|
|
|
|
_ (CopyStackIndexToSlot (o, newSlot, stackIndex));
|
|
|
|
|
o->wasmStack [stackIndex] = newSlot;
|
|
|
|
|
|
|
|
|
|
// dump_type_stack (o);
|
|
|
|
|
_ (CopyStackIndexToSlot (o, newSlot, i));
|
|
|
|
|
o->wasmStack [i] = newSlot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ (EmitOp (o, op_Loop));
|
|
|
|
@ -1902,7 +1896,7 @@ _ (EmitSlotNumOfStackTopAndPop (o));
|
|
|
|
|
IM3FuncType blockType;
|
|
|
|
|
_ (ReadBlockType (o, & blockType));
|
|
|
|
|
|
|
|
|
|
dump_type_stack (o);
|
|
|
|
|
// dump_type_stack (o);
|
|
|
|
|
|
|
|
|
|
u16 stackIndex = o->stackIndex;
|
|
|
|
|
|
|
|
|
@ -1915,14 +1909,16 @@ _ (CompileElseBlock (o, pc, blockType));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// if block produces values and there isn't a defined else
|
|
|
|
|
// case, then we need to make one up so that the pass-through
|
|
|
|
|
// results end up in the right place
|
|
|
|
|
if (GetFuncTypeNumResults (blockType))
|
|
|
|
|
{
|
|
|
|
|
// rewind to the if's end to create a fake else block
|
|
|
|
|
o->wasm--;
|
|
|
|
|
|
|
|
|
|
o->stackIndex = stackIndex;
|
|
|
|
|
|
|
|
|
|
dump_type_stack (o);
|
|
|
|
|
// dump_type_stack (o);
|
|
|
|
|
|
|
|
|
|
_ (CompileElseBlock (o, pc, blockType));
|
|
|
|
|
}
|
|
|
|
@ -2586,13 +2582,13 @@ M3Result CompileBlock (IM3Compilation o, IM3FuncType i_blockType, m3opcode_t i
|
|
|
|
|
{
|
|
|
|
|
for (u16 i = 0; i < numParams; ++i)
|
|
|
|
|
{
|
|
|
|
|
u8 type = GetFuncTypeParamType (i_blockType, i);
|
|
|
|
|
u8 type = GetFuncTypeParamType (i_blockType, numParams - 1 - i);
|
|
|
|
|
_ (PopType (o, type));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else o->stackIndex -= numParams;
|
|
|
|
|
|
|
|
|
|
printf ("STACK: %d\n", o->stackIndex);
|
|
|
|
|
// printf ("STACK: %d\n", o->stackIndex);
|
|
|
|
|
|
|
|
|
|
u16 paramIndex = o->stackIndex;
|
|
|
|
|
block->exitStackIndex = paramIndex; // consume the params at block exit
|
|
|
|
@ -2612,7 +2608,7 @@ _ (PopType (o, type));
|
|
|
|
|
|
|
|
|
|
block->blockStackIndex = o->stackIndex = stackIndex;
|
|
|
|
|
|
|
|
|
|
dump_type_stack (o);
|
|
|
|
|
// dump_type_stack (o);
|
|
|
|
|
|
|
|
|
|
// push the params back onto the stack -------------------
|
|
|
|
|
for (u16 i = 0; i < numParams; ++i)
|
|
|
|
@ -2626,7 +2622,7 @@ _ (PopType (o, type));
|
|
|
|
|
MarkSlotsAllocatedByType (o, slot, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dump_type_stack (o);
|
|
|
|
|
// dump_type_stack (o);
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
|
|
|
|
|
|