[INFER] Watch for recompilation triggered by ValueToObject, bug 647183.

This commit is contained in:
Brian Hackett 2011-04-03 16:11:46 -07:00
parent 6e57f07678
commit 1ddb3c2c55
2 changed files with 46 additions and 18 deletions

View File

@ -0,0 +1,23 @@
var SECTION = "";
var VERSION = "";
function test() {}
function writeTestCaseResult( expect, actual, string ) {
if (typeof document != "object" ||
!document.location.href.match(/jsreftest.html/)) {
}
}
TIME_0000 = now = new Date;
TIME_NOW = now.valueOf();
function DaysInYear( y ) {
function MakeDate( day, time ) {
}
}
function TimeClip( t ) {
if ( isNaN ) { Number.NaN; }
}
function runDSTOffsetCachingTestsFraction(part, parts) { print; };
test_times=( TIME_NOW, TIME_0000, ( SECTION, VERSION+".getUTCMinutes()",
TIME_NOW.test_times,VERSION.SECTION ) , TIME_0000, TIME_0000,
0, 0 );
try { j = 0( SECTION, TimeClip(1.1), 0 ); } catch (e) {}

View File

@ -1762,13 +1762,20 @@ ic::GetProp(VMFrame &f, ic::PICInfo *pic)
atom = f.cx->runtime->atomState.lengthAtom;
}
bool usePropCache = pic->usePropCache;
/*
* ValueToObject can trigger recompilations if it lazily initializes any
* of the primitive classes (Boolean, Number, String). :XXX: if these
* classes are made eager then this monitoring is not necessary.
*/
RecompilationMonitor monitor(f.cx);
JSObject *obj = ValueToObject(f.cx, &f.regs.sp[-1]);
if (!obj)
THROW();
bool usePropCache = pic->usePropCache;
if (pic->shouldUpdate(f.cx)) {
if (!monitor.recompiled() && pic->shouldUpdate(f.cx)) {
VoidStubPIC stub = pic->usePropCache
? DisabledGetPropIC
: DisabledGetPropICNoCache;
@ -1824,10 +1831,6 @@ DisabledSetPropICNoCache(VMFrame &f, ic::PICInfo *pic)
void JS_FASTCALL
ic::SetProp(VMFrame &f, ic::PICInfo *pic)
{
JSObject *obj = ValueToObject(f.cx, &f.regs.sp[-2]);
if (!obj)
THROW();
JSScript *script = f.fp()->script();
JS_ASSERT(pic->isSet());
@ -1841,15 +1844,15 @@ ic::SetProp(VMFrame &f, ic::PICInfo *pic)
? STRICT_VARIANT(stubs::SetName)
: STRICT_VARIANT(stubs::SetPropNoCache);
//
// Important: We update the PIC before looking up the property so that the
// PIC is updated only if the property already exists. The PIC doesn't try
// to optimize adding new properties; that is for the slow case.
//
// Also note, we can't use SetName for PROPINC PICs because the property
// cache can't handle a GET and SET from the same scripted PC.
if (pic->shouldUpdate(f.cx)) {
RecompilationMonitor monitor(f.cx);
JSObject *obj = ValueToObject(f.cx, &f.regs.sp[-2]);
if (!obj)
THROW();
// Note, we can't use SetName for PROPINC PICs because the property
// cache can't handle a GET and SET from the same scripted PC.
if (!monitor.recompiled() && pic->shouldUpdate(f.cx)) {
SetPropCompiler cc(f, script, obj, *pic, atom, stub);
LookupStatus status = cc.update();
if (status == Lookup_Error)
@ -2533,12 +2536,14 @@ ic::GetElement(VMFrame &f, ic::GetElementIC *ic)
return;
}
Value idval = f.regs.sp[-1];
RecompilationMonitor monitor(cx);
JSObject *obj = ValueToObject(cx, &f.regs.sp[-2]);
if (!obj)
THROW();
Value idval = f.regs.sp[-1];
jsid id;
if (idval.isInt32() && INT_FITS_IN_JSID(idval.toInt32())) {
id = INT_TO_JSID(idval.toInt32());
@ -2547,7 +2552,7 @@ ic::GetElement(VMFrame &f, ic::GetElementIC *ic)
THROW();
}
if (ic->shouldUpdate(cx)) {
if (!monitor.recompiled() && ic->shouldUpdate(cx)) {
#ifdef DEBUG
f.regs.sp[-2] = MagicValue(JS_GENERIC_MAGIC);
#endif