From 265ab63e19d8b6493093ae71f21bc4f937d9373a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 19 Jul 2012 13:26:06 -0600 Subject: [PATCH] fix crash when AOT compiling switch statement with only a default case The existing code handled such odd switch statements correctly in the JIT case, but did the wrong thing for the AOT case, leading to an assertion failure later on. --- src/compile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 466669b4f1..166468dcec 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -5527,12 +5527,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, uint32_t defaultIp = base + codeReadInt32(t, code, ip); assert(t, defaultIp < codeLength(t, code)); - Compiler::Operand* default_ = frame->addressOperand - (frame->addressPromise(c->machineIp(defaultIp))); - int32_t pairCount = codeReadInt32(t, code, ip); if (pairCount) { + Compiler::Operand* default_ = frame->addressOperand + (frame->addressPromise(c->machineIp(defaultIp))); + Promise* start = 0; THREAD_RUNTIME_ARRAY(t, uint32_t, ipTable, pairCount); for (int32_t i = 0; i < pairCount; ++i) { @@ -5574,7 +5574,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, } } else { // a switch statement with no cases, apparently - c->jmp(default_); + c->jmp(frame->machineIp(defaultIp)); } ip = defaultIp;