• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/ppc/constants-ppc.h"
6 #include "src/diagnostics/eh-frame.h"
7 
8 namespace v8 {
9 namespace internal {
10 
11 const int EhFrameConstants::kCodeAlignmentFactor = 4;
12 // all PPC are 4 bytes instruction
13 const int EhFrameConstants::kDataAlignmentFactor = -8;  // 64-bit always -8
14 
WriteReturnAddressRegisterCode()15 void EhFrameWriter::WriteReturnAddressRegisterCode() {
16   WriteULeb128(kLrDwarfCode);
17 }
18 
WriteInitialStateInCie()19 void EhFrameWriter::WriteInitialStateInCie() {
20   SetBaseAddressRegisterAndOffset(fp, 0);
21   RecordRegisterNotModified(kLrDwarfCode);
22 }
23 
24 // static
RegisterToDwarfCode(Register name)25 int EhFrameWriter::RegisterToDwarfCode(Register name) {
26   switch (name.code()) {
27     case kRegCode_fp:
28       return kFpDwarfCode;
29     case kRegCode_sp:
30       return kSpDwarfCode;
31     case kRegCode_r0:
32       return kR0DwarfCode;
33     default:
34       UNIMPLEMENTED();
35       return -1;
36   }
37 }
38 
39 #ifdef ENABLE_DISASSEMBLER
40 
41 // static
DwarfRegisterCodeToString(int code)42 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) {
43   switch (code) {
44     case kFpDwarfCode:
45       return "fp";
46     case kSpDwarfCode:
47       return "sp";
48     default:
49       UNIMPLEMENTED();
50       return nullptr;
51   }
52 }
53 
54 #endif
55 
56 }  // namespace internal
57 }  // namespace v8
58