Bug 692978 - Split lookupProperty into property and generic forms, and use them throughout the engine. r=bhackett

This commit is contained in:
Jeff Walden 2011-10-08 15:45:04 -07:00
parent 52fd4e450f
commit 59fdf6b2d3
20 changed files with 201 additions and 140 deletions

View File

@ -3288,7 +3288,7 @@ LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, uintN flags,
JSAutoResolveFlags rf(cx, flags);
id = js_CheckForStringIndex(id);
return obj->lookupProperty(cx, id, objp, propp);
return obj->lookupGeneric(cx, id, objp, propp);
}
#define AUTO_NAMELEN(s,n) (((n) == (size_t)-1) ? js_strlen(s) : (n))
@ -3379,7 +3379,7 @@ JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, uintN flag
assertSameCompartment(cx, obj, id);
ok = obj->isNative()
? LookupPropertyWithFlags(cx, obj, id, flags, objp, &prop)
: obj->lookupProperty(cx, id, objp, &prop);
: obj->lookupGeneric(cx, id, objp, &prop);
return ok && LookupResult(cx, obj, *objp, id, prop, vp);
}

View File

@ -391,7 +391,7 @@ GetElement(JSContext *cx, JSObject *obj, jsdouble index, JSBool *hole, Value *vp
JSObject *obj2;
JSProperty *prop;
if (!obj->lookupProperty(cx, idr.id(), &obj2, &prop))
if (!obj->lookupGeneric(cx, idr.id(), &obj2, &prop))
return JS_FALSE;
if (!prop) {
*hole = JS_TRUE;
@ -713,8 +713,8 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
}
static JSBool
array_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
array_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
{
if (!obj->isDenseArray())
return js_LookupProperty(cx, obj, id, objp, propp);
@ -731,7 +731,14 @@ array_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
*propp = NULL;
return JS_TRUE;
}
return proto->lookupProperty(cx, id, objp, propp);
return proto->lookupGeneric(cx, id, objp, propp);
}
static JSBool
array_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
JSProperty **propp)
{
return array_lookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
static JSBool
@ -759,7 +766,7 @@ static JSBool
array_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp,
JSProperty **propp)
{
return array_lookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return array_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
JSBool
@ -1227,7 +1234,7 @@ Class js::ArrayClass = {
array_trace, /* trace */
JS_NULL_CLASS_EXT,
{
array_lookupProperty,
array_lookupGeneric,
array_lookupProperty,
array_lookupElement,
array_lookupSpecial,

View File

@ -181,7 +181,7 @@ typedef JSBool
(* LookupGenericOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* LookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
(* LookupPropOp)(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
JSProperty **propp);
typedef JSBool
(* LookupElementOp)(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,

View File

@ -574,7 +574,7 @@ JSStructuredCloneWriter::write(const Value &v)
*/
JSObject *obj2;
JSProperty *prop;
if (!js_HasOwnProperty(context(), obj->getOps()->lookupProperty, obj, id,
if (!js_HasOwnProperty(context(), obj->getOps()->lookupGeneric, obj, id,
&obj2, &prop)) {
return false;
}

View File

@ -832,7 +832,7 @@ js::CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs)
bool isFunction;
const char *type, *name;
if (!obj->lookupProperty(cx, id, &obj2, &prop))
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
return false;
if (!prop)
return true;
@ -2499,7 +2499,7 @@ BEGIN_CASE(JSOP_IN)
FETCH_ELEMENT_ID(obj, -2, id);
JSObject *obj2;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &obj2, &prop))
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
goto error;
bool cond = prop != NULL;
TRY_BRANCH_AFTER_COND(cond, 2);
@ -4549,7 +4549,7 @@ BEGIN_CASE(JSOP_DEFCONST)
BEGIN_CASE(JSOP_DEFVAR)
{
uint32 index = GET_INDEX(regs.pc);
JSAtom *atom = atoms[index];
PropertyName *name = atoms[index]->asPropertyName();
JSObject *obj = &regs.fp()->varObj();
JS_ASSERT(!obj->getOps()->defineProperty);
@ -4558,7 +4558,7 @@ BEGIN_CASE(JSOP_DEFVAR)
attrs |= JSPROP_PERMANENT;
/* Lookup id in order to check for redeclaration problems. */
jsid id = ATOM_TO_JSID(atom);
jsid id = ATOM_TO_JSID(name);
bool shouldDefine;
if (op == JSOP_DEFVAR) {
/*
@ -4567,7 +4567,7 @@ BEGIN_CASE(JSOP_DEFVAR)
*/
JSProperty *prop;
JSObject *obj2;
if (!obj->lookupProperty(cx, id, &obj2, &prop))
if (!obj->lookupProperty(cx, name, &obj2, &prop))
goto error;
shouldDefine = (!prop || obj2 != obj);
} else {
@ -4652,10 +4652,11 @@ BEGIN_CASE(JSOP_DEFFUN)
JSObject *parent = &regs.fp()->varObj();
/* ES5 10.5 (NB: with subsequent errata). */
jsid id = ATOM_TO_JSID(fun->atom);
PropertyName *name = fun->atom->asPropertyName();
jsid id = ATOM_TO_JSID(name);
JSProperty *prop = NULL;
JSObject *pobj;
if (!parent->lookupProperty(cx, id, &pobj, &prop))
if (!parent->lookupProperty(cx, name, &pobj, &prop))
goto error;
Value rval = ObjectValue(*obj);

View File

@ -867,7 +867,7 @@ SuppressDeletedPropertyHelper(JSContext *cx, JSObject *obj, IdPredicate predicat
AutoObjectRooter proto(cx, obj->getProto());
AutoObjectRooter obj2(cx);
JSProperty *prop;
if (!proto.object()->lookupProperty(cx, *idp, obj2.addr(), &prop))
if (!proto.object()->lookupGeneric(cx, *idp, obj2.addr(), &prop))
return false;
if (prop) {
uintN attrs;

View File

@ -257,7 +257,7 @@ MarkSharpObjects(JSContext *cx, JSObject *obj, JSIdArray **idap)
ok = JS_TRUE;
for (i = 0, length = ida->length; i < length; i++) {
id = ida->vector[i];
ok = obj->lookupProperty(cx, id, &obj2, &prop);
ok = obj->lookupGeneric(cx, id, &obj2, &prop);
if (!ok)
break;
if (!prop)
@ -592,7 +592,7 @@ obj_toSource(JSContext *cx, uintN argc, Value *vp)
/* Get strings for id and value and GC-root them via vp. */
jsid id = ida->vector[i];
ok = obj->lookupProperty(cx, id, &obj2, &prop);
ok = obj->lookupGeneric(cx, id, &obj2, &prop);
if (!ok)
goto error;
@ -1426,7 +1426,6 @@ obj_watch(JSContext *cx, uintN argc, Value *vp)
if (!callable)
return JS_FALSE;
/* Compute the unique int/atom symbol id needed by js_LookupProperty. */
jsid propid;
if (!ValueToId(cx, vp[2], &propid))
return JS_FALSE;
@ -1480,11 +1479,11 @@ obj_hasOwnProperty(JSContext *cx, uintN argc, Value *vp)
JSObject *obj = ToObject(cx, &vp[1]);
if (!obj)
return false;
return js_HasOwnPropertyHelper(cx, obj->getOps()->lookupProperty, argc, vp);
return js_HasOwnPropertyHelper(cx, obj->getOps()->lookupGeneric, argc, vp);
}
JSBool
js_HasOwnPropertyHelper(JSContext *cx, LookupPropOp lookup, uintN argc,
js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, uintN argc,
Value *vp)
{
jsid id;
@ -1510,7 +1509,7 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupPropOp lookup, uintN argc,
}
JSBool
js_HasOwnProperty(JSContext *cx, LookupPropOp lookup, JSObject *obj, jsid id,
js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING);
@ -1577,7 +1576,7 @@ js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, Value *vp)
{
JSObject *pobj;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return false;
if (!prop) {
@ -1688,7 +1687,7 @@ obj_lookupGetter(JSContext *cx, uintN argc, Value *vp)
return JS_FALSE;
JSObject *pobj;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
vp->setUndefined();
if (prop) {
@ -1712,7 +1711,7 @@ obj_lookupSetter(JSContext *cx, uintN argc, Value *vp)
return JS_FALSE;
JSObject *pobj;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
vp->setUndefined();
if (prop) {
@ -1844,7 +1843,7 @@ GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, PropertyDescript
JSObject *pobj;
JSProperty *prop;
if (!js_HasOwnProperty(cx, obj->getOps()->lookupProperty, obj, id, &pobj, &prop))
if (!js_HasOwnProperty(cx, obj->getOps()->lookupGeneric, obj, id, &pobj, &prop))
return false;
if (!prop) {
desc->obj = NULL;
@ -2124,7 +2123,7 @@ DefinePropertyOnObject(JSContext *cx, JSObject *obj, const jsid &id, const PropD
/* 8.12.9 step 1. */
JSProperty *current;
JSObject *obj2;
JS_ASSERT(!obj->getOps()->lookupProperty);
JS_ASSERT(!obj->getOps()->lookupGeneric);
if (!js_HasOwnProperty(cx, NULL, obj, id, &obj2, &current))
return JS_FALSE;
@ -2485,7 +2484,7 @@ DefineProperty(JSContext *cx, JSObject *obj, const jsid &id, const PropDesc &des
if (obj->isArray())
return DefinePropertyOnArray(cx, obj, id, desc, throwError, rval);
if (obj->getOps()->lookupProperty) {
if (obj->getOps()->lookupGeneric) {
if (obj->isProxy())
return Proxy::defineProperty(cx, obj, id, desc.pd);
return Reject(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE, throwError, rval);
@ -3255,8 +3254,7 @@ js_InferFlags(JSContext *cx, uintN defaultFlags)
* ObjectOps and Class for with-statement stack objects.
*/
static JSBool
with_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
with_LookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProperty **propp)
{
/* Fixes bug 463997 */
uintN flags = cx->resolveFlags;
@ -3264,7 +3262,13 @@ with_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
flags = js_InferFlags(cx, flags);
flags |= JSRESOLVE_WITH;
JSAutoResolveFlags rf(cx, flags);
return obj->getProto()->lookupProperty(cx, id, objp, propp);
return obj->getProto()->lookupGeneric(cx, id, objp, propp);
}
static JSBool
with_LookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp, JSProperty **propp)
{
return with_LookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
static JSBool
@ -3274,13 +3278,13 @@ with_LookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return with_LookupProperty(cx, obj, id, objp, propp);
return with_LookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
with_LookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, JSProperty **propp)
{
return with_LookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return with_LookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
static JSBool
@ -3433,7 +3437,7 @@ Class js::WithClass = {
NULL, /* trace */
JS_NULL_CLASS_EXT,
{
with_LookupProperty,
with_LookupGeneric,
with_LookupProperty,
with_LookupElement,
with_LookupSpecial,
@ -5402,7 +5406,7 @@ CallResolveOp(JSContext *cx, JSObject *start, JSObject *obj, jsid id, uintN flag
if (!obj2->isNative()) {
/* Whoops, newresolve handed back a foreign obj2. */
JS_ASSERT(obj2 != obj);
return obj2->lookupProperty(cx, id, objp, propp);
return obj2->lookupGeneric(cx, id, objp, propp);
}
obj = obj2;
} else {
@ -5457,7 +5461,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, JSObject *obj, jsid id, uintN flags
if (!proto)
break;
if (!proto->isNative()) {
if (!proto->lookupProperty(cx, id, objp, propp))
if (!proto->lookupGeneric(cx, id, objp, propp))
return false;
#ifdef DEBUG
/*
@ -5597,7 +5601,7 @@ js_FindPropertyHelper(JSContext *cx, jsid id, bool cacheResult, bool global,
}
for (;;) {
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return NULL;
if (prop) {
PCMETER(JS_PROPERTY_CACHE(cx).nofills++);
@ -5606,7 +5610,7 @@ js_FindPropertyHelper(JSContext *cx, jsid id, bool cacheResult, bool global,
/*
* We conservatively assume that a resolve hook could mutate the scope
* chain during JSObject::lookupProperty. So we read parent here again.
* chain during JSObject::lookupGeneric. So we read parent here again.
*/
parent = obj->getParent();
if (!parent) {
@ -5685,14 +5689,14 @@ js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id)
do {
JSObject *pobj;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return NULL;
if (prop)
break;
/*
* We conservatively assume that a resolve hook could mutate the scope
* chain during JSObject::lookupProperty. So we must check if parent is
* chain during JSObject::lookupGeneric. So we must check if parent is
* not null here even if it wasn't before the lookup.
*/
JSObject *parent = obj->getParent();
@ -6636,7 +6640,7 @@ CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
break;
default:
if (!obj->lookupProperty(cx, id, &pobj, &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
if (!prop) {
if (!writing)

View File

@ -1352,12 +1352,10 @@ struct JSObject : js::gc::Cell {
/* Clear the scope, making it empty. */
void clear(JSContext *cx);
JSBool lookupProperty(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp) {
js::LookupPropOp op = getOps()->lookupProperty;
return (op ? op : js_LookupProperty)(cx, this, id, objp, propp);
}
inline JSBool lookupGeneric(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp);
inline JSBool lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp);
inline JSBool lookupElement(JSContext *cx, uint32 index, JSObject **objp, JSProperty **propp);
inline JSBool lookupSpecial(JSContext *cx, js::SpecialId sid, JSObject **objp, JSProperty **propp);
JSBool defineProperty(JSContext *cx, jsid id, const js::Value &value,
JSPropertyOp getter = JS_PropertyStub,
@ -1691,11 +1689,11 @@ extern void
js_TraceSharpMap(JSTracer *trc, JSSharpObjectMap *map);
extern JSBool
js_HasOwnPropertyHelper(JSContext *cx, js::LookupPropOp lookup, uintN argc,
js_HasOwnPropertyHelper(JSContext *cx, js::LookupGenericOp lookup, uintN argc,
js::Value *vp);
extern JSBool
js_HasOwnProperty(JSContext *cx, js::LookupPropOp lookup, JSObject *obj, jsid id,
js_HasOwnProperty(JSContext *cx, js::LookupGenericOp lookup, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp);
extern JSBool

View File

@ -919,7 +919,7 @@ JSObject::hasProperty(JSContext *cx, jsid id, bool *foundp, uintN flags)
JSObject *pobj;
JSProperty *prop;
JSAutoResolveFlags rf(cx, flags);
if (!lookupProperty(cx, id, &pobj, &prop))
if (!lookupGeneric(cx, id, &pobj, &prop))
return false;
*foundp = !!prop;
return true;
@ -1103,6 +1103,19 @@ JSObject::setSharedNonNativeMap()
setMap(&js::Shape::sharedNonNative);
}
inline JSBool
JSObject::lookupGeneric(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp)
{
js::LookupGenericOp op = getOps()->lookupGeneric;
return (op ? op : js_LookupProperty)(cx, this, id, objp, propp);
}
inline JSBool
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp)
{
return lookupGeneric(cx, ATOM_TO_JSID(name), objp, propp);
}
inline JSBool
JSObject::lookupElement(JSContext *cx, uint32 index, JSObject **objp, JSProperty **propp)
{
@ -1110,6 +1123,12 @@ JSObject::lookupElement(JSContext *cx, uint32 index, JSObject **objp, JSProperty
return (op ? op : js_LookupElement)(cx, this, index, objp, propp);
}
inline JSBool
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, JSObject **objp, JSProperty **propp)
{
return lookupGeneric(cx, SPECIALID_TO_JSID(sid), objp, propp);
}
inline JSBool
JSObject::getElement(JSContext *cx, JSObject *receiver, uint32 index, js::Value *vp)
{

View File

@ -1393,20 +1393,20 @@ CheckStrictAssignment(JSContext *cx, JSTreeContext *tc, JSParseNode *lhs)
* tc's token stream if pn is NULL.
*/
bool
CheckStrictBinding(JSContext *cx, JSTreeContext *tc, JSAtom *atom, JSParseNode *pn)
CheckStrictBinding(JSContext *cx, JSTreeContext *tc, PropertyName *name, JSParseNode *pn)
{
if (!tc->needStrictChecks())
return true;
JSAtomState *atomState = &cx->runtime->atomState;
if (atom == atomState->evalAtom ||
atom == atomState->argumentsAtom ||
FindKeyword(atom->charsZ(), atom->length()))
if (name == atomState->evalAtom ||
name == atomState->argumentsAtom ||
FindKeyword(name->charsZ(), name->length()))
{
JSAutoByteString name;
if (!js_AtomToPrintableString(cx, atom, &name))
JSAutoByteString bytes;
if (!js_AtomToPrintableString(cx, name, &bytes))
return false;
return ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_BAD_BINDING, name.ptr());
return ReportStrictModeError(cx, TS(tc->parser), tc, pn, JSMSG_BAD_BINDING, bytes.ptr());
}
return true;
@ -2608,7 +2608,7 @@ EnterFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
}
static bool
LeaveFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
LeaveFunction(JSParseNode *fn, JSTreeContext *funtc, PropertyName *funName = NULL,
FunctionSyntaxKind kind = Expression)
{
JSTreeContext *tc = funtc->parent;
@ -2636,7 +2636,7 @@ LeaveFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
JSDefinition *dn = r.front().value();
JS_ASSERT(dn->isPlaceholder());
if (atom == funAtom && kind == Expression) {
if (atom == funName && kind == Expression) {
dn->setOp(JSOP_CALLEE);
dn->pn_cookie.set(funtc->staticLevel, UpvarCookie::CALLEE_SLOT);
dn->pn_dflags |= PND_BOUND;
@ -2761,7 +2761,7 @@ LeaveFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
fn->pn_body->setKind(TOK_UPVARS);
fn->pn_body->pn_pos = body->pn_pos;
if (foundCallee)
funtc->lexdeps->remove(funAtom);
funtc->lexdeps->remove(funName);
/* Transfer ownership of the lexdep map to the parse node. */
fn->pn_body->pn_names = funtc->lexdeps;
funtc->lexdeps.clearMap();
@ -2797,7 +2797,7 @@ LeaveFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
}
static bool
DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, JSAtom *atom);
DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, PropertyName *name);
/*
* FIXME? this Parser method was factored from Parser::functionDef with minimal
@ -2944,9 +2944,9 @@ Parser::functionArguments(JSTreeContext &funtc, JSFunctionBox *funbox, JSParseNo
}
JSParseNode *
Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
Parser::functionDef(PropertyName *funName, FunctionType type, FunctionSyntaxKind kind)
{
JS_ASSERT_IF(kind == Statement, funAtom);
JS_ASSERT_IF(kind == Statement, funName);
/* Make a TOK_FUNCTION node. */
tokenStream.mungeCurrentToken(TOK_FUNCTION, JSOP_NOP);
@ -2973,7 +2973,7 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
* avoid optimizing variable references that might name a function.
*/
if (kind == Statement) {
if (JSDefinition *dn = tc->decls.lookupFirst(funAtom)) {
if (JSDefinition *dn = tc->decls.lookupFirst(funName)) {
JSDefinition::Kind dn_kind = dn->kind();
JS_ASSERT(!dn->isUsed());
@ -2981,7 +2981,7 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
if (context->hasStrictOption() || dn_kind == JSDefinition::CONST) {
JSAutoByteString name;
if (!js_AtomToPrintableString(context, funAtom, &name) ||
if (!js_AtomToPrintableString(context, funName, &name) ||
!reportErrorNumber(NULL,
(dn_kind != JSDefinition::CONST)
? JSREPORT_WARNING | JSREPORT_STRICT
@ -2994,11 +2994,11 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
}
if (bodyLevel) {
tc->decls.updateFirst(funAtom, (JSDefinition *) pn);
tc->decls.updateFirst(funName, (JSDefinition *) pn);
pn->setDefn(true);
pn->dn_uses = dn; /* dn->dn_uses is now pn_link */
if (!MakeDefIntoUse(dn, pn, funAtom, tc))
if (!MakeDefIntoUse(dn, pn, funName, tc))
return NULL;
}
} else if (bodyLevel) {
@ -3008,7 +3008,7 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
* put in tc->lexdeps on first forward reference, and recycle pn.
*/
if (JSDefinition *fn = tc->lexdeps.lookupDefn(funAtom)) {
if (JSDefinition *fn = tc->lexdeps.lookupDefn(funName)) {
JS_ASSERT(fn->isDefn());
fn->setKind(TOK_FUNCTION);
fn->setArity(PN_FUNC);
@ -3023,12 +3023,12 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
fn->pn_body = NULL;
fn->pn_cookie.makeFree();
tc->lexdeps->remove(funAtom);
tc->lexdeps->remove(funName);
RecycleTree(pn, tc);
pn = fn;
}
if (!Define(pn, funAtom, tc))
if (!Define(pn, funName, tc))
return NULL;
}
@ -3049,11 +3049,11 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
* already exists.
*/
uintN index;
switch (tc->bindings.lookup(context, funAtom, &index)) {
switch (tc->bindings.lookup(context, funName, &index)) {
case NONE:
case ARGUMENT:
index = tc->bindings.countVars();
if (!tc->bindings.addVariable(context, funAtom))
if (!tc->bindings.addVariable(context, funName))
return NULL;
/* FALL THROUGH */
@ -3074,7 +3074,7 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
if (!funtc.init(context))
return NULL;
JSFunctionBox *funbox = EnterFunction(pn, &funtc, funAtom, kind);
JSFunctionBox *funbox = EnterFunction(pn, &funtc, funName, kind);
if (!funbox)
return NULL;
@ -3135,7 +3135,7 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
if (!body)
return NULL;
if (funAtom && !CheckStrictBinding(context, &funtc, funAtom, pn))
if (funName && !CheckStrictBinding(context, &funtc, funName, pn))
return NULL;
if (!CheckStrictParameters(context, &funtc))
@ -3254,13 +3254,13 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
if (!outertc->inFunction() && bodyLevel && kind == Statement && outertc->compiling()) {
JS_ASSERT(pn->pn_cookie.isFree());
if (!DefineGlobal(pn, outertc->asCodeGenerator(), funAtom))
if (!DefineGlobal(pn, outertc->asCodeGenerator(), funName))
return NULL;
}
pn->pn_blockid = outertc->blockid();
if (!LeaveFunction(pn, &funtc, funAtom, kind))
if (!LeaveFunction(pn, &funtc, funName, kind))
return NULL;
/* If the surrounding function is not strict code, reset the lexer. */
@ -3273,9 +3273,9 @@ Parser::functionDef(JSAtom *funAtom, FunctionType type, FunctionSyntaxKind kind)
JSParseNode *
Parser::functionStmt()
{
JSAtom *name = NULL;
PropertyName *name = NULL;
if (tokenStream.getToken(TSF_KEYWORD_IS_NAME) == TOK_NAME) {
name = tokenStream.currentToken().t_atom;
name = tokenStream.currentToken().t_atom->asPropertyName();
} else {
/* Unnamed function expressions are forbidden in statement context. */
reportErrorNumber(NULL, JSREPORT_ERROR, JSMSG_UNNAMED_FUNCTION_STMT);
@ -3294,9 +3294,9 @@ Parser::functionStmt()
JSParseNode *
Parser::functionExpr()
{
JSAtom *name = NULL;
PropertyName *name = NULL;
if (tokenStream.getToken(TSF_KEYWORD_IS_NAME) == TOK_NAME)
name = tokenStream.currentToken().t_atom;
name = tokenStream.currentToken().t_atom->asPropertyName();
else
tokenStream.ungetToken();
return functionDef(name, Normal, Expression);
@ -3513,7 +3513,7 @@ BindLet(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
JS_ASSERT(!tc->atBodyLevel());
pn = data->pn;
if (!CheckStrictBinding(cx, tc, atom, pn))
if (!CheckStrictBinding(cx, tc, atom->asPropertyName(), pn))
return false;
blockObj = tc->blockChain();
@ -3623,7 +3623,7 @@ OuterLet(JSTreeContext *tc, JSStmtInfo *stmt, JSAtom *atom)
* stack frame slots.
*/
static bool
DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, JSAtom *atom)
DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, PropertyName *name)
{
GlobalScope *globalScope = cg->compiler()->globalScope;
JSObject *globalObj = globalScope->globalObj;
@ -3631,13 +3631,13 @@ DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, JSAtom *atom)
if (!cg->compileAndGo() || !globalObj || cg->compilingForEval())
return true;
AtomIndexAddPtr p = globalScope->names.lookupForAdd(atom);
AtomIndexAddPtr p = globalScope->names.lookupForAdd(name);
if (!p) {
JSContext *cx = cg->parser->context;
JSObject *holder;
JSProperty *prop;
if (!globalObj->lookupProperty(cx, ATOM_TO_JSID(atom), &holder, &prop))
if (!globalObj->lookupProperty(cx, name, &holder, &prop))
return false;
JSFunctionBox *funbox = pn->isKind(TOK_FUNCTION) ? pn->pn_funbox : NULL;
@ -3662,14 +3662,14 @@ DefineGlobal(JSParseNode *pn, JSCodeGenerator *cg, JSAtom *atom)
def = GlobalScope::GlobalDef(shape->slot);
} else {
def = GlobalScope::GlobalDef(atom, funbox);
def = GlobalScope::GlobalDef(name, funbox);
}
if (!globalScope->defs.append(def))
return false;
jsatomid index = globalScope->names.count();
if (!globalScope->names.add(p, atom, index))
if (!globalScope->names.add(p, name, index))
return false;
JS_ASSERT(index == globalScope->defs.length() - 1);
@ -3749,7 +3749,7 @@ BindTopLevelVar(JSContext *cx, BindData *data, JSParseNode *pn, JSTreeContext *t
* is present, try to bake in either an already available slot or a
* predicted slot that will be defined after compiling is completed.
*/
return DefineGlobal(pn, tc->asCodeGenerator(), pn->pn_atom);
return DefineGlobal(pn, tc->asCodeGenerator(), pn->pn_atom->asPropertyName());
}
static bool
@ -3807,7 +3807,7 @@ BindVarOrConst(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
/* Default best op for pn is JSOP_NAME; we'll try to improve below. */
pn->setOp(JSOP_NAME);
if (!CheckStrictBinding(cx, tc, atom, pn))
if (!CheckStrictBinding(cx, tc, atom->asPropertyName(), pn))
return false;
JSStmtInfo *stmt = js_LexicalLookup(tc, atom, NULL);

View File

@ -1258,7 +1258,7 @@ private:
enum FunctionType { Getter, Setter, Normal };
bool functionArguments(JSTreeContext &funtc, JSFunctionBox *funbox, JSParseNode **list);
JSParseNode *functionBody();
JSParseNode *functionDef(JSAtom *name, FunctionType type, FunctionSyntaxKind kind);
JSParseNode *functionDef(PropertyName *name, FunctionType type, FunctionSyntaxKind kind);
JSParseNode *condition();
JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid, bool isGenexp,

View File

@ -912,8 +912,8 @@ proxy_innerObject(JSContext *cx, JSObject *obj)
}
static JSBool
proxy_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
proxy_LookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
{
id = js_CheckForStringIndex(id);
@ -931,6 +931,13 @@ proxy_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
return true;
}
static JSBool
proxy_LookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
JSProperty **propp)
{
return proxy_LookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
static JSBool
proxy_LookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
JSProperty **propp)
@ -938,13 +945,13 @@ proxy_LookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return proxy_LookupProperty(cx, obj, id, objp, propp);
return proxy_LookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
proxy_LookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, JSProperty **propp)
{
return proxy_LookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return proxy_LookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
static JSBool
@ -1202,7 +1209,7 @@ JS_FRIEND_DATA(Class) js::ObjectProxyClass = {
proxy_TraceObject, /* trace */
JS_NULL_CLASS_EXT,
{
proxy_LookupProperty,
proxy_LookupGeneric,
proxy_LookupProperty,
proxy_LookupElement,
proxy_LookupSpecial,
@ -1263,7 +1270,7 @@ JS_FRIEND_DATA(Class) js::OuterWindowProxyClass = {
NULL /* unused */
},
{
proxy_LookupProperty,
proxy_LookupGeneric,
proxy_LookupProperty,
proxy_LookupElement,
proxy_LookupSpecial,
@ -1336,7 +1343,7 @@ JS_FRIEND_DATA(Class) js::FunctionProxyClass = {
proxy_TraceFunction, /* trace */
JS_NULL_CLASS_EXT,
{
proxy_LookupProperty,
proxy_LookupGeneric,
proxy_LookupProperty,
proxy_LookupElement,
proxy_LookupSpecial,

View File

@ -12054,8 +12054,8 @@ static bool
SafeLookup(JSContext *cx, JSObject* obj, jsid id, JSObject** pobjp, const Shape** shapep)
{
do {
// Avoid non-native lookupProperty hooks.
if (obj->getOps()->lookupProperty)
// Avoid non-native lookupGeneric hooks.
if (obj->getOps()->lookupGeneric)
return false;
if (const Shape *shape = obj->nativeLookup(cx, id)) {
@ -12770,7 +12770,7 @@ GetPropertyWithNativeGetter(JSContext* cx, JSObject* obj, Shape* shape, Value* v
#ifdef DEBUG
JSProperty* prop;
JSObject* pobj;
JS_ASSERT(obj->lookupProperty(cx, shape->propid, &pobj, &prop));
JS_ASSERT(obj->lookupGeneric(cx, shape->propid, &pobj, &prop));
JS_ASSERT(prop == (JSProperty*) shape);
#endif
@ -15193,12 +15193,12 @@ TraceRecorder::record_JSOP_IN()
JSObject* obj2;
JSProperty* prop;
JSBool ok = obj->lookupProperty(cx, id, &obj2, &prop);
JSBool ok = obj->lookupGeneric(cx, id, &obj2, &prop);
if (!ok)
RETURN_ERROR_A("obj->lookupProperty failed in JSOP_IN");
RETURN_ERROR_A("obj->lookupGeneric failed in JSOP_IN");
/* lookupProperty can reenter the interpreter and kill |this|. */
/* lookupGeneric can reenter the interpreter and kill |this|. */
if (!localtm.recorder)
return ARECORD_ABORTED;

View File

@ -241,8 +241,8 @@ ArrayBuffer::obj_trace(JSTracer *trc, JSObject *obj)
static JSProperty * const PROPERTY_FOUND = reinterpret_cast<JSProperty *>(1);
JSBool
ArrayBuffer::obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp)
ArrayBuffer::obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*propp = PROPERTY_FOUND;
@ -254,7 +254,7 @@ ArrayBuffer::obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
if (!delegate)
return false;
JSBool delegateResult = delegate->lookupProperty(cx, id, objp, propp);
JSBool delegateResult = delegate->lookupGeneric(cx, id, objp, propp);
/* If false, there was an error, so propagate it.
* Otherwise, if propp is non-null, the property
@ -277,7 +277,14 @@ ArrayBuffer::obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
return true;
}
return proto->lookupProperty(cx, id, objp, propp);
return proto->lookupGeneric(cx, id, objp, propp);
}
JSBool
ArrayBuffer::obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
JSBool
@ -315,7 +322,7 @@ JSBool
ArrayBuffer::obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
JSObject **objp, JSProperty **propp)
{
return obj_lookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return obj_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
JSBool
@ -658,8 +665,8 @@ TypedArray::prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
JSBool
TypedArray::obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp)
TypedArray::obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
@ -677,7 +684,14 @@ TypedArray::obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
return true;
}
return proto->lookupProperty(cx, id, objp, propp);
return proto->lookupGeneric(cx, id, objp, propp);
}
JSBool
TypedArray::obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
JSObject **objp, JSProperty **propp)
{
return obj_lookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
JSBool
@ -705,7 +719,7 @@ JSBool
TypedArray::obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
JSObject **objp, JSProperty **propp)
{
return obj_lookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return obj_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
JSBool
@ -2016,7 +2030,7 @@ Class js::ArrayBufferClass = {
ArrayBuffer::obj_trace,
JS_NULL_CLASS_EXT,
{
ArrayBuffer::obj_lookupProperty,
ArrayBuffer::obj_lookupGeneric,
ArrayBuffer::obj_lookupProperty,
ArrayBuffer::obj_lookupElement,
ArrayBuffer::obj_lookupSpecial,
@ -2128,7 +2142,7 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
_typedArray::obj_trace, /* trace */ \
JS_NULL_CLASS_EXT, \
{ \
_typedArray::obj_lookupProperty, \
_typedArray::obj_lookupGeneric, \
_typedArray::obj_lookupProperty, \
_typedArray::obj_lookupElement, \
_typedArray::obj_lookupSpecial, \

View File

@ -75,13 +75,14 @@ struct JS_FRIEND_API(ArrayBuffer) {
obj_trace(JSTracer *trc, JSObject *obj);
static JSBool
obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupElement(JSContext *cx, JSObject *obj, uint32 index,
JSObject **objp, JSProperty **propp);
static JSBool
obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp,
JSProperty **propp);
@ -212,7 +213,9 @@ struct JS_FRIEND_API(TypedArray) {
static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp);
static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, jsid id,
static JSBool obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id,
JSObject **objp, JSProperty **propp);
static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name,
JSObject **objp, JSProperty **propp);
static JSBool obj_lookupElement(JSContext *cx, JSObject *obj, uint32 index,
JSObject **objp, JSProperty **propp);

View File

@ -4688,9 +4688,9 @@ xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
}
/*
* XML objects are native. Thus xml_lookupProperty must return a valid
* XML objects are native. Thus xml_lookupGeneric must return a valid
* Shape pointer parameter via *propp to signify "property found". Since the
* only call to xml_lookupProperty is via JSObject::lookupProperty, and then
* only call to xml_lookupGeneric is via JSObject::lookupGeneric, and then
* only from js_FindProperty (in jsobj.c, called from jsinterp.c) or from
* JSOP_IN case in the interpreter, the only time we add a Shape here is when
* an unqualified name is being accessed or when "name in xml" is called.
@ -4701,7 +4701,7 @@ xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
* NB: xml_deleteProperty must take care to remove any property added here.
*
* FIXME This clashes with the function namespace implementation which also
* uses native properties. Effectively after xml_lookupProperty any property
* uses native properties. Effectively after xml_lookupGeneric any property
* stored previously using assignments to xml.function::name will be removed.
* We partially workaround the problem in GetXMLFunction. There we take
* advantage of the fact that typically function:: is used to access the
@ -4711,8 +4711,7 @@ xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
* For a proper solution see bug 355257.
*/
static JSBool
xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
JSProperty **propp)
xml_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProperty **propp)
{
JSBool found;
JSXML *xml;
@ -4748,6 +4747,13 @@ xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
return JS_TRUE;
}
static JSBool
xml_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp,
JSProperty **propp)
{
return xml_lookupGeneric(cx, obj, ATOM_TO_JSID(name), objp, propp);
}
static JSBool
xml_lookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
JSProperty **propp)
@ -4778,7 +4784,7 @@ xml_lookupElement(JSContext *cx, JSObject *obj, uint32 index, JSObject **objp,
static JSBool
xml_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, JSProperty **propp)
{
return xml_lookupProperty(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
return xml_lookupGeneric(cx, obj, SPECIALID_TO_JSID(sid), objp, propp);
}
static JSBool
@ -4960,7 +4966,7 @@ xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool st
/*
* If this object has its own (mutable) scope, then we may have added a
* property to the scope in xml_lookupProperty for it to return to mean
* property to the scope in xml_lookupGeneric for it to return to mean
* "found" and to provide a handle for access operations to call the
* property's getter or setter. But now it's time to remove any such
* property, to purge the property cache and remove the scope entry.
@ -4987,7 +4993,7 @@ xml_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBoo
/*
* If this object has its own (mutable) scope, then we may have added a
* property to the scope in xml_lookupProperty for it to return to mean
* property to the scope in xml_lookupGeneric for it to return to mean
* "found" and to provide a handle for access operations to call the
* property's getter or setter. But now it's time to remove any such
* property, to purge the property cache and remove the scope entry.
@ -5303,7 +5309,7 @@ JS_FRIEND_DATA(Class) js::XMLClass = {
xml_trace,
JS_NULL_CLASS_EXT,
{
xml_lookupProperty,
xml_lookupGeneric,
xml_lookupProperty,
xml_lookupElement,
xml_lookupSpecial,
@ -7673,7 +7679,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
return JS_TRUE;
}
} else if (!JSID_IS_VOID(funid)) {
if (!target->lookupProperty(cx, funid, &pobj, &prop))
if (!target->lookupGeneric(cx, funid, &pobj, &prop))
return JS_FALSE;
if (prop) {
*idp = funid;
@ -7698,7 +7704,7 @@ GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
JS_ASSERT(obj->isXML());
/*
* See comments before xml_lookupProperty about the need for the proto
* See comments before xml_lookupGeneric about the need for the proto
* chain lookup.
*/
JSObject *target = obj;

View File

@ -4883,14 +4883,14 @@ mjit::Compiler::testSingletonProperty(JSObject *obj, jsid id)
while (nobj) {
if (!nobj->isNative())
return false;
if (nobj->getClass()->ops.lookupProperty)
if (nobj->getClass()->ops.lookupGeneric)
return false;
nobj = nobj->getProto();
}
JSObject *holder;
JSProperty *prop = NULL;
if (!obj->lookupProperty(cx, id, &holder, &prop))
if (!obj->lookupGeneric(cx, id, &holder, &prop))
return false;
if (!prop)
return false;

View File

@ -552,7 +552,7 @@ class SetPropCompiler : public PICStubCompiler
/* lookupProperty can trigger recompilations. */
RecompilationMonitor monitor(cx);
if (!obj->lookupProperty(cx, id, &holder, &prop))
if (!obj->lookupGeneric(cx, id, &holder, &prop))
return error();
if (monitor.recompiled())
return Lookup_Uncacheable;
@ -789,7 +789,7 @@ struct GetPropertyHelper {
return ic.disable(cx, "non-native");
RecompilationMonitor monitor(cx);
if (!aobj->lookupProperty(cx, ATOM_TO_JSID(atom), &holder, &prop))
if (!aobj->lookupGeneric(cx, ATOM_TO_JSID(atom), &holder, &prop))
return ic.error(cx);
if (monitor.recompiled())
return Lookup_Uncacheable;

View File

@ -787,10 +787,11 @@ stubs::DefFun(VMFrame &f, JSFunction *fun)
JSObject *parent = &fp->varObj();
/* ES5 10.5 (NB: with subsequent errata). */
jsid id = ATOM_TO_JSID(fun->atom);
PropertyName *name = fun->atom->asPropertyName();
jsid id = ATOM_TO_JSID(name);
JSProperty *prop = NULL;
JSObject *pobj;
if (!parent->lookupProperty(cx, id, &pobj, &prop))
if (!parent->lookupProperty(cx, name, &pobj, &prop))
THROW();
Value rval = ObjectValue(*obj);
@ -2254,7 +2255,7 @@ stubs::DelElem(VMFrame &f)
}
void JS_FASTCALL
stubs::DefVarOrConst(VMFrame &f, JSAtom *atom)
stubs::DefVarOrConst(VMFrame &f, JSAtom *atom_)
{
JSContext *cx = f.cx;
StackFrame *fp = f.fp();
@ -2266,7 +2267,8 @@ stubs::DefVarOrConst(VMFrame &f, JSAtom *atom)
attrs |= JSPROP_PERMANENT;
/* Lookup id in order to check for redeclaration problems. */
jsid id = ATOM_TO_JSID(atom);
PropertyName *name = atom_->asPropertyName();
jsid id = ATOM_TO_JSID(name);
bool shouldDefine;
if (JSOp(*f.pc()) == JSOP_DEFVAR) {
/*
@ -2275,7 +2277,7 @@ stubs::DefVarOrConst(VMFrame &f, JSAtom *atom)
*/
JSProperty *prop;
JSObject *obj2;
if (!obj->lookupProperty(cx, id, &obj2, &prop))
if (!obj->lookupProperty(cx, name, &obj2, &prop))
THROW();
shouldDefine = (!prop || obj2 != obj);
} else {
@ -2332,7 +2334,7 @@ stubs::In(VMFrame &f)
JSObject *obj2;
JSProperty *prop;
if (!obj->lookupProperty(cx, id, &obj2, &prop))
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
THROWV(JS_FALSE);
return !!prop;

View File

@ -3160,7 +3160,7 @@ CopyProperty(JSContext *cx, JSObject *obj, JSObject *referent, jsid id,
if (!desc.obj)
return true;
} else {
if (!referent->lookupProperty(cx, id, objp, &prop))
if (!referent->lookupGeneric(cx, id, objp, &prop))
return false;
if (*objp != referent)
return true;