v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
deoptimization-data-inl.h
Go to the documentation of this file.
1// Copyright 2023 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_OBJECTS_DEOPTIMIZATION_DATA_INL_H_
6#define V8_OBJECTS_DEOPTIMIZATION_DATA_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
14
15// Has to be the last include (doesn't have include guards):
17
18namespace v8 {
19namespace internal {
20
21DEFINE_DEOPT_ELEMENT_ACCESSORS(FrameTranslation, DeoptimizationFrameTranslation)
22DEFINE_DEOPT_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
23DEFINE_DEOPT_ELEMENT_ACCESSORS(ProtectedLiteralArray,
26DEFINE_DEOPT_ELEMENT_ACCESSORS(OsrBytecodeOffset, Smi)
29DEFINE_DEOPT_ELEMENT_ACCESSORS(WrappedSharedFunctionInfo,
30 SharedFunctionInfoWrapperOrSmi)
34DEFINE_DEOPT_ELEMENT_ACCESSORS(EagerDeoptCount, Smi)
36
37DEFINE_DEOPT_ENTRY_ACCESSORS(BytecodeOffsetRaw, Smi)
38DEFINE_DEOPT_ENTRY_ACCESSORS(TranslationIndex, Smi)
40#ifdef DEBUG
42#endif // DEBUG
43
45 return Cast<i::SharedFunctionInfoWrapper>(WrappedSharedFunctionInfo())
46 ->shared_info();
47}
48
50 int i) const {
51 return BytecodeOffset(BytecodeOffsetRaw(i).value());
52}
53
54void DeoptimizationData::SetBytecodeOffset(int i, BytecodeOffset value) {
55 SetBytecodeOffsetRaw(i, Smi::FromInt(value.ToInt()));
56}
57
61
63 return get(GetPtrComprCageBase(), index);
64}
65
67 PtrComprCageBase cage_base, int index) const {
69
70 // Slots in the DeoptimizationLiteralArray should only be cleared when there
71 // is no possible code path that could need that slot. This works because the
72 // weakly-held deoptimization literals are basically local variables that
73 // TurboFan has decided not to keep on the stack. Thus, if the deoptimization
74 // literal goes away, then whatever code needed it should be unreachable. The
75 // exception is currently running InstructionStream: in that case, the
76 // deoptimization literals array might be the only thing keeping the target
77 // object alive. Thus, when an InstructionStream is running, we strongly mark
78 // all of its deoptimization literals.
79 CHECK(!maybe.IsCleared());
80
81 return maybe.GetHeapObjectOrSmi();
82}
83
88
89inline void DeoptimizationLiteralArray::set(int index, Tagged<Object> value) {
91 if (IsBytecodeArray(value)) {
92 // The BytecodeArray lives in trusted space, so we cannot reference it from
93 // a fixed array. However, we can use the BytecodeArray's wrapper object,
94 // which exists for exactly this purpose.
95 maybe = Cast<BytecodeArray>(value)->wrapper();
96#ifdef V8_ENABLE_SANDBOX
97 } else if (IsRegExpData(value)) {
98 // Store the RegExpData wrapper if the sandbox is enabled, as data lives in
99 // trusted space. We can't store a tagged value to a trusted space object
100 // inside the sandbox, we'd need to go through the trusted pointer table.
101 // Otherwise we can store the RegExpData object directly.
102 maybe = Cast<RegExpData>(value)->wrapper();
103#endif
105 maybe = MakeWeak(maybe);
106 }
107 TrustedWeakFixedArray::set(index, maybe);
108}
109
110} // namespace internal
111} // namespace v8
112
114
115#endif // V8_OBJECTS_DEOPTIMIZATION_DATA_INL_H_
static bool IsWeakObjectInDeoptimizationLiteralArray(Tagged< Object > object)
Definition code-inl.h:693
Tagged< ProtectedDeoptimizationLiteralArray > Tagged< TrustedPodArray< InliningPosition > > Tagged< SharedFunctionInfo > GetSharedFunctionInfo() const
BytecodeOffset GetBytecodeOffsetOrBuiltinContinuationId(int i) const
void SetBytecodeOffset(int i, BytecodeOffset value)
void set(int index, Tagged< Object > value)
Tagged< MaybeObject > get_raw(int index) const
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
void set(int index, Tagged< ElementT > value, WriteBarrierMode mode=kDefaultMode)
constexpr bool IsCleared() const
Tagged< Object > GetHeapObjectOrSmi() const
V8_INLINE PtrComprCageBase GetPtrComprCageBase()
Tagged< MaybeWeak< T > > MakeWeak(Tagged< T > value)
Definition tagged.h:893
return value
Definition map-inl.h:893
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DEFINE_DEOPT_ELEMENT_ACCESSORS(name, type)
#define DEFINE_DEOPT_ENTRY_ACCESSORS(name, type)
#define CHECK(condition)
Definition logging.h:124