Bug 1447442 - Part 4: Move some definitions to where they are used. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 13 Apr 2018 02:25:59 -0700
changeset 413332 5965536457835e02ce0e412349ed00fe541ca661
parent 413331 236f58368a5035b629217ccfeff52ed80f46142e
child 413333 a5cdb5568e441dc8bd676ee93a94293b5c55493f
push id33843
push usernerli@mozilla.com
push dateSat, 14 Apr 2018 09:49:25 +0000
treeherdermozilla-central@37b8862d354e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1447442
milestone61.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 1447442 - Part 4: Move some definitions to where they are used. r=jorendorff
js/src/builtin/JSON.h
js/src/builtin/intl/IntlObject.h
js/src/jsmath.h
js/src/vm/GlobalObject.cpp
js/src/vm/GlobalObject.h
js/src/vm/JSAtom.cpp
js/src/vm/JSAtom.h
js/src/vm/JSObject.cpp
js/src/vm/JSObject.h
js/src/vm/SavedStacks.h
--- a/js/src/builtin/JSON.h
+++ b/js/src/builtin/JSON.h
@@ -9,18 +9,22 @@
 
 #include "mozilla/Range.h"
 
 #include "NamespaceImports.h"
 
 #include "js/RootingAPI.h"
 
 namespace js {
+
+struct Class;
 class StringBuffer;
 
+extern const Class JSONClass;
+
 extern JSObject*
 InitJSONClass(JSContext* cx, HandleObject obj);
 
 enum class StringifyBehavior {
     Normal,
     RestrictedSafe
 };
 
--- a/js/src/builtin/intl/IntlObject.h
+++ b/js/src/builtin/intl/IntlObject.h
@@ -9,16 +9,20 @@
 
 #include "mozilla/Attributes.h"
 
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 
 namespace js {
 
+struct Class;
+
+extern const Class IntlClass;
+
 /**
  * Initializes the Intl Object and its standard built-in properties.
  * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
  */
 extern JSObject*
 InitIntlClass(JSContext* cx, JS::Handle<JSObject*> obj);
 
 /**
--- a/js/src/jsmath.h
+++ b/js/src/jsmath.h
@@ -11,16 +11,18 @@
 
 #include <cmath>
 #include <stdint.h>
 
 #include "NamespaceImports.h"
 
 namespace js {
 
+struct Class;
+
 typedef double (*UnaryFunType)(double);
 
 class MathCache
 {
   public:
     enum MathFuncId {
         Zero,
         Sin, Cos, Tan, Sinh, Cosh, Tanh, Asin, Acos, Atan, Asinh, Acosh, Atanh,
@@ -79,16 +81,18 @@ class MathCache
 
     size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
 };
 
 /*
  * JS math functions.
  */
 
+extern const Class MathClass;
+
 extern JSObject*
 InitMathClass(JSContext* cx, HandleObject obj);
 
 extern uint64_t
 GenerateRandomSeed();
 
 // Fill |seed[0]| and |seed[1]| with random bits, suitable for
 // seeding a XorShift128+ random number generator.
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -4,22 +4,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/GlobalObject.h"
 
 #include "jsdate.h"
 #include "jsexn.h"
 #include "jsfriendapi.h"
-#include "jsmath.h"
 
 #include "builtin/AtomicsObject.h"
 #include "builtin/DataViewObject.h"
 #include "builtin/Eval.h"
-#include "builtin/JSON.h"
 #include "builtin/MapObject.h"
 #include "builtin/ModuleObject.h"
 #include "builtin/Object.h"
 #include "builtin/Promise.h"
 #include "builtin/RegExp.h"
 #include "builtin/SelfHostingDefines.h"
 #include "builtin/Stream.h"
 #include "builtin/Symbol.h"
@@ -30,32 +28,36 @@
 #include "js/ProtoKey.h"
 #include "vm/Debugger.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/HelperThreads.h"
 #include "vm/JSContext.h"
 #include "vm/PIC.h"
 #include "vm/RegExpStatics.h"
 #include "vm/RegExpStaticsObject.h"
-#include "wasm/WasmJS.h"
 
 #include "vm/JSCompartment-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 struct ProtoTableEntry {
     const Class* clasp;
     ClassInitializerOp init;
 };
 
 namespace js {
 
+extern const Class IntlClass;
+extern const Class JSONClass;
+extern const Class MathClass;
+extern const Class WebAssemblyClass;
+
 #define DECLARE_PROTOTYPE_CLASS_INIT(name,init,clasp) \
     extern JSObject* init(JSContext* cx, Handle<JSObject*> obj);
 JS_FOR_EACH_PROTOTYPE(DECLARE_PROTOTYPE_CLASS_INIT)
 #undef DECLARE_PROTOTYPE_CLASS_INIT
 
 } // namespace js
 
 JSObject*
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -186,28 +186,16 @@ class GlobalObject : public NativeObject
     Value getPrototype(JSProtoKey key) const {
         return getSlot(prototypeSlot(key));
     }
 
     void setPrototype(JSProtoKey key, const Value& value) {
         setSlot(prototypeSlot(key), value);
     }
 
-    bool classIsInitialized(JSProtoKey key) const {
-        bool inited = !getConstructor(key).isUndefined();
-        MOZ_ASSERT(inited == !getPrototype(key).isUndefined());
-        return inited;
-    }
-
-    bool functionObjectClassesInitialized() const {
-        bool inited = classIsInitialized(JSProto_Function);
-        MOZ_ASSERT(inited == classIsInitialized(JSProto_Object));
-        return inited;
-    }
-
     /*
      * Lazy standard classes need a way to indicate they have been initialized.
      * Otherwise, when we delete them, we might accidentally recreate them via
      * a lazy initialization. We use the presence of an object in the
      * getConstructor(key) reserved slot to indicate that they've been
      * initialized.
      *
      * Note: A few builtin objects, like JSON and Math, are not constructors,
@@ -218,16 +206,28 @@ class GlobalObject : public NativeObject
         Value value = getConstructor(key);
         MOZ_ASSERT(value.isUndefined() ||
                    value.isObject() ||
                    value.isMagic(JS_OFF_THREAD_CONSTRUCTOR));
         return !value.isUndefined();
     }
 
   private:
+    bool classIsInitialized(JSProtoKey key) const {
+        bool inited = !getConstructor(key).isUndefined();
+        MOZ_ASSERT(inited == !getPrototype(key).isUndefined());
+        return inited;
+    }
+
+    bool functionObjectClassesInitialized() const {
+        bool inited = classIsInitialized(JSProto_Function);
+        MOZ_ASSERT(inited == classIsInitialized(JSProto_Object));
+        return inited;
+    }
+
     bool arrayClassInitialized() const {
         return classIsInitialized(JSProto_Array);
     }
 
     bool booleanClassInitialized() const {
         return classIsInitialized(JSProto_Boolean);
     }
     bool numberClassInitialized() const {
--- a/js/src/vm/JSAtom.cpp
+++ b/js/src/vm/JSAtom.cpp
@@ -127,20 +127,16 @@ js::AtomToPrintableString(JSContext* cx,
 #define DEFINE_PROTO_STRING(name,init,clasp) const char js_##name##_str[] = #name;
 JS_FOR_EACH_PROTOTYPE(DEFINE_PROTO_STRING)
 #undef DEFINE_PROTO_STRING
 
 #define CONST_CHAR_STR(idpart, id, text) const char js_##idpart##_str[] = text;
 FOR_EACH_COMMON_PROPERTYNAME(CONST_CHAR_STR)
 #undef CONST_CHAR_STR
 
-/* Constant strings that are not atomized. */
-const char js_getter_str[]          = "getter";
-const char js_setter_str[]          = "setter";
-
 // Use a low initial capacity for atom hash tables to avoid penalizing runtimes
 // which create a small number of atoms.
 static const uint32_t JS_STRING_HASH_COUNT = 64;
 
 MOZ_ALWAYS_INLINE AtomSet::Ptr
 js::FrozenAtomSet::readonlyThreadsafeLookup(const AtomSet::Lookup& l) const
 {
     return mSet->readonlyThreadsafeLookup(l);
--- a/js/src/vm/JSAtom.h
+++ b/js/src/vm/JSAtom.h
@@ -32,20 +32,16 @@ class PropertyName;
 #define DECLARE_PROTO_STR(name,init,clasp) extern const char js_##name##_str[];
 JS_FOR_EACH_PROTOTYPE(DECLARE_PROTO_STR)
 #undef DECLARE_PROTO_STR
 
 #define DECLARE_CONST_CHAR_STR(idpart, id, text)  extern const char js_##idpart##_str[];
 FOR_EACH_COMMON_PROPERTYNAME(DECLARE_CONST_CHAR_STR)
 #undef DECLARE_CONST_CHAR_STR
 
-/* Constant strings that are not atomized. */
-extern const char js_getter_str[];
-extern const char js_setter_str[];
-
 namespace js {
 
 class AutoLockForExclusiveAccess;
 
 /*
  * Atom tracing and garbage collection hooks.
  */
 void
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -267,16 +267,19 @@ js::Throw(JSContext* cx, jsid id, unsign
     }
 
     return false;
 }
 
 
 /*** PropertyDescriptor operations and DefineProperties ******************************************/
 
+static const char js_getter_str[] = "getter";
+static const char js_setter_str[] = "setter";
+
 static Result<>
 CheckCallable(JSContext* cx, JSObject* obj, const char* fieldName)
 {
     if (obj && !obj->isCallable()) {
         JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD,
                                   fieldName);
         return cx->alreadyReportedError();
     }
--- a/js/src/vm/JSObject.h
+++ b/js/src/vm/JSObject.h
@@ -29,20 +29,16 @@ class GCMarker;
 class Nursery;
 
 namespace gc {
 class RelocationOverlay;
 } // namespace gc
 
 /******************************************************************************/
 
-extern const Class IntlClass;
-extern const Class JSONClass;
-extern const Class MathClass;
-
 class GlobalObject;
 class NewObjectCache;
 
 enum class IntegrityLevel {
     Sealed,
     Frozen
 };
 
--- a/js/src/vm/SavedStacks.h
+++ b/js/src/vm/SavedStacks.h
@@ -6,18 +6,16 @@
 
 #ifndef vm_SavedStacks_h
 #define vm_SavedStacks_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/FastBernoulliTrial.h"
 #include "mozilla/Maybe.h"
 
-#include "jsmath.h"
-
 #include "js/HashTable.h"
 #include "js/Wrapper.h"
 #include "vm/JSContext.h"
 #include "vm/SavedFrame.h"
 #include "vm/Stack.h"
 
 namespace js {