v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
deoptimizer-x64.cc
Go to the documentation of this file.
1// Copyright 2012 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#if V8_TARGET_ARCH_X64
6
12
13namespace v8 {
14namespace internal {
15
16// The deopt exit sizes below depend on the following IsolateData layout
17// guarantees:
18#define ASSERT_OFFSET(BuiltinName) \
19 static_assert(IsolateData::builtin_tier0_entry_table_offset() + \
20 Builtins::ToInt(BuiltinName) * kSystemPointerSize <= \
21 0x7F)
22ASSERT_OFFSET(Builtin::kDeoptimizationEntry_Eager);
23ASSERT_OFFSET(Builtin::kDeoptimizationEntry_Lazy);
24#undef ASSERT_OFFSET
25
27#ifdef V8_ENABLE_CET_IBT
28// With IBT, the lazy deopt entry has an additional endbr64 instruction.
30#else
32#endif
33
34#if V8_ENABLE_CET_SHADOW_STACK
36#else
38#endif
39
40// static
42 if (!Assembler::IsNop(pc)) {
43 // The place holder could be already patched.
45 return;
46 }
47
48 RwxMemoryWriteScope rwx_write_scope("Patch jump to deopt trampoline");
49 intptr_t displacement =
51 CHECK(is_int32(displacement));
52 // We'll overwrite only one instruction of 5-bytes. Give enough
53 // space not to try to grow the buffer.
54 constexpr int kSize = 32;
55 Assembler masm(
56 AssemblerOptions{},
57 ExternalAssemblerBuffer(reinterpret_cast<uint8_t*>(pc), kSize));
58 int offset = static_cast<int>(new_pc - pc);
59 masm.jmp_rel(offset);
61}
62
65 reinterpret_cast<Address>(simd128_registers_ + n));
66}
67
71 reinterpret_cast<Address>(simd128_registers_ + n));
72}
73
74void RegisterValues::SetDoubleRegister(unsigned n, Float64 value) {
76 reinterpret_cast<Address>(simd128_registers_ + n), value);
77}
78
79void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) {
80 SetFrameSlot(offset, value);
82}
83
84void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) {
85 SetFrameSlot(offset, value);
86}
87
88void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) {
89 // No embedded constant pool support.
91}
92
93void FrameDescription::SetPc(intptr_t pc) { pc_ = pc; }
94
95} // namespace internal
96} // namespace v8
97
98#endif // V8_TARGET_ARCH_X64
static bool IsJmpRel(Address addr)
static bool IsNop(Instr instr, int type=NON_MARKING_NOP)
static constexpr int kIntraSegmentJmpInstrSize
static void PatchToJump(Address pc, Address new_pc)
static V8_EXPORT_PRIVATE const int kEagerDeoptExitSize
static V8_EXPORT_PRIVATE const int kAdaptShadowStackOffsetToSubtract
static V8_EXPORT_PRIVATE const int kLazyDeoptExitSize
void SetCallerFp(unsigned offset, intptr_t value)
void SetCallerConstantPool(unsigned offset, intptr_t value)
void SetCallerPc(unsigned offset, intptr_t value)
void SetFrameSlot(unsigned offset, intptr_t value)
void SetDoubleRegister(unsigned n, Float64 value)
Float64 GetDoubleRegister(unsigned n) const
Float32 GetFloatRegister(unsigned n) const
Simd128 simd128_registers_[Simd128Register::kNumRegisters]
#define ASSERT_OFFSET(BuiltinName)
int32_t displacement
int32_t offset
static V ReadUnalignedValue(Address p)
Definition memory.h:28
static void WriteUnalignedValue(Address p, V value)
Definition memory.h:41
FloatWithBits< 32 > Float32
Definition index.h:233
FloatWithBits< 64 > Float64
Definition index.h:234
void FlushInstructionCache(void *start, size_t size)
return value
Definition map-inl.h:893
std::unique_ptr< AssemblerBuffer > ExternalAssemblerBuffer(void *start, int size)
Definition assembler.cc:161
#define CHECK(condition)
Definition logging.h:124
#define DCHECK(condition)
Definition logging.h:482
#define arraysize(array)
Definition macros.h:67
#define V8_ASSUME
Definition v8config.h:533