summaryrefslogtreecommitdiff
path: root/deps/v8/src/maglev/maglev-concurrent-dispatcher.h
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2022-04-12 11:10:15 +0200
committerMichaël Zasso <targos@protonmail.com>2022-04-12 22:08:39 +0200
commitfd4f80ce54d7f7b7503e0999f6a9d293d493846d (patch)
tree00fba34b8aabeb481c7128fccee635719ee44a3b /deps/v8/src/maglev/maglev-concurrent-dispatcher.h
parent73d53fe9f56d7ce5de4b9c9ad5257dc601bbce14 (diff)
downloadnode-new-fd4f80ce54d7f7b7503e0999f6a9d293d493846d.tar.gz
deps: update V8 to 10.1.124.6
PR-URL: https://github.com/nodejs/node/pull/42657 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'deps/v8/src/maglev/maglev-concurrent-dispatcher.h')
-rw-r--r--deps/v8/src/maglev/maglev-concurrent-dispatcher.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/deps/v8/src/maglev/maglev-concurrent-dispatcher.h b/deps/v8/src/maglev/maglev-concurrent-dispatcher.h
new file mode 100644
index 0000000000..0b2a086e5a
--- /dev/null
+++ b/deps/v8/src/maglev/maglev-concurrent-dispatcher.h
@@ -0,0 +1,92 @@
+// Copyright 2022 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_MAGLEV_MAGLEV_CONCURRENT_DISPATCHER_H_
+#define V8_MAGLEV_MAGLEV_CONCURRENT_DISPATCHER_H_
+
+#ifdef V8_ENABLE_MAGLEV
+
+#include <memory>
+
+#include "src/codegen/compiler.h" // For OptimizedCompilationJob.
+#include "src/utils/locked-queue.h"
+
+namespace v8 {
+namespace internal {
+
+class Isolate;
+
+namespace maglev {
+
+class MaglevCompilationInfo;
+
+// Exports needed functionality without exposing implementation details.
+class ExportedMaglevCompilationInfo final {
+ public:
+ explicit ExportedMaglevCompilationInfo(MaglevCompilationInfo* info)
+ : info_(info) {}
+
+ Zone* zone() const;
+ void set_canonical_handles(
+ std::unique_ptr<CanonicalHandlesMap>&& canonical_handles);
+
+ private:
+ MaglevCompilationInfo* const info_;
+};
+
+// The job is a single actual compilation task.
+class MaglevCompilationJob final : public OptimizedCompilationJob {
+ public:
+ static std::unique_ptr<MaglevCompilationJob> New(Isolate* isolate,
+ Handle<JSFunction> function);
+ virtual ~MaglevCompilationJob();
+
+ Status PrepareJobImpl(Isolate* isolate) override;
+ Status ExecuteJobImpl(RuntimeCallStats* stats,
+ LocalIsolate* local_isolate) override;
+ Status FinalizeJobImpl(Isolate* isolate) override;
+
+ private:
+ explicit MaglevCompilationJob(std::unique_ptr<MaglevCompilationInfo>&& info);
+
+ MaglevCompilationInfo* info() const { return info_.get(); }
+
+ const std::unique_ptr<MaglevCompilationInfo> info_;
+};
+
+// The public API for Maglev concurrent compilation.
+// Keep this as minimal as possible.
+class MaglevConcurrentDispatcher final {
+ class JobTask;
+
+ // TODO(jgruber): There's no reason to use locking queues here, we only use
+ // them for simplicity - consider replacing with lock-free data structures.
+ using QueueT = LockedQueue<std::unique_ptr<MaglevCompilationJob>>;
+
+ public:
+ explicit MaglevConcurrentDispatcher(Isolate* isolate);
+ ~MaglevConcurrentDispatcher();
+
+ // Called from the main thread.
+ void EnqueueJob(std::unique_ptr<MaglevCompilationJob>&& job);
+
+ // Called from the main thread.
+ void FinalizeFinishedJobs();
+
+ bool is_enabled() const { return static_cast<bool>(job_handle_); }
+
+ private:
+ Isolate* const isolate_;
+ std::unique_ptr<JobHandle> job_handle_;
+ QueueT incoming_queue_;
+ QueueT outgoing_queue_;
+};
+
+} // namespace maglev
+} // namespace internal
+} // namespace v8
+
+#endif // V8_ENABLE_MAGLEV
+
+#endif // V8_MAGLEV_MAGLEV_CONCURRENT_DISPATCHER_H_