Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: src/compiler/arm64/unwinding-info-writer-arm64.cc

Issue 2026313002: Emit unwinding information for TurboFan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame
Patch Set: MarkFrameConstructed inside has_frame branch on ARM. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/arm64/unwinding-info-writer-arm64.h ('k') | src/compiler/code-generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/arm64/unwinding-info-writer-arm64.cc
diff --git a/src/compiler/arm64/unwinding-info-writer-arm64.cc b/src/compiler/arm64/unwinding-info-writer-arm64.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f4b732bf77ae6fba397494e5fbd9fd26ace2659e
--- /dev/null
+++ b/src/compiler/arm64/unwinding-info-writer-arm64.cc
@@ -0,0 +1,109 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler/arm64/unwinding-info-writer-arm64.h"
+#include "src/compiler/instruction.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+void UnwindingInfoWriter::BeginInstructionBlock(int pc_offset,
+ const InstructionBlock* block) {
+ if (!enabled()) return;
+
+ block_will_exit_ = false;
+
+ DCHECK_LT(block->rpo_number().ToInt(), block_initial_states_.size());
+ const BlockInitialState* initial_state =
+ block_initial_states_[block->rpo_number().ToInt()];
+ if (initial_state) {
+ if (initial_state->saved_lr_ != saved_lr_) {
+ eh_frame_writer_.AdvanceLocation(pc_offset);
+ if (initial_state->saved_lr_) {
+ eh_frame_writer_.RecordRegisterSavedToStack(lr, kPointerSize);
+ } else {
+ eh_frame_writer_.RecordRegisterFollowsInitialRule(lr);
+ }
+ saved_lr_ = initial_state->saved_lr_;
+ }
+ } else {
+ // The entry block always lacks an explicit initial state.
+ // The exit block may lack an explicit state, if it is only reached by
+ // the block ending in a ret.
+ // All the other blocks must have an explicit initial state.
+ DCHECK(block->predecessors().empty() || block->successors().empty());
+ }
+}
+
+void UnwindingInfoWriter::EndInstructionBlock(const InstructionBlock* block) {
+ if (!enabled() || block_will_exit_) return;
+
+ for (const RpoNumber& successor : block->successors()) {
+ int successor_index = successor.ToInt();
+ DCHECK_LT(successor_index, block_initial_states_.size());
+ const BlockInitialState* existing_state =
+ block_initial_states_[successor_index];
+
+ // If we already had an entry for this BB, check that the values are the
+ // same we are trying to insert.
+ if (existing_state) {
+ DCHECK_EQ(existing_state->saved_lr_, saved_lr_);
+ } else {
+ block_initial_states_[successor_index] =
+ new (zone_) BlockInitialState(saved_lr_);
+ }
+ }
+}
+
+void UnwindingInfoWriter::MarkFrameConstructed(int at_pc) {
+ if (!enabled()) return;
+
+ // Regardless of the type of frame constructed, the relevant part of the
+ // layout is always the one in the diagram:
+ //
+ // | .... | higher addresses
+ // +----------+ ^
+ // | LR | | |
+ // +----------+ | |
+ // | saved FP | | |
+ // +----------+ <-- FP v
+ // | .... | stack growth
+ //
+ // The LR is pushed on the stack, and we can record this fact at the end of
+ // the construction, since the LR itself is not modified in the process.
+ eh_frame_writer_.AdvanceLocation(at_pc);
+ eh_frame_writer_.RecordRegisterSavedToStack(lr, kPointerSize);
+ saved_lr_ = true;
+}
+
+void UnwindingInfoWriter::MarkFrameDeconstructed(int at_pc) {
+ if (!enabled()) return;
+
+ // The lr is restored by the last operation in LeaveFrame().
+ eh_frame_writer_.AdvanceLocation(at_pc);
+ eh_frame_writer_.RecordRegisterFollowsInitialRule(lr);
+ saved_lr_ = false;
+}
+
+void UnwindingInfoWriter::MarkLinkRegisterOnTopOfStack(int pc_offset,
+ const Register& sp) {
+ if (!enabled()) return;
+
+ eh_frame_writer_.AdvanceLocation(pc_offset);
+ eh_frame_writer_.SetBaseAddressRegisterAndOffset(sp, 0);
+ eh_frame_writer_.RecordRegisterSavedToStack(lr, 0);
+}
+
+void UnwindingInfoWriter::MarkPopLinkRegisterFromTopOfStack(int pc_offset) {
+ if (!enabled()) return;
+
+ eh_frame_writer_.AdvanceLocation(pc_offset);
+ eh_frame_writer_.SetBaseAddressRegisterAndOffset(fp, 0);
+ eh_frame_writer_.RecordRegisterFollowsInitialRule(lr);
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/compiler/arm64/unwinding-info-writer-arm64.h ('k') | src/compiler/code-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698