extensions
Steven Massey 5 years ago
parent 6ab012cf77
commit 0909d2160e

@ -1052,7 +1052,7 @@ _ (ReadBlockType (o, & blockType));
_ (EmitOp (o, i_opcode == 0x03 ? op_Loop : op_Block)); // TODO: block operation not required
_ (Compile_Block (o, blockType, i_opcode));
_ (CompileBlock (o, blockType, i_opcode));
catch: return result;
}
@ -1077,7 +1077,7 @@ _ (EmitTopSlotAndPop (o));
u8 blockType;
_ (ReadBlockType (o, & blockType));
_ (Compile_Block (o, blockType, i_opcode));
_ (CompileBlock (o, blockType, i_opcode));
if (o->previousOpcode == c_waOp_else)
{
@ -1282,9 +1282,9 @@ const M3OpInfo c_operations [] =
{ "f32.load", 0, f_32, NULL, NULL, NULL}, // 0x2a
{ "f64.load", 0, f_64, NULL, NULL, NULL}, // 0x2b
{ "i32.load8_s", 0, i_32, op_i32_Load_i8_r, op_i32_Load_i8_s, NULL, Compile_Load_Store }, // 0x2c
{ "i32.load8_u", 0, i_32, op_i32_Load_u8_r, op_i32_Load_u8_s, NULL, Compile_Load_Store }, // 0x2d
{ "i32.load16_s", 0, i_32, op_i32_Load_i16_r, op_i32_Load_i16_s, NULL, Compile_Load_Store }, // 0x2e
{ "i32.load8_s", 0, i_32, op_i32_Load_i8_r, op_i32_Load_i8_s, NULL, Compile_Load_Store }, // 0x2c
{ "i32.load8_u", 0, i_32, op_i32_Load_u8_r, op_i32_Load_u8_s, NULL, Compile_Load_Store }, // 0x2d
{ "i32.load16_s", 0, i_32, op_i32_Load_i16_r, op_i32_Load_i16_s, NULL, Compile_Load_Store }, // 0x2e
{ "i32.load16_u", 0, i_32, op_i32_Load_u16_r, op_i32_Load_u16_s, NULL, Compile_Load_Store }, // 0x2f
{ "i64.load8_s", 0, i_64, NULL, NULL, NULL, }, // 0x30
@ -1569,32 +1569,16 @@ _ (MoveStackTopToRegister (o));
}
M3Result Compile_Block (IM3Compilation o, u8 i_blockType, u8 i_blockOpcode)
{
M3Result result;
M3Result CompileBlock (IM3Compilation o, u8 i_blockType, u8 i_blockOpcode)
{ d_m3Assert (not IsRegisterAllocated (o, 0));
M3Result result; d_m3Assert (not IsRegisterAllocated (o, 1));
u32 numArgsAndLocals = GetFunctionNumArgsAndLocals (o->function);
// save and clear the locals modification slots
u16 locals [numArgsAndLocals];
// {
// u16 i = GetFunctionNumArgsAndLocals (o->function);
// while (i < o->stackIndex)
// {
// u16 location = o->wasmStack [i];
// if (IsRegisterLocation (location))
// {
// printf ("deal! %d - %d \n", (i32) i, (i32) location);
//// abort ();
//// d_m3Assert(false);
// }
// ++i;
// }
// }
d_m3Assert (not IsRegisterAllocated (o, 0));
d_m3Assert (not IsRegisterAllocated (o, 1));
memcpy (locals, o->wasmStack, numArgsAndLocals * sizeof (u16));
for (u32 i = 0; i < numArgsAndLocals; ++i)
{
@ -1643,7 +1627,7 @@ M3Result Compile_ElseBlock (IM3Compilation o, pc_t * o_startPC, u8 i_blockType
IM3CodePage savedPage = o->page;
o->page = elsePage;
_ (Compile_Block (o, i_blockType, c_waOp_else));
_ (CompileBlock (o, i_blockType, c_waOp_else));
_ (EmitOp (o, op_Branch));
EmitPointer (o, GetPagePC (savedPage));

@ -150,7 +150,7 @@ void EmitConstant (IM3Compilation o, const u64 immediate);
void Push (IM3Compilation o, u8 i_waType, i16 i_location);
void EmitPointer (IM3Compilation o, const void * const i_immediate);
M3Result Compile_Block (IM3Compilation io, u8 i_blockType, u8 i_blockOpcode);
M3Result CompileBlock (IM3Compilation io, u8 i_blockType, u8 i_blockOpcode);
M3Result Compile_ElseBlock (IM3Compilation io, pc_t * o_startPC, u8 i_blockType);
M3Result Compile_BlockStatements (IM3Compilation io);

@ -78,7 +78,7 @@ static const char * m3LogTruncFilename (const char * i_file)
# define d_m3Log_parse d_m3LogParse // required for m3logif
# define d_m3Log_stack d_m3LogStack
# define d_m3Log_stack d_m3LogWasmStack
# define d_m3Log_exec d_m3LogExec
# if d_m3LogOutput
@ -99,7 +99,7 @@ static const char * m3LogTruncFilename (const char * i_file)
# define m3log_compile(...)
# endif
# if d_m3LogStack
# if d_m3LogWasmStack
# define m3log_stack(CATEGORY, FMT, ...) d_m3Log(CATEGORY, FMT, ##__VA_ARGS__)
# else
# define m3log_stack(...)

@ -161,7 +161,7 @@ M3Result EvaluateExpression (IM3Module i_module, void * o_expressed, u8 i_type
if (page)
{
pc_t m3code = GetPagePC (page);
result = Compile_Block (& o, i_type, 0);
result = CompileBlock (& o, i_type, 0);
if (not result)
{

Loading…
Cancel
Save