mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Merge tracemonkey to mozilla-central.
This commit is contained in:
commit
5697ba7870
@ -18,4 +18,19 @@ function run_test() {
|
||||
do_check_eq(x[0], 6);
|
||||
do_check_eq(x[1], 8);
|
||||
do_check_eq(x[2], 10);
|
||||
}
|
||||
|
||||
// make sure reviver isn't called after a failed parse
|
||||
var called = false;
|
||||
function dontCallMe(k, v) {
|
||||
called = true;
|
||||
}
|
||||
|
||||
try {
|
||||
x = JSON.parse('{{{{{{{}}}}', dontCallMe);
|
||||
} catch (e) {
|
||||
if (! (e instanceof SyntaxError))
|
||||
throw("wrong exception");
|
||||
}
|
||||
|
||||
do_check_false(called);
|
||||
}
|
||||
|
@ -1715,7 +1715,7 @@ CloseNativeIterators(JSContext *cx)
|
||||
#define NGCHIST 64
|
||||
|
||||
static struct GCHist {
|
||||
JSBool lastDitch;
|
||||
bool lastDitch;
|
||||
JSGCThing *freeList;
|
||||
} gchist[NGCHIST];
|
||||
|
||||
@ -1790,15 +1790,21 @@ EnsureLocalFreeList(JSContext *cx)
|
||||
|
||||
#endif
|
||||
|
||||
static JS_INLINE JSBool
|
||||
static JS_INLINE bool
|
||||
IsGCThresholdReached(JSRuntime *rt)
|
||||
{
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (rt->gcZeal >= 1)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Since the initial value of the gcLastBytes parameter is not equal to
|
||||
* zero (see the js_InitGC function) the return value is false when
|
||||
* the gcBytes value is close to zero at the JS engine start.
|
||||
*/
|
||||
return rt->gcBytes / rt->gcTriggerFactor >= rt->gcLastBytes / 100;
|
||||
return rt->gcMallocBytes >= rt->gcMaxMallocBytes ||
|
||||
rt->gcBytes / rt->gcTriggerFactor >= rt->gcLastBytes / 100;
|
||||
}
|
||||
|
||||
void *
|
||||
@ -1806,7 +1812,7 @@ js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
uintN flindex;
|
||||
JSBool doGC;
|
||||
bool doGC;
|
||||
JSGCThing *thing;
|
||||
uint8 *flagp;
|
||||
JSGCArenaList *arenaList;
|
||||
@ -1867,17 +1873,13 @@ js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
doGC = (rt->gcMallocBytes >= rt->gcMaxMallocBytes && rt->gcPoke) ||
|
||||
IsGCThresholdReached(rt);
|
||||
#ifdef JS_GC_ZEAL
|
||||
doGC = doGC || rt->gcZeal >= 2 || (rt->gcZeal >= 1 && rt->gcPoke);
|
||||
# ifdef JS_TRACER
|
||||
#if defined JS_GC_ZEAL && defined JS_TRACER
|
||||
if (rt->gcZeal >= 1 && JS_TRACE_MONITOR(cx).useReservedObjects)
|
||||
goto testReservedObjects;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
arenaList = &rt->gcArenaList[flindex];
|
||||
doGC = IsGCThresholdReached(rt);
|
||||
for (;;) {
|
||||
if (doGC
|
||||
#ifdef JS_TRACER
|
||||
@ -1908,9 +1910,9 @@ js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes)
|
||||
* Refill the local free list by taking several things from the
|
||||
* global free list unless we are still at rt->gcMaxMallocBytes
|
||||
* barrier or the free list is already populated. The former
|
||||
* happens when GC is canceled due to !gcCallback(cx, JSGC_BEGIN)
|
||||
* or no gcPoke. The latter is caused via allocating new things
|
||||
* in gcCallback(cx, JSGC_END).
|
||||
* happens when GC is canceled due to gcCallback(cx, JSGC_BEGIN)
|
||||
* returning false. The latter is caused via allocating new
|
||||
* things in gcCallback(cx, JSGC_END).
|
||||
*/
|
||||
if (rt->gcMallocBytes >= rt->gcMaxMallocBytes)
|
||||
break;
|
||||
@ -1967,7 +1969,7 @@ testReservedObjects:
|
||||
if (!a) {
|
||||
if (doGC || JS_ON_TRACE(cx))
|
||||
goto fail;
|
||||
doGC = JS_TRUE;
|
||||
doGC = true;
|
||||
continue;
|
||||
}
|
||||
a->list = arenaList;
|
||||
@ -2100,14 +2102,8 @@ RefillDoubleFreeList(JSContext *cx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((rt->gcMallocBytes >= rt->gcMaxMallocBytes && rt->gcPoke) ||
|
||||
IsGCThresholdReached(rt)
|
||||
#ifdef JS_GC_ZEAL
|
||||
|| rt->gcZeal >= 2 || (rt->gcZeal >= 1 && rt->gcPoke)
|
||||
#endif
|
||||
) {
|
||||
if (IsGCThresholdReached(rt))
|
||||
goto do_gc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop until we find a flag bitmap byte with unset bits indicating free
|
||||
@ -2302,11 +2298,7 @@ js_AddAsGCBytes(JSContext *cx, size_t sz)
|
||||
rt = cx->runtime;
|
||||
if (rt->gcBytes >= rt->gcMaxBytes ||
|
||||
sz > (size_t) (rt->gcMaxBytes - rt->gcBytes) ||
|
||||
IsGCThresholdReached(rt)
|
||||
#ifdef JS_GC_ZEAL
|
||||
|| rt->gcZeal >= 2 || (rt->gcZeal >= 1 && rt->gcPoke)
|
||||
#endif
|
||||
) {
|
||||
IsGCThresholdReached(rt)) {
|
||||
if (JS_ON_TRACE(cx)) {
|
||||
/*
|
||||
* If we can't leave the trace, signal OOM condition, otherwise
|
||||
|
@ -3262,7 +3262,6 @@ js_Interpret(JSContext *cx)
|
||||
slot = GET_SLOTNO(regs.pc);
|
||||
JS_ASSERT(slot < fp->script->nslots);
|
||||
vp = &fp->slots[slot];
|
||||
GC_POKE(cx, *vp);
|
||||
*vp = regs.sp[-1];
|
||||
END_CASE(JSOP_FORLOCAL)
|
||||
|
||||
@ -5554,7 +5553,6 @@ js_Interpret(JSContext *cx)
|
||||
JS_ASSERT(slot < fp->fun->nargs);
|
||||
METER_SLOT_OP(op, slot);
|
||||
vp = &fp->argv[slot];
|
||||
GC_POKE(cx, *vp);
|
||||
*vp = FETCH_OPND(-1);
|
||||
END_SET_CASE(JSOP_SETARG)
|
||||
|
||||
@ -5575,7 +5573,6 @@ js_Interpret(JSContext *cx)
|
||||
slot = GET_SLOTNO(regs.pc);
|
||||
JS_ASSERT(slot < script->nslots);
|
||||
vp = &fp->slots[slot];
|
||||
GC_POKE(cx, *vp);
|
||||
*vp = FETCH_OPND(-1);
|
||||
END_SET_CASE(JSOP_SETLOCAL)
|
||||
|
||||
|
@ -590,15 +590,18 @@ js_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver)
|
||||
|
||||
if (!js_RemoveRoot(cx->runtime, &jp->objectStack))
|
||||
return JS_FALSE;
|
||||
|
||||
JSBool ok = *jp->statep == JSON_PARSE_STATE_FINISHED;
|
||||
jsval *v = jp->rootVal;
|
||||
jsval *vp = jp->rootVal;
|
||||
JS_free(cx, jp);
|
||||
|
||||
if (!ok)
|
||||
if (!ok) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(reviver) && js_IsCallable(JSVAL_TO_OBJECT(reviver), cx))
|
||||
ok = Revive(cx, reviver, v);
|
||||
ok = Revive(cx, reviver, vp);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -4893,10 +4893,8 @@ TraceRecorder::alu(LOpcode v, jsdouble v0, jsdouble v1, LIns* s0, LIns* s1)
|
||||
*/
|
||||
v = (LOpcode)((int)v & ~LIR64);
|
||||
LIns* result = lir->ins2(v, d0, d1);
|
||||
if (!overflowSafe(d0) || !overflowSafe(d1)) {
|
||||
lir->insGuard(LIR_xt, lir->ins1(LIR_ov, result),
|
||||
snapshot(OVERFLOW_EXIT));
|
||||
}
|
||||
if (!result->isconst() && (!overflowSafe(d0) || !overflowSafe(d1)))
|
||||
lir->insGuard(LIR_xt, lir->ins1(LIR_ov, result), snapshot(OVERFLOW_EXIT));
|
||||
return lir->ins1(LIR_i2f, result);
|
||||
}
|
||||
/*
|
||||
@ -5060,7 +5058,7 @@ TraceRecorder::tableswitch()
|
||||
pc += JUMPX_OFFSET_LEN;
|
||||
low = GET_JUMPX_OFFSET(pc);
|
||||
pc += JUMPX_OFFSET_LEN;
|
||||
high = GET_JUMPX_OFFSET(pc);
|
||||
high = GET_JUMPX_OFFSET(pc);
|
||||
}
|
||||
|
||||
/* Really large tables won't fit in a page. This is a conservative check.
|
||||
@ -6519,8 +6517,11 @@ TraceRecorder::record_JSOP_NEG()
|
||||
(!JSVAL_IS_DOUBLE(v) || !JSDOUBLE_IS_NEGZERO(*JSVAL_TO_DOUBLE(v))) &&
|
||||
-asNumber(v) == (int)-asNumber(v)) {
|
||||
a = lir->ins1(LIR_neg, ::demote(lir, a));
|
||||
lir->insGuard(LIR_xt, lir->ins1(LIR_ov, a), snapshot(OVERFLOW_EXIT));
|
||||
lir->insGuard(LIR_xt, lir->ins2(LIR_eq, a, lir->insImm(0)), snapshot(OVERFLOW_EXIT));
|
||||
if (!a->isconst()) {
|
||||
LIns* exit = snapshot(OVERFLOW_EXIT);
|
||||
lir->insGuard(LIR_xt, lir->ins1(LIR_ov, a), exit);
|
||||
lir->insGuard(LIR_xt, lir->ins2(LIR_eq, a, lir->insImm(0)), exit);
|
||||
}
|
||||
a = lir->ins1(LIR_i2f, a);
|
||||
} else {
|
||||
a = lir->ins1(LIR_fneg, a);
|
||||
|
Loading…
Reference in New Issue
Block a user