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

Unified Diff: src/eh-frame.cc

Issue 1993653003: Initial support for emitting unwinding information in perf jitdump. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix imprecision in diagram . Created 4 years, 6 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/eh-frame.h ('k') | src/factory.cc » ('j') | src/factory.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/eh-frame.cc
diff --git a/src/eh-frame.cc b/src/eh-frame.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6bc60499e252403e9f82f48613ed26d892598cb4
--- /dev/null
+++ b/src/eh-frame.cc
@@ -0,0 +1,90 @@
+// 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/eh-frame.h"
+#include "src/objects-inl.h"
+#include "src/objects.h"
+
+namespace v8 {
+namespace internal {
+
+static const int DW_EH_PE_pcrel = 0x10;
+static const int DW_EH_PE_datarel = 0x30;
+static const int DW_EH_PE_udata4 = 0x03;
+static const int DW_EH_PE_sdata4 = 0x0b;
+
+const int EhFrameHdr::kCIESize = 0;
+
+//
+// In order to calculate offsets in the .eh_frame_hdr, we must know the layout
+// of the DSO generated by perf inject, which is assumed to be the following:
+//
+// | ... | |
+// +---------------+ <-- (F) --- | Larger offsets in file
+// | | ^ |
+// | Instructions | | .text v
+// | | v
+// +---------------+ <-- (E) ---
+// |///////////////|
+// |////Padding////|
+// |///////////////|
+// +---------------+ <-- (D) ---
+// | | ^
+// | CIE | |
+// | | |
+// +---------------+ <-- (C) | .eh_frame
+// | | |
+// | FDE | |
+// | | v
+// +---------------+ <-- (B) ---
+// | version | ^
+// +---------------+ |
+// | encoding | |
+// | specifiers | |
+// +---------------+ <---(A) | .eh_frame_hdr
+// | offset to | |
+// | .eh_frame | |
+// +---------------+ |
+// | ... | ...
+//
+// (F) is aligned at a 16-byte boundary.
+// (D) is aligned at a 8-byte boundary.
+// (B) is aligned at a 4-byte boundary.
+// (E), (C) and (A) have no alignment requirements.
+//
+// The size of the .eh_frame is required to be a multiple of the pointer size,
+// which means that (B) will always be aligned to a 4-byte boundary on all the
+// architectures we support. Instead, there could be padding between (E) and (D)
+// to reach the appropriate alignment. Since (F) is aligned at a 16-byte
+// boundary, thus to a 8-byte one as well, we have D - F = RoundUp(E - F, 8),
+// which means we don't need to know the absolute value of E.
rmcilroy 2016/06/24 09:45:25 I'm not sure what the "Instead..." sentence really
Stefano Sanfilippo 2016/06/24 10:36:37 The point is that we are guaranteed that there wil
+//
+EhFrameHdr::EhFrameHdr(Code* code) {
+ int code_size = code->is_crankshafted() ? code->safepoint_table_offset()
+ : code->instruction_size();
rmcilroy 2016/06/24 09:45:26 Looks like this code is in a couple of places (e.g
Stefano Sanfilippo 2016/06/24 10:36:37 Sure thing, maybe let's coordinate with jarin@.
+ version_ = 1;
+ eh_frame_ptr_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_pcrel;
+ lut_size_encoding_ = DW_EH_PE_udata4;
+ lut_entries_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_datarel;
+
+ // .eh_frame pointer and LUT
+ if (code->has_unwinding_info()) {
+ DCHECK_GE(code->unwinding_info_size(), EhFrameHdr::kRecordSize);
+ int eh_frame_size = code->unwinding_info_size() - EhFrameHdr::kRecordSize;
+
+ offset_to_eh_frame_ = -(eh_frame_size + 4); // A -> D
rmcilroy 2016/06/24 09:45:25 Where does the "+ 4" come from? Could you make the
Stefano Sanfilippo 2016/06/24 10:36:36 + 4 is the size of <version> (1 byte) and <encodin
rmcilroy 2016/06/24 12:55:25 Why not just have two constants: kVersionSize and
Stefano Sanfilippo 2016/06/24 13:17:28 Done.
+ lut_entries_number_ = 1;
+ offset_to_procedure_ = -(RoundUp(code_size, 8) + eh_frame_size); // B -> F
+ offset_to_fde_ = -(eh_frame_size - kCIESize); // B -> C
+ } else {
+ // Create a dummy table
+ offset_to_eh_frame_ = 0;
+ lut_entries_number_ = 0;
+ offset_to_procedure_ = 0;
+ offset_to_fde_ = 0;
+ }
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/eh-frame.h ('k') | src/factory.cc » ('j') | src/factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698