v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
unwinding-info-writer-x64.cc
Go to the documentation of this file.
1// Copyright 2016 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
7
8namespace v8 {
9namespace internal {
10namespace compiler {
11
13 const InstructionBlock* block) {
14 if (!enabled()) return;
15
16 block_will_exit_ = false;
17
18 DCHECK_LT(block->rpo_number().ToInt(),
19 static_cast<int>(block_initial_states_.size()));
20 const BlockInitialState* initial_state =
21 block_initial_states_[block->rpo_number().ToInt()];
22 if (!initial_state) return;
23 if (initial_state->register_ != eh_frame_writer_.base_register() &&
24 initial_state->offset_ != eh_frame_writer_.base_offset()) {
27 initial_state->offset_);
28 } else if (initial_state->register_ != eh_frame_writer_.base_register()) {
30 eh_frame_writer_.SetBaseAddressRegister(initial_state->register_);
31 } else if (initial_state->offset_ != eh_frame_writer_.base_offset()) {
33 eh_frame_writer_.SetBaseAddressOffset(initial_state->offset_);
34 }
35
36 tracking_fp_ = initial_state->tracking_fp_;
37}
38
39void UnwindingInfoWriter::EndInstructionBlock(const InstructionBlock* block) {
40 if (!enabled() || block_will_exit_) return;
41
42 for (const RpoNumber& successor : block->successors()) {
43 int successor_index = successor.ToInt();
44 DCHECK_LT(successor_index, static_cast<int>(block_initial_states_.size()));
45 const BlockInitialState* existing_state =
46 block_initial_states_[successor_index];
47 // If we already had an entry for this BB, check that the values are the
48 // same we are trying to insert.
49 if (existing_state) {
50 DCHECK(existing_state->register_ == eh_frame_writer_.base_register());
51 DCHECK_EQ(existing_state->offset_, eh_frame_writer_.base_offset());
52 DCHECK_EQ(existing_state->tracking_fp_, tracking_fp_);
53 } else {
54 block_initial_states_[successor_index] = zone_->New<BlockInitialState>(
57 }
58 }
59}
60
62 if (!enabled()) return;
63
64 // push rbp
67 // <base address> points at the bottom of the current frame on x64 and
68 // <base register> is rsp, which points to the top of the frame by definition.
69 // Thus, the distance between <base address> and the top is -<base offset>.
70 int top_of_stack = -eh_frame_writer_.base_offset();
72
73 // mov rbp, rsp
76
77 tracking_fp_ = true;
78}
79
81 if (!enabled()) return;
82
83 // mov rsp, rbp
86
87 // pop rbp
90
91 tracking_fp_ = false;
92}
93
94} // namespace compiler
95} // namespace internal
96} // namespace v8
void SetBaseAddressOffset(int base_offset)
Definition eh-frame.cc:277
void SetBaseAddressRegisterAndOffset(Register base_register, int base_offset)
Definition eh-frame.cc:293
void IncreaseBaseAddressOffset(int base_delta)
Definition eh-frame.h:97
void AdvanceLocation(int pc_offset)
Definition eh-frame.cc:251
void SetBaseAddressRegister(Register base_register)
Definition eh-frame.cc:285
void RecordRegisterSavedToStack(Register name, int offset)
Definition eh-frame.h:104
Register base_register() const
Definition eh-frame.h:130
T * New(Args &&... args)
Definition zone.h:114
ZoneVector< const BlockInitialState * > block_initial_states_
void BeginInstructionBlock(int pc_offset, const InstructionBlock *block)
void EndInstructionBlock(const InstructionBlock *block)
int pc_offset
constexpr int kInt64Size
Definition globals.h:402
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485