v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
liftoff-compiler.h
Go to the documentation of this file.
1// Copyright 2018 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_WASM_BASELINE_LIFTOFF_COMPILER_H_
6#define V8_WASM_BASELINE_LIFTOFF_COMPILER_H_
7
9
10namespace v8 {
11namespace internal {
12
13class AccountingAllocator;
14class Counters;
15
16namespace wasm {
17
18struct CompilationEnv;
19class DebugSideTable;
20struct FunctionBody;
21class WasmDetectedFeatures;
22
23// Note: If this list changes, also the histogram "V8.LiftoffBailoutReasons"
24// on the chromium side needs to be updated.
25// Deprecating entries is always fine. Repurposing works if you don't care about
26// temporary mix-ups. Increasing the number of reasons {kNumBailoutReasons} is
27// more tricky, and might require introducing a new (updated) histogram.
28enum LiftoffBailoutReason : int8_t {
29 // Nothing actually failed.
31 // Compilation failed, but not because of Liftoff.
33 // Liftoff is not implemented on that architecture.
35 // More complex code would be needed because a CPU feature is not present.
37 // Liftoff does not implement a complex (and rare) instruction.
39 // Unimplemented proposals:
40 kSimd = 5,
48 kGC = 13,
50 // A little gap, for forward compatibility.
51 // Any other reason (use rarely; introduce new reasons if this spikes).
53 // Marker:
55};
56
57// Further information about a location for a deopt: A call_ref can either be
58// just an inline call (that didn't cause a deopt) with a deopt happening within
59// the inlinee or it could be the deopt point itself. This changes whether the
60// relevant stackstate is the one before the call or after the call.
61enum class LocationKindForDeopt : uint8_t {
62 kNone,
63 kEagerDeopt, // The location is the point of an eager deopt.
64 kInlinedCall, // The loation is an inlined call, not a deopt.
65};
66
68 int func_index = -1;
70 Counters* counters = nullptr;
73 std::unique_ptr<DebugSideTable>* debug_sidetable = nullptr;
75 int32_t* max_steps = nullptr;
77 uint32_t deopt_info_bytecode_offset = std::numeric_limits<uint32_t>::max();
79
80 // Check that all non-optional fields have been initialized.
81 bool is_initialized() const { return func_index >= 0; }
82
83 // We keep the macro as small as possible by offloading the actual DCHECK and
84 // assignment to another function. This makes debugging easier.
85#define SETTER(field) \
86 LiftoffOptions& set_##field(decltype(field) new_value) { \
87 return Set<decltype(field)>(&LiftoffOptions::field, new_value); \
88 }
89
92 SETTER(counters)
101
102#undef SETTER
103
104 private:
105 template <typename T>
106 LiftoffOptions& Set(T LiftoffOptions::*field_ptr, T new_value) {
107 // The field must still have its default value (set each field only once).
108 DCHECK_EQ(this->*field_ptr, LiftoffOptions{}.*field_ptr);
109 this->*field_ptr = new_value;
110 return *this;
111 }
112};
113
114V8_EXPORT_PRIVATE WasmCompilationResult ExecuteLiftoffCompilation(
115 CompilationEnv*, const FunctionBody&, const LiftoffOptions&);
116
117V8_EXPORT_PRIVATE std::unique_ptr<DebugSideTable> GenerateLiftoffDebugSideTable(
118 const WasmCode*);
119
120} // namespace wasm
121} // namespace internal
122} // namespace v8
123
124#endif // V8_WASM_BASELINE_LIFTOFF_COMPILER_H_
#define SETTER(field)
WasmCompilationResult ExecuteLiftoffCompilation(CompilationEnv *env, const FunctionBody &func_body, const LiftoffOptions &compiler_options)
std::unique_ptr< DebugSideTable > GenerateLiftoffDebugSideTable(const WasmCode *code)
Definition c-api.cc:87
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define V8_EXPORT_PRIVATE
Definition macros.h:460
base::Vector< const int > breakpoints
std::unique_ptr< DebugSideTable > * debug_sidetable
WasmDetectedFeatures * detected_features
LocationKindForDeopt deopt_location_kind
LiftoffOptions & Set(T LiftoffOptions::*field_ptr, T new_value)