Bug 380889: fixing the disassembler, r=brendan

This commit is contained in:
igor@mir2.org 2007-05-16 12:00:47 -07:00
parent d43420f5f7
commit 57a947de4b

View File

@ -907,8 +907,8 @@ PCToLine(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
#ifdef DEBUG #ifdef DEBUG
static void static void
GetSwitchTableBounds(JSScript *script, uintN offset, UpdateSwitchTableBounds(JSScript *script, uintN offset,
uintN *start, uintN *end) uintN *start, uintN *end)
{ {
jsbytecode *pc; jsbytecode *pc;
JSOp op; JSOp op;
@ -935,8 +935,7 @@ GetSwitchTableBounds(JSScript *script, uintN offset,
case JSOP_LOOKUPSWITCHX: case JSOP_LOOKUPSWITCHX:
jmplen = JUMPX_OFFSET_LEN; jmplen = JUMPX_OFFSET_LEN;
goto lookup_table; goto lookup_table;
default: case JSOP_LOOKUPSWITCH:
JS_ASSERT(op == JSOP_LOOKUPSWITCH);
jmplen = JUMP_OFFSET_LEN; jmplen = JUMP_OFFSET_LEN;
lookup_table: lookup_table:
pc += jmplen; pc += jmplen;
@ -944,6 +943,11 @@ GetSwitchTableBounds(JSScript *script, uintN offset,
pc += ATOM_INDEX_LEN; pc += ATOM_INDEX_LEN;
jmplen += JUMP_OFFSET_LEN; jmplen += JUMP_OFFSET_LEN;
break; break;
default:
/* [condswitch] switch does not have any jump or lookup tables. */
JS_ASSERT(op == JSOP_CONDSWITCH);
return;
} }
*start = (uintN)(pc - script->code); *start = (uintN)(pc - script->code);
@ -1030,8 +1034,8 @@ SrcNotes(JSContext *cx, JSScript *script)
caseOff = (uintN) js_GetSrcNoteOffset(sn, 1); caseOff = (uintN) js_GetSrcNoteOffset(sn, 1);
if (caseOff) if (caseOff)
fprintf(gOutFile, " first case offset %u", caseOff); fprintf(gOutFile, " first case offset %u", caseOff);
GetSwitchTableBounds(script, offset, UpdateSwitchTableBounds(script, offset,
&switchTableStart, &switchTableEnd); &switchTableStart, &switchTableEnd);
break; break;
case SRC_CATCH: case SRC_CATCH:
delta = (uintN) js_GetSrcNoteOffset(sn, 0); delta = (uintN) js_GetSrcNoteOffset(sn, 0);