V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
eh-frame-x64.cc
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 #include "src/zone/zone-containers.h"
7 
8 namespace v8 {
9 namespace internal {
10 
11 static const int kRaxDwarfCode = 0;
12 static const int kRbpDwarfCode = 6;
13 static const int kRspDwarfCode = 7;
14 static const int kRipDwarfCode = 16;
15 
16 const int EhFrameConstants::kCodeAlignmentFactor = 1;
17 const int EhFrameConstants::kDataAlignmentFactor = -8;
18 
19 void EhFrameWriter::WriteReturnAddressRegisterCode() {
20  WriteULeb128(kRipDwarfCode);
21 }
22 
23 void EhFrameWriter::WriteInitialStateInCie() {
24  SetBaseAddressRegisterAndOffset(rsp, kPointerSize);
25  // x64 rip (r16) has no Register instance associated.
26  RecordRegisterSavedToStack(kRipDwarfCode, -kPointerSize);
27 }
28 
29 // static
30 int EhFrameWriter::RegisterToDwarfCode(Register name) {
31  switch (name.code()) {
32  case kRegCode_rbp:
33  return kRbpDwarfCode;
34  case kRegCode_rsp:
35  return kRspDwarfCode;
36  case kRegCode_rax:
37  return kRaxDwarfCode;
38  default:
39  UNIMPLEMENTED();
40  return -1;
41  }
42 }
43 
44 #ifdef ENABLE_DISASSEMBLER
45 
46 // static
47 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) {
48  switch (code) {
49  case kRbpDwarfCode:
50  return "rbp";
51  case kRspDwarfCode:
52  return "rsp";
53  case kRipDwarfCode:
54  return "rip";
55  default:
56  UNIMPLEMENTED();
57  return nullptr;
58  }
59 }
60 
61 #endif
62 
63 } // namespace internal
64 } // namespace v8
Definition: libplatform.h:13