Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/frames.h

Issue 1696043002: [runtime] Unify and simplify how frames are marked (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix merge problems Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // -2 | parameter n-1 | (slot < 0) 132 // -2 | parameter n-1 | (slot < 0)
133 // |- - - - - - - - -| | 133 // |- - - - - - - - -| |
134 // -1 | parameter n | v 134 // -1 | parameter n | v
135 // -----+-----------------+-------------------------------- 135 // -----+-----------------+--------------------------------
136 // 0 | return addr | ^ ^ 136 // 0 | return addr | ^ ^
137 // |- - - - - - - - -| | | 137 // |- - - - - - - - -| | |
138 // 1 | saved frame ptr | Fixed | 138 // 1 | saved frame ptr | Fixed |
139 // |- - - - - - - - -| Header <-- frame ptr | 139 // |- - - - - - - - -| Header <-- frame ptr |
140 // 2 | [Constant Pool] | | | 140 // 2 | [Constant Pool] | | |
141 // |- - - - - - - - -| | | 141 // |- - - - - - - - -| | |
142 // 2+cp |Context/Frm. Type| v if a constant pool |
143 // |-----------------+---- is used, cp = 1, |
144 // 3+cp | | ^ otherwise, cp = 0 |
145 // |- - - - - - - - -| | |
146 // 4+cp | | | Callee
147 // |- - - - - - - - -| | frame slots
148 // ... | | Frame slots (slot >= 0)
149 // |- - - - - - - - -| | |
150 // | | v |
151 // -----+-----------------+----- <-- stack ptr -------------
152 //
153 class CommonFrameConstants : public AllStatic {
154 public:
155 static const int kCallerFPOffset = 0 * kPointerSize;
156 static const int kCallerPCOffset = kCallerFPOffset + 1 * kFPOnStackSize;
157 static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize;
158
159 // Fixed part of the frame consists of return address, caller fp,
160 // constant pool (if FLAG_enable_embedded_constant_pool), context, and
161 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset
162 // is the last object pointer.
163 static const int kFixedFrameSizeAboveFp = kPCOnStackSize + kFPOnStackSize;
164 static const int kFixedSlotCountAboveFp =
165 kFixedFrameSizeAboveFp / kPointerSize;
166 static const int kCPSlotSize =
167 FLAG_enable_embedded_constant_pool ? kPointerSize : 0;
168 static const int kCPSlotCount = kCPSlotSize / kPointerSize;
169 static const int kConstantPoolOffset = kCPSlotSize ? -1 * kPointerSize : 0;
170 static const int kContextOrFrameTypeSize = kPointerSize;
171 static const int kContextOrFrameTypeOffset =
172 -(kCPSlotSize + kContextOrFrameTypeSize);
173 };
174
175 // StandardFrames are used for interpreted, full-codegen and optimized
176 // JavaScript frames. They always have a context below the saved fp/constant
177 // pool and below that the JSFunction of the executing function.
178 //
179 // slot JS frame
180 // +-----------------+--------------------------------
181 // -n-1 | parameter 0 | ^
182 // |- - - - - - - - -| |
183 // -n | | Caller
184 // ... | ... | frame slots
185 // -2 | parameter n-1 | (slot < 0)
186 // |- - - - - - - - -| |
187 // -1 | parameter n | v
188 // -----+-----------------+--------------------------------
189 // 0 | return addr | ^ ^
190 // |- - - - - - - - -| | |
191 // 1 | saved frame ptr | Fixed |
192 // |- - - - - - - - -| Header <-- frame ptr |
193 // 2 | [Constant Pool] | | |
194 // |- - - - - - - - -| | |
142 // 2+cp | Context | | if a constant pool | 195 // 2+cp | Context | | if a constant pool |
143 // |- - - - - - - - -| | is used, cp = 1, | 196 // |- - - - - - - - -| | is used, cp = 1, |
144 // 3+cp |JSFunction/Marker| v otherwise, cp = 0 | 197 // 3+cp | JSFunction | v otherwise, cp = 0 |
145 // +-----------------+---- | 198 // +-----------------+---- |
146 // 4+cp | | ^ Callee 199 // 4+cp | | ^ Callee
147 // |- - - - - - - - -| | frame slots 200 // |- - - - - - - - -| | frame slots
148 // ... | | Frame slots (slot >= 0) 201 // ... | | Frame slots (slot >= 0)
149 // |- - - - - - - - -| | | 202 // |- - - - - - - - -| | |
150 // | | v | 203 // | | v |
151 // -----+-----------------+----- <-- stack ptr ------------- 204 // -----+-----------------+----- <-- stack ptr -------------
152 // 205 //
153 206 class StandardFrameConstants : public CommonFrameConstants {
154 class StandardFrameConstants : public AllStatic {
155 public: 207 public:
156 // Fixed part of the frame consists of return address, caller fp, 208 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize;
157 // constant pool (if FLAG_enable_embedded_constant_pool), context, and
158 // function. StandardFrame::IterateExpressions assumes that kLastObjectOffset
159 // is the last object pointer.
160 static const int kCPSlotSize =
161 FLAG_enable_embedded_constant_pool ? kPointerSize : 0;
162 static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize;
163 static const int kFixedFrameSizeAboveFp = kPCOnStackSize + kFPOnStackSize;
164 static const int kFixedFrameSize = 209 static const int kFixedFrameSize =
165 kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp; 210 kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp;
166 static const int kFixedSlotCountAboveFp = 211 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize;
167 kFixedFrameSizeAboveFp / kPointerSize;
168 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; 212 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize;
169 static const int kCPSlotCount = kCPSlotSize / kPointerSize; 213 static const int kContextOffset = kContextOrFrameTypeOffset;
214 static const int kFunctionOffset = -2 * kPointerSize - kCPSlotSize;
170 static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize; 215 static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize;
171 static const int kMarkerOffset = -2 * kPointerSize - kCPSlotSize;
172 static const int kContextOffset = -1 * kPointerSize - kCPSlotSize;
173 static const int kConstantPoolOffset = kCPSlotSize ? -1 * kPointerSize : 0;
174 static const int kCallerFPOffset = 0 * kPointerSize;
175 static const int kCallerPCOffset = +1 * kFPOnStackSize;
176 static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize;
177
178 static const int kLastObjectOffset = kContextOffset; 216 static const int kLastObjectOffset = kContextOffset;
179 }; 217 };
180 218
219 // TypedFrames have a SMI type maker value below the saved FP/constant pool to
220 // distinguish them from StandardFrames, which have a context in that position
221 // instead.
222 //
223 // slot JS frame
224 // +-----------------+--------------------------------
225 // -n-1 | parameter 0 | ^
226 // |- - - - - - - - -| |
227 // -n | | Caller
228 // ... | ... | frame slots
229 // -2 | parameter n-1 | (slot < 0)
230 // |- - - - - - - - -| |
231 // -1 | parameter n | v
232 // -----+-----------------+--------------------------------
233 // 0 | return addr | ^ ^
234 // |- - - - - - - - -| | |
235 // 1 | saved frame ptr | Fixed |
236 // |- - - - - - - - -| Header <-- frame ptr |
237 // 2 | [Constant Pool] | | |
238 // |- - - - - - - - -| | |
239 // 2+cp |Frame Type Marker| v if a constant pool |
240 // |-----------------+---- is used, cp = 1, |
241 // 3+cp | | ^ otherwise, cp = 0 |
242 // |- - - - - - - - -| | |
243 // 4+cp | | | Callee
244 // |- - - - - - - - -| | frame slots
245 // ... | | Frame slots (slot >= 0)
246 // |- - - - - - - - -| | |
247 // | | v |
248 // -----+-----------------+----- <-- stack ptr -------------
249 //
250 class TypedFrameConstants : public CommonFrameConstants {
251 public:
252 static const int kFrameTypeSize = kContextOrFrameTypeSize;
253 static const int kFrameTypeOffset = kContextOrFrameTypeOffset;
254 static const int kFixedFrameSizeFromFp = kCPSlotSize + kFrameTypeSize;
255 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize;
256 static const int kFixedFrameSize =
257 StandardFrameConstants::kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp;
258 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize;
259 static const int kFirstPushedFrameValueOffset =
260 -StandardFrameConstants::kCPSlotSize - kFrameTypeSize - kPointerSize;
261 };
181 262
182 class ArgumentsAdaptorFrameConstants : public AllStatic { 263 #define TYPED_FRAME_PUSHED_VALUE_OFFSET(x) \
264 (TypedFrameConstants::kFirstPushedFrameValueOffset - (x)*kPointerSize)
265 #define TYPED_FRAME_SIZE(count) \
266 (TypedFrameConstants::kFixedFrameSize + (count)*kPointerSize)
267 #define TYPED_FRAME_SIZE_FROM_SP(count) \
268 (TypedFrameConstants::kFixedFrameSizeFromFp + (count)*kPointerSize)
269 #define DEFINE_TYPED_FRAME_SIZES(count) \
270 static const int kFixedFrameSize = TYPED_FRAME_SIZE(count); \
271 static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; \
272 static const int kFixedFrameSizeFromFp = TYPED_FRAME_SIZE_FROM_SP(count); \
273 static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize
274
275 class ArgumentsAdaptorFrameConstants : public TypedFrameConstants {
183 public: 276 public:
184 // FP-relative. 277 // FP-relative.
185 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; 278 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
279 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
280 DEFINE_TYPED_FRAME_SIZES(2);
281 };
186 282
187 static const int kFrameSize = 283 class InternalFrameConstants : public TypedFrameConstants {
188 StandardFrameConstants::kFixedFrameSize + kPointerSize; 284 public:
285 // FP-relative.
286 static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
287 DEFINE_TYPED_FRAME_SIZES(1);
288 };
289
290 class FrameDropperFrameConstants : public InternalFrameConstants {
291 public:
292 // FP-relative.
293 static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
294 DEFINE_TYPED_FRAME_SIZES(2);
295 };
296
297 class ConstructFrameConstants : public TypedFrameConstants {
298 public:
299 // FP-relative.
300 static const int kContextOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
301 static const int kAllocationSiteOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
302 static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2);
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);
189 }; 315 };
190 316
191 317
192 class InternalFrameConstants : public AllStatic {
193 public:
194 // FP-relative.
195 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
196 };
197
198
199 class ConstructFrameConstants : public AllStatic {
200 public:
201 // FP-relative.
202 static const int kImplicitReceiverOffset =
203 StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize;
204 static const int kLengthOffset =
205 StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
206 static const int kAllocationSiteOffset =
207 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize;
208 static const int kCodeOffset =
209 StandardFrameConstants::kExpressionsOffset - 0 * kPointerSize;
210
211 static const int kFrameSize =
212 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
213 };
214
215
216 class InterpreterFrameConstants : public AllStatic { 318 class InterpreterFrameConstants : public AllStatic {
217 public: 319 public:
218 // Fixed frame includes new.target and bytecode offset. 320 // Fixed frame includes new.target and bytecode offset.
219 static const int kFixedFrameSize = 321 static const int kFixedFrameSize =
220 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize; 322 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
221 static const int kFixedFrameSizeFromFp = 323 static const int kFixedFrameSizeFromFp =
222 StandardFrameConstants::kFixedFrameSizeFromFp + 3 * kPointerSize; 324 StandardFrameConstants::kFixedFrameSizeFromFp + 3 * kPointerSize;
223 325
224 // FP-relative. 326 // FP-relative.
225 static const int kNewTargetFromFp = 327 static const int kNewTargetFromFp =
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 1012
911 Address GetCallerStackPointer() const override; 1013 Address GetCallerStackPointer() const override;
912 1014
913 private: 1015 private:
914 friend class StackFrameIteratorBase; 1016 friend class StackFrameIteratorBase;
915 }; 1017 };
916 1018
917 1019
918 class StubFailureTrampolineFrame: public StandardFrame { 1020 class StubFailureTrampolineFrame: public StandardFrame {
919 public: 1021 public:
920 // sizeof(Arguments) - sizeof(Arguments*) is 3 * kPointerSize), but the
921 // presubmit script complains about using sizeof() on a type.
922 static const int kFirstRegisterParameterFrameOffset =
923 StandardFrameConstants::kMarkerOffset - 3 * kPointerSize;
924
925 static const int kCallerStackParameterCountFrameOffset =
926 StandardFrameConstants::kMarkerOffset - 2 * kPointerSize;
927
928 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } 1022 Type type() const override { return STUB_FAILURE_TRAMPOLINE; }
929 1023
930 // Get the code associated with this frame. 1024 // Get the code associated with this frame.
931 // This method could be called during marking phase of GC. 1025 // This method could be called during marking phase of GC.
932 Code* unchecked_code() const override; 1026 Code* unchecked_code() const override;
933 1027
934 void Iterate(ObjectVisitor* v) const override; 1028 void Iterate(ObjectVisitor* v) const override;
935 1029
936 // Architecture-specific register description. 1030 // Architecture-specific register description.
937 static Register fp_register(); 1031 static Register fp_register();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1195
1102 1196
1103 // Reads all frames on the current stack and copies them into the current 1197 // Reads all frames on the current stack and copies them into the current
1104 // zone memory. 1198 // zone memory.
1105 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); 1199 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone);
1106 1200
1107 } // namespace internal 1201 } // namespace internal
1108 } // namespace v8 1202 } // namespace v8
1109 1203
1110 #endif // V8_FRAMES_H_ 1204 #endif // V8_FRAMES_H_
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/frames.cc » ('j') | src/x64/macro-assembler-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698