author | Kristen Wright <kwright@mozilla.com> |
Fri, 21 Jun 2019 20:38:02 +0000 | |
changeset 479981 | abacb77a97bbcfb54915aedd34ef7aefafdb0e78 |
parent 479980 | 84bba101c4f43a39dad3388c93080fb4d9cca804 |
child 479982 | bd8a279979b3969d4d8a6dd3d155df5df4bf7a3e |
push id | 36197 |
push user | aciure@mozilla.com |
push date | Tue, 25 Jun 2019 09:39:03 +0000 |
treeherder | mozilla-central@5bfd0011c6e3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sfink |
bugs | 1539270 |
milestone | 69.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
|
--- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1769,16 +1769,21 @@ JS_PUBLIC_API JSObject* JS_NewObjectForC JS_PUBLIC_API bool JS_IsNative(JSObject* obj) { return obj->isNative(); } JS_PUBLIC_API void JS::AssertObjectBelongsToCurrentThread(JSObject* obj) { JSRuntime* rt = obj->compartment()->runtimeFromAnyThread(); MOZ_RELEASE_ASSERT(CurrentThreadCanAccessRuntime(rt)); } +JS_PUBLIC_API void SetHelperThreadTaskCallback( + void (*callback)(js::RunnableTask*)) { + HelperThreadTaskCallback = callback; +} + /*** Standard internal methods **********************************************/ JS_PUBLIC_API bool JS_GetPrototype(JSContext* cx, HandleObject obj, MutableHandleObject result) { cx->check(obj); return GetPrototype(cx, obj, result); }
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -390,16 +390,22 @@ JS_PUBLIC_API bool InitSelfHostedCode(JS /** * Asserts (in debug and release builds) that `obj` belongs to the current * thread's context. */ JS_PUBLIC_API void AssertObjectBelongsToCurrentThread(JSObject* obj); } /* namespace JS */ +/** + * Set callback to send tasks to XPCOM thread pools + */ +JS_PUBLIC_API void SetHelperThreadTaskCallback( + void (*callback)(js::RunnableTask*)); + extern JS_PUBLIC_API const char* JS_GetImplementationVersion(void); extern JS_PUBLIC_API void JS_SetDestroyCompartmentCallback( JSContext* cx, JSDestroyCompartmentCallback callback); extern JS_PUBLIC_API void JS_SetSizeOfIncludingThisCompartmentCallback( JSContext* cx, JSSizeOfIncludingThisCompartmentCallback callback);
--- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -66,16 +66,18 @@ using mozilla::PodZero; using mozilla::PositiveInfinity; /* static */ MOZ_THREAD_LOCAL(JSContext*) js::TlsContext; /* static */ Atomic<size_t> JSRuntime::liveRuntimesCount; Atomic<JS::LargeAllocationFailureCallback> js::OnLargeAllocationFailure; namespace js { +void (*HelperThreadTaskCallback)(js::RunnableTask*); + bool gCanUseExtraThreads = true; } // namespace js void js::DisableExtraThreads() { gCanUseExtraThreads = false; } const JSSecurityCallbacks js::NullSecurityCallbacks = {}; static const JSWrapObjectCallbacks DefaultWrapObjectCallbacks = {
--- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -1078,11 +1078,15 @@ extern const JSSecurityCallbacks NullSec // and may be null. See comment in jsapi.h. extern mozilla::Atomic<JS::LargeAllocationFailureCallback> OnLargeAllocationFailure; // This callback is set by JS::SetBuildIdOp and may be null. See comment in // jsapi.h. extern mozilla::Atomic<JS::BuildIdOp> GetBuildId; +// This callback is set by js::SetHelperThreadTaskCallback and may be null. +// See comment in jsapi.h. +extern void (*HelperThreadTaskCallback)(js::RunnableTask*); + } /* namespace js */ #endif /* vm_Runtime_h */
--- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -3080,18 +3080,20 @@ void XPCJSRuntime::Initialize(JSContext* JS_SetAccumulateTelemetryCallback(cx, AccumulateTelemetryCallback); JS_SetSetUseCounterCallback(cx, SetUseCounterCallback); js::SetWindowProxyClass(cx, &OuterWindowProxyClass); js::SetXrayJitInfo(&gXrayJitInfo); JS::SetProcessLargeAllocationFailureCallback( OnLargeAllocationFailureCallback); JS::SetProcessBuildIdOp(GetBuildId); - // Initialize a helper thread pool for JS offthread tasks. + // Initialize a helper thread pool for JS offthread tasks. Set the + // task callback to divert tasks to the helperthreads. InitializeHelperThreadPool(); + SetHelperThreadTaskCallback(&DispatchOffThreadTask); // The JS engine needs to keep the source code around in order to implement // Function.prototype.toSource(). It'd be nice to not have to do this for // chrome code and simply stub out requests for source on it. Life is not so // easy, unfortunately. Nobody relies on chrome toSource() working in core // browser code, but chrome tests use it. The worst offenders are addons, // which like to monkeypatch chrome functions by calling toSource() on them // and using regular expressions to modify them. We avoid keeping most browser