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/codegen/arm64/assembler-arm64-inl.h" 6 #include "src/diagnostics/eh-frame.h" 7 8 namespace v8 { 9 namespace internal { 10 11 static const int kX0DwarfCode = 0; 12 static const int kFpDwarfCode = 29; 13 static const int kLrDwarfCode = 30; 14 static const int kSpDwarfCode = 31; 15 16 const int EhFrameConstants::kCodeAlignmentFactor = 4; 17 const int EhFrameConstants::kDataAlignmentFactor = -8; 18 WriteReturnAddressRegisterCode()19void EhFrameWriter::WriteReturnAddressRegisterCode() { 20 WriteULeb128(kLrDwarfCode); 21 } 22 WriteInitialStateInCie()23void EhFrameWriter::WriteInitialStateInCie() { 24 SetBaseAddressRegisterAndOffset(x29, 0); 25 RecordRegisterNotModified(x30); 26 } 27 28 // static RegisterToDwarfCode(Register name)29int EhFrameWriter::RegisterToDwarfCode(Register name) { 30 switch (name.code()) { 31 case kRegCode_x29: 32 return kFpDwarfCode; 33 case kRegCode_x30: 34 return kLrDwarfCode; 35 case kSPRegInternalCode: 36 return kSpDwarfCode; 37 case kRegCode_x0: 38 return kX0DwarfCode; 39 default: 40 UNIMPLEMENTED(); 41 } 42 } 43 44 #ifdef ENABLE_DISASSEMBLER 45 46 // static DwarfRegisterCodeToString(int code)47const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 48 switch (code) { 49 case kFpDwarfCode: 50 return "fp"; 51 case kLrDwarfCode: 52 return "lr"; 53 case kSpDwarfCode: 54 return "sp"; // This could be zr as well 55 default: 56 UNIMPLEMENTED(); 57 } 58 } 59 60 #endif 61 62 } // namespace internal 63 } // namespace v8 64