Shortcut lookup flag calculation when on trace (bug 502145, r=igor).

This commit is contained in:
Andreas Gal 2009-07-06 06:42:13 +02:00
parent 62b184e1f8
commit 539e90642d
4 changed files with 15 additions and 5 deletions

View File

@ -2168,7 +2168,7 @@ JS_DEFINE_CALLINFO_3(extern, CONSTRUCTOR_RETRY, js_NewInstance, CONTEXT, CLASS,
* access is "object-detecting" in the sense used by web scripts, e.g., when
* checking whether document.all is defined.
*/
static JS_REQUIRES_STACK JSBool
JS_REQUIRES_STACK JSBool
Detecting(JSContext *cx, jsbytecode *pc)
{
JSScript *script;
@ -2231,9 +2231,14 @@ Detecting(JSContext *cx, jsbytecode *pc)
* does not indicate whether we are in a with statement. Return defaultFlags
* if a currently executing bytecode cannot be determined.
*/
static uintN
InferFlags(JSContext *cx, uintN defaultFlags)
uintN
js_InferFlags(JSContext *cx, uintN defaultFlags)
{
if (JS_ON_TRACE(cx))
return cx->bailExit->lookupFlags;
JS_ASSERT_NOT_ON_TRACE(cx);
JSStackFrame *fp;
jsbytecode *pc;
const JSCodeSpec *cs;
@ -2271,7 +2276,7 @@ with_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
/* Fixes bug 463997 */
uintN flags = cx->resolveFlags;
if (flags == JSRESOLVE_INFER)
flags = InferFlags(cx, flags);
flags = js_InferFlags(cx, flags);
flags |= JSRESOLVE_WITH;
JSAutoResolveFlags rf(cx, flags);
JSObject *proto = OBJ_GET_PROTO(cx, obj);
@ -3837,7 +3842,7 @@ js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
if (clasp->flags & JSCLASS_NEW_RESOLVE) {
newresolve = (JSNewResolveOp)resolve;
if (flags == JSRESOLVE_INFER)
flags = InferFlags(cx, flags);
flags = js_InferFlags(cx, flags);
obj2 = (clasp->flags & JSCLASS_NEW_RESOLVE_GETS_START)
? start
: NULL;

View File

@ -864,6 +864,9 @@ JS_FRIEND_API(void) js_DumpObject(JSObject *obj);
JS_FRIEND_API(void) js_DumpStackFrame(JSStackFrame *fp);
#endif
extern uintN
js_InferFlags(JSContext *cx, uintN defaultFlags);
JS_END_EXTERN_C
#endif /* jsobj_h___ */

View File

@ -2944,6 +2944,7 @@ TraceRecorder::snapshot(ExitType exitType)
exit->sp_adj = (stackSlots * sizeof(double)) - treeInfo->nativeStackBase;
exit->rp_adj = exit->calldepth * sizeof(FrameInfo*);
exit->nativeCalleeWord = 0;
exit->lookupFlags = js_InferFlags(cx, 0);
memcpy(getFullTypeMap(exit), typemap, typemap_size);
return exit;
}

View File

@ -338,6 +338,7 @@ struct VMSideExit : public nanojit::SideExit
uint32 numStackSlots;
uint32 numStackSlotsBelowCurrentFrame;
ExitType exitType;
uintN lookupFlags;
/*
* Ordinarily 0. If a slow native function is atop the stack, the 1 bit is