Bug 1507192 - Give slot 0 of Stream callback functions a name. r=tcampbell
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 16 Nov 2018 13:31:51 +0000
changeset 446780 624e45ad97c89acc0b916c3c7c53b95cdb1f5014
parent 446779 e3e05897de25a3b5d4d8d41ac5c20463c62153e0
child 446781 766dc4a5e8f0a70985c1dc6fe781c17c8587602f
push id35052
push userapavel@mozilla.com
push dateSat, 17 Nov 2018 11:25:40 +0000
treeherdermozilla-central@efc1da42132b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1507192
milestone65.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 1507192 - Give slot 0 of Stream callback functions a name. r=tcampbell Differential Revision: https://phabricator.services.mozilla.com/D11901
js/src/builtin/Stream.cpp
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -129,41 +129,44 @@ UnwrapReaderFromStreamNoThrow(ReadableSt
         if (!readerObj) {
             return nullptr;
         }
     }
 
     return &readerObj->as<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);
     RootedFunction handlerFun(cx, NewNativeFunction(cx, handler, 0, funName,
                                                     gc::AllocKind::FUNCTION_EXTENDED,
                                                     GenericObject));
     if (!handlerFun) {
         return nullptr;
     }
-    handlerFun->setExtendedSlot(0, ObjectValue(*target));
+    handlerFun->setExtendedSlot(StreamHandlerFunctionSlot_Target, ObjectValue(*target));
     return handlerFun;
 }
 
 /**
  * Helper for handler functions that "close over" a value that is always a
  * direct reference to an object of class T, never a wrapper.
  */
 template <class T>
 inline static MOZ_MUST_USE T*
 TargetFromHandler(CallArgs& args)
 {
-    return &args.callee().as<JSFunction>().getExtendedSlot(0).toObject().as<T>();
+    JSFunction& func = args.callee().as<JSFunction>();
+    return &func.getExtendedSlot(StreamHandlerFunctionSlot_Target).toObject().as<T>();
 }
 
 inline static MOZ_MUST_USE bool
 ResetQueue(JSContext* cx, Handle<ReadableStreamController*> unwrappedContainer);
 
 inline static MOZ_MUST_USE bool
 InvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg,
              MutableHandleValue rval);