Address bug 700501 review comments, r=luke.

This commit is contained in:
Brian Hackett 2011-11-18 13:59:48 -08:00
parent 0174f509ce
commit 3854e8c2db
4 changed files with 18 additions and 6 deletions

View File

@ -3819,7 +3819,12 @@ js_InitArrayClass(JSContext *cx, JSObject *obj)
if (!ctor)
return NULL;
/* The default 'new' object for Array.prototype has unknown properties. */
/*
* The default 'new' type of Array.prototype is required by type inference
* to have unknown properties, to simplify handling of e.g. heterogenous
* arrays in JSON and script literals and allows setDenseArrayElement to
* be used without updating the indexed type set for such default arrays.
*/
if (!arrayProto->setNewTypeUnknown(cx))
return NULL;

View File

@ -5781,8 +5781,7 @@ JSObject::setNewTypeUnknown(JSContext *cx)
*/
TypeObjectSet &table = cx->compartment->newTypeObjects;
if (table.initialized()) {
TypeObjectSet::Ptr p = table.lookup(this);
if (p)
if (TypeObjectSet::Ptr p = table.lookup(this))
MarkTypeObjectUnknownProperties(cx, *p);
}

View File

@ -845,9 +845,7 @@ struct JSObject : js::gc::Cell
/*
* Mark an object as requiring its default 'new' type to have unknown
* properties. This is set for a few builtins like Object.prototype and
* Array.prototype; several places in the VM require that the default
* type for these objects have unknown contents.
* properties.
*/
bool setNewTypeUnknown(JSContext *cx);

View File

@ -106,6 +106,11 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
if (!objectProto || !objectProto->setSingletonType(cx))
return NULL;
/*
* The default 'new' type of Object.prototype is required by type inference
* to have unknown properties, to simplify handling of e.g. heterogenous
* objects in JSON and script literals.
*/
if (!objectProto->setNewTypeUnknown(cx))
return NULL;
@ -140,6 +145,11 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
if (!proto->setSingletonType(cx))
return NULL;
/*
* The default 'new' type of Function.prototype is required by type
* inference to have unknown properties, to simplify handling of e.g.
* CloneFunctionObject.
*/
if (!proto->setNewTypeUnknown(cx))
return NULL;
}