Bug 933681 - Rename the tables in jsapi.cpp to something that makes sense. r=jorendorff
authorBobby Holley <bobbyholley@gmail.com>
Fri, 22 Nov 2013 10:55:42 -0800
changeset 157064 497280442d1ddcbaee8b70a6e57770d15f6a0638
parent 157063 72db5a6ae5c8c5e345eb51e51d93c7086e72c3e4
child 157065 98881f65a6656a258b6b8338120ffe47184b15df
push id36628
push userbobbyholley@gmail.com
push dateFri, 22 Nov 2013 18:55:55 +0000
treeherdermozilla-inbound@061c63d261e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs933681
milestone28.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
Bug 933681 - Rename the tables in jsapi.cpp to something that makes sense. r=jorendorff
js/src/jsapi.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1195,27 +1195,26 @@ LookupStdName(JSRuntime *rt, HandleStrin
 
 /*
  * Table of standard classes, indexed by JSProtoKey. For entries where the
  * JSProtoKey does not correspond to a class with a meaningful constructor, we
  * insert a null entry into the table.
  */
 #define STD_NAME_ENTRY(name, code, init, clasp) { init, EAGER_CLASS_ATOM(name), clasp },
 #define STD_DUMMY_ENTRY(name, code, init, dummy) { DummyInit, 0, nullptr },
-static const JSStdName standard_class_atoms[] = {
+static const JSStdName standard_class_names[] = {
   JS_FOR_PROTOTYPES(STD_NAME_ENTRY, STD_DUMMY_ENTRY)
   { nullptr, 0, nullptr }
 };
 
 /*
- * Table of top-level function and constant names and their init functions.
- * If you add a "standard" global function or property, remember to update
- * this table.
+ * Table of top-level function and constant names and the init function of the
+ * corresponding standard class that sets them up.
  */
-static const JSStdName standard_class_names[] = {
+static const JSStdName builtin_property_names[] = {
     {js_InitObjectClass,        EAGER_ATOM(eval), &JSObject::class_},
 
     /* Global properties and functions defined by the Number class. */
     {js_InitNumberClass,        EAGER_ATOM(NaN), OCLASP(Number)},
     {js_InitNumberClass,        EAGER_ATOM(Infinity), OCLASP(Number)},
     {js_InitNumberClass,        EAGER_ATOM(isNaN), OCLASP(Number)},
     {js_InitNumberClass,        EAGER_ATOM(isFinite), OCLASP(Number)},
     {js_InitNumberClass,        EAGER_ATOM(parseFloat), OCLASP(Number)},
@@ -1292,21 +1291,21 @@ JS_ResolveStandardClass(JSContext *cx, H
         RootedValue undefinedValue(cx, UndefinedValue());
         return JSObject::defineProperty(cx, obj, undefinedAtom->asPropertyName(),
                                         undefinedValue,
                                         JS_PropertyStub, JS_StrictPropertyStub,
                                         JSPROP_PERMANENT | JSPROP_READONLY);
     }
 
     /* Try for class constructors/prototypes named by well-known atoms. */
-    stdnm = LookupStdName(rt, idstr, standard_class_atoms);
+    stdnm = LookupStdName(rt, idstr, standard_class_names);
 
     /* Try less frequently used top-level functions and constants. */
     if (!stdnm)
-        stdnm = LookupStdName(rt, idstr, standard_class_names);
+        stdnm = LookupStdName(rt, idstr, builtin_property_names);
 
     /*
      * Try even less frequently used names delegated from the global
      * object to Object.prototype, but only if the Object class hasn't
      * yet been initialized.
      */
     if (!stdnm) {
         RootedObject proto(cx);
@@ -1350,19 +1349,26 @@ JS_EnumerateStandardClasses(JSContext *c
     RootedValue undefinedValue(cx, UndefinedValue());
     if (!obj->nativeContains(cx, undefinedName) &&
         !JSObject::defineProperty(cx, obj, undefinedName, undefinedValue,
                                   JS_PropertyStub, JS_StrictPropertyStub,
                                   JSPROP_PERMANENT | JSPROP_READONLY)) {
         return false;
     }
 
-    /* Initialize any classes that have not been initialized yet. */
-    for (unsigned i = 0; standard_class_atoms[i].init; i++) {
-        const JSStdName &stdnm = standard_class_atoms[i];
+    /*
+     * Initialize any classes that have not been initialized yet. Note that
+     * resolving everything in standard_class_names has the effect of resolving
+     * everything in builtin_property_names, so we don't need to iterate over
+     * that separately. Moreover, we'll resolve the Object constructor as well,
+     * so we can also skip object_prototype_names.
+     */
+    for (unsigned i = 0; standard_class_names[i].init; i++) {
+        const JSStdName &stdnm = standard_class_names[i];
+        // Watch out for dummy entries.
         if (!stdnm.isDummy() && !obj->as<GlobalObject>().isStandardClassResolved(stdnm.clasp)) {
             if (!stdnm.init(cx, obj))
                 return false;
         }
     }
 
     return true;
 }