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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 // -2 | parameter n-1 | (slot < 0) | 130 // -2 | parameter n-1 | (slot < 0) |
131 // |- - - - - - - - -| | | 131 // |- - - - - - - - -| | |
132 // -1 | parameter n | v | 132 // -1 | parameter n | v |
133 // -----+-----------------+-------------------------------- | 133 // -----+-----------------+-------------------------------- |
134 // 0 | return addr | ^ ^ | 134 // 0 | return addr | ^ ^ |
135 // |- - - - - - - - -| | | | 135 // |- - - - - - - - -| | | |
136 // 1 | saved frame ptr | Fixed | | 136 // 1 | saved frame ptr | Fixed | |
137 // |- - - - - - - - -| Header <-- frame ptr | | 137 // |- - - - - - - - -| Header <-- frame ptr | |
138 // 2 | [Constant Pool] | | | | 138 // 2 | [Constant Pool] | | | |
139 // |- - - - - - - - -| | | | 139 // |- - - - - - - - -| | | |
140 // 2+cp |Context/Frm. Type| v if a constant pool | | |
141 // |-----------------+---- is used, cp = 1, | | |
142 // 3+cp | | ^ otherwise, cp = 0 | | |
143 // |- - - - - - - - -| | | | |
144 // 4+cp | | | Callee | |
145 // |- - - - - - - - -| | frame slots | |
146 // ... | | Frame slots (slot >= 0) | |
147 // |- - - - - - - - -| | | | |
148 // | | v | | |
149 // -----+-----------------+----- <-- stack ptr ------------- | |
150 // | |
151 class CommonFrameConstants : public AllStatic { | |
152 public: | |
153 static const int kCallerFPOffset = 0 * kPointerSize; | |
154 static const int kCallerPCOffset = +1 * kFPOnStackSize; | |
Michael Starzinger
2016/02/23 10:57:33
nit: "kCallerPCOffset = kCallerFPOffset + 1 * kFPO
danno
2016/03/07 09:33:38
Done.
| |
155 static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize; | |
156 | |
157 // Fixed part of the frame consists of return address, caller fp, | |
158 // constant pool (if FLAG_enable_embedded_constant_pool), context, and | |
159 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset | |
160 // is the last object pointer. | |
161 static const int kCPSlotSize = | |
162 FLAG_enable_embedded_constant_pool ? kPointerSize : 0; | |
163 static const int kFixedFrameSizeAboveFp = kPCOnStackSize + kFPOnStackSize; | |
164 static const int kFixedSlotCountAboveFp = | |
165 kFixedFrameSizeAboveFp / kPointerSize; | |
166 static const int kCPSlotCount = kCPSlotSize / kPointerSize; | |
167 static const int kContextOrFrameTypeSize = kPointerSize; | |
168 static const int kContextOrFrameTypeOffset = | |
169 -(kCPSlotSize + kContextOrFrameTypeSize); | |
170 }; | |
171 | |
172 // StandardFrames are used for interpreted, full-codegen and optimized | |
173 // JavaScript frames. They always have a context below the saved fp/constant | |
174 // pool and below that the JSFunction of the executing function. | |
175 // | |
176 // slot JS frame | |
177 // +-----------------+-------------------------------- | |
178 // -n-1 | parameter 0 | ^ | |
179 // |- - - - - - - - -| | | |
180 // -n | | Caller | |
181 // ... | ... | frame slots | |
182 // -2 | parameter n-1 | (slot < 0) | |
183 // |- - - - - - - - -| | | |
184 // -1 | parameter n | v | |
185 // -----+-----------------+-------------------------------- | |
186 // 0 | return addr | ^ ^ | |
187 // |- - - - - - - - -| | | | |
188 // 1 | saved frame ptr | Fixed | | |
189 // |- - - - - - - - -| Header <-- frame ptr | | |
190 // 2 | [Constant Pool] | | | | |
191 // |- - - - - - - - -| | | | |
140 // 2+cp | Context | | if a constant pool | | 192 // 2+cp | Context | | if a constant pool | |
141 // |- - - - - - - - -| | is used, cp = 1, | | 193 // |- - - - - - - - -| | is used, cp = 1, | |
142 // 3+cp |JSFunction/Marker| v otherwise, cp = 0 | | 194 // 3+cp | JSFunction | v otherwise, cp = 0 | |
143 // +-----------------+---- | | 195 // +-----------------+---- | |
144 // 4+cp | | ^ Callee | 196 // 4+cp | | ^ Callee |
145 // |- - - - - - - - -| | frame slots | 197 // |- - - - - - - - -| | frame slots |
146 // ... | | Frame slots (slot >= 0) | 198 // ... | | Frame slots (slot >= 0) |
147 // |- - - - - - - - -| | | | 199 // |- - - - - - - - -| | | |
148 // | | v | | 200 // | | v | |
149 // -----+-----------------+----- <-- stack ptr ------------- | 201 // -----+-----------------+----- <-- stack ptr ------------- |
150 // | 202 // |
151 | 203 class StandardFrameConstants : public CommonFrameConstants { |
152 class StandardFrameConstants : public AllStatic { | |
153 public: | 204 public: |
154 // Fixed part of the frame consists of return address, caller fp, | 205 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize; |
155 // constant pool (if FLAG_enable_embedded_constant_pool), context, and | |
156 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset | |
157 // is the last object pointer. | |
158 static const int kCPSlotSize = | |
159 FLAG_enable_embedded_constant_pool ? kPointerSize : 0; | |
160 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize; | |
161 static const int kFixedFrameSizeAboveFp = kPCOnStackSize + kFPOnStackSize; | |
162 static const int kFixedFrameSize = | 206 static const int kFixedFrameSize = |
163 kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp; | 207 kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp; |
164 static const int kFixedSlotCountAboveFp = | 208 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize; |
165 kFixedFrameSizeAboveFp / kPointerSize; | |
166 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; | 209 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; |
167 static const int kCPSlotCount = kCPSlotSize / kPointerSize; | 210 static const int kContextOffset = kContextOrFrameTypeOffset; |
211 static const int kFunctionOffset = -2 * kPointerSize - kCPSlotSize; | |
168 static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize; | 212 static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize; |
169 static const int kMarkerOffset = -2 * kPointerSize - kCPSlotSize; | |
170 static const int kContextOffset = -1 * kPointerSize - kCPSlotSize; | |
171 static const int kConstantPoolOffset = kCPSlotSize ? -1 * kPointerSize : 0; | 213 static const int kConstantPoolOffset = kCPSlotSize ? -1 * kPointerSize : 0; |
172 static const int kCallerFPOffset = 0 * kPointerSize; | |
173 static const int kCallerPCOffset = +1 * kFPOnStackSize; | |
174 static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize; | |
175 | |
176 static const int kLastObjectOffset = kContextOffset; | 214 static const int kLastObjectOffset = kContextOffset; |
177 }; | 215 }; |
178 | 216 |
217 // TypedFrames have a SMI type maker value below the saved FP/constant pool to | |
218 // distinguish them from StandardFrames, which have a context in that position | |
219 // instead. | |
220 // | |
221 // slot JS frame | |
222 // +-----------------+-------------------------------- | |
223 // -n-1 | parameter 0 | ^ | |
224 // |- - - - - - - - -| | | |
225 // -n | | Caller | |
226 // ... | ... | frame slots | |
227 // -2 | parameter n-1 | (slot < 0) | |
228 // |- - - - - - - - -| | | |
229 // -1 | parameter n | v | |
230 // -----+-----------------+-------------------------------- | |
231 // 0 | return addr | ^ ^ | |
232 // |- - - - - - - - -| | | | |
233 // 1 | saved frame ptr | Fixed | | |
234 // |- - - - - - - - -| Header <-- frame ptr | | |
235 // 2 | [Constant Pool] | | | | |
236 // |- - - - - - - - -| | | | |
237 // 2+cp |Frame Type Marker| v if a constant pool | | |
238 // |-----------------+---- is used, cp = 1, | | |
239 // 3+cp | | ^ otherwise, cp = 0 | | |
240 // |- - - - - - - - -| | | | |
241 // 4+cp | | | Callee | |
242 // |- - - - - - - - -| | frame slots | |
243 // ... | | Frame slots (slot >= 0) | |
244 // |- - - - - - - - -| | | | |
245 // | | v | | |
246 // -----+-----------------+----- <-- stack ptr ------------- | |
247 // | |
248 class TypedFrameConstants : public CommonFrameConstants { | |
249 public: | |
250 static const int kFrameTypeSize = kContextOrFrameTypeSize; | |
251 static const int kFrameTypeOffset = kContextOrFrameTypeOffset; | |
252 static const int kFixedFrameSizeFromFp = kCPSlotSize + kFrameTypeSize; | |
253 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize; | |
254 static const int kFixedFrameSize = | |
255 StandardFrameConstants::kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp; | |
256 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; | |
257 static const int kFirstPushedFrameValueOffset = | |
258 -StandardFrameConstants::kCPSlotSize - kFrameTypeSize - kPointerSize; | |
259 }; | |
179 | 260 |
180 class ArgumentsAdaptorFrameConstants : public AllStatic { | 261 #define TYPED_FRAME_PUSHED_VALUE_OFFSET(x) \ |
262 (TypedFrameConstants::kFirstPushedFrameValueOffset - (x)*kPointerSize) | |
263 #define TYPED_FRAME_SIZE(count) \ | |
264 (TypedFrameConstants::kFixedFrameSize + (count)*kPointerSize) | |
265 #define TYPED_FRAME_SIZE_FROM_SP(count) \ | |
266 (TypedFrameConstants::kFixedFrameSizeFromFp + (count)*kPointerSize) | |
267 #define DEFINE_TYPED_FRAME_SIZES(count) \ | |
268 static const int kFixedFrameSize = TYPED_FRAME_SIZE(count); \ | |
269 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; \ | |
270 static const int kFixedFrameSizeFromFp = TYPED_FRAME_SIZE_FROM_SP(count); \ | |
271 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize | |
272 | |
273 class ArgumentsAdaptorFrameConstants : public TypedFrameConstants { | |
181 public: | 274 public: |
182 // FP-relative. | 275 // FP-relative. |
183 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; | 276 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); |
277 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | |
278 DEFINE_TYPED_FRAME_SIZES(2); | |
279 }; | |
184 | 280 |
185 static const int kFrameSize = | 281 class InternalFrameConstants : public TypedFrameConstants { |
186 StandardFrameConstants::kFixedFrameSize + kPointerSize; | 282 public: |
283 // FP-relative. | |
284 static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | |
285 DEFINE_TYPED_FRAME_SIZES(1); | |
286 }; | |
287 | |
288 class FrameDropperFrameConstants : public InternalFrameConstants { | |
289 public: | |
290 // FP-relative. | |
291 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | |
292 DEFINE_TYPED_FRAME_SIZES(2); | |
293 }; | |
294 | |
295 class ConstructFrameConstants : public TypedFrameConstants { | |
296 public: | |
297 // FP-relative. | |
298 static const int kContextOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | |
299 static const int kAllocationSiteOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | |
300 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); | |
301 | |
302 // static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3); | |
Michael Starzinger
2016/02/23 10:57:33
nit: Looks like leftover, can we drop this line an
danno
2016/03/07 09:33:38
Done.
| |
303 static const int kImplicitReceiverOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3); | |
304 DEFINE_TYPED_FRAME_SIZES(4); | |
305 }; | |
306 | |
307 class StubFailureTrampolineFrameConstants : public InternalFrameConstants { | |
308 public: | |
309 static const int kArgumentsArgumentsOffset = | |
310 TYPED_FRAME_PUSHED_VALUE_OFFSET(0); | |
311 static const int kArgumentsLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1); | |
312 static const int kArgumentsPointerOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2); | |
313 static const int kFixedHeaderBottomOffset = kArgumentsPointerOffset; | |
314 DEFINE_TYPED_FRAME_SIZES(3); | |
187 }; | 315 }; |
188 | 316 |
189 | 317 |
190 class InternalFrameConstants : public AllStatic { | |
191 public: | |
192 // FP-relative. | |
193 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; | |
194 }; | |
195 | |
196 | |
197 class ConstructFrameConstants : public AllStatic { | |
198 public: | |
199 // FP-relative. | |
200 static const int kImplicitReceiverOffset = | |
201 StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize; | |
202 static const int kLengthOffset = | |
203 StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize; | |
204 static const int kAllocationSiteOffset = | |
205 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | |
206 static const int kCodeOffset = | |
207 StandardFrameConstants::kExpressionsOffset - 0 * kPointerSize; | |
208 | |
209 static const int kFrameSize = | |
210 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize; | |
211 }; | |
212 | |
213 | |
214 class InterpreterFrameConstants : public AllStatic { | 318 class InterpreterFrameConstants : public AllStatic { |
215 public: | 319 public: |
216 // Fixed frame includes new.target and bytecode offset. | 320 // Fixed frame includes new.target and bytecode offset. |
217 static const int kFixedFrameSize = | 321 static const int kFixedFrameSize = |
218 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize; | 322 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize; |
219 static const int kFixedFrameSizeFromFp = | 323 static const int kFixedFrameSizeFromFp = |
220 StandardFrameConstants::kFixedFrameSizeFromFp + 3 * kPointerSize; | 324 StandardFrameConstants::kFixedFrameSizeFromFp + 3 * kPointerSize; |
221 | 325 |
222 // FP-relative. | 326 // FP-relative. |
223 static const int kNewTargetFromFp = | 327 static const int kNewTargetFromFp = |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 | 966 |
863 Address GetCallerStackPointer() const override; | 967 Address GetCallerStackPointer() const override; |
864 | 968 |
865 private: | 969 private: |
866 friend class StackFrameIteratorBase; | 970 friend class StackFrameIteratorBase; |
867 }; | 971 }; |
868 | 972 |
869 | 973 |
870 class StubFailureTrampolineFrame: public StandardFrame { | 974 class StubFailureTrampolineFrame: public StandardFrame { |
871 public: | 975 public: |
872 // sizeof(Arguments) - sizeof(Arguments*) is 3 * kPointerSize), but the | |
873 // presubmit script complains about using sizeof() on a type. | |
874 static const int kFirstRegisterParameterFrameOffset = | |
875 StandardFrameConstants::kMarkerOffset - 3 * kPointerSize; | |
876 | |
877 static const int kCallerStackParameterCountFrameOffset = | |
878 StandardFrameConstants::kMarkerOffset - 2 * kPointerSize; | |
879 | |
880 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } | 976 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } |
881 | 977 |
882 // Get the code associated with this frame. | 978 // Get the code associated with this frame. |
883 // This method could be called during marking phase of GC. | 979 // This method could be called during marking phase of GC. |
884 Code* unchecked_code() const override; | 980 Code* unchecked_code() const override; |
885 | 981 |
886 void Iterate(ObjectVisitor* v) const override; | 982 void Iterate(ObjectVisitor* v) const override; |
887 | 983 |
888 // Architecture-specific register description. | 984 // Architecture-specific register description. |
889 static Register fp_register(); | 985 static Register fp_register(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1055 | 1151 |
1056 | 1152 |
1057 // Reads all frames on the current stack and copies them into the current | 1153 // Reads all frames on the current stack and copies them into the current |
1058 // zone memory. | 1154 // zone memory. |
1059 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1155 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1060 | 1156 |
1061 } // namespace internal | 1157 } // namespace internal |
1062 } // namespace v8 | 1158 } // namespace v8 |
1063 | 1159 |
1064 #endif // V8_FRAMES_H_ | 1160 #endif // V8_FRAMES_H_ |
OLD | NEW |