Bug 1530745 - Part 2: Move declarations from JSFunction.h as static entries to JSFunction.cpp. r=arai
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 08 Mar 2019 12:34:49 +0000
changeset 521217 4e633d85d45d
parent 521216 8e4f92791cd3
child 521218 588b9eec2edb
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1530745
milestone67.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 1530745 - Part 2: Move declarations from JSFunction.h as static entries to JSFunction.cpp. r=arai Depends on D22665 Differential Revision: https://phabricator.services.mozilla.com/D22667
js/src/vm/JSFunction.cpp
js/src/vm/JSFunction.h
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -677,17 +677,17 @@ template XDRResult js::XDRInterpretedFun
                                               MutableHandleFunction);
 
 template XDRResult js::XDRInterpretedFunction(XDRState<XDR_DECODE>*,
                                               HandleScope,
                                               HandleScriptSourceObject,
                                               MutableHandleFunction);
 
 /* ES6 (04-25-16) 19.2.3.6 Function.prototype [ @@hasInstance ] */
-bool js::fun_symbolHasInstance(JSContext* cx, unsigned argc, Value* vp) {
+static bool fun_symbolHasInstance(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
 
   if (args.length() < 1) {
     args.rval().setBoolean(false);
     return true;
   }
 
   /* Step 1. */
@@ -825,36 +825,16 @@ static JSObject* CreateFunctionPrototype
   RootedObject objectProto(cx, &self->getPrototype(JSProto_Object).toObject());
 
   return NewFunctionWithProto(cx, FunctionPrototype, 0, JSFunction::NATIVE_FUN,
                               nullptr, HandlePropertyName(cx->names().empty),
                               objectProto, gc::AllocKind::FUNCTION,
                               SingletonObject);
 }
 
-static const ClassOps JSFunctionClassOps = {
-    nullptr,                                /* addProperty */
-    nullptr,                                /* delProperty */
-    fun_enumerate, nullptr,                 /* newEnumerate */
-    fun_resolve,   fun_mayResolve, nullptr, /* finalize    */
-    nullptr,                                /* call        */
-    nullptr,       nullptr,                 /* construct   */
-    fun_trace,
-};
-
-static const ClassSpec JSFunctionClassSpec = {
-    CreateFunctionConstructor, CreateFunctionPrototype, nullptr, nullptr,
-    function_methods,          function_properties};
-
-const Class JSFunction::class_ = {js_Function_str,
-                                  JSCLASS_HAS_CACHED_PROTO(JSProto_Function),
-                                  &JSFunctionClassOps, &JSFunctionClassSpec};
-
-const Class* const js::FunctionClassPtr = &JSFunction::class_;
-
 JSString* js::FunctionToStringCache::lookup(JSScript* script) const {
   for (size_t i = 0; i < NumEntries; i++) {
     if (entries_[i].script == script) {
       return entries_[i].string;
     }
   }
   return nullptr;
 }
@@ -1054,17 +1034,17 @@ bool js::FunctionHasDefaultHasInstance(J
                                        const WellKnownSymbols& symbols) {
   jsid id = SYMBOL_TO_JSID(symbols.hasInstance);
   Shape* shape = fun->lookupPure(id);
   if (shape) {
     if (!shape->isDataProperty()) {
       return false;
     }
     const Value hasInstance = fun->as<NativeObject>().getSlot(shape->slot());
-    return IsNativeFunction(hasInstance, js::fun_symbolHasInstance);
+    return IsNativeFunction(hasInstance, fun_symbolHasInstance);
   }
   return true;
 }
 
 bool js::fun_toString(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   MOZ_ASSERT(IsFunctionObject(args.calleev()));
 
@@ -1206,16 +1186,46 @@ bool js::fun_apply(JSContext* cx, unsign
       return false;
     }
   }
 
   // Step 9.
   return Call(cx, fval, args[0], args2, args.rval());
 }
 
+static const JSFunctionSpec function_methods[] = {
+    JS_FN(js_toSource_str, fun_toSource, 0, 0),
+    JS_FN(js_toString_str, fun_toString, 0, 0),
+    JS_FN(js_apply_str, fun_apply, 2, 0),
+    JS_FN(js_call_str, fun_call, 1, 0),
+    JS_SELF_HOSTED_FN("bind", "FunctionBind", 2, 0),
+    JS_SYM_FN(hasInstance, fun_symbolHasInstance, 1,
+              JSPROP_READONLY | JSPROP_PERMANENT),
+    JS_FS_END};
+
+static const ClassOps JSFunctionClassOps = {
+    nullptr,                                /* addProperty */
+    nullptr,                                /* delProperty */
+    fun_enumerate, nullptr,                 /* newEnumerate */
+    fun_resolve,   fun_mayResolve, nullptr, /* finalize    */
+    nullptr,                                /* call        */
+    nullptr,       nullptr,                 /* construct   */
+    fun_trace,
+};
+
+static const ClassSpec JSFunctionClassSpec = {
+    CreateFunctionConstructor, CreateFunctionPrototype, nullptr, nullptr,
+    function_methods,          function_properties};
+
+const Class JSFunction::class_ = {js_Function_str,
+                                  JSCLASS_HAS_CACHED_PROTO(JSProto_Function),
+                                  &JSFunctionClassOps, &JSFunctionClassSpec};
+
+const Class* const js::FunctionClassPtr = &JSFunction::class_;
+
 bool JSFunction::isDerivedClassConstructor() {
   bool derived;
   if (isInterpretedLazy()) {
     // There is only one plausible lazy self-hosted derived
     // constructor.
     if (isSelfHostedBuiltin()) {
       JSAtom* name =
           &getExtendedSlot(LAZY_FUNCTION_NAME_SLOT).toString()->asAtom();
@@ -1751,26 +1761,16 @@ void JSFunction::maybeRelazify(JSRuntime
     MOZ_ASSERT(isSelfHostedBuiltin());
     MOZ_ASSERT(isExtended());
     MOZ_ASSERT(getExtendedSlot(LAZY_FUNCTION_NAME_SLOT).toString()->isAtom());
   }
 
   realm->scheduleDelazificationForDebugger();
 }
 
-const JSFunctionSpec js::function_methods[] = {
-    JS_FN(js_toSource_str, fun_toSource, 0, 0),
-    JS_FN(js_toString_str, fun_toString, 0, 0),
-    JS_FN(js_apply_str, fun_apply, 2, 0),
-    JS_FN(js_call_str, fun_call, 1, 0),
-    JS_SELF_HOSTED_FN("bind", "FunctionBind", 2, 0),
-    JS_SYM_FN(hasInstance, fun_symbolHasInstance, 1,
-              JSPROP_READONLY | JSPROP_PERMANENT),
-    JS_FS_END};
-
 // ES2018 draft rev 2aea8f3e617b49df06414eb062ab44fad87661d3
 // 19.2.1.1.1 CreateDynamicFunction( constructor, newTarget, kind, args )
 static bool CreateDynamicFunction(JSContext* cx, const CallArgs& args,
                                   GeneratorKind generatorKind,
                                   FunctionAsyncKind asyncKind) {
   using namespace frontend;
 
   // Steps 1-5.
--- a/js/src/vm/JSFunction.h
+++ b/js/src/vm/JSFunction.h
@@ -18,18 +18,16 @@
 
 namespace js {
 
 class FunctionExtended;
 
 typedef JSNative Native;
 }  // namespace js
 
-struct JSAtomState;
-
 static const uint32_t JSSLOT_BOUND_FUNCTION_TARGET = 2;
 static const uint32_t JSSLOT_BOUND_FUNCTION_THIS = 3;
 static const uint32_t JSSLOT_BOUND_FUNCTION_ARGS = 4;
 
 static const char FunctionConstructorMedialSigils[] = ") {\n";
 static const char FunctionConstructorFinalBrace[] = "\n}";
 
 enum class FunctionPrefixKind { None, Get, Set };
@@ -910,18 +908,16 @@ extern JSFunction* DefineFunction(
 
 extern bool fun_toString(JSContext* cx, unsigned argc, Value* vp);
 
 struct WellKnownSymbols;
 
 extern bool FunctionHasDefaultHasInstance(JSFunction* fun,
                                           const WellKnownSymbols& symbols);
 
-extern bool fun_symbolHasInstance(JSContext* cx, unsigned argc, Value* vp);
-
 extern void ThrowTypeErrorBehavior(JSContext* cx);
 
 /*
  * Function extended with reserved slots for use by various kinds of functions.
  * Most functions do not have these extensions, but enough do that efficient
  * storage is required (no malloc'ed reserved slots).
  */
 class FunctionExtended : public JSFunction {
@@ -1038,19 +1034,16 @@ extern void ReportIncompatibleMethod(JSC
                                      const Class* clasp);
 
 /*
  * Report an error that call.thisv is not an acceptable this for the callee
  * function.
  */
 extern void ReportIncompatible(JSContext* cx, const CallArgs& args);
 
-extern const JSFunctionSpec function_methods[];
-extern const JSFunctionSpec function_selfhosted_methods[];
-
 extern bool fun_apply(JSContext* cx, unsigned argc, Value* vp);
 
 extern bool fun_call(JSContext* cx, unsigned argc, Value* vp);
 
 } /* namespace js */
 
 #ifdef DEBUG
 namespace JS {