v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1// Copyright 2019 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_COMPILER_GLOBALS_H_
6#define V8_COMPILER_GLOBALS_H_
7
8#include <ostream>
9
10#include "src/common/globals.h"
11#include "src/flags/flags.h"
13#include "src/runtime/runtime.h"
14
15namespace v8 {
16namespace internal {
17namespace compiler {
18
19// The nci flag is currently used to experiment with feedback collection in
20// optimized code produced by generic lowering.
21// Considerations:
22// - Should we increment the call count? https://crbug.com/v8/10524
23// - Is feedback already megamorphic in all these cases?
24//
25// TODO(jgruber): Remove once we've made a decision whether to collect feedback
26// unconditionally.
28 return v8_flags.turbo_collect_feedback_in_generic_lowering;
29}
30
31enum class StackCheckKind : uint8_t {
35 kWasm,
36};
37
40 return Runtime::kStackGuardWithGap;
42 return Runtime::kHandleNoHeapWritesInterrupts;
43 } else {
44 return Runtime::kStackGuard;
45 }
46}
47
48enum class CanThrow : uint8_t { kNo, kYes };
49enum class LazyDeoptOnThrow : uint8_t { kNo, kYes };
50
51inline std::ostream& operator<<(std::ostream& os,
52 LazyDeoptOnThrow lazy_deopt_on_throw) {
53 switch (lazy_deopt_on_throw) {
55 return os << "LazyDeoptOnThrow";
57 return os << "DoNOTLazyDeoptOnThrow";
58 }
59}
60
61inline std::ostream& operator<<(std::ostream& os, StackCheckKind kind) {
62 switch (kind) {
64 return os << "JSFunctionEntry";
66 return os << "JSIterationBody";
68 return os << "CodeStubAssembler";
70 return os << "Wasm";
71 }
73}
74
76 return static_cast<size_t>(kind);
77}
78
83
84inline size_t hash_value(CheckForMinusZeroMode mode) {
85 return static_cast<size_t>(mode);
86}
87
88inline std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) {
89 switch (mode) {
91 return os << "check-for-minus-zero";
93 return os << "dont-check-for-minus-zero";
94 }
96}
97
98// The CallFeedbackRelation provides the meaning of the call feedback for a
99// TurboFan JSCall operator
100// - kReceiver: The call target was Function.prototype.apply and its receiver
101// was recorded as the feedback value.
102// - kTarget: The call target was recorded as the feedback value.
103// - kUnrelated: The feedback is no longer related to the call. If, during
104// lowering, a JSCall (e.g. of a higher order function) is replaced by a
105// JSCall with another target, the feedback has to be kept but is now
106// unrelated.
108
109inline std::ostream& operator<<(std::ostream& os,
110 CallFeedbackRelation call_feedback_relation) {
111 switch (call_feedback_relation) {
113 return os << "CallFeedbackRelation::kReceiver";
115 return os << "CallFeedbackRelation::kTarget";
117 return os << "CallFeedbackRelation::kUnrelated";
118 }
119 UNREACHABLE();
120}
121
122// Maximum depth and total number of elements and properties for literal
123// graphs to be considered for fast deep-copying. The limit is chosen to
124// match the maximum number of inobject properties, to ensure that the
125// performance of using object literals is not worse than using constructor
126// functions, see crbug.com/v8/6211 for details.
129
131
132enum class MemoryAccessKind : uint8_t {
133 kNormal,
136};
137
139
140V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, MemoryAccessKind);
141
143 switch (kind) {
144#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
145 case TYPE##_ELEMENTS: \
146 case RAB_GSAB_##TYPE##_ELEMENTS: \
147 return kExternal##Type##Array;
149#undef TYPED_ARRAY_CASE
150 default:
151 break;
152 }
153 UNREACHABLE();
154}
155
156inline int ExternalArrayElementSize(const ExternalArrayType element_type) {
157 switch (element_type) {
158#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
159 case kExternal##Type##Array: \
160 DCHECK_LE(sizeof(ctype), 8); \
161 return sizeof(ctype);
163 default:
164 UNREACHABLE();
165#undef TYPED_ARRAY_CASE
166 }
167}
168
169} // namespace compiler
170} // namespace internal
171} // namespace v8
172
173// The biggest double value that fits within the int64_t/uint64_t value range.
174// This is different from safe integer range in that there are gaps of integers
175// in-between that cannot be represented as a double.
176constexpr double kMaxDoubleRepresentableInt64 = 9223372036854774784.0;
178 std::numeric_limits<int64_t>::min();
179constexpr double kMaxDoubleRepresentableUint64 = 18446744073709549568.0;
180
181// There is no (currently) available constexpr version of base::bit_cast, so
182// we have to make do with constructing the -0.0 bits manually (by setting the
183// sign bit to 1 and everything else to 0).
184// TODO(leszeks): Revisit when upgrading to C++20.
185constexpr int32_t kMinusZeroLoBits = static_cast<int32_t>(0);
186constexpr int32_t kMinusZeroHiBits = static_cast<int32_t>(1) << 31;
187constexpr int64_t kMinusZeroBits =
188 (static_cast<uint64_t>(kMinusZeroHiBits) << 32) | kMinusZeroLoBits;
189
190#endif // V8_COMPILER_GLOBALS_H_
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype)
Builtins::Kind kind
Definition builtins.cc:40
static const int kMaxInObjectProperties
Definition js-objects.h:959
constexpr int32_t kMinusZeroLoBits
Definition globals.h:185
constexpr double kMaxDoubleRepresentableInt64
Definition globals.h:176
constexpr int64_t kMinusZeroBits
Definition globals.h:187
constexpr double kMinDoubleRepresentableInt64
Definition globals.h:177
constexpr int32_t kMinusZeroHiBits
Definition globals.h:186
constexpr double kMaxDoubleRepresentableUint64
Definition globals.h:179
#define TYPED_ARRAYS(V)
const int kMaxFastLiteralDepth
Definition globals.h:127
const int kMaxFastLiteralProperties
Definition globals.h:128
Runtime::FunctionId GetBuiltinForStackCheckKind(StackCheckKind kind)
Definition globals.h:38
bool CollectFeedbackInGenericLowering()
Definition globals.h:27
size_t hash_value(const BranchParameters &p)
int ExternalArrayElementSize(const ExternalArrayType element_type)
Definition globals.h:156
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
ExternalArrayType GetArrayTypeFromElementsKind(ElementsKind kind)
Definition globals.h:142
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
V8_EXPORT_PRIVATE FlagValues v8_flags
#define V8_EXPORT_PRIVATE
Definition macros.h:460