Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / v8 / src / mips / frames-mips.h
1 // Copyright 2011 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
6
7 #ifndef V8_MIPS_FRAMES_MIPS_H_
8 #define V8_MIPS_FRAMES_MIPS_H_
9
10 namespace v8 {
11 namespace internal {
12
13 // Register lists.
14 // Note that the bit values must match those used in actual instruction
15 // encoding.
16 const int kNumRegs = 32;
17
18 const RegList kJSCallerSaved =
19   1 << 2  |  // v0
20   1 << 3  |  // v1
21   1 << 4  |  // a0
22   1 << 5  |  // a1
23   1 << 6  |  // a2
24   1 << 7  |  // a3
25   1 << 8  |  // t0
26   1 << 9  |  // t1
27   1 << 10 |  // t2
28   1 << 11 |  // t3
29   1 << 12 |  // t4
30   1 << 13 |  // t5
31   1 << 14 |  // t6
32   1 << 15;   // t7
33
34 const int kNumJSCallerSaved = 14;
35
36
37 // Return the code of the n-th caller-saved register available to JavaScript
38 // e.g. JSCallerSavedReg(0) returns a0.code() == 4.
39 int JSCallerSavedCode(int n);
40
41
42 // Callee-saved registers preserved when switching from C to JavaScript.
43 const RegList kCalleeSaved =
44   1 << 16 |  // s0
45   1 << 17 |  // s1
46   1 << 18 |  // s2
47   1 << 19 |  // s3
48   1 << 20 |  // s4
49   1 << 21 |  // s5
50   1 << 22 |  // s6 (roots in Javascript code)
51   1 << 23 |  // s7 (cp in Javascript code)
52   1 << 30;   // fp/s8
53
54 const int kNumCalleeSaved = 9;
55
56 const RegList kCalleeSavedFPU =
57   1 << 20 |  // f20
58   1 << 22 |  // f22
59   1 << 24 |  // f24
60   1 << 26 |  // f26
61   1 << 28 |  // f28
62   1 << 30;   // f30
63
64 const int kNumCalleeSavedFPU = 6;
65
66 const RegList kCallerSavedFPU =
67   1 << 0  |  // f0
68   1 << 2  |  // f2
69   1 << 4  |  // f4
70   1 << 6  |  // f6
71   1 << 8  |  // f8
72   1 << 10 |  // f10
73   1 << 12 |  // f12
74   1 << 14 |  // f14
75   1 << 16 |  // f16
76   1 << 18;   // f18
77
78
79 // Number of registers for which space is reserved in safepoints. Must be a
80 // multiple of 8.
81 const int kNumSafepointRegisters = 24;
82
83 // Define the list of registers actually saved at safepoints.
84 // Note that the number of saved registers may be smaller than the reserved
85 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
86 const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved;
87 const int kNumSafepointSavedRegisters =
88     kNumJSCallerSaved + kNumCalleeSaved;
89
90 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
91
92 const int kUndefIndex = -1;
93 // Map with indexes on stack that corresponds to codes of saved registers.
94 const int kSafepointRegisterStackIndexMap[kNumRegs] = {
95   kUndefIndex,  // zero_reg
96   kUndefIndex,  // at
97   0,   // v0
98   1,   // v1
99   2,   // a0
100   3,   // a1
101   4,   // a2
102   5,   // a3
103   6,   // t0
104   7,   // t1
105   8,   // t2
106   9,   // t3
107   10,  // t4
108   11,  // t5
109   12,  // t6
110   13,  // t7
111   14,  // s0
112   15,  // s1
113   16,  // s2
114   17,  // s3
115   18,  // s4
116   19,  // s5
117   20,  // s6
118   21,  // s7
119   kUndefIndex,  // t8
120   kUndefIndex,  // t9
121   kUndefIndex,  // k0
122   kUndefIndex,  // k1
123   kUndefIndex,  // gp
124   kUndefIndex,  // sp
125   22,  // fp
126   kUndefIndex
127 };
128
129
130 // ----------------------------------------------------
131
132 class EntryFrameConstants : public AllStatic {
133  public:
134   static const int kCallerFPOffset =
135       -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
136 };
137
138
139 class ExitFrameConstants : public AllStatic {
140  public:
141   static const int kFrameSize = 2 * kPointerSize;
142
143   static const int kCodeOffset = -2 * kPointerSize;
144   static const int kSPOffset = -1 * kPointerSize;
145
146   // The caller fields are below the frame pointer on the stack.
147   static const int kCallerFPOffset = +0 * kPointerSize;
148   // The calling JS function is between FP and PC.
149   static const int kCallerPCOffset = +1 * kPointerSize;
150
151   // MIPS-specific: a pointer to the old sp to avoid unnecessary calculations.
152   static const int kCallerSPOffset = +2 * kPointerSize;
153
154   // FP-relative displacement of the caller's SP.
155   static const int kCallerSPDisplacement = +2 * kPointerSize;
156
157   static const int kConstantPoolOffset = 0;  // Not used.
158 };
159
160
161 class JavaScriptFrameConstants : public AllStatic {
162  public:
163   // FP-relative.
164   static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
165   static const int kLastParameterOffset = +2 * kPointerSize;
166   static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
167
168   // Caller SP-relative.
169   static const int kParam0Offset   = -2 * kPointerSize;
170   static const int kReceiverOffset = -1 * kPointerSize;
171 };
172
173
174 class ArgumentsAdaptorFrameConstants : public AllStatic {
175  public:
176   // FP-relative.
177   static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
178
179   static const int kFrameSize =
180       StandardFrameConstants::kFixedFrameSize + kPointerSize;
181 };
182
183
184 class ConstructFrameConstants : public AllStatic {
185  public:
186   // FP-relative.
187   static const int kImplicitReceiverOffset = -6 * kPointerSize;
188   static const int kConstructorOffset      = -5 * kPointerSize;
189   static const int kLengthOffset           = -4 * kPointerSize;
190   static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
191
192   static const int kFrameSize =
193       StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
194 };
195
196
197 class InternalFrameConstants : public AllStatic {
198  public:
199   // FP-relative.
200   static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
201 };
202
203
204 inline Object* JavaScriptFrame::function_slot_object() const {
205   const int offset = JavaScriptFrameConstants::kFunctionOffset;
206   return Memory::Object_at(fp() + offset);
207 }
208
209
210 inline void StackHandler::SetFp(Address slot, Address fp) {
211   Memory::Address_at(slot) = fp;
212 }
213
214
215 } }  // namespace v8::internal
216
217 #endif