Index: src/unwinding-info.cc |
diff --git a/src/unwinding-info.cc b/src/unwinding-info.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..25cfac6363ffc65c6be77f3995129e84945dc853 |
--- /dev/null |
+++ b/src/unwinding-info.cc |
@@ -0,0 +1,59 @@ |
+// 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/unwinding-info.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; |
+ |
+static const int kSizeOfCIE = 0; |
+ |
+EhFrameHdr::EhFrameHdr(Code* code) { |
rmcilroy
2016/06/21 13:47:44
Can we have a test (cctest or unittest) for this c
Stefano Sanfilippo
2016/06/23 15:23:44
Done. I wrote a cctest because we need to pass thr
|
+ int code_size = code->is_crankshafted() ? code->safepoint_table_offset() |
+ : code->instruction_size(); |
+ 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); |
+ lut_entries_number_ = 1; |
+ offset_to_procedure_ = -(RoundUp(code_size, 8) + eh_frame_size); |
+ offset_to_fde_ = -(eh_frame_size - static_cast<int>(kSizeOfCIE)); |
+ } else { |
+ // Create a dummy table |
+ offset_to_eh_frame_ = 0; |
+ lut_entries_number_ = 0; |
+ offset_to_procedure_ = 0; |
+ offset_to_fde_ = 0; |
+ } |
+} |
+ |
+void PatchProcedureBoundariesInEhFrame(Code* code) { |
rmcilroy
2016/06/21 13:47:44
As mentioned above, please remove this from this C
Stefano Sanfilippo
2016/06/23 15:23:44
Removed. The issue was that in some circumstances
|
+ int boundaries_base_offset = kSizeOfCIE + 8; |
+ int32_t code_size = code->is_crankshafted() ? code->safepoint_table_offset() |
+ : code->instruction_size(); |
+ int32_t offset_to_text = -(RoundUp(code_size, 8) + boundaries_base_offset); |
+ |
+ MemMove(code->unwinding_info_start() + boundaries_base_offset, |
+ &offset_to_text, sizeof(offset_to_text)); |
+ MemMove(code->unwinding_info_start() + boundaries_base_offset + |
+ sizeof(offset_to_text), |
+ &code_size, sizeof(code_size)); |
+} |
+ |
+} // namespace internal |
+} // namespace v8 |