v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
unwinding-info-writer-arm64.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
12// TODO(v8:10026): When using CFI, we need to generate unwinding info to tell
13// the unwinder that return addresses are signed.
14
16 const InstructionBlock* block) {
17 if (!enabled()) return;
18
19 block_will_exit_ = false;
20
21 DCHECK_LT(block->rpo_number().ToInt(),
22 static_cast<int>(block_initial_states_.size()));
23 const BlockInitialState* initial_state =
24 block_initial_states_[block->rpo_number().ToInt()];
25 if (!initial_state) return;
26 if (initial_state->saved_lr_ != saved_lr_) {
28 if (initial_state->saved_lr_) {
31 } else {
33 }
34 saved_lr_ = initial_state->saved_lr_;
35 }
36}
37
38void UnwindingInfoWriter::EndInstructionBlock(const InstructionBlock* block) {
39 if (!enabled() || block_will_exit_) return;
40
41 for (const RpoNumber& successor : block->successors()) {
42 int successor_index = successor.ToInt();
43 DCHECK_LT(successor_index, static_cast<int>(block_initial_states_.size()));
44 const BlockInitialState* existing_state =
45 block_initial_states_[successor_index];
46
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_EQ(existing_state->saved_lr_, saved_lr_);
51 } else {
52 block_initial_states_[successor_index] =
53 zone_->New<BlockInitialState>(saved_lr_);
54 }
55 }
56}
57
59 if (!enabled()) return;
60
61 // Regardless of the type of frame constructed, the relevant part of the
62 // layout is always the one in the diagram:
63 //
64 // | .... | higher addresses
65 // +----------+ ^
66 // | LR | | |
67 // +----------+ | |
68 // | saved FP | | |
69 // +----------+ <-- FP v
70 // | .... | stack growth
71 //
72 // The LR is pushed on the stack, and we can record this fact at the end of
73 // the construction, since the LR itself is not modified in the process.
77 saved_lr_ = true;
78}
79
81 if (!enabled()) return;
82
83 // The lr is restored by the last operation in LeaveFrame().
86 saved_lr_ = false;
87}
88
97
99 if (!enabled()) return;
100
104}
105
106} // namespace compiler
107} // namespace internal
108} // namespace v8
void SetBaseAddressRegisterAndOffset(Register base_register, int base_offset)
Definition eh-frame.cc:293
void AdvanceLocation(int pc_offset)
Definition eh-frame.cc:251
void RecordRegisterSavedToStack(Register name, int offset)
Definition eh-frame.h:104
void RecordRegisterFollowsInitialRule(Register name)
Definition eh-frame.cc:333
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 kSystemPointerSize
Definition globals.h:410
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485