Bug 1556861 - Adding ThreadType to js::RunnableTask r=jonco

Added thread type as ThreadType enum. Default is ThreadType::THREAD_TYPE_NONE. RunnableTasks must specify their own thread type.

Differential Revision: https://phabricator.services.mozilla.com/D33818

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kristen Wright 2019-06-07 21:09:05 +00:00
Родитель 984d318461
Коммит cae8e5b60b
6 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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

Просмотреть файл

@ -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<Ok> traverseBytecode();
AbortReasonOr<Ok> processIterators();

Просмотреть файл

@ -752,6 +752,7 @@ struct ParseTask : public mozilla::LinkedListElement<ParseTask>,
}
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 */

Просмотреть файл

@ -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

Просмотреть файл

@ -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() {