5 #include "src/compiler/backend/x64/unwinding-info-writer-x64.h" 6 #include "src/compiler/backend/instruction.h" 12 void UnwindingInfoWriter::BeginInstructionBlock(
int pc_offset,
13 const InstructionBlock* block) {
14 if (!enabled())
return;
16 block_will_exit_ =
false;
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()];
23 if (initial_state->register_ != eh_frame_writer_.base_register() &&
24 initial_state->offset_ != eh_frame_writer_.base_offset()) {
25 eh_frame_writer_.AdvanceLocation(pc_offset);
26 eh_frame_writer_.SetBaseAddressRegisterAndOffset(initial_state->register_,
27 initial_state->offset_);
28 }
else if (initial_state->register_ != eh_frame_writer_.base_register()) {
29 eh_frame_writer_.AdvanceLocation(pc_offset);
30 eh_frame_writer_.SetBaseAddressRegister(initial_state->register_);
31 }
else if (initial_state->offset_ != eh_frame_writer_.base_offset()) {
32 eh_frame_writer_.AdvanceLocation(pc_offset);
33 eh_frame_writer_.SetBaseAddressOffset(initial_state->offset_);
36 tracking_fp_ = initial_state->tracking_fp_;
42 DCHECK(block->predecessors().empty() || block->successors().empty());
46 void UnwindingInfoWriter::EndInstructionBlock(
const InstructionBlock* block) {
47 if (!enabled() || block_will_exit_)
return;
49 for (
const RpoNumber& successor : block->successors()) {
50 int successor_index = successor.ToInt();
51 DCHECK_LT(successor_index, static_cast<int>(block_initial_states_.size()));
52 const BlockInitialState* existing_state =
53 block_initial_states_[successor_index];
57 DCHECK(existing_state->register_ == eh_frame_writer_.base_register());
58 DCHECK_EQ(existing_state->offset_, eh_frame_writer_.base_offset());
59 DCHECK_EQ(existing_state->tracking_fp_, tracking_fp_);
61 block_initial_states_[successor_index] =
new (zone_)
62 BlockInitialState(eh_frame_writer_.base_register(),
63 eh_frame_writer_.base_offset(), tracking_fp_);
68 void UnwindingInfoWriter::MarkFrameConstructed(
int pc_base) {
69 if (!enabled())
return;
72 eh_frame_writer_.AdvanceLocation(pc_base + 1);
73 eh_frame_writer_.IncreaseBaseAddressOffset(kInt64Size);
77 int top_of_stack = -eh_frame_writer_.base_offset();
78 eh_frame_writer_.RecordRegisterSavedToStack(rbp, top_of_stack);
81 eh_frame_writer_.AdvanceLocation(pc_base + 4);
82 eh_frame_writer_.SetBaseAddressRegister(rbp);
87 void UnwindingInfoWriter::MarkFrameDeconstructed(
int pc_base) {
88 if (!enabled())
return;
91 eh_frame_writer_.AdvanceLocation(pc_base + 3);
92 eh_frame_writer_.SetBaseAddressRegister(rsp);
95 eh_frame_writer_.AdvanceLocation(pc_base + 4);
96 eh_frame_writer_.IncreaseBaseAddressOffset(-kInt64Size);