OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FRAMES_H_ | 5 #ifndef V8_FRAMES_H_ |
6 #define V8_FRAMES_H_ | 6 #define V8_FRAMES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/safepoint-table.h" | 10 #include "src/safepoint-table.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 V(EXIT, ExitFrame) \ | 104 V(EXIT, ExitFrame) \ |
105 V(JAVA_SCRIPT, JavaScriptFrame) \ | 105 V(JAVA_SCRIPT, JavaScriptFrame) \ |
106 V(OPTIMIZED, OptimizedFrame) \ | 106 V(OPTIMIZED, OptimizedFrame) \ |
107 V(INTERPRETED, InterpretedFrame) \ | 107 V(INTERPRETED, InterpretedFrame) \ |
108 V(STUB, StubFrame) \ | 108 V(STUB, StubFrame) \ |
109 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ | 109 V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \ |
110 V(INTERNAL, InternalFrame) \ | 110 V(INTERNAL, InternalFrame) \ |
111 V(CONSTRUCT, ConstructFrame) \ | 111 V(CONSTRUCT, ConstructFrame) \ |
112 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) | 112 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) |
113 | 113 |
114 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume | |
115 // two slots. | |
116 // | |
117 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to | |
118 // the callee's saved return address and 1 corresponding to the saved frame | |
119 // pointer. Some frames have additional information stored in the fixed header, | |
120 // for example JSFunctions store the function context and marker in the fixed | |
121 // header, with slot index 2 corresponding to the current function context and 3 | |
122 // corresponding to the frame marker/JSFunction. | |
123 // | |
124 // slot JS frame | |
125 // +-----------------+-------------------------------- | |
126 // -n-1 | parameter 0 | ^ | |
127 // |- - - - - - - - -| | | |
128 // -n | | Caller | |
129 // ... | ... | frame slots | |
130 // -2 | parameter n-1 | (slot < 0) | |
131 // |- - - - - - - - -| | | |
132 // -1 | parameter n | v | |
133 // -----+-----------------+-------------------------------- | |
134 // 0 | return addr | ^ ^ | |
135 // |- - - - - - - - -| | | | |
136 // 1 | saved frame ptr | Fixed | | |
137 // |- - - - - - - - -| Header <-- frame ptr | | |
138 // 2 | [Constant Pool] | | | | |
139 // |- - - - - - - - -| | | | |
140 // 2+cp | Context | | if a constant pool | | |
141 // |- - - - - - - - -| | is used, cp = 1, | | |
142 // 3+cp |JSFunction/Marker| v otherwise, cp = 0 | | |
143 // +-----------------+---- | | |
144 // 4+cp | | ^ Callee | |
145 // |- - - - - - - - -| | frame slots | |
146 // ... | | Frame slots (slot >= 0) | |
147 // |- - - - - - - - -| | | | |
148 // | | v | | |
149 // -----+-----------------+----- <-- stack ptr ------------- | |
150 // | |
151 | 114 |
152 class StandardFrameConstants : public AllStatic { | 115 class StandardFrameConstants : public AllStatic { |
153 public: | 116 public: |
154 // Fixed part of the frame consists of return address, caller fp, | 117 // Fixed part of the frame consists of return address, caller fp, |
155 // constant pool (if FLAG_enable_embedded_constant_pool), context, and | 118 // constant pool (if FLAG_enable_embedded_constant_pool), context, and |
156 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset | 119 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset |
157 // is the last object pointer. | 120 // is the last object pointer. |
158 static const int kCPSlotSize = | 121 static const int kCPSlotSize = |
159 FLAG_enable_embedded_constant_pool ? kPointerSize : 0; | 122 FLAG_enable_embedded_constant_pool ? kPointerSize : 0; |
160 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize; | 123 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 static const int kLastParamFromRegisterPointer = | 203 static const int kLastParamFromRegisterPointer = |
241 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize; | 204 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize; |
242 | 205 |
243 static const int kBytecodeOffsetFromRegisterPointer = 1 * kPointerSize; | 206 static const int kBytecodeOffsetFromRegisterPointer = 1 * kPointerSize; |
244 static const int kBytecodeArrayFromRegisterPointer = 2 * kPointerSize; | 207 static const int kBytecodeArrayFromRegisterPointer = 2 * kPointerSize; |
245 static const int kNewTargetFromRegisterPointer = 3 * kPointerSize; | 208 static const int kNewTargetFromRegisterPointer = 3 * kPointerSize; |
246 static const int kFunctionFromRegisterPointer = 4 * kPointerSize; | 209 static const int kFunctionFromRegisterPointer = 4 * kPointerSize; |
247 static const int kContextFromRegisterPointer = 5 * kPointerSize; | 210 static const int kContextFromRegisterPointer = 5 * kPointerSize; |
248 }; | 211 }; |
249 | 212 |
250 inline static int FPOffsetToFrameSlot(int frame_offset) { | |
251 return StandardFrameConstants::kFixedSlotCountAboveFp - 1 - | |
252 frame_offset / kPointerSize; | |
253 } | |
254 | |
255 inline static int FrameSlotToFPOffset(int slot) { | |
256 return (StandardFrameConstants::kFixedSlotCountAboveFp - 1 - slot) * | |
257 kPointerSize; | |
258 } | |
259 | 213 |
260 // Abstract base class for all stack frames. | 214 // Abstract base class for all stack frames. |
261 class StackFrame BASE_EMBEDDED { | 215 class StackFrame BASE_EMBEDDED { |
262 public: | 216 public: |
263 #define DECLARE_TYPE(type, ignore) type, | 217 #define DECLARE_TYPE(type, ignore) type, |
264 enum Type { | 218 enum Type { |
265 NONE = 0, | 219 NONE = 0, |
266 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) | 220 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) |
267 NUMBER_OF_TYPES, | 221 NUMBER_OF_TYPES, |
268 // Used by FrameScope to indicate that the stack frame is constructed | 222 // Used by FrameScope to indicate that the stack frame is constructed |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 | 1009 |
1056 | 1010 |
1057 // Reads all frames on the current stack and copies them into the current | 1011 // Reads all frames on the current stack and copies them into the current |
1058 // zone memory. | 1012 // zone memory. |
1059 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1013 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1060 | 1014 |
1061 } // namespace internal | 1015 } // namespace internal |
1062 } // namespace v8 | 1016 } // namespace v8 |
1063 | 1017 |
1064 #endif // V8_FRAMES_H_ | 1018 #endif // V8_FRAMES_H_ |
OLD | NEW |