• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 
29 
30 #ifndef V8_MIPS_FRAMES_MIPS_H_
31 #define V8_MIPS_FRAMES_MIPS_H_
32 
33 
34 namespace v8 {
35 namespace internal {
36 
37 // Register lists.
38 // Note that the bit values must match those used in actual instruction
39 // encoding.
40 static const int kNumRegs = 32;
41 
42 static const RegList kJSCallerSaved =
43   1 << 4 |  // a0
44   1 << 5 |  // a1
45   1 << 6 |  // a2
46   1 << 7;   // a3
47 
48 static const int kNumJSCallerSaved = 4;
49 
50 
51 // Return the code of the n-th caller-saved register available to JavaScript
52 // e.g. JSCallerSavedReg(0) returns r0.code() == 0.
53 int JSCallerSavedCode(int n);
54 
55 
56 // Callee-saved registers preserved when switching from C to JavaScript.
57 static const RegList kCalleeSaved =
58   // Saved temporaries.
59   1 << 16 | 1 << 17 | 1 << 18 | 1 << 19 |
60   1 << 20 | 1 << 21 | 1 << 22 | 1 << 23 |
61   // gp, sp, fp
62   1 << 28 | 1 << 29 | 1 << 30;
63 
64 static const int kNumCalleeSaved = 11;
65 
66 
67 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
68 
69 
70 // ----------------------------------------------------
71 
72 class StackHandlerConstants : public AllStatic {
73  public:
74   static const int kNextOffset  = 0 * kPointerSize;
75   static const int kStateOffset = 1 * kPointerSize;
76   static const int kFPOffset    = 2 * kPointerSize;
77   static const int kPCOffset    = 3 * kPointerSize;
78 
79   static const int kSize = kPCOffset + kPointerSize;
80 };
81 
82 
83 class EntryFrameConstants : public AllStatic {
84  public:
85   static const int kCallerFPOffset      = -3 * kPointerSize;
86 };
87 
88 
89 class ExitFrameConstants : public AllStatic {
90  public:
91   // Exit frames have a debug marker on the stack.
92   static const int kSPDisplacement = -1 * kPointerSize;
93 
94   // The debug marker is just above the frame pointer.
95   static const int kDebugMarkOffset = -1 * kPointerSize;
96   // Must be the same as kDebugMarkOffset. Alias introduced when upgrading.
97   static const int kCodeOffset = -1 * kPointerSize;
98 
99   static const int kSavedRegistersOffset = 0 * kPointerSize;
100 
101   // The caller fields are below the frame pointer on the stack.
102   static const int kCallerFPOffset = +0 * kPointerSize;
103   // The calling JS function is between FP and PC.
104   static const int kCallerPCOffset = +1 * kPointerSize;
105 
106   // FP-relative displacement of the caller's SP.
107   static const int kCallerSPDisplacement = +4 * kPointerSize;
108 };
109 
110 
111 class StandardFrameConstants : public AllStatic {
112  public:
113   static const int kExpressionsOffset = -3 * kPointerSize;
114   static const int kMarkerOffset      = -2 * kPointerSize;
115   static const int kContextOffset     = -1 * kPointerSize;
116   static const int kCallerFPOffset    =  0 * kPointerSize;
117   static const int kCallerPCOffset    = +1 * kPointerSize;
118   static const int kCallerSPOffset    = +2 * kPointerSize;
119 
120   // Size of the MIPS 4 32-bit argument slots.
121   // This is just an alias with a shorter name. Use it from now on.
122   static const int kRArgsSlotsSize = 4 * kPointerSize;
123   static const int kRegularArgsSlotsSize = kRArgsSlotsSize;
124 
125   // C/C++ argument slots size.
126   static const int kCArgsSlotsSize = 4 * kPointerSize;
127   // JS argument slots size.
128   static const int kJSArgsSlotsSize = 0 * kPointerSize;
129 };
130 
131 
132 class JavaScriptFrameConstants : public AllStatic {
133  public:
134   // FP-relative.
135   static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
136   static const int kSavedRegistersOffset = +2 * kPointerSize;
137   static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
138 
139   // Caller SP-relative.
140   static const int kParam0Offset   = -2 * kPointerSize;
141   static const int kReceiverOffset = -1 * kPointerSize;
142 };
143 
144 
145 class ArgumentsAdaptorFrameConstants : public AllStatic {
146  public:
147   static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
148 };
149 
150 
151 class InternalFrameConstants : public AllStatic {
152  public:
153   static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
154 };
155 
156 
function_slot_object()157 inline Object* JavaScriptFrame::function_slot_object() const {
158   const int offset = JavaScriptFrameConstants::kFunctionOffset;
159   return Memory::Object_at(fp() + offset);
160 }
161 
162 } }  // namespace v8::internal
163 
164 #endif
165