Bug 1530319: Don't create a singleton objects for functions which can be created multiple times. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 25 Feb 2019 09:06:29 -0800
changeset 519523 4339eeddc19dde44ebd77022a8df74cb41377d6b
parent 519522 fa45218ad1c585bb3882807b833c539cd07f76fc
child 519524 7eb6431fcc65e7baf25e9bb6a1bf18e9c5e90cdf
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)
reviewersjorendorff
bugs1530319
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 1530319: Don't create a singleton objects for functions which can be created multiple times. r=jorendorff
js/src/builtin/Stream.cpp
js/src/proxy/ScriptedProxyHandler.cpp
js/src/wasm/WasmJS.cpp
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -86,17 +86,17 @@ static MOZ_MUST_USE ReadableStreamReader
 }
 
 constexpr size_t StreamHandlerFunctionSlot_Target = 0;
 
 inline static MOZ_MUST_USE JSFunction* NewHandler(JSContext* cx, Native handler,
                                                   HandleObject target) {
   cx->check(target);
 
-  RootedAtom funName(cx, cx->names().empty);
+  HandlePropertyName funName = cx->names().empty;
   RootedFunction handlerFun(
       cx, NewNativeFunction(cx, handler, 0, funName,
                             gc::AllocKind::FUNCTION_EXTENDED, GenericObject));
   if (!handlerFun) {
     return nullptr;
   }
   handlerFun->setExtendedSlot(StreamHandlerFunctionSlot_Target,
                               ObjectValue(*target));
@@ -1428,19 +1428,20 @@ static MOZ_MUST_USE JSObject* ReadableSt
   RootedObject sourceCancelPromise(
       cx, ReadableStreamControllerCancelSteps(cx, unwrappedController, reason));
   if (!sourceCancelPromise) {
     return nullptr;
   }
 
   // Step 6: Return the result of transforming sourceCancelPromise with a
   //         fulfillment handler that returns undefined.
-  RootedAtom funName(cx, cx->names().empty);
+  HandlePropertyName funName = cx->names().empty;
   RootedFunction returnUndefined(
-      cx, NewNativeFunction(cx, ReturnUndefined, 0, funName));
+      cx, NewNativeFunction(cx, ReturnUndefined, 0, funName,
+                            gc::AllocKind::FUNCTION, GenericObject));
   if (!returnUndefined) {
     return nullptr;
   }
   return JS::CallOriginalPromiseThen(cx, sourceCancelPromise, returnUndefined,
                                      nullptr);
 }
 
 static MOZ_MUST_USE JSObject* ReadableStreamCreateReadResult(
--- a/js/src/proxy/ScriptedProxyHandler.cpp
+++ b/js/src/proxy/ScriptedProxyHandler.cpp
@@ -6,16 +6,17 @@
 
 #include "proxy/ScriptedProxyHandler.h"
 
 #include "jsapi.h"
 
 #include "js/CharacterEncoding.h"
 #include "js/PropertyDescriptor.h"  // JS::FromPropertyDescriptor
 #include "vm/EqualityOperations.h"  // js::SameValue
+#include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 using JS::IsArrayAnswer;
@@ -1534,25 +1535,25 @@ bool js::proxy_revocable(JSContext* cx, 
 
   if (!ProxyCreate(cx, args, "Proxy.revocable")) {
     return false;
   }
 
   RootedValue proxyVal(cx, args.rval());
   MOZ_ASSERT(proxyVal.toObject().is<ProxyObject>());
 
-  RootedObject revoker(
-      cx, NewFunctionByIdWithReserved(cx, RevokeProxy, 0, 0,
-                                      NameToId(cx->names().revoke)));
+  HandlePropertyName funName = cx->names().revoke;
+  RootedFunction revoker(
+      cx, NewNativeFunction(cx, RevokeProxy, 0, funName,
+                            gc::AllocKind::FUNCTION_EXTENDED, GenericObject));
   if (!revoker) {
     return false;
   }
 
-  revoker->as<JSFunction>().initExtendedSlot(ScriptedProxyHandler::REVOKE_SLOT,
-                                             proxyVal);
+  revoker->initExtendedSlot(ScriptedProxyHandler::REVOKE_SLOT, proxyVal);
 
   RootedPlainObject result(cx, NewBuiltinClassInstance<PlainObject>(cx));
   if (!result) {
     return false;
   }
 
   RootedValue revokeVal(cx, ObjectValue(*revoker));
   if (!DefineDataProperty(cx, result, cx->names().proxy, proxyVal) ||
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -3563,24 +3563,24 @@ static bool ResolveResponse(JSContext* c
       cx, ResolveResponseClosure::create(cx, *compileArgs, promise, instantiate,
                                          importObj));
   if (!closure) {
     return false;
   }
 
   RootedFunction onResolved(
       cx, NewNativeFunction(cx, ResolveResponse_OnFulfilled, 1, nullptr,
-                            gc::AllocKind::FUNCTION_EXTENDED));
+                            gc::AllocKind::FUNCTION_EXTENDED, GenericObject));
   if (!onResolved) {
     return false;
   }
 
   RootedFunction onRejected(
       cx, NewNativeFunction(cx, ResolveResponse_OnRejected, 1, nullptr,
-                            gc::AllocKind::FUNCTION_EXTENDED));
+                            gc::AllocKind::FUNCTION_EXTENDED, GenericObject));
   if (!onRejected) {
     return false;
   }
 
   onResolved->setExtendedSlot(0, ObjectValue(*closure));
   onRejected->setExtendedSlot(0, ObjectValue(*closure));
 
   RootedObject resolve(cx,