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 7namespace v8 { 8namespace internal { 9 10static const int kR0DwarfCode = 0; 11static const int kFpDwarfCode = 11; 12static const int kSpDwarfCode = 13; 13static const int kLrDwarfCode = 14; 14 15const int EhFrameConstants::kCodeAlignmentFactor = 4; 16const int EhFrameConstants::kDataAlignmentFactor = -4; 17 18void EhFrameWriter::WriteReturnAddressRegisterCode() { 19 WriteULeb128(kLrDwarfCode); 20} 21 22void EhFrameWriter::WriteInitialStateInCie() { 23 SetBaseAddressRegisterAndOffset(fp, 0); 24 RecordRegisterNotModified(lr); 25} 26 27// static 28int EhFrameWriter::RegisterToDwarfCode(Register name) { 29 switch (name.code()) { 30 case Register::kCode_fp: 31 return kFpDwarfCode; 32 case Register::kCode_sp: 33 return kSpDwarfCode; 34 case Register::kCode_lr: 35 return kLrDwarfCode; 36 case Register::kCode_r0: 37 return kR0DwarfCode; 38 default: 39 UNIMPLEMENTED(); 40 return -1; 41 } 42} 43 44#ifdef ENABLE_DISASSEMBLER 45 46// static 47const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 48 switch (code) { 49 case kFpDwarfCode: 50 return "fp"; 51 case kSpDwarfCode: 52 return "sp"; 53 case kLrDwarfCode: 54 return "lr"; 55 default: 56 UNIMPLEMENTED(); 57 return nullptr; 58 } 59} 60 61#endif 62 63} // namespace internal 64} // namespace v8 65