Address bug 700501 review comments, r=luke.
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 18 Nov 2011 13:59:48 -0800
changeset 82964 5fc138076bd6f58763d210a41cc38ebfe0710fd4
parent 82963 073ff2185f16e08e48499fd4f2e838d7cc9c67db
child 82965 94f8d3e3f2426c4a7c579428c4489fd073a96f9f
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs700501
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Address bug 700501 review comments, r=luke.
js/src/jsarray.cpp
js/src/jsinfer.cpp
js/src/jsobj.h
js/src/vm/GlobalObject.cpp
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -3814,17 +3814,22 @@ js_InitArrayClass(JSContext *cx, JSObjec
         return NULL;
     arrayProto->setArrayLength(cx, 0);
 
     JSFunction *ctor = global->createConstructor(cx, js_Array, &ArrayClass,
                                                  CLASS_ATOM(cx, Array), 1);
     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;
 
     if (!LinkConstructorAndPrototype(cx, ctor, arrayProto))
         return NULL;
 
     if (!DefinePropertiesAndBrand(cx, arrayProto, NULL, array_methods) ||
         !DefinePropertiesAndBrand(cx, ctor, NULL, array_static_methods))
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -5776,18 +5776,17 @@ JSObject::setNewTypeUnknown(JSContext *c
 
     /*
      * If the object already has a new type, mark that type as unknown. It will
      * not have the SETS_MARKED_UNKNOWN bit set, so may require a type set
      * crawl if prototypes of the object change dynamically in the future.
      */
     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);
     }
 
     return true;
 }
 
 TypeObject *
 JSObject::getNewType(JSContext *cx, JSFunction *fun)
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -840,19 +840,17 @@ struct JSObject : js::gc::Cell
      * Mark an object that has been iterated over and is a singleton. We need
      * to recover this information in the object's type information after it
      * is purged on GC.
      */
     inline bool setIteratedSingleton(JSContext *cx);
 
     /*
      * 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);
 
     /* Set a new prototype for an object with a singleton type. */
     bool splicePrototype(JSContext *cx, JSObject *proto);
 
     /*
      * For bootstrapping, whether to splice a prototype for Function.prototype
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -101,16 +101,21 @@ GlobalObject::initFunctionAndObjectClass
     /*
      * Create |Object.prototype| first, mirroring CreateBlankProto but for the
      * prototype of the created object.
      */
     JSObject *objectProto = NewObjectWithGivenProto(cx, &ObjectClass, NULL, this);
     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;
 
     /* Create |Function.prototype| next so we can create other functions. */
     JSFunction *functionProto;
     {
         JSObject *proto = NewObjectWithGivenProto(cx, &FunctionClass, objectProto, this);
         if (!proto)
@@ -135,16 +140,21 @@ GlobalObject::initFunctionAndObjectClass
         script->code[1] = SRC_NULL;
         functionProto->initScript(script);
         functionProto->getType(cx)->interpretedFunction = functionProto;
         script->setFunction(functionProto);
 
         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;
     }
 
     /* Create the Object function now that we have a [[Prototype]] for it. */
     jsid objectId = ATOM_TO_JSID(CLASS_ATOM(cx, Object));
     JSFunction *objectCtor;
     {