Bug 866888 part 1 - Add SRC_TRY source note for JSOP_TRY. r=luke

This commit is contained in:
Jan de Mooij 2013-07-23 09:23:34 +02:00
parent 1b60d0f165
commit 7e5cff87d3
4 changed files with 25 additions and 12 deletions

View File

@ -3714,7 +3714,6 @@ MOZ_NEVER_INLINE static bool
EmitTry(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
{
StmtInfoBCE stmtInfo(cx);
ptrdiff_t catchJump = -1;
/*
* Push stmtInfo to track jumps-over-catches and gosubs-to-finally
@ -3739,7 +3738,8 @@ EmitTry(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
int depth = bce->stackDepth;
/* Mark try location for decompilation, then emit try block. */
if (Emit1(cx, bce, JSOP_TRY) < 0)
ptrdiff_t noteIndex = NewSrcNote(cx, bce, SRC_TRY);
if (noteIndex < 0 || Emit1(cx, bce, JSOP_TRY) < 0)
return false;
ptrdiff_t tryStart = bce->offset();
if (!EmitTree(cx, bce, pn->pn_kid1))
@ -3754,9 +3754,14 @@ EmitTry(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
return false;
}
/* Source note points to the jump at the end of the try block. */
if (!SetSrcNoteOffset(cx, bce, noteIndex, 0, bce->offset() - tryStart + JSOP_TRY_LENGTH))
return false;
/* Emit (hidden) jump over catch and/or finally. */
if (NewSrcNote(cx, bce, SRC_HIDDEN) < 0)
return false;
ptrdiff_t catchJump = -1;
if (EmitBackPatchOp(cx, bce, &catchJump) < 0)
return false;
@ -6406,11 +6411,12 @@ const JSSrcNoteSpec js_SrcNoteSpec[] = {
/* 16 */ {"catch", 0},
/* 17 */ {"colspan", 1},
/* 18 */ {"newline", 0},
/* 19 */ {"setline", 1},
/* 17 */ {"try", 1},
/* 18 */ {"colspan", 1},
/* 19 */ {"newline", 0},
/* 20 */ {"setline", 1},
/* 20 */ {"unused20", 0},
/* 21 */ {"unused21", 0},
/* 22 */ {"unused22", 0},
/* 23 */ {"unused23", 0},

View File

@ -66,14 +66,16 @@ enum SrcNoteType {
SRC_CATCH = 16, /* catch block has guard */
SRC_TRY = 17, /* JSOP_TRY, offset points to goto at the
end of the try block. */
/* All notes below here are "gettable". See SN_IS_GETTABLE below. */
SRC_LAST_GETTABLE = SRC_CATCH,
SRC_LAST_GETTABLE = SRC_TRY,
SRC_COLSPAN = 17, /* number of columns this opcode spans */
SRC_NEWLINE = 18, /* bytecode follows a source newline */
SRC_SETLINE = 19, /* a file-absolute source line number note */
SRC_COLSPAN = 18, /* number of columns this opcode spans */
SRC_NEWLINE = 19, /* bytecode follows a source newline */
SRC_SETLINE = 20, /* a file-absolute source line number note */
SRC_UNUSED20 = 20,
SRC_UNUSED21 = 21,
SRC_UNUSED22 = 22,
SRC_UNUSED23 = 23,

View File

@ -1813,6 +1813,11 @@ SrcNotes(JSContext *cx, HandleScript script, Sprinter *sp)
break;
}
case SRC_TRY:
JS_ASSERT(JSOp(script->code[offset]) == JSOP_TRY);
Sprint(sp, " offset to jump %u", unsigned(js_GetSrcNoteOffset(sn, 0)));
break;
default:
JS_ASSERT(0);
break;

View File

@ -26,7 +26,7 @@ namespace js {
* and saved versions. If deserialization fails, the data should be
* invalidated if possible.
*/
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 148);
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 149);
class XDRBuffer {
public: