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