multi-value tests passing

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

File diff suppressed because it is too large Load Diff

@ -48,9 +48,9 @@ typedef struct M3CompilationScope
struct M3CompilationScope * outer; struct M3CompilationScope * outer;
pc_t pc; // used by ContinueLoop's pc_t pc; // used by ContinueLoop's
pc_t patches; pc_t patches;
i32 depth; i32 depth;
u16 exitStackIndex; u16 exitStackIndex;
i16 blockStackIndex; i16 blockStackIndex;
// u16 topSlot; // u16 topSlot;
IM3FuncType type; IM3FuncType type;
@ -81,8 +81,8 @@ typedef struct
u32 numOpcodes; u32 numOpcodes;
#endif #endif
u16 stackFirstDynamicIndex; // args and locals are pushed to the stack so that their slot locations can be tracked. the wasm model itself doesn't u16 stackFirstDynamicIndex; // args and locals are pushed to the stack so that their slot locations can be tracked. the wasm model itself doesn't
// treat these values as being on the stack, so stackFirstDynamicIndex marks the start of the real Wasm stack // treat these values as being on the stack, so stackFirstDynamicIndex marks the start of the real Wasm stack
u16 stackIndex; // current stack top u16 stackIndex; // current stack top
u16 slotFirstConstIndex; u16 slotFirstConstIndex;

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

@ -89,12 +89,12 @@ void EmitSlotOffset (IM3Compilation o, const i32 i_offset)
pc_t EmitPointer (IM3Compilation o, const void * const i_pointer) pc_t EmitPointer (IM3Compilation o, const void * const i_pointer)
{ {
pc_t ptr = GetPagePC (o->page); pc_t ptr = GetPagePC (o->page);
if (o->page) if (o->page)
EmitWord (o->page, i_pointer); EmitWord (o->page, i_pointer);
return ptr; return ptr;
} }
void * ReservePointer (IM3Compilation o) void * ReservePointer (IM3Compilation o)

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

@ -28,23 +28,23 @@ bool AreFuncTypesEqual (const IM3FuncType i_typeA, const IM3FuncType i_typeB)
u16 GetFuncTypeNumParams (const IM3FuncType i_funcType) u16 GetFuncTypeNumParams (const IM3FuncType i_funcType)
{ {
return i_funcType ? i_funcType->numArgs : 0; return i_funcType ? i_funcType->numArgs : 0;
} }
u8 GetFuncTypeParamType (const IM3FuncType i_funcType, u16 i_index) u8 GetFuncTypeParamType (const IM3FuncType i_funcType, u16 i_index)
{ {
u8 type = c_m3Type_unknown; u8 type = c_m3Type_unknown;
if (i_funcType) if (i_funcType)
{ {
if (i_index < i_funcType->numArgs) if (i_index < i_funcType->numArgs)
{ {
type = i_funcType->types [i_funcType->numRets + i_index]; type = i_funcType->types [i_funcType->numRets + i_index];
} }
} }
return type; return type;
} }

@ -30,8 +30,8 @@ typedef M3FuncType * IM3FuncType;
M3Result AllocFuncType (IM3FuncType * o_functionType, u32 i_numTypes); M3Result AllocFuncType (IM3FuncType * o_functionType, u32 i_numTypes);
bool AreFuncTypesEqual (const IM3FuncType i_typeA, const IM3FuncType i_typeB); bool AreFuncTypesEqual (const IM3FuncType i_typeA, const IM3FuncType i_typeB);
u16 GetFuncTypeNumParams (const IM3FuncType i_funcType); u16 GetFuncTypeNumParams (const IM3FuncType i_funcType);
u8 GetFuncTypeParamType (const IM3FuncType i_funcType, u16 i_index); u8 GetFuncTypeParamType (const IM3FuncType i_funcType, u16 i_index);
u16 GetFuncTypeNumResults (const IM3FuncType i_funcType); u16 GetFuncTypeNumResults (const IM3FuncType i_funcType);
u8 GetFuncTypeResultType (const IM3FuncType i_funcType, u16 i_index); u8 GetFuncTypeResultType (const IM3FuncType i_funcType, u16 i_index);

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

Loading…
Cancel
Save