Bug 547140, part 5 - Remove flags argument from lookup functions. r=Waldo.

This commit is contained in:
Jason Orendorff 2014-04-25 16:11:03 -05:00
parent 409179b8a6
commit 492cbe1d52
9 changed files with 38 additions and 115 deletions

View File

@ -113,7 +113,6 @@ EnterBaseline(JSContext *cx, EnterJitData &data)
{
AssertCompartmentUnchanged pcc(cx);
JitActivation activation(cx, data.constructing);
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
AutoFlushInhibitor afi(cx->runtime()->jitRuntime());
if (data.osrFrame)

View File

@ -2381,7 +2381,6 @@ EnterIon(JSContext *cx, EnterJitData &data)
{
AssertCompartmentUnchanged pcc(cx);
JitActivation activation(cx, data.constructing);
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
AutoFlushInhibitor afi(cx->runtime()->jitRuntime());
CALL_GENERATED_CODE(enter, data.jitcode, data.maxArgc, data.maxArgv, /* osrFrame = */nullptr, data.calleeToken,
@ -2493,8 +2492,6 @@ jit::FastInvoke(JSContext *cx, HandleFunction fun, CallArgs &args)
RootedValue result(cx, Int32Value(args.length()));
JS_ASSERT(args.length() >= fun->nargs());
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
CALL_GENERATED_CODE(enter, jitcode, args.length() + 1, args.array() - 1, /* osrFrame = */nullptr,
calleeToken, /* scopeChain = */ nullptr, 0, result.address());

View File

@ -2679,14 +2679,13 @@ JS_DeepFreezeObject(JSContext *cx, HandleObject obj)
}
static bool
LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
JSAutoResolveFlags rf(cx, flags);
return JSObject::lookupGeneric(cx, obj, id, objp, propp);
}
@ -2734,7 +2733,7 @@ JS_LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id, MutableHandl
RootedObject obj2(cx);
RootedShape prop(cx);
return LookupPropertyById(cx, obj, id, 0, &obj2, &prop) &&
return LookupPropertyById(cx, obj, id, &obj2, &prop) &&
LookupResult(cx, obj, obj2, id, prop, vp);
}
@ -2773,42 +2772,12 @@ JS_LookupUCProperty(JSContext *cx, HandleObject objArg, const jschar *name, size
return JS_LookupPropertyById(cx, obj, id, vp);
}
JS_PUBLIC_API(bool)
JS_LookupPropertyWithFlagsById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, MutableHandleValue vp)
{
RootedShape prop(cx);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
if (!(obj->isNative()
? LookupPropertyWithFlags(cx, obj, id, flags, objp, &prop)
: JSObject::lookupGeneric(cx, obj, id, objp, &prop)))
return false;
return LookupResult(cx, obj, objp, id, prop, vp);
}
JS_PUBLIC_API(bool)
JS_LookupPropertyWithFlags(JSContext *cx, HandleObject obj, const char *name, unsigned flags,
MutableHandleValue vp)
{
RootedObject obj2(cx);
JSAtom *atom = Atomize(cx, name, strlen(name));
if (!atom)
return false;
RootedId id(cx, AtomToId(atom));
return JS_LookupPropertyWithFlagsById(cx, obj, id, flags, &obj2, vp);
}
JS_PUBLIC_API(bool)
JS_HasPropertyById(JSContext *cx, HandleObject obj, HandleId id, bool *foundp)
{
RootedObject obj2(cx);
RootedShape prop(cx);
bool ok = LookupPropertyById(cx, obj, id, 0, &obj2, &prop);
bool ok = LookupPropertyById(cx, obj, id, &obj2, &prop);
*foundp = (prop != nullptr);
return ok;
}
@ -2855,7 +2824,7 @@ JS_AlreadyHasOwnPropertyById(JSContext *cx, HandleObject obj, HandleId id, bool
RootedObject obj2(cx);
RootedShape prop(cx);
if (!LookupPropertyById(cx, obj, id, 0, &obj2, &prop))
if (!LookupPropertyById(cx, obj, id, &obj2, &prop))
return false;
*foundp = (obj == obj2);
return true;
@ -3299,7 +3268,7 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id,
RootedObject obj2(cx);
RootedShape shape(cx);
if (!LookupPropertyById(cx, obj, id, 0, &obj2, &shape))
if (!LookupPropertyById(cx, obj, id, &obj2, &shape))
return false;
desc.clear();

View File

@ -2867,14 +2867,6 @@ extern JS_PUBLIC_API(bool)
JS_LookupPropertyById(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
JS::MutableHandleValue vp);
extern JS_PUBLIC_API(bool)
JS_LookupPropertyWithFlags(JSContext *cx, JS::HandleObject obj, const char *name,
unsigned flags, JS::MutableHandleValue vp);
extern JS_PUBLIC_API(bool)
JS_LookupPropertyWithFlagsById(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
unsigned flags, JS::MutableHandleObject objp, JS::MutableHandleValue vp);
struct JSPropertyDescriptor {
JSObject *obj;
unsigned attrs;

View File

@ -3303,7 +3303,7 @@ js::FindClassObject(ExclusiveContext *cx, MutableHandleObject protop, const Clas
RootedObject pobj(cx);
RootedShape shape(cx);
if (!LookupPropertyWithFlags(cx, cx->global(), id, 0, &pobj, &shape))
if (!LookupNativeProperty(cx, cx->global(), id, &pobj, &shape))
return false;
RootedValue v(cx);
if (shape && pobj->isNative()) {
@ -3767,7 +3767,7 @@ DefinePropertyOrElement(typename ExecutionModeTraits<mode>::ExclusiveContextType
}
static bool
NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, unsigned flags,
NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,
MutableHandle<Shape*> shapep);
bool
@ -3791,7 +3791,7 @@ js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, Ha
* If we are defining a getter whose setter was already defined, or
* vice versa, finish the job via obj->changeProperty.
*/
if (!NativeLookupOwnProperty(cx, obj, id, 0, &shape))
if (!NativeLookupOwnProperty(cx, obj, id, &shape))
return false;
if (shape) {
if (IsImplicitDenseOrTypedArrayElement(shape)) {
@ -3937,13 +3937,12 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject
template <AllowGC allowGC>
static MOZ_ALWAYS_INLINE bool
LookupOwnPropertyWithFlagsInline(ExclusiveContext *cx,
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
unsigned flags,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp,
bool *donep)
LookupOwnPropertyInline(ExclusiveContext *cx,
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp,
bool *donep)
{
// Check for a native dense element.
if (JSID_IS_INT(id) && obj->containsDenseElement(JSID_TO_INT(id))) {
@ -4013,13 +4012,13 @@ LookupOwnPropertyWithFlagsInline(ExclusiveContext *cx,
}
static bool
NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, unsigned flags,
NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,
MutableHandle<Shape*> shapep)
{
RootedObject pobj(cx);
bool done;
if (!LookupOwnPropertyWithFlagsInline<CanGC>(cx, obj, id, flags, &pobj, shapep, &done))
if (!LookupOwnPropertyInline<CanGC>(cx, obj, id, &pobj, shapep, &done))
return false;
if (!done || pobj != obj)
shapep.set(nullptr);
@ -4028,12 +4027,11 @@ NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, uns
template <AllowGC allowGC>
static MOZ_ALWAYS_INLINE bool
LookupPropertyWithFlagsInline(ExclusiveContext *cx,
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
unsigned flags,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
LookupPropertyInline(ExclusiveContext *cx,
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
/* NB: The logic of this procedure is implicitly reflected in IonBuilder.cpp's
* |CanEffectlesslyCallLookupGenericOnObject| logic.
@ -4045,7 +4043,7 @@ LookupPropertyWithFlagsInline(ExclusiveContext *cx,
while (true) {
bool done;
if (!LookupOwnPropertyWithFlagsInline<allowGC>(cx, current, id, flags, objp, propp, &done))
if (!LookupOwnPropertyInline<allowGC>(cx, current, id, objp, propp, &done))
return false;
if (done)
return true;
@ -4080,13 +4078,7 @@ baseops::LookupProperty(ExclusiveContext *cx,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
/* NB: The logic of this procedure is implicitly reflected in IonBuilder.cpp's
* |CanEffectlesslyCallLookupGenericOnObject| logic.
* If this changes, please remember to update the logic there as well.
*/
uint32_t resolveFlags =
cx->isJSContext() ? cx->asJSContext()->resolveFlags : 0;
return LookupPropertyWithFlagsInline<allowGC>(cx, obj, id, resolveFlags, objp, propp);
return LookupPropertyInline<allowGC>(cx, obj, id, objp, propp);
}
template bool
@ -4121,14 +4113,14 @@ baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
if (!IndexToId(cx, index, &id))
return false;
return LookupPropertyWithFlagsInline<CanGC>(cx, obj, id, cx->resolveFlags, objp, propp);
return LookupPropertyInline<CanGC>(cx, obj, id, objp, propp);
}
bool
js::LookupPropertyWithFlags(ExclusiveContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, MutableHandleShape propp)
js::LookupNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp)
{
return LookupPropertyWithFlagsInline<CanGC>(cx, obj, id, flags, objp, propp);
return LookupPropertyInline<CanGC>(cx, obj, id, objp, propp);
}
bool
@ -4163,11 +4155,8 @@ js::LookupNameNoGC(JSContext *cx, PropertyName *name, JSObject *scopeChain,
for (JSObject *scope = scopeChain; scope; scope = scope->enclosingScope()) {
if (scope->getOps()->lookupGeneric)
return false;
if (!LookupPropertyWithFlagsInline<NoGC>(cx, scope, NameToId(name),
cx->resolveFlags, pobjp, propp))
{
if (!LookupPropertyInline<NoGC>(cx, scope, NameToId(name), pobjp, propp))
return false;
}
if (*propp) {
*objp = scope;
return true;
@ -4207,8 +4196,6 @@ js::HasOwnProperty(JSContext *cx, LookupGenericOp lookup,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
if (lookup) {
JSAutoResolveFlags rf(cx, 0);
if (!allowGC)
return false;
if (!lookup(cx,
@ -4221,7 +4208,7 @@ js::HasOwnProperty(JSContext *cx, LookupGenericOp lookup,
}
} else {
bool done;
if (!LookupOwnPropertyWithFlagsInline<allowGC>(cx, obj, id, 0, objp, propp, &done))
if (!LookupOwnPropertyInline<allowGC>(cx, obj, id, objp, propp, &done))
return false;
if (!done) {
objp.set(nullptr);
@ -4415,10 +4402,10 @@ GetPropertyHelperInline(JSContext *cx,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<Value, allowGC>::MutableHandleType vp)
{
/* This call site is hot -- use the always-inlined variant of LookupPropertyWithFlags(). */
/* This call site is hot -- use the always-inlined variant of LookupNativeProperty(). */
typename MaybeRooted<JSObject*, allowGC>::RootType obj2(cx);
typename MaybeRooted<Shape*, allowGC>::RootType shape(cx);
if (!LookupPropertyWithFlagsInline<allowGC>(cx, obj, id, cx->resolveFlags, &obj2, &shape))
if (!LookupPropertyInline<allowGC>(cx, obj, id, &obj2, &shape))
return false;
if (!shape) {
@ -4475,11 +4462,9 @@ GetPropertyHelperInline(JSContext *cx,
return true;
/* Do not warn about tests like (obj[prop] == undefined). */
if (cx->resolveFlags == RESOLVE_INFER) {
pc += js_CodeSpec[op].length;
if (Detecting(cx, script, pc))
return true;
}
pc += js_CodeSpec[op].length;
if (Detecting(cx, script, pc))
return true;
unsigned flags = JSREPORT_WARNING | JSREPORT_STRICT;
script->setWarnedAboutUndefinedProp();
@ -4866,7 +4851,7 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
return false;
} else {
JSContext *cx = cxArg->asJSContext();
if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &shape))
if (!LookupNativeProperty(cx, obj, id, &pobj, &shape))
return false;
}
if (shape) {

View File

@ -1386,12 +1386,9 @@ DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, Handle
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned defineHow = 0);
/*
* Specialized subroutine that allows caller to preset JSRESOLVE_* flags.
*/
extern bool
LookupPropertyWithFlags(ExclusiveContext *cx, HandleObject obj, HandleId id, unsigned flags,
js::MutableHandleObject objp, js::MutableHandleShape propp);
LookupNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,
js::MutableHandleObject objp, js::MutableHandleShape propp);
/*
* Call the [[DefineOwnProperty]] internal method of obj.
@ -1417,12 +1414,6 @@ extern bool
ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccessors,
AutoIdVector *ids, AutoPropDescArrayRooter *descs);
/*
* Constant to pass to js_LookupPropertyWithFlags to infer bits from current
* bytecode.
*/
static const unsigned RESOLVE_INFER = 0xffff;
/* Read the name using a dynamic lookup on the scopeChain. */
extern bool
LookupName(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,

View File

@ -1080,14 +1080,6 @@ DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, PropertyName *name,
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, defineHow);
}
inline bool
LookupPropertyWithFlags(ExclusiveContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupPropertyWithFlags(cx, obj, id, flags, objp, propp);
}
namespace baseops {
inline bool

View File

@ -3014,7 +3014,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
objp.set(nullptr);
if (referent->isNative()) {
if (!LookupPropertyWithFlags(cx, referent, id, 0, &obj2, &shape))
if (!LookupNativeProperty(cx, referent, id, &obj2, &shape))
return false;
if (obj2 != referent)
return true;

View File

@ -1442,8 +1442,6 @@ Interpret(JSContext *cx, RunState &state)
activation.opMask() == EnableInterruptsPseudoOpcode); \
JS_END_MACRO
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
gc::MaybeVerifyBarriers(cx, true);
JS_ASSERT(!cx->compartment()->activeAnalysis);