• 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   }
36 }
37 
38 #ifdef ENABLE_DISASSEMBLER
39 
40 // static
DwarfRegisterCodeToString(int code)41 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) {
42   switch (code) {
43     case kFpDwarfCode:
44       return "fp";
45     case kSpDwarfCode:
46       return "sp";
47     default:
48       UNIMPLEMENTED();
49   }
50 }
51 
52 #endif
53 
54 }  // namespace internal
55 }  // namespace v8
56