1// Copyright 2012 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#ifndef V8_IA32_FRAMES_IA32_H_
6#define V8_IA32_FRAMES_IA32_H_
7
8namespace v8 {
9namespace internal {
10
11
12// Register lists
13// Note that the bit values must match those used in actual instruction encoding
14const int kNumRegs = 8;
15
16
17// Caller-saved registers
18const RegList kJSCallerSaved =
19  1 << 0 |  // eax
20  1 << 1 |  // ecx
21  1 << 2 |  // edx
22  1 << 3 |  // ebx - used as a caller-saved register in JavaScript code
23  1 << 7;   // edi - callee function
24
25const int kNumJSCallerSaved = 5;
26
27
28// Number of registers for which space is reserved in safepoints.
29const int kNumSafepointRegisters = 8;
30
31const int kNoAlignmentPadding = 0;
32const int kAlignmentPaddingPushed = 2;
33const int kAlignmentZapValue = 0x12345678;  // Not heap object tagged.
34
35// ----------------------------------------------------
36
37
38class EntryFrameConstants : public AllStatic {
39 public:
40  static const int kCallerFPOffset      = -6 * kPointerSize;
41
42  static const int kFunctionArgOffset   = +3 * kPointerSize;
43  static const int kReceiverArgOffset   = +4 * kPointerSize;
44  static const int kArgcOffset          = +5 * kPointerSize;
45  static const int kArgvOffset          = +6 * kPointerSize;
46};
47
48
49class ExitFrameConstants : public AllStatic {
50 public:
51  static const int kFrameSize      = 2 * kPointerSize;
52
53  static const int kCodeOffset     = -2 * kPointerSize;
54  static const int kSPOffset       = -1 * kPointerSize;
55
56  static const int kCallerFPOffset =  0 * kPointerSize;
57  static const int kCallerPCOffset = +1 * kPointerSize;
58
59  // FP-relative displacement of the caller's SP.  It points just
60  // below the saved PC.
61  static const int kCallerSPDisplacement = +2 * kPointerSize;
62
63  static const int kConstantPoolOffset   = 0;  // Not used
64};
65
66
67class JavaScriptFrameConstants : public AllStatic {
68 public:
69  // FP-relative.
70  static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
71  static const int kLastParameterOffset = +2 * kPointerSize;
72  static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
73
74  // Caller SP-relative.
75  static const int kParam0Offset   = -2 * kPointerSize;
76  static const int kReceiverOffset = -1 * kPointerSize;
77
78  static const int kDynamicAlignmentStateOffset = kLocal0Offset;
79};
80
81
82class ArgumentsAdaptorFrameConstants : public AllStatic {
83 public:
84  // FP-relative.
85  static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
86
87  static const int kFrameSize =
88      StandardFrameConstants::kFixedFrameSize + kPointerSize;
89};
90
91
92class ConstructFrameConstants : public AllStatic {
93 public:
94  // FP-relative.
95  static const int kImplicitReceiverOffset = -5 * kPointerSize;
96  static const int kConstructorOffset      = kMinInt;
97  static const int kLengthOffset           = -4 * kPointerSize;
98  static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
99
100  static const int kFrameSize =
101      StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
102};
103
104
105class InternalFrameConstants : public AllStatic {
106 public:
107  // FP-relative.
108  static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
109};
110
111
112inline Object* JavaScriptFrame::function_slot_object() const {
113  const int offset = JavaScriptFrameConstants::kFunctionOffset;
114  return Memory::Object_at(fp() + offset);
115}
116
117
118inline void StackHandler::SetFp(Address slot, Address fp) {
119  Memory::Address_at(slot) = fp;
120}
121
122
123} }  // namespace v8::internal
124
125#endif  // V8_IA32_FRAMES_IA32_H_
126