зеркало из https://github.com/mozilla/pjs.git
Recover trapped opcode in js_GetIndexFromBytecode (416665, r=igor).
This commit is contained in:
Родитель
5a517d507d
Коммит
706a1e1472
|
@ -161,21 +161,16 @@ JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
JS_PUBLIC_API(JSOp)
|
JS_PUBLIC_API(JSOp)
|
||||||
JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc)
|
JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||||
{
|
{
|
||||||
|
JSRuntime *rt;
|
||||||
JSTrap *trap;
|
JSTrap *trap;
|
||||||
|
JSOp op;
|
||||||
|
|
||||||
DBG_LOCK_EVAL(cx->runtime, trap = FindTrap(cx->runtime, script, pc));
|
rt = cx->runtime;
|
||||||
if (!trap) {
|
DBG_LOCK(rt);
|
||||||
#ifdef JS_THREADSAFE
|
trap = FindTrap(rt, script, pc);
|
||||||
/*
|
op = trap ? trap->op : (JSOp) *pc;
|
||||||
* If we lost a race with another thread, return JSOP_LIMIT so our
|
DBG_UNLOCK(rt);
|
||||||
* caller can detect this case and do something sane.
|
return op;
|
||||||
*/
|
|
||||||
#else
|
|
||||||
JS_ASSERT(0); /* XXX can't happen */
|
|
||||||
#endif
|
|
||||||
return JSOP_LIMIT;
|
|
||||||
}
|
|
||||||
return trap->op;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -123,12 +123,15 @@ GetJumpOffset(jsbytecode *pc, jsbytecode *pc2)
|
||||||
}
|
}
|
||||||
|
|
||||||
uintN
|
uintN
|
||||||
js_GetIndexFromBytecode(JSScript *script, jsbytecode *pc, ptrdiff_t pcoff)
|
js_GetIndexFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
|
ptrdiff_t pcoff)
|
||||||
{
|
{
|
||||||
JSOp op;
|
JSOp op;
|
||||||
uintN span, base;
|
uintN span, base;
|
||||||
|
|
||||||
op = (JSOp)*pc;
|
op = (JSOp)*pc;
|
||||||
|
if (op == JSOP_TRAP)
|
||||||
|
op = JS_GetTrapOpcode(cx, script, pc);
|
||||||
JS_ASSERT(js_CodeSpec[op].length >= 1 + pcoff + UINT16_LEN);
|
JS_ASSERT(js_CodeSpec[op].length >= 1 + pcoff + UINT16_LEN);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -241,8 +244,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
case JOF_BYTE:
|
case JOF_BYTE:
|
||||||
if (op == JSOP_TRAP) {
|
if (op == JSOP_TRAP) {
|
||||||
op = JS_GetTrapOpcode(cx, script, pc);
|
op = JS_GetTrapOpcode(cx, script, pc);
|
||||||
if (op == JSOP_LIMIT)
|
|
||||||
return 0;
|
|
||||||
len = (ptrdiff_t) js_CodeSpec[op].length;
|
len = (ptrdiff_t) js_CodeSpec[op].length;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -256,7 +257,7 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
case JOF_ATOM:
|
case JOF_ATOM:
|
||||||
case JOF_OBJECT:
|
case JOF_OBJECT:
|
||||||
case JOF_REGEXP:
|
case JOF_REGEXP:
|
||||||
index = js_GetIndexFromBytecode(script, pc, 0);
|
index = js_GetIndexFromBytecode(cx, script, pc, 0);
|
||||||
if (type == JOF_ATOM) {
|
if (type == JOF_ATOM) {
|
||||||
JS_GET_SCRIPT_ATOM(script, index, atom);
|
JS_GET_SCRIPT_ATOM(script, index, atom);
|
||||||
v = ATOM_KEY(atom);
|
v = ATOM_KEY(atom);
|
||||||
|
@ -348,7 +349,7 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
case JOF_SLOTATOM:
|
case JOF_SLOTATOM:
|
||||||
case JOF_SLOTOBJECT:
|
case JOF_SLOTOBJECT:
|
||||||
fprintf(fp, " %u", GET_VARNO(pc));
|
fprintf(fp, " %u", GET_VARNO(pc));
|
||||||
index = js_GetIndexFromBytecode(script, pc, VARNO_LEN);
|
index = js_GetIndexFromBytecode(cx, script, pc, VARNO_LEN);
|
||||||
if (type == JOF_SLOTATOM) {
|
if (type == JOF_SLOTATOM) {
|
||||||
JS_GET_SCRIPT_ATOM(script, index, atom);
|
JS_GET_SCRIPT_ATOM(script, index, atom);
|
||||||
v = ATOM_KEY(atom);
|
v = ATOM_KEY(atom);
|
||||||
|
@ -4131,10 +4132,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
||||||
#endif /* JS_HAS_EXPORT_IMPORT */
|
#endif /* JS_HAS_EXPORT_IMPORT */
|
||||||
|
|
||||||
case JSOP_TRAP:
|
case JSOP_TRAP:
|
||||||
op = JS_GetTrapOpcode(cx, jp->script, pc);
|
saveop = op = JS_GetTrapOpcode(cx, jp->script, pc);
|
||||||
if (op == JSOP_LIMIT)
|
|
||||||
return NULL;
|
|
||||||
saveop = op;
|
|
||||||
*pc = op;
|
*pc = op;
|
||||||
cs = &js_CodeSpec[op];
|
cs = &js_CodeSpec[op];
|
||||||
len = cs->length;
|
len = cs->length;
|
||||||
|
|
|
@ -302,10 +302,14 @@ js_puts(JSPrinter *jp, const char *s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get index operand from the bytecode using a bytecode analysis to deduce the
|
* Get index operand from the bytecode using a bytecode analysis to deduce the
|
||||||
* the index register.
|
* the index register. This function is infallible, in spite of taking cx as
|
||||||
|
* its first parameter; it uses only cx->runtime when calling JS_GetTrapOpcode.
|
||||||
|
* The GET_*_FROM_BYTECODE macros that call it pick up cx from their caller's
|
||||||
|
* lexical environments.
|
||||||
*/
|
*/
|
||||||
uintN
|
uintN
|
||||||
js_GetIndexFromBytecode(JSScript *script, jsbytecode *pc, ptrdiff_t pcoff);
|
js_GetIndexFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
|
ptrdiff_t pcoff);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A slower version of GET_ATOM when the caller does not want to maintain
|
* A slower version of GET_ATOM when the caller does not want to maintain
|
||||||
|
@ -313,13 +317,13 @@ js_GetIndexFromBytecode(JSScript *script, jsbytecode *pc, ptrdiff_t pcoff);
|
||||||
*/
|
*/
|
||||||
#define GET_ATOM_FROM_BYTECODE(script, pc, pcoff, atom) \
|
#define GET_ATOM_FROM_BYTECODE(script, pc, pcoff, atom) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
uintN index_ = js_GetIndexFromBytecode((script), (pc), (pcoff)); \
|
uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff)); \
|
||||||
JS_GET_SCRIPT_ATOM((script), index_, atom); \
|
JS_GET_SCRIPT_ATOM((script), index_, atom); \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
#define GET_OBJECT_FROM_BYTECODE(script, pc, pcoff, obj) \
|
#define GET_OBJECT_FROM_BYTECODE(script, pc, pcoff, obj) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
uintN index_ = js_GetIndexFromBytecode((script), (pc), (pcoff)); \
|
uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff)); \
|
||||||
JS_GET_SCRIPT_OBJECT((script), index_, obj); \
|
JS_GET_SCRIPT_OBJECT((script), index_, obj); \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
|
@ -331,7 +335,7 @@ js_GetIndexFromBytecode(JSScript *script, jsbytecode *pc, ptrdiff_t pcoff);
|
||||||
|
|
||||||
#define GET_REGEXP_FROM_BYTECODE(script, pc, pcoff, obj) \
|
#define GET_REGEXP_FROM_BYTECODE(script, pc, pcoff, obj) \
|
||||||
JS_BEGIN_MACRO \
|
JS_BEGIN_MACRO \
|
||||||
uintN index_ = js_GetIndexFromBytecode((script), (pc), (pcoff)); \
|
uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff)); \
|
||||||
JS_GET_SCRIPT_REGEXP((script), index_, obj); \
|
JS_GET_SCRIPT_REGEXP((script), index_, obj); \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче