| OLD | NEW |
| (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/eh-frame.h" | |
| 6 | |
| 7 namespace v8 { | |
| 8 namespace internal { | |
| 9 | |
| 10 static const int kRaxDwarfCode = 0; | |
| 11 static const int kRbpDwarfCode = 6; | |
| 12 static const int kRspDwarfCode = 7; | |
| 13 static const int kRipDwarfCode = 16; | |
| 14 | |
| 15 STATIC_CONST_MEMBER_DEFINITION const int | |
| 16 EhFrameConstants::kCodeAlignmentFactor = 1; | |
| 17 | |
| 18 STATIC_CONST_MEMBER_DEFINITION const int | |
| 19 EhFrameConstants::kDataAlignmentFactor = -8; | |
| 20 | |
| 21 void EhFrameWriter::WriteReturnAddressRegisterCode() { | |
| 22 WriteULeb128(kRipDwarfCode); | |
| 23 } | |
| 24 | |
| 25 void EhFrameWriter::WriteInitialStateInCie() { | |
| 26 SetBaseAddressRegisterAndOffset(rsp, kPointerSize); | |
| 27 // x64 rip (r16) has no Register instance associated. | |
| 28 RecordRegisterSavedToStack(kRipDwarfCode, -kPointerSize); | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 int EhFrameWriter::RegisterToDwarfCode(Register name) { | |
| 33 switch (name.code()) { | |
| 34 case Register::kCode_rbp: | |
| 35 return kRbpDwarfCode; | |
| 36 case Register::kCode_rsp: | |
| 37 return kRspDwarfCode; | |
| 38 case Register::kCode_rax: | |
| 39 return kRaxDwarfCode; | |
| 40 default: | |
| 41 UNIMPLEMENTED(); | |
| 42 return -1; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 #ifdef ENABLE_DISASSEMBLER | |
| 47 | |
| 48 // static | |
| 49 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { | |
| 50 switch (code) { | |
| 51 case kRbpDwarfCode: | |
| 52 return "rbp"; | |
| 53 case kRspDwarfCode: | |
| 54 return "rsp"; | |
| 55 case kRipDwarfCode: | |
| 56 return "rip"; | |
| 57 default: | |
| 58 UNIMPLEMENTED(); | |
| 59 return nullptr; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 #endif | |
| 64 | |
| 65 } // namespace internal | |
| 66 } // namespace v8 | |
| OLD | NEW |