diff --git a/js/public/Utility.h b/js/public/Utility.h index 84cf9f09d169..e55b8a57bbc1 100644 --- a/js/public/Utility.h +++ b/js/public/Utility.h @@ -83,6 +83,7 @@ enum ThreadType { * mozilla::HelperThreadPool's runnable handler to call runTask() on each type. */ struct RunnableTask { + virtual ThreadType threadType() = 0; virtual void runTask() = 0; }; diff --git a/js/src/gc/GCParallelTask.h b/js/src/gc/GCParallelTask.h index c2b4c6d37919..eab605c718a9 100644 --- a/js/src/gc/GCParallelTask.h +++ b/js/src/gc/GCParallelTask.h @@ -99,6 +99,10 @@ class GCParallelTask : public RunnableTask { void runTask() override { func_(this); } + ThreadType threadType() override { + return ThreadType::THREAD_TYPE_GCPARALLEL; + } + private: void assertNotStarted() const { // Don't lock here because that adds extra synchronization in debug diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h index fea234eb60d9..437a234707fb 100644 --- a/js/src/jit/IonBuilder.h +++ b/js/src/jit/IonBuilder.h @@ -69,6 +69,9 @@ class IonBuilder : public MIRGenerator, void runTask() override; + // for use when ion compiles are being run offthread. + ThreadType threadType() override { return THREAD_TYPE_ION; } + private: AbortReasonOr traverseBytecode(); AbortReasonOr processIterators(); diff --git a/js/src/vm/HelperThreads.h b/js/src/vm/HelperThreads.h index 32ad50771770..ec72df7e9c42 100644 --- a/js/src/vm/HelperThreads.h +++ b/js/src/vm/HelperThreads.h @@ -752,6 +752,7 @@ struct ParseTask : public mozilla::LinkedListElement, } void runTask() override; + ThreadType threadType() override { return ThreadType::THREAD_TYPE_PARSE; } }; struct ScriptDecodeTask : public ParseTask { @@ -842,6 +843,8 @@ class SourceCompressionTask : public RunnableTask { void runTask() override; void complete(); + ThreadType threadType() override { return ThreadType::THREAD_TYPE_COMPRESS; } + private: struct PerformTaskWork; friend struct PerformTaskWork; @@ -875,6 +878,7 @@ struct PromiseHelperTask : OffThreadPromiseTask, public RunnableTask { // the caller must immediately return from the stream callback. void executeAndResolveAndDestroy(JSContext* cx); void runTask() override; + ThreadType threadType() override { return THREAD_TYPE_PROMISE_TASK; } }; } /* namespace js */ diff --git a/js/src/wasm/WasmGenerator.h b/js/src/wasm/WasmGenerator.h index 42db9aff7aea..e3d7e15b414b 100644 --- a/js/src/wasm/WasmGenerator.h +++ b/js/src/wasm/WasmGenerator.h @@ -127,6 +127,7 @@ struct CompileTask : public RunnableTask { size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; void runTask() override; + ThreadType threadType() override { return ThreadType::THREAD_TYPE_WASM; } }; // A ModuleGenerator encapsulates the creation of a wasm module. During the diff --git a/js/src/wasm/WasmModule.cpp b/js/src/wasm/WasmModule.cpp index 354c480fe913..7d8f7291e406 100644 --- a/js/src/wasm/WasmModule.cpp +++ b/js/src/wasm/WasmModule.cpp @@ -65,6 +65,9 @@ class Module::Tier2GeneratorTaskImpl : public Tier2GeneratorTask { void runTask() override { CompileTier2(*compileArgs_, bytecode_->bytes, *module_, &cancelled_); } + ThreadType threadType() override { + return ThreadType::THREAD_TYPE_WASM_TIER2; + } }; Module::~Module() {