Bug 790349 - Convert all fooAtom uses to simply foo. r=jorendorff

--HG--
extra : rebase_source : b0b255d242dbb8cef2df3c758bec82e88699ecdd
This commit is contained in:
Jeff Walden 2012-09-11 10:32:33 -07:00
parent d6e3e21556
commit 6f6a379cab
48 changed files with 367 additions and 397 deletions

View File

@ -847,8 +847,8 @@ ParallelArrayObject::initClass(JSContext *cx, JSObject *obj)
return NULL;
JSProtoKey key = JSProto_ParallelArray;
Rooted<PropertyName*> name(cx, cx->runtime->atomState.ParallelArrayAtom);
RootedFunction ctor(cx, global->createConstructor(cx, construct, name, 0));
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, construct, cx->names().ParallelArray, 0);
if (!ctor ||
!LinkConstructorAndPrototype(cx, ctor, proto) ||
!DefinePropertiesAndBrand(cx, proto, NULL, methods) ||
@ -858,8 +858,8 @@ ParallelArrayObject::initClass(JSContext *cx, JSObject *obj)
}
// Define the length and shape properties.
RootedId lengthId(cx, AtomToId(cx->runtime->atomState.lengthAtom));
RootedId shapeId(cx, AtomToId(cx->runtime->atomState.shapeAtom));
RootedId lengthId(cx, AtomToId(cx->names().length));
RootedId shapeId(cx, AtomToId(cx->names().shape));
unsigned flags = JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_GETTER;
JSObject *scriptedLength = js_NewFunction(cx, NULL, NonGenericMethod<lengthGetter>,
@ -1533,7 +1533,7 @@ ParallelArrayObject::toStringBufferImpl(JSContext *cx, IndexInfo &iv, bool useLo
if (!robj)
return false;
id = NameToId(cx->runtime->atomState.toLocaleStringAtom);
id = NameToId(cx->names().toLocaleString);
if (!robj->callMethod(cx, id, 0, NULL, &localeElem) ||
!ValueToStringBuffer(cx, localeElem, sb))
{
@ -1611,7 +1611,7 @@ ParallelArrayObject::lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
if (js_IdIsIndex(id, &i))
return lookupElement(cx, obj, i, objp, propp);
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
if (JSID_IS_ATOM(id, cx->names().length)) {
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
return true;
@ -1718,7 +1718,7 @@ JSBool
ParallelArrayObject::getProperty(JSContext *cx, HandleObject obj, HandleObject receiver,
HandlePropertyName name, MutableHandleValue vp)
{
if (name == cx->runtime->atomState.lengthAtom) {
if (name == cx->names().length) {
vp.setNumber(as(obj)->outermostDimension());
return true;
}
@ -1789,7 +1789,7 @@ JSBool
ParallelArrayObject::getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id,
unsigned *attrsp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
if (JSID_IS_ATOM(id, cx->names().length))
*attrsp = JSPROP_PERMANENT | JSPROP_READONLY;
else
*attrsp = JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_ENUMERATE;
@ -1801,7 +1801,7 @@ JSBool
ParallelArrayObject::getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name,
unsigned *attrsp)
{
if (name == cx->runtime->atomState.lengthAtom)
if (name == cx->names().length)
*attrsp = JSPROP_PERMANENT | JSPROP_READONLY;
return true;
}
@ -1892,7 +1892,7 @@ ParallelArrayObject::enumerate(JSContext *cx, HandleObject obj, unsigned flags,
{
RootedParallelArrayObject source(cx, as(obj));
if (flags & JSITER_HIDDEN && !props->append(NameToId(cx->runtime->atomState.lengthAtom)))
if (flags & JSITER_HIDDEN && !props->append(NameToId(cx->names().length)))
return false;
// ParallelArray objects have no holes.

View File

@ -37,16 +37,14 @@ class RegExpMatchBuilder
}
bool setIndex(int index) {
Rooted<PropertyName*> name(cx, cx->runtime->atomState.indexAtom);
RootedValue value(cx, Int32Value(index));
return setProperty(name, value);
return setProperty(cx->names().index, value);
}
bool setInput(JSString *str) {
JS_ASSERT(str);
Rooted<PropertyName*> name(cx, cx->runtime->atomState.inputAtom);
RootedValue value(cx, StringValue(str));
return setProperty(name, value);
return setProperty(cx->names().input, value);
}
};
@ -244,7 +242,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
* to executing RegExpObject::getSource on the unwrapped object.
*/
RootedValue v(cx);
if (!JSObject::getProperty(cx, sourceObj, sourceObj, cx->runtime->atomState.sourceAtom, &v))
if (!JSObject::getProperty(cx, sourceObj, sourceObj, cx->names().source, &v))
return false;
Rooted<JSAtom*> sourceAtom(cx, &v.toString()->asAtom());
@ -493,8 +491,8 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
return NULL;
proto->setPrivate(NULL);
HandlePropertyName empty = cx->names().empty;
RegExpObjectBuilder builder(cx, &proto->asRegExp());
Rooted<JSAtom*> empty(cx, cx->runtime->emptyString);
if (!builder.build(empty, RegExpFlag(0)))
return NULL;
@ -502,7 +500,7 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
return NULL;
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, regexp_construct, cx->runtime->atomState.RegExpAtom, 2);
ctor = global->createConstructor(cx, regexp_construct, cx->names().RegExp, 2);
if (!ctor)
return NULL;

View File

@ -224,7 +224,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, StackFrame *call
// It's an error to use |arguments| in a function that has a rest parameter.
if (callerFrame && callerFrame->isFunctionFrame() && callerFrame->fun()->hasRest()) {
PropertyName *arguments = cx->runtime->atomState.argumentsAtom;
HandlePropertyName arguments = cx->names().arguments;
for (AtomDefnRange r = pc.lexdeps->all(); !r.empty(); r.popFront()) {
if (r.front().key() == arguments) {
parser.reportError(NULL, JSMSG_ARGUMENTS_AND_REST);

View File

@ -772,7 +772,7 @@ EmitAtomOp(JSContext *cx, JSAtom *atom, JSOp op, BytecodeEmitter *bce)
{
JS_ASSERT(JOF_OPTYPE(op) == JOF_ATOM);
if (op == JSOP_GETPROP && atom == cx->runtime->atomState.lengthAtom) {
if (op == JSOP_GETPROP && atom == cx->names().length) {
/* Specialize length accesses for the interpreter. */
op = JSOP_LENGTH;
}
@ -2626,7 +2626,7 @@ frontend::EmitFunctionScript(JSContext *cx, BytecodeEmitter *bce, ParseNode *bod
if (bce->script->varIsAliased(varIndex)) {
ScopeCoordinate sc;
sc.hops = 0;
sc.slot = AliasedNameToSlot(bce->script, cx->runtime->atomState.argumentsAtom);
sc.slot = AliasedNameToSlot(bce->script, cx->names().arguments);
if (!EmitAliasedVarOp(cx, JSOP_SETALIASEDVAR, sc, bce))
return false;
} else {
@ -3553,7 +3553,7 @@ EmitAssignment(JSContext *cx, BytecodeEmitter *bce, ParseNode *lhs, JSOp op, Par
case PNK_DOT: {
if (Emit1(cx, bce, JSOP_DUP) < 0)
return false;
bool isLength = (lhs->pn_atom == cx->runtime->atomState.lengthAtom);
bool isLength = (lhs->pn_atom == cx->names().length);
if (!EmitIndex32(cx, isLength ? JSOP_LENGTH : JSOP_GETPROP, atomIndex, bce))
return false;
break;
@ -3776,7 +3776,7 @@ ParseNode::getConstantValue(JSContext *cx, bool strictChecks, Value *vp)
return false;
} else {
JS_ASSERT(pnid->isKind(PNK_NAME) || pnid->isKind(PNK_STRING));
JS_ASSERT(pnid->pn_atom != cx->runtime->atomState.protoAtom);
JS_ASSERT(pnid->pn_atom != cx->names().proto);
RootedId id(cx, AtomToId(pnid->pn_atom));
if (!DefineNativeProperty(cx, obj, id, value, NULL, NULL,
JSPROP_ENUMERATE, 0, 0)) {
@ -4356,9 +4356,9 @@ EmitXMLTag(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
{
jsatomid index;
JSAtom *tagAtom = (pn->isKind(PNK_XMLETAGO))
? cx->runtime->atomState.etagoAtom
: cx->runtime->atomState.stagoAtom;
HandlePropertyName tagAtom = (pn->isKind(PNK_XMLETAGO))
? cx->names().etago
: cx->names().stago;
if (!bce->makeAtomIndex(tagAtom, &index))
return false;
if (!EmitIndex32(cx, JSOP_STRING, index, bce))
@ -4390,8 +4390,9 @@ EmitXMLTag(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
{
jsatomid index;
JSAtom *tmp = (pn->isKind(PNK_XMLPTAGC)) ? cx->runtime->atomState.ptagcAtom
: cx->runtime->atomState.tagcAtom;
HandlePropertyName tmp = pn->isKind(PNK_XMLPTAGC)
? cx->names().ptagc
: cx->names().tagc;
if (!bce->makeAtomIndex(tmp, &index))
return false;
if (!EmitIndex32(cx, JSOP_STRING, index, bce))
@ -5351,7 +5352,7 @@ EmitCallOrNew(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff_t top)
return false;
break;
case PNK_INTRINSICNAME:
if (pn2->name() == cx->runtime->atomState._CallFunctionAtom)
if (pn2->name() == cx->names()._CallFunction)
{
/*
* Special-casing of %_CallFunction to emit bytecode that directly
@ -5800,7 +5801,7 @@ EmitObject(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
* Disable NEWOBJECT on initializers that set __proto__, which has
* a non-standard setter on objects.
*/
if (pn3->pn_atom == cx->runtime->atomState.protoAtom)
if (pn3->pn_atom == cx->names().proto)
obj = NULL;
op = JSOP_INITPROP;
@ -6545,9 +6546,8 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
if (pn->pn_xflags & PNX_XMLROOT) {
if (pn->pn_count == 0) {
JS_ASSERT(pn->isKind(PNK_XMLLIST));
JSAtom *atom = cx->runtime->atomState.emptyAtom;
jsatomid index;
if (!bce->makeAtomIndex(atom, &index))
if (!bce->makeAtomIndex(cx->names().empty, &index))
return false;
if (!EmitIndex32(cx, JSOP_STRING, index, bce))
return false;

View File

@ -201,9 +201,9 @@ FoldXMLConstants(JSContext *cx, ParseNode *pn, Parser *parser)
RootedString str(cx);
if ((pn->pn_xflags & PNX_CANTFOLD) == 0) {
if (kind == PNK_XMLETAGO)
accum = cx->runtime->atomState.etagoAtom;
accum = cx->names().etago;
else if (kind == PNK_XMLSTAGO || kind == PNK_XMLPTAGC)
accum = cx->runtime->atomState.stagoAtom;
accum = cx->names().stago;
}
/*
@ -307,9 +307,9 @@ FoldXMLConstants(JSContext *cx, ParseNode *pn, Parser *parser)
str = NULL;
if ((pn->pn_xflags & PNX_CANTFOLD) == 0) {
if (kind == PNK_XMLPTAGC)
str = cx->runtime->atomState.ptagcAtom;
str = cx->names().ptagc;
else if (kind == PNK_XMLSTAGO || kind == PNK_XMLETAGO)
str = cx->runtime->atomState.tagcAtom;
str = cx->names().tagc;
}
if (str) {
accum = js_ConcatStrings(cx, accum, str);

View File

@ -174,7 +174,7 @@ ParseContext::define(JSContext *cx, PropertyName *name, ParseNode *pn, Definitio
return false;
if (!args_.append(dn))
return false;
if (name == cx->runtime->atomState.emptyAtom)
if (name == cx->names().empty)
break;
if (!decls_.addUnique(name, dn))
return false;
@ -696,8 +696,7 @@ CheckStrictAssignment(JSContext *cx, Parser *parser, ParseNode *lhs)
{
if (parser->pc->sc->needStrictChecks() && lhs->isKind(PNK_NAME)) {
JSAtom *atom = lhs->pn_atom;
JSAtomState *atomState = &cx->runtime->atomState;
if (atom == atomState->evalAtom || atom == atomState->argumentsAtom) {
if (atom == cx->names().eval || atom == cx->names().arguments) {
JSAutoByteString name;
if (!js_AtomToPrintableString(cx, atom, &name) ||
!parser->reportStrictModeError(lhs, JSMSG_DEPRECATED_ASSIGN, name.ptr()))
@ -721,9 +720,8 @@ CheckStrictBinding(JSContext *cx, Parser *parser, HandlePropertyName name, Parse
if (!parser->pc->sc->needStrictChecks())
return true;
JSAtomState *atomState = &cx->runtime->atomState;
if (name == atomState->evalAtom ||
name == atomState->argumentsAtom ||
if (name == cx->names().eval ||
name == cx->names().arguments ||
FindKeyword(name->charsZ(), name->length()))
{
JSAutoByteString bytes;
@ -790,7 +788,7 @@ Parser::functionBody(FunctionBodyType type)
}
/* Time to implement the odd semantics of 'arguments'. */
Rooted<PropertyName*> arguments(context, context->runtime->atomState.argumentsAtom);
Handle<PropertyName*> arguments = context->names().arguments;
/*
* Non-top-level functions use JSOP_DEFFUN which is a dynamic scope
@ -1425,7 +1423,7 @@ Parser::functionArguments(ParseNode **listp, ParseNode* funcpn, bool &hasRest)
* anonymous positional parameter into the destructuring
* left-hand-side expression and accumulate it in list.
*/
PropertyName *name = context->runtime->atomState.emptyAtom;
HandlePropertyName name = context->names().empty;
ParseNode *rhs = NameNode::create(PNK_NAME, name, this, this->pc);
if (!rhs)
return false;
@ -1912,7 +1910,7 @@ Parser::processDirectives(ParseNode *stmts)
tokenStream.matchToken(TOK_SEMI);
if (isDirective) {
// It's a directive. Is it one we know?
if (atom == context->runtime->atomState.useStrictAtom && !gotStrictMode) {
if (atom == context->names().useStrict && !gotStrictMode) {
pc->sc->setExplicitUseStrict();
if (!setStrictMode(true))
return false;
@ -2953,7 +2951,7 @@ Parser::matchInOrOf(bool *isForOfp)
return true;
}
if (tokenStream.matchToken(TOK_NAME)) {
if (tokenStream.currentToken().name() == context->runtime->atomState.ofAtom) {
if (tokenStream.currentToken().name() == context->names().of) {
*isForOfp = true;
return true;
}
@ -2978,7 +2976,7 @@ Parser::forStatement()
pn->setOp(JSOP_ITER);
pn->pn_iflags = 0;
if (tokenStream.matchToken(TOK_NAME)) {
if (tokenStream.currentToken().name() == context->runtime->atomState.eachAtom)
if (tokenStream.currentToken().name() == context->names().each)
pn->pn_iflags = JSITER_FOREACH;
else
tokenStream.ungetToken();
@ -5161,7 +5159,7 @@ Parser::comprehensionTail(ParseNode *kid, unsigned blockid, bool isGenexp,
pn2->setOp(JSOP_ITER);
pn2->pn_iflags = JSITER_ENUMERATE;
if (tokenStream.matchToken(TOK_NAME)) {
if (tokenStream.currentToken().name() == context->runtime->atomState.eachAtom)
if (tokenStream.currentToken().name() == context->names().each)
pn2->pn_iflags |= JSITER_FOREACH;
else
tokenStream.ungetToken();
@ -5392,8 +5390,7 @@ Parser::generatorExpr(ParseNode *kid)
genfn->pn_pos.begin = body->pn_pos.begin = kid->pn_pos.begin;
genfn->pn_pos.end = body->pn_pos.end = tokenStream.currentToken().pos.end;
JSAtom *arguments = context->runtime->atomState.argumentsAtom;
if (AtomDefnPtr p = genpc.lexdeps->lookup(arguments)) {
if (AtomDefnPtr p = genpc.lexdeps->lookup(context->names().arguments)) {
Definition *dn = p.value();
ParseNode *errorNode = dn->dn_uses ? dn->dn_uses : body;
reportError(errorNode, JSMSG_BAD_GENEXP_BODY, js_arguments_str);
@ -5695,7 +5692,7 @@ Parser::memberExpr(bool allowCallSyntax)
nextMember->setOp(JSOP_CALL);
if (lhs->isOp(JSOP_NAME)) {
if (lhs->pn_atom == context->runtime->atomState.evalAtom) {
if (lhs->pn_atom == context->names().eval) {
/* Select JSOP_EVAL and flag pc as heavyweight. */
nextMember->setOp(JSOP_EVAL);
pc->sc->setBindingsAccessedDynamically();
@ -5709,9 +5706,9 @@ Parser::memberExpr(bool allowCallSyntax)
}
} else if (lhs->isOp(JSOP_GETPROP)) {
/* Select JSOP_FUNAPPLY given foo.apply(...). */
if (lhs->pn_atom == context->runtime->atomState.applyAtom)
if (lhs->pn_atom == context->names().apply)
nextMember->setOp(JSOP_FUNAPPLY);
else if (lhs->pn_atom == context->runtime->atomState.callAtom)
else if (lhs->pn_atom == context->names().call)
nextMember->setOp(JSOP_FUNCALL);
}
@ -5830,7 +5827,7 @@ Parser::propertySelector()
if (!selector)
return NULL;
selector->setOp(JSOP_ANYNAME);
selector->pn_atom = context->runtime->atomState.starAtom;
selector->pn_atom = context->names().star;
} else {
JS_ASSERT(tokenStream.isCurrentTokenType(TOK_NAME));
selector = NullaryNode::create(PNK_NAME, this);
@ -5866,7 +5863,7 @@ Parser::qualifiedSuffix(ParseNode *pn)
pn2->setOp(JSOP_QNAMECONST);
pn2->pn_pos.begin = pn->pn_pos.begin;
pn2->pn_atom = (tt == TOK_STAR)
? context->runtime->atomState.starAtom
? context->names().star
: tokenStream.currentToken().name();
pn2->pn_expr = pn;
pn2->pn_cookie.makeFree();
@ -6465,7 +6462,7 @@ Parser::intrinsicName()
}
PropertyName *name = tokenStream.currentToken().name();
if (!(name == context->runtime->atomState._CallFunctionAtom ||
if (!(name == context->names()._CallFunction ||
context->global()->hasIntrinsicFunction(context, name)))
{
reportError(NULL, JSMSG_INTRINSIC_NOT_DEFINED, JS_EncodeString(context, name));
@ -6720,9 +6717,9 @@ Parser::primaryExpr(TokenKind tt, bool afterDoubleDot)
case TOK_NAME:
{
atom = tokenStream.currentToken().name();
if (atom == context->runtime->atomState.getAtom) {
if (atom == context->names().get) {
op = JSOP_GETTER;
} else if (atom == context->runtime->atomState.setAtom) {
} else if (atom == context->names().set) {
op = JSOP_SETTER;
} else {
pn3 = NullaryNode::create(PNK_NAME, this);
@ -6821,7 +6818,7 @@ Parser::primaryExpr(TokenKind tt, bool afterDoubleDot)
* so that we can later assume singleton objects delegate to
* the default Object.prototype.
*/
if (!pnval->isConstant() || atom == context->runtime->atomState.protoAtom)
if (!pnval->isConstant() || atom == context->names().proto)
pn->pn_xflags |= PNX_NONCONST;
}
#if JS_HAS_DESTRUCTURING_SHORTHAND

View File

@ -1041,7 +1041,7 @@ TokenStream::getXMLMarkup(TokenKind *ttp, Token **tpp)
JSAtom *data;
if (contentIndex < 0) {
data = cx->runtime->atomState.emptyAtom;
data = cx->names().empty;
} else {
data = AtomizeChars(cx, tokenbuf.begin() + contentIndex,
tokenbuf.length() - contentIndex);

View File

@ -3168,7 +3168,7 @@ CodeGenerator::visitOutOfLineCacheGetProperty(OutOfLineCache *ool)
switch (ins->op()) {
case LInstruction::LOp_InstanceOfO:
case LInstruction::LOp_InstanceOfV:
name = gen->compartment->rt->atomState.classPrototypeAtom;
name = gen->compartment->rt->atomState.classPrototype;
objReg = ToRegister(ins->getTemp(1));
output = TypedOrValueRegister(MIRType_Object, ToAnyRegister(ins->getDef(0)));
break;
@ -3475,29 +3475,29 @@ CodeGenerator::visitTypeOfV(LTypeOfV *lir)
Label notNumber;
masm.branchTestNumber(Assembler::NotEqual, tag, &notNumber);
masm.movePtr(ImmGCPtr(rt->atomState.numberAtom), output);
masm.movePtr(ImmGCPtr(rt->atomState.number), output);
masm.jump(&done);
masm.bind(&notNumber);
Label notUndefined;
masm.branchTestUndefined(Assembler::NotEqual, tag, &notUndefined);
masm.movePtr(ImmGCPtr(rt->atomState.undefinedAtom), output);
masm.movePtr(ImmGCPtr(rt->atomState.undefined), output);
masm.jump(&done);
masm.bind(&notUndefined);
Label notNull;
masm.branchTestNull(Assembler::NotEqual, tag, &notNull);
masm.movePtr(ImmGCPtr(rt->atomState.objectAtom), output);
masm.movePtr(ImmGCPtr(rt->atomState.object), output);
masm.jump(&done);
masm.bind(&notNull);
Label notBoolean;
masm.branchTestBoolean(Assembler::NotEqual, tag, &notBoolean);
masm.movePtr(ImmGCPtr(rt->atomState.booleanAtom), output);
masm.movePtr(ImmGCPtr(rt->atomState.boolean), output);
masm.jump(&done);
masm.bind(&notBoolean);
masm.movePtr(ImmGCPtr(rt->atomState.stringAtom), output);
masm.movePtr(ImmGCPtr(rt->atomState.string), output);
masm.bind(&done);
masm.bind(ool->rejoin());

View File

@ -3465,8 +3465,7 @@ IonBuilder::createThisScripted(MDefinition *callee)
// This instruction MUST be idempotent: since it does not correspond to an
// explicit operation in the bytecode, we cannot use resumeAfter(). But
// calling GetProperty can trigger a GC, and thus invalidation.
RootedPropertyName name(cx, cx->runtime->atomState.classPrototypeAtom);
MCallGetProperty *getProto = MCallGetProperty::New(callee, name);
MCallGetProperty *getProto = MCallGetProperty::New(callee, cx->names().classPrototype);
// Getters may not override |prototype| fetching, so this is repeatable.
getProto->markUneffectful();
@ -3486,7 +3485,7 @@ IonBuilder::getSingletonPrototype(JSFunction *target)
if (target->getType(cx)->unknownProperties())
return NULL;
jsid protoid = AtomToId(cx->runtime->atomState.classPrototypeAtom);
jsid protoid = NameToId(cx->names().classPrototype);
types::HeapTypeSet *protoTypes = target->getType(cx)->getProperty(cx, protoid, false);
if (!protoTypes)
return NULL;
@ -3679,7 +3678,7 @@ GetBuiltinRegExpTest(JSContext *cx, JSScript *script, JSFunction **result)
// to avoid calling a getter.
RootedShape shape(cx);
RootedObject holder(cx);
if (!JSObject::lookupProperty(cx, proto, cx->runtime->atomState.testAtom, &holder, &shape))
if (!JSObject::lookupProperty(cx, proto, cx->names().test, &holder, &shape))
return false;
if (proto != holder || !shape || !shape->hasDefaultGetter() || !shape->hasSlot())
@ -4612,11 +4611,11 @@ bool
IonBuilder::jsop_getgname(HandlePropertyName name)
{
// Optimize undefined, NaN, and Infinity.
if (name == cx->runtime->atomState.undefinedAtom)
if (name == cx->names().undefined)
return pushConstant(UndefinedValue());
if (name == cx->runtime->atomState.NaNAtom)
if (name == cx->names().NaN)
return pushConstant(cx->runtime->NaNValue);
if (name == cx->runtime->atomState.InfinityAtom)
if (name == cx->names().Infinity)
return pushConstant(cx->runtime->positiveInfinityValue);
RootedObject globalObj(cx, &script->global());

View File

@ -131,7 +131,7 @@ InitProp(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue v
RootedValue rval(cx, value);
RootedId id(cx, NameToId(name));
if (name == cx->runtime->atomState.protoAtom)
if (name == cx->names().proto)
return baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, false);
return !!DefineNativeProperty(cx, obj, id, rval, NULL, NULL, JSPROP_ENUMERATE, 0, 0, 0);
}

View File

@ -1805,7 +1805,7 @@ typedef struct JSStdName {
Class *clasp;
} JSStdName;
static PropertyName *
static Handle<PropertyName*>
StdNameToPropertyName(JSContext *cx, JSStdName *stdn)
{
return OFFSET_TO_NAME(cx->runtime, stdn->atomOffset);
@ -1955,7 +1955,7 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *objArg, jsid id, JSBool *resolv
idstr = JSID_TO_STRING(id);
/* Check whether we're resolving 'undefined', and define it if so. */
atom = rt->atomState.undefinedAtom;
atom = rt->atomState.undefined;
if (idstr == atom) {
*resolved = true;
RootedValue undefinedValue(cx, UndefinedValue());
@ -2048,7 +2048,7 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *objArg)
* Check whether we need to bind 'undefined' and define it if so.
* Since ES5 15.1.1.3 undefined can't be deleted.
*/
RootedPropertyName undefinedName(cx, cx->runtime->atomState.undefinedAtom);
HandlePropertyName undefinedName = cx->names().undefined;
RootedValue undefinedValue(cx, UndefinedValue());
if (!obj->nativeContains(cx, undefinedName) &&
!JSObject::defineProperty(cx, obj, undefinedName, undefinedValue,
@ -2157,12 +2157,12 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *objArg, JSIdArray *
}
/* Check whether 'undefined' has been resolved and enumerate it if so. */
Rooted<PropertyName*> name(cx, rt->atomState.undefinedAtom);
ida = EnumerateIfResolved(cx, obj, name, ida, &i, &found);
ida = EnumerateIfResolved(cx, obj, cx->names().undefined, ida, &i, &found);
if (!ida)
return NULL;
/* Enumerate only classes that *have* been resolved. */
Rooted<PropertyName*> name(cx);
for (j = 0; standard_class_atoms[j].init; j++) {
name = OFFSET_TO_NAME(rt, standard_class_atoms[j].atomOffset);
ida = EnumerateIfResolved(cx, obj, name, ida, &i, &found);
@ -3373,7 +3373,7 @@ JS_GetConstructor(JSContext *cx, JSObject *protoArg)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
if (!JSObject::getProperty(cx, proto, proto, cx->runtime->atomState.constructorAtom, &cval))
if (!JSObject::getProperty(cx, proto, proto, cx->names().constructor, &cval))
return NULL;
}
if (!IsFunctionObject(cval)) {
@ -6392,8 +6392,8 @@ JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacerArg, jsval space,
return false;
*vp = value;
if (sb.empty()) {
JSAtom *nullAtom = cx->runtime->atomState.nullAtom;
return callback(nullAtom->chars(), nullAtom->length(), data);
HandlePropertyName null = cx->names().null;
return callback(null->chars(), null->length(), data);
}
return callback(sb.begin(), sb.length(), data);
}

View File

@ -135,7 +135,7 @@ GetLengthProperty(JSContext *cx, HandleObject obj, uint32_t *lengthp)
}
RootedValue value(cx);
if (!JSObject::getProperty(cx, obj, obj, cx->runtime->atomState.lengthAtom, &value))
if (!JSObject::getProperty(cx, obj, obj, cx->names().length, &value))
return false;
if (value.isInt32()) {
@ -491,7 +491,7 @@ js::SetLengthProperty(JSContext *cx, HandleObject obj, double length)
RootedValue v(cx, NumberValue(length));
/* We don't support read-only array length yet. */
return JSObject::setProperty(cx, obj, obj, cx->runtime->atomState.lengthAtom, &v, false);
return JSObject::setProperty(cx, obj, obj, cx->names().length, &v, false);
}
/*
@ -518,7 +518,7 @@ static JSBool
array_length_setter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHandleValue vp)
{
if (!obj->isArray()) {
return JSObject::defineProperty(cx, obj, cx->runtime->atomState.lengthAtom, vp,
return JSObject::defineProperty(cx, obj, cx->names().length, vp,
NULL, NULL, JSPROP_ENUMERATE);
}
@ -623,7 +623,7 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
JS_ASSERT(obj->isDenseArray());
uint32_t i;
return JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom) ||
return JSID_IS_ATOM(id, cx->names().length) ||
(js_IdIsIndex(id, &i) && IsDenseArrayIndex(obj, i));
}
@ -694,7 +694,7 @@ js_GetDenseArrayElementValue(JSContext *cx, HandleObject obj, jsid id, Value *vp
uint32_t i;
if (!js_IdIsIndex(id, &i)) {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom));
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length));
vp->setNumber(obj->getArrayLength());
return JS_TRUE;
}
@ -706,7 +706,7 @@ static JSBool
array_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name,
MutableHandleValue vp)
{
if (name == cx->runtime->atomState.lengthAtom) {
if (name == cx->names().length) {
vp.setNumber(obj->getArrayLength());
return true;
}
@ -808,7 +808,7 @@ static JSBool
array_setGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleValue vp, JSBool strict)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
if (JSID_IS_ATOM(id, cx->names().length))
return array_length_setter(cx, obj, id, strict, vp);
if (!obj->isDenseArray())
@ -922,7 +922,7 @@ static JSBool
array_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
JSPropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
if (JSID_IS_ATOM(id, cx->names().length))
return JS_TRUE;
if (!obj->isDenseArray())
@ -1015,7 +1015,7 @@ array_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Handle
static JSBool
array_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
*attrsp = JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)
*attrsp = JSID_IS_ATOM(id, cx->names().length)
? JSPROP_PERMANENT : JSPROP_ENUMERATE;
return true;
}
@ -1023,7 +1023,7 @@ array_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigne
static JSBool
array_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
*attrsp = (name == cx->runtime->atomState.lengthAtom)
*attrsp = (name == cx->names().length)
? JSPROP_PERMANENT
: JSPROP_ENUMERATE;
return true;
@ -1078,7 +1078,7 @@ array_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
if (!obj->isDenseArray())
return baseops::DeleteProperty(cx, obj, name, rval, strict);
if (name == cx->runtime->atomState.lengthAtom) {
if (name == cx->names().length) {
rval.setBoolean(false);
return true;
}
@ -1241,7 +1241,7 @@ AddLengthProperty(JSContext *cx, HandleObject obj)
* as accesses to 'length' will use the elements header.
*/
RootedId lengthId(cx, NameToId(cx->runtime->atomState.lengthAtom));
RootedId lengthId(cx, NameToId(cx->names().length));
JS_ASSERT(!obj->nativeLookup(cx, lengthId));
if (!obj->allocateSlowArrayElements(cx))
@ -1459,7 +1459,7 @@ array_join_sub(JSContext *cx, CallArgs &args, bool locale)
return false;
if (detector.foundCycle()) {
args.rval().setString(cx->runtime->atomState.emptyAtom);
args.rval().setString(cx->names().empty);
return true;
}
@ -1540,7 +1540,7 @@ array_join_sub(JSContext *cx, CallArgs &args, bool locale)
JSObject *robj = ToObject(cx, elt);
if (!robj)
return false;
RootedId id(cx, NameToId(cx->runtime->atomState.toLocaleStringAtom));
RootedId id(cx, NameToId(cx->names().toLocaleString));
if (!robj->callMethod(cx, id, 0, NULL, &elt))
return false;
}
@ -1576,7 +1576,7 @@ array_toString(JSContext *cx, unsigned argc, Value *vp)
return false;
RootedValue join(cx, args.calleev());
if (!JSObject::getProperty(cx, obj, obj, cx->runtime->atomState.joinAtom, &join))
if (!JSObject::getProperty(cx, obj, obj, cx->names().join, &join))
return false;
if (!js_IsCallable(join)) {
@ -3552,7 +3552,7 @@ js_InitArrayClass(JSContext *cx, JSObject *obj)
arrayProto->setArrayLength(cx, 0);
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, js_Array, cx->runtime->atomState.ArrayAtom, 1);
ctor = global->createConstructor(cx, js_Array, cx->names().Array, 1);
if (!ctor)
return NULL;

View File

@ -156,11 +156,11 @@ inline Handle<PropertyName*>
TypeName(JSType type, JSRuntime *rt)
{
JS_ASSERT(type < JSTYPE_LIMIT);
JS_STATIC_ASSERT(offsetof(JSAtomState, undefinedAtom) +
JS_STATIC_ASSERT(offsetof(JSAtomState, undefined) +
JSTYPE_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
sizeof(JSAtomState));
JS_STATIC_ASSERT(JSTYPE_VOID == 0);
return (&rt->atomState.undefinedAtom)[type];
return (&rt->atomState.undefined)[type];
}
inline Handle<PropertyName*>
@ -173,11 +173,11 @@ inline Handle<PropertyName*>
ClassName(JSProtoKey key, JSContext *cx)
{
JS_ASSERT(key < JSProto_LIMIT);
JS_STATIC_ASSERT(offsetof(JSAtomState, NullAtom) +
JS_STATIC_ASSERT(offsetof(JSAtomState, Null) +
JSProto_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
sizeof(JSAtomState));
JS_STATIC_ASSERT(JSProto_Null == 0);
return (&cx->runtime->atomState.NullAtom)[key];
return (&cx->runtime->atomState.Null)[key];
}
} // namespace js

View File

@ -154,8 +154,7 @@ js_InitBooleanClass(JSContext *cx, JSObject *obj)
return NULL;
booleanProto->setFixedSlot(BooleanObject::PRIMITIVE_VALUE_SLOT, BooleanValue(false));
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, Boolean, cx->runtime->atomState.BooleanAtom, 1);
RootedFunction ctor(cx, global->createConstructor(cx, Boolean, cx->names().Boolean, 1));
if (!ctor)
return NULL;
@ -165,7 +164,7 @@ js_InitBooleanClass(JSContext *cx, JSObject *obj)
if (!DefinePropertiesAndBrand(cx, booleanProto, NULL, boolean_methods))
return NULL;
Rooted<PropertyName*> valueOfName(cx, cx->runtime->atomState.valueOfAtom);
Handle<PropertyName*> valueOfName = cx->names().valueOf;
Rooted<JSFunction*> valueOf(cx,
js_NewFunction(cx, NULL, bool_valueOf, 0, 0, global, valueOfName));
if (!valueOf)

View File

@ -382,25 +382,15 @@ struct RuntimeSizes;
/* Various built-in or commonly-used names pinned on first context. */
struct JSAtomState
{
#define PROPERTYNAME_FIELD(idpart, id, text) \
union { \
js::FixedHeapPtr<js::PropertyName> idpart##Atom; \
js::FixedHeapPtr<js::PropertyName> id; \
};
#define PROPERTYNAME_FIELD(idpart, id, text) js::FixedHeapPtr<js::PropertyName> id;
FOR_EACH_COMMON_PROPERTYNAME(PROPERTYNAME_FIELD)
#undef PROPERTYNAME_FIELD
#define PROPERTYNAME_FIELD(name, code, init) \
union { \
js::FixedHeapPtr<js::PropertyName> name##Atom; \
js::FixedHeapPtr<js::PropertyName> name; \
};
#define PROPERTYNAME_FIELD(name, code, init) js::FixedHeapPtr<js::PropertyName> name;
JS_FOR_EACH_PROTOTYPE(PROPERTYNAME_FIELD)
#undef PROPERTYNAME_FIELD
};
#define ATOM(name) (cx->names().name)
#define NAME_OFFSET(name) offsetof(JSAtomState, name##Atom)
#define NAME_OFFSET(name) offsetof(JSAtomState, name)
#define OFFSET_TO_NAME(rt,off) (*(js::FixedHeapPtr<js::PropertyName>*)((char*)&(rt)->atomState + (off)))
struct JSRuntime : js::RuntimeFriendFields

View File

@ -2609,7 +2609,7 @@ date_toJSON(JSContext *cx, unsigned argc, Value *vp)
/* Step 4. */
RootedValue toISO(cx);
if (!JSObject::getProperty(cx, obj, obj, cx->runtime->atomState.toISOStringAtom, &toISO))
if (!JSObject::getProperty(cx, obj, obj, cx->names().toISOString, &toISO))
return false;
/* Step 5. */
@ -3161,7 +3161,7 @@ js_InitDateClass(JSContext *cx, JSObject *obj)
SetDateToNaN(cx, dateProto);
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, js_Date, cx->runtime->atomState.DateAtom, MAXARGS);
ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS);
if (!ctor)
return NULL;
@ -3179,8 +3179,8 @@ js_InitDateClass(JSContext *cx, JSObject *obj)
if (!JS_DefineFunctions(cx, dateProto, date_methods))
return NULL;
RootedValue toUTCStringFun(cx);
RootedId toUTCStringId(cx, NameToId(cx->runtime->atomState.toUTCStringAtom));
RootedId toGMTStringId(cx, NameToId(cx->runtime->atomState.toGMTStringAtom));
RootedId toUTCStringId(cx, NameToId(cx->names().toUTCString));
RootedId toGMTStringId(cx, NameToId(cx->names().toGMTString));
if (!baseops::GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
!baseops::DefineGeneric(cx, dateProto, toGMTStringId, toUTCStringFun,
JS_PropertyStub, JS_StrictPropertyStub, 0))

View File

@ -39,7 +39,7 @@ JS_FRIEND_API(JSString *)
JS_GetAnonymousString(JSRuntime *rt)
{
JS_ASSERT(rt->hasContexts());
return rt->atomState.anonymousAtom;
return rt->atomState.anonymous;
}
JS_FRIEND_API(JSObject *)

View File

@ -108,7 +108,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
StackFrame *fp = iter.fp();
if (JSID_IS_ATOM(id, cx->runtime->atomState.argumentsAtom)) {
if (JSID_IS_ATOM(id, cx->names().arguments)) {
if (fun->hasRest()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_FUNCTION_ARGUMENTS_AND_REST);
return false;
@ -141,7 +141,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
if (iter.isScript() && iter.isIon())
fp = NULL;
if (JSID_IS_ATOM(id, cx->runtime->atomState.callerAtom) && fp && fp->prev()) {
if (JSID_IS_ATOM(id, cx->names().caller) && fp && fp->prev()) {
/*
* If the frame was called from within an inlined frame, mark the
* innermost function as uninlineable to expand its frame and allow us
@ -158,7 +158,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
}
#endif
if (JSID_IS_ATOM(id, cx->runtime->atomState.callerAtom)) {
if (JSID_IS_ATOM(id, cx->names().caller)) {
++iter;
if (iter.done() || !iter.isFunctionFrame()) {
JS_ASSERT(vp.isNull());
@ -205,16 +205,16 @@ fun_enumerate(JSContext *cx, HandleObject obj)
bool found;
if (!obj->isBoundFunction()) {
id = NameToId(cx->runtime->atomState.classPrototypeAtom);
id = NameToId(cx->names().classPrototype);
if (!JSObject::hasProperty(cx, obj, id, &found, JSRESOLVE_QUALIFIED))
return false;
}
id = NameToId(cx->runtime->atomState.lengthAtom);
id = NameToId(cx->names().length);
if (!JSObject::hasProperty(cx, obj, id, &found, JSRESOLVE_QUALIFIED))
return false;
id = NameToId(cx->runtime->atomState.nameAtom);
id = NameToId(cx->names().name);
if (!JSObject::hasProperty(cx, obj, id, &found, JSRESOLVE_QUALIFIED))
return false;
@ -264,10 +264,10 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
*/
RootedValue protoVal(cx, ObjectValue(*proto));
RootedValue objVal(cx, ObjectValue(*obj));
if (!JSObject::defineProperty(cx, obj, cx->runtime->atomState.classPrototypeAtom,
if (!JSObject::defineProperty(cx, obj, cx->names().classPrototype,
protoVal, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT) ||
!JSObject::defineProperty(cx, proto, cx->runtime->atomState.constructorAtom,
!JSObject::defineProperty(cx, proto, cx->names().constructor,
objVal, JS_PropertyStub, JS_StrictPropertyStub, 0))
{
return NULL;
@ -285,7 +285,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
RootedFunction fun(cx, obj->toFunction());
if (JSID_IS_ATOM(id, cx->runtime->atomState.classPrototypeAtom)) {
if (JSID_IS_ATOM(id, cx->names().classPrototype)) {
/*
* Built-in functions do not have a .prototype property per ECMA-262,
* or (Object.prototype, Function.prototype, etc.) have that property
@ -307,12 +307,11 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
return true;
}
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom) ||
JSID_IS_ATOM(id, cx->runtime->atomState.nameAtom)) {
if (JSID_IS_ATOM(id, cx->names().length) || JSID_IS_ATOM(id, cx->names().name)) {
JS_ASSERT(!IsInternalFunctionObject(obj));
RootedValue v(cx);
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
if (JSID_IS_ATOM(id, cx->names().length))
v.setInt32(fun->nargs - fun->hasRest());
else
v.setString(fun->atom() == NULL ? cx->runtime->emptyString : fun->atom());
@ -480,7 +479,7 @@ fun_hasInstance(JSContext *cx, HandleObject objArg, MutableHandleValue v, JSBool
}
RootedValue pval(cx);
if (!JSObject::getProperty(cx, obj, obj, cx->runtime->atomState.classPrototypeAtom, &pval))
if (!JSObject::getProperty(cx, obj, obj, cx->names().classPrototype, &pval))
return JS_FALSE;
if (pval.isPrimitive()) {
@ -1386,7 +1385,7 @@ Function(JSContext *cx, unsigned argc, Value *vp)
* and so would a call to f from another top-level's script or function.
*/
RootedFunction fun(cx, js_NewFunction(cx, NULL, NULL, 0, JSFUN_LAMBDA | JSFUN_INTERPRETED,
global, cx->runtime->atomState.anonymousAtom));
global, cx->names().anonymous));
if (!fun)
return false;

View File

@ -54,44 +54,44 @@ using namespace js::analyze;
static inline jsid
id_prototype(JSContext *cx) {
return NameToId(cx->runtime->atomState.classPrototypeAtom);
return NameToId(cx->names().classPrototype);
}
static inline jsid
id_arguments(JSContext *cx) {
return NameToId(cx->runtime->atomState.argumentsAtom);
return NameToId(cx->names().arguments);
}
static inline jsid
id_length(JSContext *cx) {
return NameToId(cx->runtime->atomState.lengthAtom);
return NameToId(cx->names().length);
}
static inline jsid
id___proto__(JSContext *cx) {
return NameToId(cx->runtime->atomState.protoAtom);
return NameToId(cx->names().proto);
}
static inline jsid
id_constructor(JSContext *cx) {
return NameToId(cx->runtime->atomState.constructorAtom);
return NameToId(cx->names().constructor);
}
static inline jsid
id_caller(JSContext *cx) {
return NameToId(cx->runtime->atomState.callerAtom);
return NameToId(cx->names().caller);
}
static inline jsid
id_toString(JSContext *cx)
{
return NameToId(cx->runtime->atomState.toStringAtom);
return NameToId(cx->names().toString);
}
static inline jsid
id_toSource(JSContext *cx)
{
return NameToId(cx->runtime->atomState.toSourceAtom);
return NameToId(cx->names().toSource);
}
#ifdef DEBUG
@ -3738,11 +3738,11 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset,
* the method JIT will bypass this, and we need to add the types
* directly.
*/
if (id == NameToId(cx->runtime->atomState.undefinedAtom))
if (id == NameToId(cx->names().undefined))
seen->addType(cx, Type::UndefinedType());
if (id == NameToId(cx->runtime->atomState.NaNAtom))
if (id == NameToId(cx->names().NaN))
seen->addType(cx, Type::DoubleType());
if (id == NameToId(cx->runtime->atomState.InfinityAtom))
if (id == NameToId(cx->names().Infinity))
seen->addType(cx, Type::DoubleType());
TypeObject *global = script->global().getType(cx);

View File

@ -172,7 +172,7 @@ js::OnUnknownMethod(JSContext *cx, HandleObject obj, Value idval_, MutableHandle
{
RootedValue idval(cx, idval_);
RootedId id(cx, NameToId(cx->runtime->atomState.noSuchMethodAtom));
RootedId id(cx, NameToId(cx->names().noSuchMethod));
RootedValue value(cx);
if (!GetMethod(cx, obj, id, 0, &value))
return false;
@ -3163,7 +3163,7 @@ BEGIN_CASE(JSOP_INITPROP)
RootedId &id = rootId0;
id = NameToId(name);
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
if (JS_UNLIKELY(name == cx->names().proto)
? !baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, script->strictModeCode)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {
@ -3981,7 +3981,7 @@ js::Throw(JSContext *cx, HandleValue v)
bool
js::GetProperty(JSContext *cx, HandleValue v, PropertyName *name, MutableHandleValue vp)
{
if (name == cx->runtime->atomState.lengthAtom) {
if (name == cx->names().length) {
// Fast path for strings, arrays and arguments.
if (GetLengthProperty(v, vp))
return true;

View File

@ -104,7 +104,7 @@ Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
* the built-in prototypes). So exclude __proto__ if the object where the
* property was found has no [[Prototype]] and might be |Object.prototype|.
*/
if (JS_UNLIKELY(!pobj->getProto() && JSID_IS_ATOM(id, cx->runtime->atomState.protoAtom)))
if (JS_UNLIKELY(!pobj->getProto() && JSID_IS_ATOM(id, cx->names().proto)))
return true;
if (!(flags & JSITER_OWNONLY) || pobj->isProxy() || pobj->getOps()->enumerate) {
@ -157,10 +157,8 @@ static bool
EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, unsigned flags,
IdSet &ht, AutoIdVector *props)
{
if (!Enumerate(cx, obj, pobj, NameToId(cx->runtime->atomState.lengthAtom), false,
flags, ht, props)) {
if (!Enumerate(cx, obj, pobj, NameToId(cx->names().length), false, flags, ht, props))
return false;
}
if (pobj->getArrayLength() > 0) {
size_t initlen = pobj->getDenseArrayInitializedLength();
@ -355,7 +353,7 @@ GetCustomIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandle
JS_CHECK_RECURSION(cx, return false);
/* Check whether we have a valid __iterator__ method. */
RootedPropertyName name(cx, cx->runtime->atomState.iteratorIntrinsicAtom);
HandlePropertyName name = cx->names().iteratorIntrinsic;
if (!GetMethod(cx, obj, name, 0, vp))
return false;
@ -584,7 +582,7 @@ GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleValue
if (flags == JSITER_FOR_OF) {
// for-of loop. The iterator is simply |obj.iterator()|.
RootedValue method(cx);
if (!JSObject::getProperty(cx, obj, obj, cx->runtime->atomState.iteratorAtom, &method))
if (!JSObject::getProperty(cx, obj, obj, cx->names().iterator, &method))
return false;
// Throw if obj.iterator isn't callable. js::Invoke is about to check
@ -1243,7 +1241,7 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, MutableHandleValue rval)
return false;
} else {
/* Call the iterator object's .next method. */
if (!GetMethod(cx, iterobj, cx->runtime->atomState.nextAtom, 0, rval))
if (!GetMethod(cx, iterobj, cx->names().next, 0, rval))
return false;
if (!Invoke(cx, ObjectValue(*iterobj), rval, 0, NULL, rval.address())) {
/* Check for StopIteration. */
@ -1778,7 +1776,7 @@ GlobalObject::initIteratorClasses(JSContext *cx, Handle<GlobalObject *> global)
iteratorProto->asPropertyIterator().setNativeIterator(ni);
Rooted<JSFunction*> ctor(cx);
ctor = global->createConstructor(cx, IteratorConstructor, cx->runtime->atomState.IteratorAtom, 2);
ctor = global->createConstructor(cx, IteratorConstructor, cx->names().Iterator, 2);
if (!ctor)
return false;
if (!LinkConstructorAndPrototype(cx, ctor, iteratorProto))

View File

@ -656,7 +656,7 @@ js::math_tan(JSContext *cx, unsigned argc, Value *vp)
static JSBool
math_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->runtime->atomState.MathAtom);
vp->setString(cx->names().Math);
return JS_TRUE;
}
#endif

View File

@ -1137,7 +1137,7 @@ js_InitNumberClass(JSContext *cx, JSObject *obj)
numberProto->asNumber().setPrimitiveValue(0);
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, Number, cx->runtime->atomState.NumberAtom, 1);
ctor = global->createConstructor(cx, Number, cx->names().Number, 1);
if (!ctor)
return NULL;
@ -1161,10 +1161,10 @@ js_InitNumberClass(JSContext *cx, JSObject *obj)
RootedValue valueInfinity(cx, cx->runtime->positiveInfinityValue);
/* ES5 15.1.1.1, 15.1.1.2 */
if (!DefineNativeProperty(cx, global, cx->runtime->atomState.NaNAtom, valueNaN,
if (!DefineNativeProperty(cx, global, cx->names().NaN, valueNaN,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0) ||
!DefineNativeProperty(cx, global, cx->runtime->atomState.InfinityAtom, valueInfinity,
!DefineNativeProperty(cx, global, cx->names().Infinity, valueInfinity,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))
{

View File

@ -162,13 +162,13 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
if (attrs & JSPROP_GETTER) {
doGet = false;
val[valcnt] = shape->getterValue();
gsop[valcnt] = cx->runtime->atomState.getAtom;
gsop[valcnt] = cx->names().get;
valcnt++;
}
if (attrs & JSPROP_SETTER) {
doGet = false;
val[valcnt] = shape->setterValue();
gsop[valcnt] = cx->runtime->atomState.setAtom;
gsop[valcnt] = cx->names().set;
valcnt++;
}
}
@ -341,13 +341,13 @@ obj_toString(JSContext *cx, unsigned argc, Value *vp)
/* Step 1. */
if (args.thisv().isUndefined()) {
args.rval().setString(cx->runtime->atomState.objectUndefinedAtom);
args.rval().setString(cx->names().objectUndefined);
return true;
}
/* Step 2. */
if (args.thisv().isNull()) {
args.rval().setString(cx->runtime->atomState.objectNullAtom);
args.rval().setString(cx->names().objectNull);
return true;
}
@ -378,7 +378,7 @@ obj_toLocaleString(JSContext *cx, unsigned argc, Value *vp)
return false;
/* Steps 2-4. */
RootedId id(cx, NameToId(cx->runtime->atomState.toStringAtom));
RootedId id(cx, NameToId(cx->names().toString));
return obj->callMethod(cx, id, 0, NULL, args.rval());
}
@ -643,19 +643,19 @@ DefineAccessor(JSContext *cx, unsigned argc, Value *vp)
if (!descObj)
return false;
JSAtomState &state = cx->runtime->atomState;
JSAtomState &names = cx->names();
RootedValue trueVal(cx, BooleanValue(true));
/* enumerable: true */
if (!JSObject::defineProperty(cx, descObj, state.enumerableAtom, trueVal))
if (!JSObject::defineProperty(cx, descObj, names.enumerable, trueVal))
return false;
/* configurable: true */
if (!JSObject::defineProperty(cx, descObj, state.configurableAtom, trueVal))
if (!JSObject::defineProperty(cx, descObj, names.configurable, trueVal))
return false;
/* enumerable: true */
PropertyName *acc = (Type == Getter) ? state.getAtom : state.setAtom;
PropertyName *acc = (Type == Getter) ? names.get : names.set;
RootedValue accessorVal(cx, args[1]);
if (!JSObject::defineProperty(cx, descObj, acc, accessorVal))
return false;
@ -857,22 +857,22 @@ PropDesc::makeObject(JSContext *cx)
if (!obj)
return false;
const JSAtomState &atomState = cx->runtime->atomState;
const JSAtomState &names = cx->names();
RootedValue configurableVal(cx, BooleanValue((attrs & JSPROP_PERMANENT) == 0));
RootedValue enumerableVal(cx, BooleanValue((attrs & JSPROP_ENUMERATE) != 0));
RootedValue writableVal(cx, BooleanValue((attrs & JSPROP_READONLY) == 0));
if ((hasConfigurable() &&
!JSObject::defineProperty(cx, obj, atomState.configurableAtom, configurableVal)) ||
!JSObject::defineProperty(cx, obj, names.configurable, configurableVal)) ||
(hasEnumerable() &&
!JSObject::defineProperty(cx, obj, atomState.enumerableAtom, enumerableVal)) ||
!JSObject::defineProperty(cx, obj, names.enumerable, enumerableVal)) ||
(hasGet() &&
!JSObject::defineProperty(cx, obj, atomState.getAtom, getterValue())) ||
!JSObject::defineProperty(cx, obj, names.get, getterValue())) ||
(hasSet() &&
!JSObject::defineProperty(cx, obj, atomState.setAtom, setterValue())) ||
!JSObject::defineProperty(cx, obj, names.set, setterValue())) ||
(hasValue() &&
!JSObject::defineProperty(cx, obj, atomState.valueAtom, value())) ||
!JSObject::defineProperty(cx, obj, names.value, value())) ||
(hasWritable() &&
!JSObject::defineProperty(cx, obj, atomState.writableAtom, writableVal)))
!JSObject::defineProperty(cx, obj, names.writable, writableVal)))
{
return false;
}
@ -1051,7 +1051,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
RootedId id(cx);
/* 8.10.5 step 3 */
id = NameToId(cx->runtime->atomState.enumerableAtom);
id = NameToId(cx->names().enumerable);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1061,7 +1061,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.5 step 4 */
id = NameToId(cx->runtime->atomState.configurableAtom);
id = NameToId(cx->names().configurable);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1071,7 +1071,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.5 step 5 */
id = NameToId(cx->runtime->atomState.valueAtom);
id = NameToId(cx->names().value);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1080,7 +1080,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.6 step 6 */
id = NameToId(cx->runtime->atomState.writableAtom);
id = NameToId(cx->names().writable);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1090,7 +1090,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.7 step 7 */
id = NameToId(cx->runtime->atomState.getAtom);
id = NameToId(cx->names().get);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1103,7 +1103,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
}
/* 8.10.7 step 8 */
id = NameToId(cx->runtime->atomState.setAtom);
id = NameToId(cx->names().set);
if (!HasProperty(cx, desc, id, &v, &found))
return false;
if (found) {
@ -1565,7 +1565,7 @@ DefinePropertyOnArray(JSContext *cx, HandleObject obj, HandleId id, const PropDe
uint32_t oldLen = obj->getArrayLength();
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
if (JSID_IS_ATOM(id, cx->names().length)) {
/*
* Our optimization of storage of the length property of arrays makes
* it very difficult to properly implement defining the property. For
@ -2313,7 +2313,7 @@ JSObject*
js_CreateThis(JSContext *cx, Class *newclasp, HandleObject callee)
{
RootedValue protov(cx);
if (!JSObject::getProperty(cx, callee, callee, cx->runtime->atomState.classPrototypeAtom, &protov))
if (!JSObject::getProperty(cx, callee, callee, cx->names().classPrototype, &protov))
return NULL;
JSObject *proto = protov.isObjectOrNull() ? protov.toObjectOrNull() : NULL;
@ -2367,7 +2367,7 @@ JSObject *
js_CreateThisForFunction(JSContext *cx, HandleObject callee, bool newType)
{
RootedValue protov(cx);
if (!JSObject::getProperty(cx, callee, callee, cx->runtime->atomState.classPrototypeAtom, &protov))
if (!JSObject::getProperty(cx, callee, callee, cx->names().classPrototype, &protov))
return NULL;
JSObject *proto;
if (protov.isObject())
@ -2434,7 +2434,7 @@ Detecting(JSContext *cx, jsbytecode *pc)
* global binding...because, really?
*/
atom = script->getAtom(GET_UINT32_INDEX(pc));
if (atom == cx->runtime->atomState.undefinedAtom &&
if (atom == cx->names().undefined &&
(pc += js_CodeSpec[op].length) < endpc) {
op = JSOp(*pc);
return op == JSOP_EQ || op == JSOP_NE || op == JSOP_STRICTEQ || op == JSOP_STRICTNE;
@ -4323,7 +4323,7 @@ js_GetPropertyHelperInline(JSContext *cx, HandleObject obj, HandleObject receive
* XXX do not warn about missing __iterator__ as the function
* may be called from JS_GetMethodById. See bug 355145.
*/
if (JSID_IS_ATOM(id, cx->runtime->atomState.iteratorIntrinsicAtom))
if (JSID_IS_ATOM(id, cx->names().iteratorIntrinsic))
return JS_TRUE;
/* Do not warn about tests like (obj[prop] == undefined). */
@ -4855,7 +4855,7 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
Class *clasp = obj->getClass();
if (hint == JSTYPE_STRING) {
id = NameToId(cx->runtime->atomState.toStringAtom);
id = NameToId(cx->names().toString);
/* Optimize (new String(...)).toString(). */
if (clasp == &StringClass) {
@ -4870,7 +4870,7 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
if (vp.isPrimitive())
return true;
id = NameToId(cx->runtime->atomState.valueOfAtom);
id = NameToId(cx->names().valueOf);
if (!MaybeCallMethod(cx, obj, id, vp))
return false;
if (vp.isPrimitive())
@ -4879,7 +4879,7 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
/* Optimize new String(...).valueOf(). */
if (clasp == &StringClass) {
id = NameToId(cx->runtime->atomState.valueOfAtom);
id = NameToId(cx->names().valueOf);
if (ClassMethodIsNative(cx, obj, &StringClass, id, js_str_toString)) {
vp.setString(obj->asString().unbox());
return true;
@ -4888,20 +4888,20 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
/* Optimize new Number(...).valueOf(). */
if (clasp == &NumberClass) {
id = NameToId(cx->runtime->atomState.valueOfAtom);
id = NameToId(cx->names().valueOf);
if (ClassMethodIsNative(cx, obj, &NumberClass, id, js_num_valueOf)) {
vp.setNumber(obj->asNumber().unbox());
return true;
}
}
id = NameToId(cx->runtime->atomState.valueOfAtom);
id = NameToId(cx->names().valueOf);
if (!MaybeCallMethod(cx, obj, id, vp))
return false;
if (vp.isPrimitive())
return true;
id = NameToId(cx->runtime->atomState.toStringAtom);
id = NameToId(cx->names().toString);
if (!MaybeCallMethod(cx, obj, id, vp))
return false;
if (vp.isPrimitive())
@ -5062,7 +5062,7 @@ js_GetClassPrototype(JSContext *cx, JSProtoKey protoKey, MutableHandleObject pro
if (IsFunctionObject(v)) {
RootedObject ctor(cx, &v.get().toObject());
if (!JSObject::getProperty(cx, ctor, ctor, cx->runtime->atomState.classPrototypeAtom, &v))
if (!JSObject::getProperty(cx, ctor, ctor, cx->names().classPrototype, &v))
return false;
}

View File

@ -374,7 +374,7 @@ JSObject::setArrayLength(JSContext *cx, uint32_t length)
js::types::MarkTypeObjectFlags(cx, this,
js::types::OBJECT_FLAG_NON_PACKED_ARRAY |
js::types::OBJECT_FLAG_NON_DENSE_ARRAY);
jsid lengthId = js::NameToId(cx->runtime->atomState.lengthAtom);
jsid lengthId = js::NameToId(cx->names().length);
js::types::AddTypePropertyId(cx, this, lengthId,
js::types::Type::DoubleType());
}

View File

@ -68,7 +68,7 @@ js_json_parse(JSContext *cx, unsigned argc, Value *vp)
if (!linear)
return false;
} else {
linear = cx->runtime->atomState.undefinedAtom;
linear = cx->names().undefined;
}
JS::Anchor<JSString *> anchor(linear);
@ -281,7 +281,7 @@ PreprocessValue(JSContext *cx, HandleObject holder, KeyType key, MutableHandleVa
/* Step 2. */
if (vp.get().isObject()) {
RootedValue toJSON(cx);
RootedId id(cx, NameToId(cx->runtime->atomState.toJSONAtom));
RootedId id(cx, NameToId(cx->names().toJSON));
Rooted<JSObject*> obj(cx, &vp.get().toObject());
if (!GetMethod(cx, obj, id, 0, &toJSON))
return false;
@ -725,7 +725,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
return false;
/* Step 10. */
RootedId emptyId(cx, NameToId(cx->runtime->atomState.emptyAtom));
RootedId emptyId(cx, NameToId(cx->names().empty));
if (!DefineNativeProperty(cx, wrapper, emptyId, vp, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_ENUMERATE, 0, 0))
{
@ -856,10 +856,10 @@ Revive(JSContext *cx, HandleValue reviver, MutableHandleValue vp)
if (!obj)
return false;
if (!JSObject::defineProperty(cx, obj, cx->runtime->atomState.emptyAtom, vp))
if (!JSObject::defineProperty(cx, obj, cx->names().empty, vp))
return false;
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.emptyAtom));
Rooted<jsid> id(cx, NameToId(cx->names().empty));
return Walk(cx, obj, id, reviver, vp);
}
@ -887,7 +887,7 @@ ParseJSONWithReviver(JSContext *cx, const jschar *chars, size_t length, HandleVa
static JSBool
json_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->runtime->atomState.JSONAtom);
vp->setString(cx->names().JSON);
return JS_TRUE;
}
#endif

View File

@ -429,7 +429,7 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
while (!r.empty()) {
Rooted<Shape*> shape(cx, &r.front());
JSAtom *atom = JSID_IS_INT(shape->propid())
? cx->runtime->atomState.emptyAtom
? cx->names().empty
: JSID_TO_ATOM(shape->propid());
JSAutoByteString bytes;
@ -2342,7 +2342,7 @@ GetBlockNames(JSContext *cx, StaticBlockObject &blockObj, AtomVector *atoms)
--i;
LOCAL_ASSERT((unsigned)shape.shortid() == i);
(*atoms)[i] = JSID_IS_INT(shape.propid())
? cx->runtime->atomState.emptyAtom
? cx->names().empty
: JSID_TO_ATOM(shape.propid());
}
@ -3467,7 +3467,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
if (ss->sprinter.put(rhs + DestructuredStringLength) < 0)
return NULL;
} else {
JS_ASSERT(atoms[i] != cx->runtime->atomState.emptyAtom);
JS_ASSERT(atoms[i] != cx->names().empty);
if (!QuoteString(&ss->sprinter, atoms[i], 0))
return NULL;
if (*rhs) {
@ -5960,7 +5960,7 @@ ExpressionDecompiler::decompilePC(jsbytecode *pc)
case JSOP_LENGTH:
case JSOP_GETPROP:
case JSOP_CALLPROP: {
JSAtom *prop = (op == JSOP_LENGTH) ? cx->runtime->atomState.lengthAtom : loadAtom(pc);
JSAtom *prop = (op == JSOP_LENGTH) ? cx->names().length : loadAtom(pc);
if (!decompilePC(pcstack[-1]))
return false;
if (IsIdentifier(prop))

View File

@ -17,12 +17,12 @@ static inline PropertyName *
GetNameFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op)
{
if (op == JSOP_LENGTH)
return cx->runtime->atomState.lengthAtom;
return cx->names().length;
// The method JIT's implementation of instanceof contains an internal lookup
// of the prototype property.
if (op == JSOP_INSTANCEOF)
return cx->runtime->atomState.classPrototypeAtom;
return cx->names().classPrototype;
PropertyName *name;
GET_NAME_FROM_BYTECODE(script, pc, 0, name);

View File

@ -638,12 +638,12 @@ static bool
GetDerivedTrap(JSContext *cx, HandleObject handler, HandlePropertyName name,
MutableHandleValue fvalp)
{
JS_ASSERT(name == ATOM(has) ||
name == ATOM(hasOwn) ||
name == ATOM(get) ||
name == ATOM(set) ||
name == ATOM(keys) ||
name == ATOM(iterate));
JS_ASSERT(name == cx->names().has ||
name == cx->names().hasOwn ||
name == cx->names().get ||
name == cx->names().set ||
name == cx->names().keys ||
name == cx->names().iterate);
return JSObject::getProperty(cx, handler, handler, name, fvalp);
}
@ -816,10 +816,10 @@ ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *pro
RootedObject proxy(cx, proxy_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, ATOM(getPropertyDescriptor), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().getPropertyDescriptor, &fval) &&
Trap1(cx, handler, fval, id, value.address()) &&
((value.get().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
(ReturnedValueMustNotBePrimitive(cx, proxy, ATOM(getPropertyDescriptor), value) &&
(ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().getPropertyDescriptor, value) &&
ParsePropertyDescriptorObject(cx, proxy, value, desc)));
}
@ -831,10 +831,10 @@ ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *
RootedObject proxy(cx, proxy_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, ATOM(getOwnPropertyDescriptor), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().getOwnPropertyDescriptor, &fval) &&
Trap1(cx, handler, fval, id, value.address()) &&
((value.get().isUndefined() && IndicatePropertyNotFound(cx, desc)) ||
(ReturnedValueMustNotBePrimitive(cx, proxy, ATOM(getPropertyDescriptor), value) &&
(ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().getPropertyDescriptor, value) &&
ParsePropertyDescriptorObject(cx, proxy, value, desc)));
}
@ -845,7 +845,7 @@ ScriptedIndirectProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsi
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
RootedId id(cx, id_);
return GetFundamentalTrap(cx, handler, ATOM(defineProperty), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().defineProperty, &fval) &&
NewPropertyDescriptorObject(cx, desc, value.address()) &&
Trap2(cx, handler, fval, id, value, value.address());
}
@ -856,7 +856,7 @@ ScriptedIndirectProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy
{
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, ATOM(getOwnPropertyNames), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().getOwnPropertyNames, &fval) &&
Trap(cx, handler, fval, 0, NULL, value.address()) &&
ArrayToIdVector(cx, value, props);
}
@ -867,7 +867,7 @@ ScriptedIndirectProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id_,
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedId id(cx, id_);
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, ATOM(delete_), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().delete_, &fval) &&
Trap1(cx, handler, fval, id, value.address()) &&
ValueToBool(cx, value, bp);
}
@ -877,7 +877,7 @@ ScriptedIndirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy, AutoIdVe
{
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
return GetFundamentalTrap(cx, handler, ATOM(enumerate), &fval) &&
return GetFundamentalTrap(cx, handler, cx->names().enumerate, &fval) &&
Trap(cx, handler, fval, 0, NULL, value.address()) &&
ArrayToIdVector(cx, value, props);
}
@ -889,7 +889,7 @@ ScriptedIndirectProxyHandler::has(JSContext *cx, JSObject *proxy_, jsid id_, boo
RootedId id(cx, id_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
if (!GetDerivedTrap(cx, handler, ATOM(has), &fval))
if (!GetDerivedTrap(cx, handler, cx->names().has, &fval))
return false;
if (!js_IsCallable(fval))
return BaseProxyHandler::has(cx, proxy, id, bp);
@ -904,7 +904,7 @@ ScriptedIndirectProxyHandler::hasOwn(JSContext *cx, JSObject *proxy_, jsid id_,
RootedId id(cx, id_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue fval(cx), value(cx);
if (!GetDerivedTrap(cx, handler, ATOM(hasOwn), &fval))
if (!GetDerivedTrap(cx, handler, cx->names().hasOwn, &fval))
return false;
if (!js_IsCallable(fval))
return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
@ -926,7 +926,7 @@ ScriptedIndirectProxyHandler::get(JSContext *cx, JSObject *proxy_, JSObject *rec
Value argv[] = { ObjectOrNullValue(receiver), value };
AutoValueArray ava(cx, argv, 2);
RootedValue fval(cx);
if (!GetDerivedTrap(cx, handler, ATOM(get), &fval))
if (!GetDerivedTrap(cx, handler, cx->names().get, &fval))
return false;
if (!js_IsCallable(fval))
return BaseProxyHandler::get(cx, proxy, receiver, id, vp);
@ -947,7 +947,7 @@ ScriptedIndirectProxyHandler::set(JSContext *cx, JSObject *proxy_, JSObject *rec
Value argv[] = { ObjectOrNullValue(receiver), value, *vp };
AutoValueArray ava(cx, argv, 3);
RootedValue fval(cx);
if (!GetDerivedTrap(cx, handler, ATOM(set), &fval))
if (!GetDerivedTrap(cx, handler, cx->names().set, &fval))
return false;
if (!js_IsCallable(fval))
return BaseProxyHandler::set(cx, proxy, receiver, id, strict, vp);
@ -960,7 +960,7 @@ ScriptedIndirectProxyHandler::keys(JSContext *cx, JSObject *proxy_, AutoIdVector
RootedObject proxy(cx, proxy_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue value(cx);
if (!GetDerivedTrap(cx, handler, ATOM(keys), &value))
if (!GetDerivedTrap(cx, handler, cx->names().keys, &value))
return false;
if (!js_IsCallable(value))
return BaseProxyHandler::keys(cx, proxy, props);
@ -974,12 +974,12 @@ ScriptedIndirectProxyHandler::iterate(JSContext *cx, JSObject *proxy_, unsigned
RootedObject proxy(cx, proxy_);
RootedObject handler(cx, GetIndirectProxyHandlerObject(cx, proxy));
RootedValue value(cx);
if (!GetDerivedTrap(cx, handler, ATOM(iterate), &value))
if (!GetDerivedTrap(cx, handler, cx->names().iterate, &value))
return false;
if (!js_IsCallable(value))
return BaseProxyHandler::iterate(cx, proxy, flags, vp);
return Trap(cx, handler, value, 0, NULL, vp) &&
ReturnedValueMustNotBePrimitive(cx, proxy, ATOM(iterate), *vp);
ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().iterate, *vp);
}
bool
@ -1121,9 +1121,9 @@ NormalizePropertyDescriptor(JSContext *cx, MutableHandleValue vp, bool complete
if (JSID_IS_ATOM(id)) {
JSAtom *atom = JSID_TO_ATOM(id);
const JSAtomState &atomState = cx->runtime->atomState;
if (atom == atomState.valueAtom || atom == atomState.writableAtom ||
atom == atomState.getAtom || atom == atomState.setAtom ||
atom == atomState.enumerableAtom || atom == atomState.configurableAtom)
if (atom == atomState.value || atom == atomState.writable ||
atom == atomState.get || atom == atomState.set ||
atom == atomState.enumerable || atom == atomState.configurable)
{
continue;
}
@ -1306,7 +1306,7 @@ TrapGetOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHandle
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(getOwnPropertyDescriptor), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().getOwnPropertyDescriptor, &trap))
return false;
// step 4
@ -1408,7 +1408,7 @@ TrapDefineOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHan
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(defineProperty), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().defineProperty, &trap))
return false;
// step 4
@ -1667,7 +1667,7 @@ ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy_,
// step c
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(getOwnPropertyNames), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().getOwnPropertyNames, &trap))
return false;
// step d
@ -1684,13 +1684,13 @@ ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy_,
// step f
if (trapResult.isPrimitive()) {
ReportInvalidTrapResult(cx, proxy, ATOM(getOwnPropertyNames));
ReportInvalidTrapResult(cx, proxy, cx->names().getOwnPropertyNames);
return false;
}
// steps g to n are shared
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY | JSITER_HIDDEN,
ATOM(getOwnPropertyNames));
cx->names().getOwnPropertyNames);
}
// Proxy.[[Delete]](P, Throw)
@ -1708,7 +1708,7 @@ ScriptedDirectProxyHandler::delete_(JSContext *cx, JSObject *proxy_, jsid id_, b
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(deleteProperty), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().deleteProperty, &trap))
return false;
// step 4
@ -1762,7 +1762,7 @@ ScriptedDirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy_, AutoIdVec
// step c
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(enumerate), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().enumerate, &trap))
return false;
// step d
@ -1780,7 +1780,7 @@ ScriptedDirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy_, AutoIdVec
// step f
if (trapResult.isPrimitive()) {
JSAutoByteString bytes;
if (!js_AtomToPrintableString(cx, ATOM(enumerate), &bytes))
if (!js_AtomToPrintableString(cx, cx->names().enumerate, &bytes))
return false;
RootedValue v(cx, ObjectOrNullValue(proxy));
js_ReportValueError2(cx, JSMSG_INVALID_TRAP_RESULT, JSDVG_SEARCH_STACK,
@ -1790,7 +1790,7 @@ ScriptedDirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy_, AutoIdVec
// steps g-m are shared
// FIXME: the trap should return an iterator object, see bug 783826
return ArrayToIdVector(cx, proxy, target, trapResult, props, 0, ATOM(enumerate));
return ArrayToIdVector(cx, proxy, target, trapResult, props, 0, cx->names().enumerate);
}
// Proxy.[[HasProperty]](P)
@ -1808,7 +1808,7 @@ ScriptedDirectProxyHandler::has(JSContext *cx, JSObject *proxy_, jsid id_, bool
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(has), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().has, &trap))
return false;
// step 4
@ -1871,7 +1871,7 @@ ScriptedDirectProxyHandler::hasOwn(JSContext *cx, JSObject *proxy_, jsid id_, bo
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(hasOwn), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().hasOwn, &trap))
return false;
// step 4
@ -1944,7 +1944,7 @@ ScriptedDirectProxyHandler::get(JSContext *cx, JSObject *proxy_, JSObject *recei
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(get), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().get, &trap))
return false;
// step 4
@ -2017,7 +2017,7 @@ ScriptedDirectProxyHandler::set(JSContext *cx, JSObject *proxy_, JSObject *recei
// step 3
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(set), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().set, &trap))
return false;
// step 4
@ -2087,7 +2087,7 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, JSObject *proxy_, AutoIdVector &
// step c
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(keys), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().keys, &trap))
return false;
// step d
@ -2105,7 +2105,7 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, JSObject *proxy_, AutoIdVector &
// step f
if (trapResult.isPrimitive()) {
JSAutoByteString bytes;
if (!js_AtomToPrintableString(cx, ATOM(keys), &bytes))
if (!js_AtomToPrintableString(cx, cx->names().keys, &bytes))
return false;
RootedValue v(cx, ObjectOrNullValue(proxy));
js_ReportValueError2(cx, JSMSG_INVALID_TRAP_RESULT, JSDVG_IGNORE_STACK,
@ -2114,7 +2114,7 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, JSObject *proxy_, AutoIdVector &
}
// steps g-n are shared
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY, ATOM(keys));
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY, cx->names().keys);
}
bool
@ -2147,7 +2147,7 @@ ScriptedDirectProxyHandler::call(JSContext *cx, JSObject *proxy_, unsigned argc,
// step 4
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(apply), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().apply, &trap))
return false;
// step 5
@ -2188,7 +2188,7 @@ ScriptedDirectProxyHandler::construct(JSContext *cx, JSObject *proxy_, unsigned
// step 4
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, ATOM(construct), &trap))
if (!JSObject::getProperty(cx, handler, handler, cx->names().construct, &trap))
return false;
// step 5

View File

@ -1696,7 +1696,7 @@ class ASTSerializer
DebugOnly<uint32_t> lineno;
RawValue unrootedAtomContents(RawAtom atom) {
return StringValue(atom ? atom : cx->runtime->atomState.emptyAtom);
return StringValue(atom ? atom : cx->names().empty);
}
BinaryOperator binop(ParseNodeKind kind, JSOp op);
@ -3418,7 +3418,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
RootedValue prop(cx);
/* config.loc */
RootedId locId(cx, NameToId(cx->runtime->atomState.locAtom));
RootedId locId(cx, NameToId(cx->names().loc));
RootedValue trueVal(cx, BooleanValue(true));
if (!baseops::GetPropertyDefault(cx, config, locId, trueVal, &prop))
return JS_FALSE;
@ -3427,7 +3427,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
if (loc) {
/* config.source */
RootedId sourceId(cx, NameToId(cx->runtime->atomState.sourceAtom));
RootedId sourceId(cx, NameToId(cx->names().source));
RootedValue nullVal(cx, NullValue());
if (!baseops::GetPropertyDefault(cx, config, sourceId, nullVal, &prop))
return JS_FALSE;
@ -3449,7 +3449,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
}
/* config.line */
RootedId lineId(cx, NameToId(cx->runtime->atomState.lineAtom));
RootedId lineId(cx, NameToId(cx->names().line));
RootedValue oneValue(cx, Int32Value(1));
if (!baseops::GetPropertyDefault(cx, config, lineId, oneValue, &prop) ||
!ToUint32(cx, prop, &lineno)) {
@ -3458,7 +3458,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
}
/* config.builder */
RootedId builderId(cx, NameToId(cx->runtime->atomState.builderAtom));
RootedId builderId(cx, NameToId(cx->names().builder));
RootedValue nullVal(cx, NullValue());
if (!baseops::GetPropertyDefault(cx, config, builderId, nullVal, &prop))
return JS_FALSE;

View File

@ -53,7 +53,7 @@ using namespace js::frontend;
unsigned
Bindings::argumentsVarIndex(JSContext *cx) const
{
PropertyName *arguments = cx->runtime->atomState.argumentsAtom;
HandlePropertyName arguments = cx->names().arguments;
BindingIter bi(*this);
while (bi->name() != arguments)
bi++;

View File

@ -66,7 +66,7 @@ static JSLinearString *
ArgToRootedString(JSContext *cx, CallArgs &args, unsigned argno)
{
if (argno >= args.length())
return cx->runtime->atomState.undefinedAtom;
return cx->names().undefined;
Value &arg = args[argno];
JSString *str = ToString(cx, arg);
@ -439,7 +439,7 @@ ThisToStringForStringProto(JSContext *cx, CallReceiver call)
if (call.thisv().isObject()) {
RootedObject obj(cx, &call.thisv().toObject());
if (obj->isString()) {
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.toStringAtom));
Rooted<jsid> id(cx, NameToId(cx->names().toString));
if (ClassMethodIsNative(cx, obj, &StringClass, id, js_str_toString)) {
JSString *str = obj->asString().unbox();
call.setThis(StringValue(str));
@ -1727,8 +1727,8 @@ BuildFlatMatchArray(JSContext *cx, HandleString textstr, const FlatMatch &fm, Ca
RootedValue textVal(cx, StringValue(textstr));
if (!JSObject::defineElement(cx, obj, 0, patternVal) ||
!JSObject::defineProperty(cx, obj, cx->runtime->atomState.indexAtom, matchVal) ||
!JSObject::defineProperty(cx, obj, cx->runtime->atomState.inputAtom, textVal))
!JSObject::defineProperty(cx, obj, cx->names().index, matchVal) ||
!JSObject::defineProperty(cx, obj, cx->names().input, textVal))
{
return false;
}
@ -3220,7 +3220,7 @@ StringObject::assignInitialShape(JSContext *cx)
{
JS_ASSERT(nativeEmpty());
return addDataProperty(cx, NameToId(cx->runtime->atomState.lengthAtom),
return addDataProperty(cx, NameToId(cx->names().length),
LENGTH_SLOT, JSPROP_PERMANENT | JSPROP_READONLY);
}
@ -3238,7 +3238,7 @@ js_InitStringClass(JSContext *cx, JSObject *obj)
/* Now create the String function. */
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, js_String, cx->runtime->atomState.StringAtom, 1);
ctor = global->createConstructor(cx, js_String, cx->names().String, 1);
if (!ctor)
return NULL;
@ -3423,9 +3423,9 @@ js::ToStringSlow(JSContext *cx, const Value &arg)
} else if (v.isBoolean()) {
str = js_BooleanToString(cx, v.toBoolean());
} else if (v.isNull()) {
str = cx->runtime->atomState.nullAtom;
str = cx->names().null;
} else {
str = cx->runtime->atomState.undefinedAtom;
str = cx->names().undefined;
}
return str;
}
@ -3436,7 +3436,7 @@ js_ValueToSource(JSContext *cx, const Value &v)
JS_CHECK_RECURSION(cx, return NULL);
if (v.isUndefined())
return cx->runtime->atomState.void0Atom;
return cx->names().void0;
if (v.isString())
return js_QuoteString(cx, v.toString(), '"');
if (v.isPrimitive()) {
@ -3452,7 +3452,7 @@ js_ValueToSource(JSContext *cx, const Value &v)
Value rval = NullValue();
RootedValue fval(cx);
RootedId id(cx, NameToId(cx->runtime->atomState.toSourceAtom));
RootedId id(cx, NameToId(cx->names().toSource));
Rooted<JSObject*> obj(cx, &v.toObject());
if (!GetMethod(cx, obj, id, 0, &fval))
return NULL;

View File

@ -1596,16 +1596,16 @@ class TypedArrayTemplate
static
bool defineGetters(JSContext *cx, HandleObject proto)
{
if (!DefineGetter<lengthValue>(cx, cx->runtime->atomState.lengthAtom, proto))
if (!DefineGetter<lengthValue>(cx, cx->names().length, proto))
return false;
if (!DefineGetter<bufferValue>(cx, cx->runtime->atomState.bufferAtom, proto))
if (!DefineGetter<bufferValue>(cx, cx->names().buffer, proto))
return false;
if (!DefineGetter<byteLengthValue>(cx, cx->runtime->atomState.byteLengthAtom, proto))
if (!DefineGetter<byteLengthValue>(cx, cx->names().byteLength, proto))
return false;
if (!DefineGetter<byteOffsetValue>(cx, cx->runtime->atomState.byteOffsetAtom, proto))
if (!DefineGetter<byteOffsetValue>(cx, cx->names().byteOffset, proto))
return false;
return true;
@ -3215,11 +3215,11 @@ InitTypedArrayClass(JSContext *cx)
RootedValue bytesValue(cx, Int32Value(ArrayType::BYTES_PER_ELEMENT));
if (!JSObject::defineProperty(cx, ctor,
cx->runtime->atomState.BYTES_PER_ELEMENTAtom, bytesValue,
cx->names().BYTES_PER_ELEMENT, bytesValue,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY) ||
!JSObject::defineProperty(cx, proto,
cx->runtime->atomState.BYTES_PER_ELEMENTAtom, bytesValue,
cx->names().BYTES_PER_ELEMENT, bytesValue,
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY))
{
@ -3291,14 +3291,14 @@ InitArrayBufferClass(JSContext *cx)
return NULL;
RootedFunction ctor(cx, global->createConstructor(cx, ArrayBufferObject::class_constructor,
cx->runtime->atomState.ArrayBufferAtom, 1));
cx->names().ArrayBuffer, 1));
if (!ctor)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, arrayBufferProto))
return NULL;
RootedId byteLengthId(cx, NameToId(cx->runtime->atomState.byteLengthAtom));
RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
unsigned flags = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
JSObject *getter = js_NewFunction(cx, NULL, ArrayBufferObject::byteLengthGetter, 0, 0, global, NULL);
if (!getter)
@ -3420,20 +3420,20 @@ DataViewObject::initClass(JSContext *cx)
return NULL;
RootedFunction ctor(cx, global->createConstructor(cx, DataViewObject::class_constructor,
cx->runtime->atomState.DataViewAtom, 3));
cx->names().DataView, 3));
if (!ctor)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, proto))
return NULL;
if (!defineGetter<bufferValue>(cx, cx->runtime->atomState.bufferAtom, proto))
if (!defineGetter<bufferValue>(cx, cx->names().buffer, proto))
return NULL;
if (!defineGetter<byteLengthValue>(cx, cx->runtime->atomState.byteLengthAtom, proto))
if (!defineGetter<byteLengthValue>(cx, cx->names().byteLength, proto))
return NULL;
if (!defineGetter<byteOffsetValue>(cx, cx->runtime->atomState.byteOffsetAtom, proto))
if (!defineGetter<byteOffsetValue>(cx, cx->names().byteOffset, proto))
return NULL;
if (!JS_DefineFunctions(cx, proto, DataViewObject::jsfuncs))

View File

@ -373,7 +373,7 @@ js_InitWeakMapClass(JSContext *cx, JSObject *obj)
return NULL;
RootedFunction ctor(cx, global->createConstructor(cx, WeakMap_construct,
cx->runtime->atomState.WeakMapAtom, 0));
cx->names().WeakMap, 0));
if (!ctor)
return NULL;

View File

@ -354,12 +354,12 @@ ConvertQNameToString(JSContext *cx, JSObject *obj)
RootedString str(cx);
if (!uri) {
/* No uri means wildcard qualifier. */
str = cx->runtime->atomState.starQualifierAtom;
str = cx->names().starQualifier;
} else if (uri->empty()) {
/* Empty string for uri means localName is in no namespace. */
str = cx->runtime->emptyString;
} else {
RootedString qualstr(cx, cx->runtime->atomState.qualifierAtom);
RootedString qualstr(cx, cx->names().qualifier);
str = js_ConcatStrings(cx, uri, qualstr);
if (!str)
return NULL;
@ -737,7 +737,7 @@ QNameHelper(JSContext *cx, int argc, jsval *argv, jsval *rval)
if (argc == 0) {
name = cx->runtime->emptyString;
} else if (argc < 0) {
name = cx->runtime->atomState.undefinedAtom;
name = cx->names().undefined;
} else {
name = ToAtom(cx, nameval);
if (!name)
@ -2805,7 +2805,7 @@ ToAttributeName(JSContext *cx, jsval v)
name = qn->getQNameLocalName();
} else {
if (clasp == &AnyNameClass) {
name = cx->runtime->atomState.starAtom;
name = cx->names().star;
} else {
name = ToAtom(cx, v);
if (!name)
@ -2833,7 +2833,7 @@ namespace js {
bool
GetLocalNameFromFunctionQName(JSObject *qn, JSAtom **namep, JSContext *cx)
{
JSAtom *atom = cx->runtime->atomState.functionNamespaceURIAtom;
JSAtom *atom = cx->names().functionNamespaceURI;
JSLinearString *uri = qn->getNameURI();
if (uri && (uri == atom || EqualStrings(uri, atom))) {
*namep = qn->getQNameLocalName();
@ -2879,7 +2879,7 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
if (clasp == &AttributeNameClass || clasp == &QNameClass)
goto out;
if (clasp == &AnyNameClass) {
name = cx->runtime->atomState.starAtom;
name = cx->names().star;
goto construct;
}
name = ToStringSlow(cx, v);
@ -4160,7 +4160,7 @@ PutProperty(JSContext *cx, HandleObject obj_, HandleId id_, JSBool strict, Mutab
kidobj = js_GetXMLObject(cx, kid);
if (!kidobj)
goto bad;
id = NameToId(cx->runtime->atomState.starAtom);
id = NameToId(cx->names().star);
ok = PutProperty(cx, kidobj, id, strict, vp);
if (!ok)
goto out;
@ -4258,7 +4258,7 @@ PutProperty(JSContext *cx, HandleObject obj_, HandleId id_, JSBool strict, Mutab
if (!left)
goto bad;
RootedString space(cx, cx->runtime->atomState.spaceAtom);
RootedString space(cx, cx->names().space);
for (i = 1; i < n; i++) {
left = js_ConcatStrings(cx, left, space);
if (!left)
@ -5505,7 +5505,7 @@ xml_attribute(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
xml_attributes(JSContext *cx, unsigned argc, jsval *vp)
{
jsval name = STRING_TO_JSVAL(cx->runtime->atomState.starAtom);
jsval name = STRING_TO_JSVAL(cx->names().star);
JSObject *qn = ToAttributeName(cx, name);
if (!qn)
return JS_FALSE;
@ -5674,7 +5674,7 @@ xml_children(JSContext *cx, unsigned argc, jsval *vp)
RootedObject obj(cx, ToObject(cx, HandleValue::fromMarkedLocation(&vp[1])));
if (!obj)
return false;
RootedId name(cx, NameToId(cx->runtime->atomState.starAtom));
RootedId name(cx, NameToId(cx->names().star));
return GetProperty(cx, obj, name, MutableHandleValue::fromMarkedLocation(vp));
}
@ -5788,7 +5788,7 @@ xml_descendants(JSContext *cx, unsigned argc, jsval *vp)
JSXML *list;
XML_METHOD_PROLOG;
name = argc == 0 ? STRING_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
name = argc == 0 ? STRING_TO_JSVAL(cx->names().star) : vp[2];
list = Descendants(cx, xml, name);
if (!list)
return JS_FALSE;
@ -5860,7 +5860,7 @@ xml_elements(JSContext *cx, unsigned argc, jsval *vp)
XML_METHOD_PROLOG;
name = (argc == 0) ? STRING_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
name = (argc == 0) ? STRING_TO_JSVAL(cx->names().star) : vp[2];
nameqn = ToXMLName(cx, name, &funid);
if (!nameqn)
return JS_FALSE;
@ -6413,7 +6413,7 @@ xml_processingInstructions(JSContext *cx, unsigned argc, jsval *vp)
XML_METHOD_PROLOG;
name = (argc == 0) ? STRING_TO_JSVAL(cx->runtime->atomState.starAtom) : vp[2];
name = (argc == 0) ? STRING_TO_JSVAL(cx->names().star) : vp[2];
nameqn = ToXMLName(cx, name, &funid);
if (!nameqn)
return JS_FALSE;
@ -6550,7 +6550,7 @@ xml_replace(JSContext *cx, unsigned argc, jsval *vp)
goto done;
if (argc <= 1) {
value = STRING_TO_JSVAL(cx->runtime->atomState.undefinedAtom);
value = STRING_TO_JSVAL(cx->names().undefined);
} else {
value = vp[3];
vxml = VALUE_IS_XML(value)
@ -6622,7 +6622,7 @@ xml_setChildren(JSContext *cx, unsigned argc, jsval *vp)
if (!StartNonListXMLMethod(cx, vp, &obj))
return JS_FALSE;
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.starAtom));
Rooted<jsid> id(cx, NameToId(cx->names().star));
*vp = argc != 0 ? vp[2] : JSVAL_VOID; /* local root */
if (!PutProperty(cx, obj, id, false, MutableHandleValue::fromMarkedLocation(vp)))
return JS_FALSE;
@ -6642,7 +6642,7 @@ xml_setLocalName(JSContext *cx, unsigned argc, jsval *vp)
JSAtom *namestr;
if (argc == 0) {
namestr = cx->runtime->atomState.undefinedAtom;
namestr = cx->names().undefined;
} else {
jsval name = vp[2];
if (!JSVAL_IS_PRIMITIVE(name) && JSVAL_TO_OBJECT(name)->isQName()) {
@ -6678,7 +6678,7 @@ xml_setName(JSContext *cx, unsigned argc, jsval *vp)
return JS_TRUE;
if (argc == 0) {
name = STRING_TO_JSVAL(cx->runtime->atomState.undefinedAtom);
name = STRING_TO_JSVAL(cx->names().undefined);
} else {
name = vp[2];
if (!JSVAL_IS_PRIMITIVE(name) &&
@ -7340,7 +7340,7 @@ js_InitNamespaceClass(JSContext *cx, JSObject *obj)
const unsigned NAMESPACE_CTOR_LENGTH = 2;
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, Namespace, cx->runtime->atomState.NamespaceAtom,
ctor = global->createConstructor(cx, Namespace, cx->names().Namespace,
NAMESPACE_CTOR_LENGTH);
if (!ctor)
return NULL;
@ -7373,7 +7373,7 @@ js_InitQNameClass(JSContext *cx, JSObject *obj)
return NULL;
const unsigned QNAME_CTOR_LENGTH = 2;
RootedFunction ctor(cx, global->createConstructor(cx, QName, cx->runtime->atomState.QNameAtom,
RootedFunction ctor(cx, global->createConstructor(cx, QName, cx->names().QName,
QNAME_CTOR_LENGTH));
if (!ctor)
return NULL;
@ -7414,7 +7414,7 @@ js_InitXMLClass(JSContext *cx, JSObject *obj)
const unsigned XML_CTOR_LENGTH = 1;
RootedFunction ctor(cx);
ctor = global->createConstructor(cx, XML, cx->runtime->atomState.XMLAtom, XML_CTOR_LENGTH);
ctor = global->createConstructor(cx, XML, cx->names().XML, XML_CTOR_LENGTH);
if (!ctor)
return NULL;
@ -7435,7 +7435,7 @@ js_InitXMLClass(JSContext *cx, JSObject *obj)
if (!xmllist)
return NULL;
RootedValue value(cx, ObjectValue(*xmlProto));
if (!JSObject::defineProperty(cx, xmllist, cx->runtime->atomState.classPrototypeAtom,
if (!JSObject::defineProperty(cx, xmllist, cx->names().classPrototype,
value, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY))
{
@ -7469,9 +7469,8 @@ GlobalObject::getFunctionNamespace(JSContext *cx, Value *vp)
{
Value v = getSlot(FUNCTION_NS);
if (v.isUndefined()) {
JSRuntime *rt = cx->runtime;
JSLinearString *prefix = rt->atomState.functionAtom;
JSLinearString *uri = rt->atomState.functionNamespaceURIAtom;
HandlePropertyName prefix = cx->names().function;
HandlePropertyName uri = cx->names().functionNamespaceURI;
RootedObject obj(cx, NewXMLNamespace(cx, prefix, uri, JS_FALSE));
if (!obj)
return false;
@ -7648,7 +7647,7 @@ js_GetAnyName(JSContext *cx, jsid *idp)
JS_ASSERT(!obj->getProto());
JSRuntime *rt = cx->runtime;
if (!InitXMLQName(cx, obj, rt->emptyString, rt->emptyString, rt->atomState.starAtom))
if (!InitXMLQName(cx, obj, rt->emptyString, rt->emptyString, rt->atomState.star))
return false;
v.setObject(*obj);
@ -7673,7 +7672,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, MutableHandleObject objp
JS_ASSERT(nameval.isObject());
nameobj = &nameval.toObject();
if (nameobj->getClass() == &AnyNameClass) {
v = STRING_TO_JSVAL(cx->runtime->atomState.starAtom);
v = STRING_TO_JSVAL(cx->names().star);
nameobj = ConstructObjectWithArguments(cx, &QNameClass, 1, &v);
if (!nameobj)
return JS_FALSE;

View File

@ -5026,13 +5026,12 @@ mjit::Compiler::jsop_getprop(PropertyName *name, JSValueType knownType,
*/
RejoinState rejoin = REJOIN_GETTER;
if (forPrototype) {
JS_ASSERT(top->isType(JSVAL_TYPE_OBJECT) &&
name == cx->runtime->atomState.classPrototypeAtom);
JS_ASSERT(top->isType(JSVAL_TYPE_OBJECT) && name == cx->names().classPrototype);
rejoin = REJOIN_THIS_PROTOTYPE;
}
/* Handle length accesses on known strings without using a PIC. */
if (name == cx->runtime->atomState.lengthAtom &&
if (name == cx->names().length &&
top->isType(JSVAL_TYPE_STRING) &&
(!cx->typeInferenceEnabled() || knownPushedType(0) == JSVAL_TYPE_INT32)) {
if (top->isConstant()) {
@ -5052,7 +5051,7 @@ mjit::Compiler::jsop_getprop(PropertyName *name, JSValueType knownType,
}
/* Handle lenth accesses of optimize 'arguments'. */
if (name == cx->runtime->atomState.lengthAtom &&
if (name == cx->names().length &&
cx->typeInferenceEnabled() &&
analysis->poppedTypes(PC, 0)->isMagicArguments() &&
knownPushedType(0) == JSVAL_TYPE_INT32)
@ -6460,15 +6459,15 @@ mjit::Compiler::jsop_getgname(uint32_t index)
{
/* Optimize undefined, NaN and Infinity. */
PropertyName *name = script->getName(index);
if (name == cx->runtime->atomState.undefinedAtom) {
if (name == cx->names().undefined) {
frame.push(UndefinedValue());
return true;
}
if (name == cx->runtime->atomState.NaNAtom) {
if (name == cx->names().NaN) {
frame.push(cx->runtime->NaNValue);
return true;
}
if (name == cx->runtime->atomState.InfinityAtom) {
if (name == cx->names().Infinity) {
frame.push(cx->runtime->positiveInfinityValue);
return true;
}
@ -6796,7 +6795,7 @@ mjit::Compiler::jsop_instanceof()
/* This is sadly necessary because the error case needs the object. */
frame.dup();
if (!jsop_getprop(cx->runtime->atomState.classPrototypeAtom, JSVAL_TYPE_UNKNOWN))
if (!jsop_getprop(cx->names().classPrototype, JSVAL_TYPE_UNKNOWN))
return false;
/* Primitive prototypes are invalid. */
@ -7378,7 +7377,7 @@ mjit::Compiler::constructThis()
break;
}
jsid id = NameToId(cx->runtime->atomState.classPrototypeAtom);
Rooted<jsid> id(cx, NameToId(cx->names().classPrototype));
types::HeapTypeSet *protoTypes = fun->getType(cx)->getProperty(cx, id, false);
JSObject *proto = protoTypes->getSingleton(cx);
@ -7427,7 +7426,7 @@ mjit::Compiler::constructThis()
frame.pushCallee();
// Get callee.prototype.
if (!jsop_getprop(cx->runtime->atomState.classPrototypeAtom, JSVAL_TYPE_UNKNOWN, false, /* forPrototype = */ true))
if (!jsop_getprop(cx->names().classPrototype, JSVAL_TYPE_UNKNOWN, false, /* forPrototype = */ true))
return false;
// Reach into the proto Value and grab a register for its data.

View File

@ -692,22 +692,22 @@ mjit::Compiler::jsop_typeof()
JSAtom *atom = NULL;
switch (fe->getKnownType()) {
case JSVAL_TYPE_STRING:
atom = rt->atomState.stringAtom;
atom = rt->atomState.string;
break;
case JSVAL_TYPE_UNDEFINED:
atom = rt->atomState.undefinedAtom;
atom = rt->atomState.undefined;
break;
case JSVAL_TYPE_NULL:
atom = rt->atomState.objectAtom;
atom = rt->atomState.object;
break;
case JSVAL_TYPE_OBJECT:
atom = NULL;
break;
case JSVAL_TYPE_BOOLEAN:
atom = rt->atomState.booleanAtom;
atom = rt->atomState.boolean;
break;
default:
atom = rt->atomState.numberAtom;
atom = rt->atomState.number;
break;
}
@ -730,13 +730,13 @@ mjit::Compiler::jsop_typeof()
? Assembler::Equal
: Assembler::NotEqual;
if (atom == rt->atomState.undefinedAtom) {
if (atom == rt->atomState.undefined) {
type = JSVAL_TYPE_UNDEFINED;
} else if (atom == rt->atomState.stringAtom) {
} else if (atom == rt->atomState.string) {
type = JSVAL_TYPE_STRING;
} else if (atom == rt->atomState.booleanAtom) {
} else if (atom == rt->atomState.boolean) {
type = JSVAL_TYPE_BOOLEAN;
} else if (atom == rt->atomState.numberAtom) {
} else if (atom == rt->atomState.number) {
type = JSVAL_TYPE_INT32;
/* JSVAL_TYPE_DOUBLE is 0x0 and JSVAL_TYPE_INT32 is 0x1, use <= or > to match both */

View File

@ -849,7 +849,7 @@ LoopState::invariantProperty(const CrossSSAValue &obj, jsid id)
if (skipAnalysis)
return NULL;
if (id == NameToId(cx->runtime->atomState.lengthAtom))
if (id == NameToId(cx->names().length))
return NULL;
uint32_t objSlot;

View File

@ -1984,7 +1984,7 @@ ic::GetProp(VMFrame &f, ic::PICInfo *pic)
VoidStubPIC stub = cached ? DisabledGetPropIC : DisabledGetPropNoCacheIC;
RootedPropertyName name(f.cx, pic->name);
if (name == f.cx->runtime->atomState.lengthAtom) {
if (name == f.cx->names().length) {
if (IsOptimizedArguments(f.fp(), &f.regs.sp[-1])) {
f.regs.sp[-1].setInt32(f.regs.fp()->numActualArgs());
return;
@ -2014,7 +2014,7 @@ ic::GetProp(VMFrame &f, ic::PICInfo *pic)
if (f.regs.sp[-1].isString()) {
GetPropCompiler cc(f, NULL, *pic, name, stub);
if (name == f.cx->runtime->atomState.lengthAtom) {
if (name == f.cx->names().length) {
LookupStatus status = cc.generateStringLengthStub();
if (status == Lookup_Error)
THROW();

View File

@ -1033,7 +1033,7 @@ stubs::GetPropNoCache(VMFrame &f, PropertyName *name)
// Uncached lookups are only used for .prototype accesses at the start of constructors.
JS_ASSERT(lval.isObject());
JS_ASSERT(name == cx->runtime->atomState.classPrototypeAtom);
JS_ASSERT(name == cx->names().classPrototype);
RootedObject obj(cx, &lval.toObject());
RootedValue rval(cx);
@ -1081,7 +1081,7 @@ InitPropOrMethod(VMFrame &f, PropertyName *name, JSOp op)
/* Get the immediate property name into id. */
RootedId id(cx, NameToId(name));
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
if (JS_UNLIKELY(name == cx->names().proto)
? !baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, false)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {

View File

@ -122,9 +122,9 @@ args_delProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValu
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg))
argsobj.markElementDeleted(arg);
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
} else if (JSID_IS_ATOM(id, cx->names().length)) {
argsobj.markLengthOverridden();
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom)) {
} else if (JSID_IS_ATOM(id, cx->names().callee)) {
argsobj.asNormalArguments().clearCallee();
}
return true;
@ -145,11 +145,11 @@ ArgGetter(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg))
vp.set(argsobj.element(arg));
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
} else if (JSID_IS_ATOM(id, cx->names().length)) {
if (!argsobj.hasOverriddenLength())
vp.setInt32(argsobj.initialLength());
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom));
JS_ASSERT(JSID_IS_ATOM(id, cx->names().callee));
if (!argsobj.callee().isMagic(JS_OVERWRITTEN_CALLEE))
vp.set(argsobj.callee());
}
@ -183,8 +183,7 @@ ArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHa
return true;
}
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom) ||
JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom));
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length) || JSID_IS_ATOM(id, cx->names().callee));
}
/*
@ -215,11 +214,11 @@ args_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
return true;
attrs |= JSPROP_ENUMERATE;
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
} else if (JSID_IS_ATOM(id, cx->names().length)) {
if (argsobj->hasOverriddenLength())
return true;
} else {
if (!JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom))
if (!JSID_IS_ATOM(id, cx->names().callee))
return true;
if (argsobj->callee().isMagic(JS_OVERWRITTEN_CALLEE))
@ -247,9 +246,9 @@ args_enumerate(JSContext *cx, HandleObject obj)
int argc = int(argsobj->initialLength());
for (int i = -2; i != argc; i++) {
id = (i == -2)
? NameToId(cx->runtime->atomState.lengthAtom)
? NameToId(cx->names().length)
: (i == -1)
? NameToId(cx->runtime->atomState.calleeAtom)
? NameToId(cx->names().callee)
: INT_TO_JSID(i);
RootedObject pobj(cx);
@ -277,7 +276,7 @@ StrictArgGetter(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg))
vp.set(argsobj.element(arg));
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom));
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length));
if (!argsobj.hasOverriddenLength())
vp.setInt32(argsobj.initialLength());
}
@ -305,7 +304,7 @@ StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Mut
return true;
}
} else {
JS_ASSERT(JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom));
JS_ASSERT(JSID_IS_ATOM(id, cx->names().length));
}
/*
@ -337,14 +336,12 @@ strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
return true;
attrs |= JSPROP_ENUMERATE;
} else if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
} else if (JSID_IS_ATOM(id, cx->names().length)) {
if (argsobj->hasOverriddenLength())
return true;
} else {
if (!JSID_IS_ATOM(id, cx->runtime->atomState.calleeAtom) &&
!JSID_IS_ATOM(id, cx->runtime->atomState.callerAtom)) {
if (!JSID_IS_ATOM(id, cx->names().callee) && !JSID_IS_ATOM(id, cx->names().caller))
return true;
}
attrs = JSPROP_PERMANENT | JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED;
getter = CastAsPropertyOp(argsobj->global().getThrowTypeError());
@ -373,17 +370,17 @@ strictargs_enumerate(JSContext *cx, HandleObject obj)
RootedId id(cx);
// length
id = NameToId(cx->runtime->atomState.lengthAtom);
id = NameToId(cx->names().length);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
// callee
id = NameToId(cx->runtime->atomState.calleeAtom);
id = NameToId(cx->names().callee);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
// caller
id = NameToId(cx->runtime->atomState.callerAtom);
id = NameToId(cx->names().caller);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;

View File

@ -1798,7 +1798,7 @@ Debugger::construct(JSContext *cx, unsigned argc, Value *vp)
/* Get Debugger.prototype. */
RootedValue v(cx);
RootedObject callee(cx, &args.callee());
if (!JSObject::getProperty(cx, callee, callee, cx->runtime->atomState.classPrototypeAtom, &v))
if (!JSObject::getProperty(cx, callee, callee, cx->names().classPrototype, &v))
return false;
RootedObject proto(cx, &v.toObject());
JS_ASSERT(proto->getClass() == &Debugger::jsclass);
@ -2000,7 +2000,7 @@ class Debugger::ScriptQuery {
* scripts scoped to a particular global object.
*/
RootedValue global(cx);
if (!JSObject::getProperty(cx, query, query, cx->runtime->atomState.globalAtom, &global))
if (!JSObject::getProperty(cx, query, query, cx->names().global, &global))
return false;
if (global.isUndefined()) {
matchAllDebuggeeGlobals();
@ -2021,7 +2021,7 @@ class Debugger::ScriptQuery {
}
/* Check for a 'url' property. */
if (!JSObject::getProperty(cx, query, query, cx->runtime->atomState.urlAtom, &url))
if (!JSObject::getProperty(cx, query, query, cx->names().url, &url))
return false;
if (!url.isUndefined() && !url.isString()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
@ -2031,7 +2031,7 @@ class Debugger::ScriptQuery {
/* Check for a 'line' property. */
RootedValue lineProperty(cx);
if (!JSObject::getProperty(cx, query, query, cx->runtime->atomState.lineAtom, &lineProperty))
if (!JSObject::getProperty(cx, query, query, cx->names().line, &lineProperty))
return false;
if (lineProperty.isUndefined()) {
hasLine = false;
@ -2055,7 +2055,7 @@ class Debugger::ScriptQuery {
}
/* Check for an 'innermost' property. */
PropertyName *innermostName = cx->runtime->atomState.innermostAtom;
PropertyName *innermostName = cx->names().innermost;
RootedValue innermostProperty(cx);
if (!JSObject::getProperty(cx, query, query, innermostName, &innermostProperty))
return false;
@ -3065,10 +3065,10 @@ DebuggerFrame_getType(JSContext *cx, unsigned argc, Value *vp)
* order of checks here is significant.
*/
args.rval().setString(fp->isEvalFrame()
? cx->runtime->atomState.evalAtom
? cx->names().eval
: fp->isGlobalFrame()
? cx->runtime->atomState.globalAtom
: cx->runtime->atomState.callAtom);
? cx->names().global
: cx->names().call);
return true;
}
@ -3234,7 +3234,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
JS_ASSERT(fp->numActualArgs() <= 0x7fffffff);
unsigned fargc = fp->numActualArgs();
RootedValue fargcVal(cx, Int32Value(fargc));
if (!DefineNativeProperty(cx, argsobj, cx->runtime->atomState.lengthAtom,
if (!DefineNativeProperty(cx, argsobj, cx->names().length,
fargcVal, NULL, NULL,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))
{

View File

@ -75,7 +75,7 @@ ProtoGetterImpl(JSContext *cx, CallArgs args)
unsigned dummy;
RootedObject obj(cx, &args.thisv().toObject());
RootedId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
RootedId nid(cx, NameToId(cx->names().proto));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSACC_PROTO, &v, &dummy))
return false;
@ -154,7 +154,7 @@ ProtoSetterImpl(JSContext *cx, CallArgs args)
Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());
unsigned dummy;
RootedId nid(cx, NameToId(cx->runtime->atomState.protoAtom));
RootedId nid(cx, NameToId(cx->names().proto));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), &v, &dummy))
return false;
@ -348,7 +348,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
if (!ctor)
return NULL;
objectCtor = js_NewFunction(cx, ctor, js_Object, 1, JSFUN_CONSTRUCTOR, self,
cx->runtime->atomState.ObjectAtom);
cx->names().Object);
if (!objectCtor)
return NULL;
}
@ -367,7 +367,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
if (!ctor)
return NULL;
functionCtor = js_NewFunction(cx, ctor, Function, 1, JSFUN_CONSTRUCTOR, self,
cx->runtime->atomState.FunctionAtom);
cx->names().Function);
if (!functionCtor)
return NULL;
JS_ASSERT(ctor == functionCtor);
@ -404,7 +404,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
return NULL;
RootedValue undefinedValue(cx, UndefinedValue());
if (!JSObject::defineProperty(cx, objectProto,
cx->runtime->atomState.protoAtom, undefinedValue,
cx->names().proto, undefinedValue,
JS_DATA_TO_FUNC_PTR(PropertyOp, getter.get()),
JS_DATA_TO_FUNC_PTR(StrictPropertyOp, setter.get()),
JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED))
@ -424,17 +424,17 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
}
/* Add the global Function and Object properties now. */
jsid objectId = NameToId(cx->runtime->atomState.ObjectAtom);
jsid objectId = NameToId(cx->names().Object);
if (!self->addDataProperty(cx, objectId, JSProto_Object + JSProto_LIMIT * 2, 0))
return NULL;
jsid functionId = NameToId(cx->runtime->atomState.FunctionAtom);
jsid functionId = NameToId(cx->names().Function);
if (!self->addDataProperty(cx, functionId, JSProto_Function + JSProto_LIMIT * 2, 0))
return NULL;
/* Heavy lifting done, but lingering tasks remain. */
/* ES5 15.1.2.1. */
RootedId id(cx, NameToId(cx->runtime->atomState.evalAtom));
RootedId id(cx, NameToId(cx->names().eval));
JSObject *evalobj = js_DefineFunction(cx, self, id, IndirectEval, 1, JSFUN_STUB_GSOPS);
if (!evalobj)
return NULL;
@ -504,11 +504,9 @@ GlobalObject::create(JSContext *cx, Class *clasp)
/* static */ bool
GlobalObject::initStandardClasses(JSContext *cx, Handle<GlobalObject*> global)
{
JSAtomState &state = cx->runtime->atomState;
/* Define a top-level property 'undefined' with the undefined value. */
RootedValue undefinedValue(cx, UndefinedValue());
if (!JSObject::defineProperty(cx, global, state.undefinedAtom, undefinedValue,
if (!JSObject::defineProperty(cx, global, cx->names().undefined, undefinedValue,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_PERMANENT | JSPROP_READONLY))
{
return false;
@ -601,10 +599,10 @@ LinkConstructorAndPrototype(JSContext *cx, JSObject *ctor_, JSObject *proto_)
RootedValue protoVal(cx, ObjectValue(*proto));
RootedValue ctorVal(cx, ObjectValue(*ctor));
return JSObject::defineProperty(cx, ctor, cx->runtime->atomState.classPrototypeAtom,
return JSObject::defineProperty(cx, ctor, cx->names().classPrototype,
protoVal, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT | JSPROP_READONLY) &&
JSObject::defineProperty(cx, proto, cx->runtime->atomState.constructorAtom,
JSObject::defineProperty(cx, proto, cx->names().constructor,
ctorVal, JS_PropertyStub, JS_StrictPropertyStub, 0);
}

View File

@ -333,26 +333,26 @@ RegExpObject::assignInitialShape(JSContext *cx)
RootedObject self(cx, this);
/* The lastIndex property alone is writable but non-configurable. */
if (!addDataProperty(cx, NameToId(cx->runtime->atomState.lastIndexAtom),
if (!addDataProperty(cx, NameToId(cx->names().lastIndex),
LAST_INDEX_SLOT, JSPROP_PERMANENT))
{
return NULL;
}
/* Remaining instance properties are non-writable and non-configurable. */
if (!self->addDataProperty(cx, NameToId(cx->runtime->atomState.sourceAtom),
if (!self->addDataProperty(cx, NameToId(cx->names().source),
SOURCE_SLOT, JSPROP_PERMANENT | JSPROP_READONLY) ||
!self->addDataProperty(cx, NameToId(cx->runtime->atomState.globalAtom),
!self->addDataProperty(cx, NameToId(cx->names().global),
GLOBAL_FLAG_SLOT, JSPROP_PERMANENT | JSPROP_READONLY) ||
!self->addDataProperty(cx, NameToId(cx->runtime->atomState.ignoreCaseAtom),
!self->addDataProperty(cx, NameToId(cx->names().ignoreCase),
IGNORE_CASE_FLAG_SLOT, JSPROP_PERMANENT | JSPROP_READONLY) ||
!self->addDataProperty(cx, NameToId(cx->runtime->atomState.multilineAtom),
!self->addDataProperty(cx, NameToId(cx->names().multiline),
MULTILINE_FLAG_SLOT, JSPROP_PERMANENT | JSPROP_READONLY))
{
return NULL;
}
return self->addDataProperty(cx, NameToId(cx->runtime->atomState.stickyAtom),
return self->addDataProperty(cx, NameToId(cx->names().sticky),
STICKY_FLAG_SLOT, JSPROP_PERMANENT | JSPROP_READONLY);
}
@ -374,18 +374,17 @@ RegExpObject::init(JSContext *cx, HandleAtom source, RegExpFlag flags)
JS_ASSERT(!self->nativeEmpty());
}
DebugOnly<JSAtomState *> atomState = &cx->runtime->atomState;
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->lastIndexAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().lastIndex))->slot() ==
LAST_INDEX_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->sourceAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().source))->slot() ==
SOURCE_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->globalAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().global))->slot() ==
GLOBAL_FLAG_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->ignoreCaseAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().ignoreCase))->slot() ==
IGNORE_CASE_FLAG_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->multilineAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().multiline))->slot() ==
MULTILINE_FLAG_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(atomState->stickyAtom))->slot() ==
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().sticky))->slot() ==
STICKY_FLAG_SLOT);
/*

View File

@ -127,7 +127,7 @@ js::ScopeCoordinateName(JSRuntime *rt, JSScript *script, jsbytecode *pc)
/* Beware nameless destructuring formal. */
if (!JSID_IS_ATOM(id))
return rt->atomState.emptyAtom;
return rt->atomState.empty;
return JSID_TO_ATOM(id)->asPropertyName();
}
@ -1226,7 +1226,7 @@ class DebugScopeProxy : public BaseProxyHandler
static bool isArguments(JSContext *cx, jsid id)
{
return id == NameToId(cx->runtime->atomState.argumentsAtom);
return id == NameToId(cx->names().arguments);
}
static bool isFunctionScope(ScopeObject &scope)
@ -1381,9 +1381,8 @@ class DebugScopeProxy : public BaseProxyHandler
{
ScopeObject &scope = proxy->asDebugScope().scope();
if (isMissingArgumentsBinding(scope) &&
!props.append(NameToId(cx->runtime->atomState.argumentsAtom)))
{
if (isMissingArgumentsBinding(scope)) {
if (!props.append(NameToId(cx->names().arguments)))
return false;
}

View File

@ -688,7 +688,7 @@ StackSpace::markAndClobberFrame(JSTracer *trc, StackFrame *fp, Value *slotsEnd,
else if (type == JSVAL_TYPE_BOOLEAN)
*vp = BooleanValue(false);
else if (type == JSVAL_TYPE_STRING)
*vp = StringValue(rt->atomState.nullAtom);
*vp = StringValue(rt->atomState.null);
else if (type == JSVAL_TYPE_NULL)
*vp = NullValue();
else if (type == JSVAL_TYPE_OBJECT)

View File

@ -43,7 +43,7 @@ StringBuffer::finishString()
{
JSContext *cx = context();
if (cb.empty())
return cx->runtime->atomState.emptyAtom;
return cx->names().empty;
size_t length = cb.length();
if (!JSString::validateLength(cx, length))
@ -73,7 +73,7 @@ StringBuffer::finishAtom()
size_t length = cb.length();
if (length == 0)
return cx->runtime->atomState.emptyAtom;
return cx->names().empty;
JSAtom *atom = AtomizeChars(cx, cb.begin(), length);
cb.clear();
@ -94,7 +94,7 @@ js::ValueToStringBufferSlow(JSContext *cx, const Value &arg, StringBuffer &sb)
if (v.isBoolean())
return BooleanToStringBuffer(cx, v.toBoolean(), sb);
if (v.isNull())
return sb.append(cx->runtime->atomState.nullAtom);
return sb.append(cx->names().null);
JS_ASSERT(v.isUndefined());
return sb.append(cx->runtime->atomState.undefinedAtom);
return sb.append(cx->names().undefined);
}

View File

@ -38,8 +38,7 @@ StringObject::init(JSContext *cx, HandleString str)
}
}
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->runtime->atomState.lengthAtom))->slot()
== LENGTH_SLOT);
JS_ASSERT(self->nativeLookupNoAllocation(NameToId(cx->names().length))->slot() == LENGTH_SLOT);
self->setStringThis(str);