v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
baseline-batch-compiler.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_BASELINE_BASELINE_BATCH_COMPILER_H_
6#define V8_BASELINE_BASELINE_BATCH_COMPILER_H_
7
8#include <atomic>
9
11#include "src/handles/handles.h"
12
13namespace v8 {
14namespace internal {
15namespace baseline {
16
17class BaselineCompiler;
18class ConcurrentBaselineCompiler;
19
21 public:
22 static const int kInitialQueueSize = 32;
23
24 explicit BaselineBatchCompiler(Isolate* isolate);
26 // Enqueues SharedFunctionInfo of |function| for compilation.
29
30 void set_enabled(bool enabled) { enabled_ = enabled; }
31 bool is_enabled() { return enabled_; }
32
33 void InstallBatch();
34
35 private:
36 bool concurrent() const;
37
38 // Ensure there is enough space in the compilation queue to enqueue another
39 // function, growing the queue if necessary.
41
42 // Enqueues SharedFunctionInfo.
44
45 // Returns true if the current batch exceeds the threshold and should be
46 // compiled.
48
49 // Compiles the current batch.
51
52 // Compiles the current batch concurrently.
54
55 // Resets the current batch.
56 void ClearBatch();
57
58 // Tries to compile |maybe_sfi|. Returns false if compilation was not possible
59 // (e.g. bytecode was fushed, weak handle no longer valid, ...).
61
63
64 // Global handle to shared function infos enqueued for compilation in the
65 // current batch.
67
68 // Last index set in compilation_queue_;
70
71 // Estimated insturction size of current batch.
73
74 // Flag indicating whether batch compilation is enabled.
75 // Batch compilation can be dynamically disabled e.g. when creating snapshots.
77
78 // Handle to the background compilation jobs.
79 std::unique_ptr<ConcurrentBaselineCompiler> concurrent_compiler_;
80};
81
82} // namespace baseline
83} // namespace internal
84} // namespace v8
85
86#endif // V8_BASELINE_BASELINE_BATCH_COMPILER_H_
void Enqueue(DirectHandle< SharedFunctionInfo > shared)
bool ShouldCompileBatch(Tagged< SharedFunctionInfo > shared)
void CompileBatch(DirectHandle< JSFunction > function)
bool MaybeCompileFunction(Tagged< MaybeObject > maybe_sfi)
void CompileBatchConcurrent(Tagged< SharedFunctionInfo > shared)
void EnqueueFunction(DirectHandle< JSFunction > function)
std::unique_ptr< ConcurrentBaselineCompiler > concurrent_compiler_
void EnqueueSFI(Tagged< SharedFunctionInfo > shared)