Chromium Code Reviews

Side by Side Diff: src/compiler/x64/unwinding-info-writer-x64.cc

Issue 2026313002: Emit unwinding information for TurboFan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame
Patch Set: Clarify assumptions on frame ction/dtion routines in arm/arm64. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
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
5 #include "src/compiler/x64/unwinding-info-writer-x64.h"
6 #include "src/compiler/instruction.h"
7
8 namespace v8 {
9 namespace internal {
10 namespace compiler {
11
12 void UnwindingInfoWriter::BeginInstructionBlock(int pc_offset,
13 const InstructionBlock* block) {
14 block_will_exit_ = false;
15
16 auto lookup = block_initial_states_.find(block->rpo_number().ToInt());
17 if (lookup != block_initial_states_.end()) {
18 if (!lookup->second.register_.is(eh_frame_writer_.base_register()) &&
19 lookup->second.offset_ != eh_frame_writer_.base_offset()) {
20 eh_frame_writer_.AdvanceLocation(pc_offset);
21 eh_frame_writer_.SetBaseAddressRegisterAndOffset(lookup->second.register_,
22 lookup->second.offset_);
23 } else if (!lookup->second.register_.is(eh_frame_writer_.base_register())) {
24 eh_frame_writer_.AdvanceLocation(pc_offset);
25 eh_frame_writer_.SetBaseAddressRegister(lookup->second.register_);
26 } else if (lookup->second.offset_ != eh_frame_writer_.base_offset()) {
27 eh_frame_writer_.AdvanceLocation(pc_offset);
28 eh_frame_writer_.SetBaseAddressOffset(lookup->second.offset_);
29 }
30
31 tracking_fp_ = lookup->second.tracking_fp_;
32 } else {
33 // The entry block always lacks an explicit initial state.
34 // The exit block may lack an explicit state, if it is only reached by
35 // the block ending in a ret.
36 // All the other blocks must have an explicit initial state.
37 DCHECK(block->predecessors().empty() || block->successors().empty());
38 }
39 }
40
41 void UnwindingInfoWriter::EndInstructionBlock(const InstructionBlock* block) {
42 if (block_will_exit_) return;
43
44 for (const RpoNumber& successor : block->successors()) {
45 BlockInitialState state = {eh_frame_writer_.base_register(),
46 eh_frame_writer_.base_offset(), tracking_fp_};
47 auto inserted = block_initial_states_.insert({successor.ToInt(), state});
48 // If we already had an entry for this BB, check that the values are the
49 // same we were trying to insert.
50 if (!inserted.second) {
51 DCHECK(inserted.first->second.register_.is(state.register_));
52 DCHECK_EQ(inserted.first->second.offset_, state.offset_);
53 DCHECK_EQ(inserted.first->second.tracking_fp_, state.tracking_fp_);
54 }
55 }
56 }
57
58 void UnwindingInfoWriter::MarkFrameConstructed(int pc_base) {
59 // push rbp
60 eh_frame_writer_.AdvanceLocation(pc_base + 1);
61 eh_frame_writer_.IncreaseBaseAddressOffset(kInt64Size);
62 eh_frame_writer_.RecordRegisterSavedToStack(rbp);
63
64 // mov rbp, rsp
65 eh_frame_writer_.AdvanceLocation(pc_base + 4);
66 eh_frame_writer_.SetBaseAddressRegister(rbp);
67
68 tracking_fp_ = true;
69 }
70
71 void UnwindingInfoWriter::MarkFrameDeconstructed(int pc_base) {
72 // mov rsp, rbp
73 eh_frame_writer_.AdvanceLocation(pc_base + 3);
74 eh_frame_writer_.SetBaseAddressRegister(rsp);
75
76 // pop rbp
77 eh_frame_writer_.AdvanceLocation(pc_base + 4);
78 eh_frame_writer_.IncreaseBaseAddressOffset(-kInt64Size);
79
80 tracking_fp_ = false;
81 }
82
83 } // namespace compiler
84 } // namespace internal
85 } // namespace v8
OLDNEW

Powered by Google App Engine