multi-value tests passing

extensions
Steven Massey 3 years ago
parent 1aa41b9064
commit 8d0efc2b7a

@ -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);
//--------------------------------------------------------

@ -156,7 +156,7 @@ M3CodePageHeader;
#define d_m3MemPageSize 65536
#define d_m3Reg0SlotAlias 60000
#define d_m3Fp0SlotAlias 60002
#define d_m3Fp0SlotAlias (d_m3Reg0SlotAlias + 2)
#define d_m3MaxSaneTypesCount 100000
#define d_m3MaxSaneFunctionsCount 100000

@ -747,9 +747,7 @@ u8 * GetStackPointerForArgs (IM3Function i_function)
u64 * stack = (u64 *) i_function->module->runtime->stack;
IM3FuncType ftype = i_function->funcType;
u16 numReturnSlots = ftype->numRets;
stack += numReturnSlots;
stack += ftype->numRets;
return (u8 *) stack;
}
@ -913,7 +911,7 @@ M3Result m3_GetResults (IM3Function i_function, uint32_t i_retc, const void *
switch (d_FuncRetType(ftype, i)) {
case c_m3Type_i32: *(i32*)o_retptrs[i] = *(i32*)(s); s += 8; break;
case c_m3Type_i64: *(i64*)o_retptrs[i] = *(i64*)(s); s += 8; break;
case c_m3Type_f32: *(f32*)o_retptrs[i] = *(f32*)(s); s += 4; break;
case c_m3Type_f32: *(f32*)o_retptrs[i] = *(f32*)(s); s += 8; break;
case c_m3Type_f64: *(f64*)o_retptrs[i] = *(f64*)(s); s += 8; break;
default: return "unknown return type";
}

@ -358,8 +358,11 @@ void dump_type_stack (IM3Compilation o)
printf ("%s %s ", regAllocated [0] ? "(r0)" : " ", regAllocated [1] ? "(fp0)" : " ");
// printf ("%d", o->stackIndex -)
for (u32 i = o->stackFirstDynamicIndex; i < o->stackIndex; ++i)
for (u32 i = 0; i < o->stackIndex; ++i)
{
if (i > 0 and i == o->stackFirstDynamicIndex)
printf ("]");
if (i == o->block.blockStackIndex)
printf (" |");

Loading…
Cancel
Save