diff --git a/source/m3_compile.c b/source/m3_compile.c index 02d7876..ac6ace5 100644 --- a/source/m3_compile.c +++ b/source/m3_compile.c @@ -375,11 +375,9 @@ void PushRegister (IM3Compilation o, u8 i_m3Type) M3Result Pop (IM3Compilation o) { - // TODO: multivalue changes this constraint, but this should check underrunning the current block? - M3Result result = c_m3Err_none; - if (o->stackIndex) + if (o->stackIndex > o->block.initStackIndex) { o->stackIndex--; // printf ("pop: %d\n", (i32) o->stackIndex); @@ -411,7 +409,7 @@ M3Result UnwindBlockStack (IM3Compilation o) if (o->stackIndex > initStackIndex) { - m3log (compile, "reseting stack top"); + m3log (compile, "unwinding stack top"); while (o->stackIndex > initStackIndex ) _ (Pop (o)); @@ -983,7 +981,9 @@ _ (m3Alloc (& scope->patches, M3BranchPatch, 1)); } } -_ (UnwindBlockStack (o)); + o->block.isPolymorphic = true; + +//_ (UnwindBlockStack (o)); _catch: return result; } @@ -1811,11 +1811,14 @@ _ (EmitOp (o, op_Branch)); 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; } diff --git a/source/m3_env.c b/source/m3_env.c index f4b1904..f8c81ec 100644 --- a/source/m3_env.c +++ b/source/m3_env.c @@ -626,12 +626,12 @@ IM3CodePage AcquireCodePageWithCapacity (IM3Runtime i_runtime, u32 i_lineCount 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 defined (DEBUG) && d_m3LogCodePages + dump_code_page (i_codePage, /* startPC: */ NULL); +# endif + IM3CodePage * list; if (NumFreeLines (i_codePage) < c_m3CodePageFreeLinesThreshold) diff --git a/test/run-spec-test.py b/test/run-spec-test.py index 34a1a05..022fd99 100755 --- a/test/run-spec-test.py +++ b/test/run-spec-test.py @@ -453,11 +453,11 @@ else: "address", "align", "endianness", "memory_redundancy", "float_memory", - "switch" + "switch", "if" #--- TODO --- #"start", - #"if", "loop", "labels", "block", "br", "br_if", "br_table", "return", "unwind", + #"loop", "labels", "block", "br", "br_if", "br_table", "return", "unwind", #"float_exprs", #"nop", "unreachable", #"memory", "memory_trap", "memory_grow",