still cleaning up branching

extensions
Steven Massey 5 years ago
parent d2f605e82e
commit ecee4bf0cb

@ -375,11 +375,9 @@ void PushRegister (IM3Compilation o, u8 i_m3Type)
M3Result Pop (IM3Compilation o) M3Result Pop (IM3Compilation o)
{ {
// TODO: multivalue changes this constraint, but this should check underrunning the current block?
M3Result result = c_m3Err_none; M3Result result = c_m3Err_none;
if (o->stackIndex) if (o->stackIndex > o->block.initStackIndex)
{ {
o->stackIndex--; // printf ("pop: %d\n", (i32) o->stackIndex); o->stackIndex--; // printf ("pop: %d\n", (i32) o->stackIndex);
@ -411,7 +409,7 @@ M3Result UnwindBlockStack (IM3Compilation o)
if (o->stackIndex > initStackIndex) if (o->stackIndex > initStackIndex)
{ {
m3log (compile, "reseting stack top"); m3log (compile, "unwinding stack top");
while (o->stackIndex > initStackIndex ) while (o->stackIndex > initStackIndex )
_ (Pop (o)); _ (Pop (o));
@ -983,7 +981,9 @@ _ (m3Alloc (& scope->patches, M3BranchPatch, 1));
} }
} }
_ (UnwindBlockStack (o)); o->block.isPolymorphic = true;
//_ (UnwindBlockStack (o));
_catch: return result; _catch: return result;
} }
@ -1811,11 +1811,14 @@ _ (EmitOp (o, op_Branch));
o->page = savedPage; o->page = savedPage;
ReleaseCodePage (o->runtime, elsePage);
} }
else _throw (c_m3Err_mallocFailedCodePage); else result = c_m3Err_mallocFailedCodePage;
_catch: return result; _catch:
ReleaseCodePage (o->runtime, elsePage);
return result;
} }

@ -626,12 +626,12 @@ IM3CodePage AcquireCodePageWithCapacity (IM3Runtime i_runtime, u32 i_lineCount
void ReleaseCodePage (IM3Runtime i_runtime, IM3CodePage i_codePage) void ReleaseCodePage (IM3Runtime i_runtime, IM3CodePage i_codePage)
{ {
# if defined (DEBUG) && d_m3LogCodePages
dump_code_page (i_codePage, /* startPC: */ NULL);
# endif
if (i_codePage) if (i_codePage)
{ {
# if defined (DEBUG) && d_m3LogCodePages
dump_code_page (i_codePage, /* startPC: */ NULL);
# endif
IM3CodePage * list; IM3CodePage * list;
if (NumFreeLines (i_codePage) < c_m3CodePageFreeLinesThreshold) if (NumFreeLines (i_codePage) < c_m3CodePageFreeLinesThreshold)

@ -453,11 +453,11 @@ else:
"address", "align", "endianness", "address", "align", "endianness",
"memory_redundancy", "float_memory", "memory_redundancy", "float_memory",
"switch" "switch", "if"
#--- TODO --- #--- TODO ---
#"start", #"start",
#"if", "loop", "labels", "block", "br", "br_if", "br_table", "return", "unwind", #"loop", "labels", "block", "br", "br_if", "br_table", "return", "unwind",
#"float_exprs", #"float_exprs",
#"nop", "unreachable", #"nop", "unreachable",
#"memory", "memory_trap", "memory_grow", #"memory", "memory_trap", "memory_grow",

Loading…
Cancel
Save