v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frame-constants.h
Go to the documentation of this file.
1// Copyright 2017 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#ifndef V8_EXECUTION_FRAME_CONSTANTS_H_
6#define V8_EXECUTION_FRAME_CONSTANTS_H_
7
9#include "src/flags/flags.h"
10
11namespace v8 {
12namespace internal {
13
14// Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume
15// two slots.
16//
17// Stack slot indices >= 0 access the callee stack with slot 0 corresponding to
18// the callee's saved return address and 1 corresponding to the saved frame
19// pointer. Some frames have additional information stored in the fixed header,
20// for example JSFunctions store the function context and marker in the fixed
21// header, with slot index 2 corresponding to the current function context and 3
22// corresponding to the frame marker/JSFunction.
23//
24// slot JS frame
25// +-----------------+--------------------------------
26// -n-1 | parameter n | ^
27// |- - - - - - - - -| |
28// -n | parameter n-1 | Caller
29// ... | ... | frame slots
30// -2 | parameter 1 | (slot < 0)
31// |- - - - - - - - -| |
32// -1 | parameter 0 | v
33// -----+-----------------+--------------------------------
34// 0 | return addr | ^ ^
35// |- - - - - - - - -| | |
36// 1 | saved frame ptr | Fixed |
37// |- - - - - - - - -| Header <-- frame ptr |
38// 2 | [Constant Pool] | | |
39// |- - - - - - - - -| | |
40// 2+cp |Context/Frm. Type| v if a constant pool |
41// |-----------------+---- is used, cp = 1, |
42// 3+cp | | ^ otherwise, cp = 0 |
43// |- - - - - - - - -| | |
44// 4+cp | | | Callee
45// |- - - - - - - - -| | frame slots
46// ... | | Frame slots (slot >= 0)
47// |- - - - - - - - -| | |
48// | | v |
49// -----+-----------------+----- <-- stack ptr -------------
50//
52 public:
53 static constexpr int kCallerFPOffset = 0 * kSystemPointerSize;
54 static constexpr int kCallerPCOffset = kCallerFPOffset + 1 * kFPOnStackSize;
55 static constexpr int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize;
56
57 // Fixed part of the frame consists of return address, caller fp,
58 // constant pool (if V8_EMBEDDED_CONSTANT_POOL_BOOL), context, and
59 // function. CommonFrame::IterateExpressions assumes that kLastObjectOffset
60 // is the last object pointer.
62 static constexpr int kFixedSlotCountAboveFp =
64 static constexpr int kCPSlotSize =
67 static constexpr int kConstantPoolOffset =
70 static constexpr int kContextOrFrameTypeOffset =
72};
73
74// StandardFrames are used for both unoptimized and optimized JavaScript
75// frames. They always have a context below the saved fp/constant
76// pool, below that the JSFunction of the executing function and below that an
77// integer (not a Smi) containing the actual number of arguments passed to the
78// JavaScript code.
79//
80// slot JS frame
81// +-----------------+--------------------------------
82// -n-1 | parameter n | ^
83// |- - - - - - - - -| |
84// -n | parameter n-1 | Caller
85// ... | ... | frame slots
86// -2 | parameter 1 | (slot < 0)
87// |- - - - - - - - -| |
88// -1 | parameter 0 | v
89// -----+-----------------+--------------------------------
90// 0 | return addr | ^ ^
91// |- - - - - - - - -| | |
92// 1 | saved frame ptr | Fixed |
93// |- - - - - - - - -| Header <-- frame ptr |
94// 2 | [Constant Pool] | | |
95// |- - - - - - - - -| | |
96// 2+cp | Context | | if a constant pool |
97// |- - - - - - - - -| | is used, cp = 1, |
98// 3+cp | JSFunction | | otherwise, cp = 0 |
99// |- - - - - - - - -| | |
100// 4+cp | argc | v |
101// +-----------------+---- |
102// 5+cp | expressions or | ^ Callee
103// |- - - - - - - - -| | frame slots
104// ... | pushed values | Frame slots (slot >= 0)
105// |- - - - - - - - -| | |
106// | | v |
107// -----+-----------------+----- <-- stack ptr -------------
108//
126
127// TypedFrames have a type maker value below the saved FP/constant pool to
128// distinguish them from StandardFrames, which have a context in that position
129// instead.
130//
131// slot JS frame
132// +-----------------+--------------------------------
133// -n-1 | parameter n | ^
134// |- - - - - - - - -| |
135// -n | parameter n-1 | Caller
136// ... | ... | frame slots
137// -2 | parameter 1 | (slot < 0)
138// |- - - - - - - - -| |
139// -1 | parameter 0 | v
140// -----+-----------------+--------------------------------
141// 0 | return addr | ^ ^
142// |- - - - - - - - -| | |
143// 1 | saved frame ptr | Fixed |
144// |- - - - - - - - -| Header <-- frame ptr |
145// 2 | [Constant Pool] | | |
146// |- - - - - - - - -| | |
147// 2+cp |Frame Type Marker| v if a constant pool |
148// |-----------------+---- is used, cp = 1, |
149// 3+cp | pushed value 0 | ^ otherwise, cp = 0 |
150// |- - - - - - - - -| | |
151// 4+cp | pushed value 1 | | Callee
152// |- - - - - - - - -| | frame slots
153// ... | | Frame slots (slot >= 0)
154// |- - - - - - - - -| | |
155// | | v |
156// -----+-----------------+----- <-- stack ptr -------------
157//
172
173#define FRAME_PUSHED_VALUE_OFFSET(parent, x) \
174 (parent::kFirstPushedFrameValueOffset - (x)*kSystemPointerSize)
175#define FRAME_SIZE(parent, count) \
176 (parent::kFixedFrameSize + (count)*kSystemPointerSize)
177#define FRAME_SIZE_FROM_FP(parent, count) \
178 (parent::kFixedFrameSizeFromFp + (count)*kSystemPointerSize)
179#define DEFINE_FRAME_SIZES(parent, count) \
180 static constexpr int kFixedFrameSize = FRAME_SIZE(parent, count); \
181 static constexpr int kFixedSlotCount = kFixedFrameSize / kSystemPointerSize; \
182 static constexpr int kFixedFrameSizeFromFp = \
183 FRAME_SIZE_FROM_FP(parent, count); \
184 static constexpr int kFixedSlotCountFromFp = \
185 kFixedFrameSizeFromFp / kSystemPointerSize; \
186 static constexpr int kFirstPushedFrameValueOffset = \
187 parent::kFirstPushedFrameValueOffset - (count) * kSystemPointerSize; \
188 /* The number of slots added on top of given parent frame type. */ \
189 template <typename TParentFrameConstants> \
190 static constexpr int getExtraSlotsCountFrom() { \
191 return kFixedSlotCount - TParentFrameConstants::kFixedSlotCount; \
192 } \
193 /* TODO(ishell): remove in favour of getExtraSlotsCountFrom() because */ \
194 /* it's not clear from which base should we count "extra" - from direct */ \
195 /* parent or maybe from parent's parent? */ \
196 static constexpr int kExtraSlotCount = \
197 kFixedSlotCount - parent::kFixedSlotCount
198
199#define STANDARD_FRAME_EXTRA_PUSHED_VALUE_OFFSET(x) \
200 FRAME_PUSHED_VALUE_OFFSET(StandardFrameConstants, x)
201#define DEFINE_STANDARD_FRAME_SIZES(count) \
202 DEFINE_FRAME_SIZES(StandardFrameConstants, count)
203
204#define TYPED_FRAME_PUSHED_VALUE_OFFSET(x) \
205 FRAME_PUSHED_VALUE_OFFSET(TypedFrameConstants, x)
206#define DEFINE_TYPED_FRAME_SIZES(count) \
207 DEFINE_FRAME_SIZES(TypedFrameConstants, count)
208
210 public:
211 // FP-relative.
215};
216
229
231 public:
232 // FP-relative.
234 static constexpr int kImplicitReceiverOffset =
237};
238
239#if V8_ENABLE_WEBASSEMBLY
240class CWasmEntryFrameConstants : public TypedFrameConstants {
241 public:
242 // FP-relative:
243 static constexpr int kCEntryFPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
245};
246
247class WasmFrameConstants : public TypedFrameConstants {
248 public:
249 // FP-relative.
250 static constexpr int kWasmInstanceDataOffset =
253
254 // The WasmTrapHandlerLandingPad builtin gets called from the WebAssembly
255 // trap handler when an out-of-bounds memory access happened or when a null
256 // reference gets dereferenced. This builtin then fakes a call from the
257 // instruction that triggered the signal to the runtime. This is done by
258 // setting a return address and then jumping to a builtin which will call
259 // further to the runtime. As the return address we use the fault address +
260 // {kProtectedInstructionReturnAddressOffset}. Using the fault address itself
261 // would cause problems with safepoints and source positions.
262 //
263 // The problem with safepoints is that a safepoint has to be registered at the
264 // return address, and that at most one safepoint should be registered at a
265 // location. However, there could already be a safepoint registered at the
266 // fault address if the fault address is the return address of a call.
267 //
268 // The problem with source positions is that the stack trace code looks for
269 // the source position of a call before the return address. The source
270 // position of the faulty memory access, however, is recorded at the fault
271 // address. Therefore the stack trace code would not find the source position
272 // if we used the fault address as the return address.
273 static constexpr int kProtectedInstructionReturnAddressOffset = 1;
274};
275
276#if V8_ENABLE_DRUMBRAKE
277class WasmInterpreterFrameConstants : public TypedFrameConstants {
278 public:
279 // FP-relative.
280 static constexpr int kWasmInstanceObjectOffset =
283};
284
285// Fixed frame slots shared by the interpreter wasm-to-js wrapper.
286class WasmToJSInterpreterFrameConstants : public TypedFrameConstants {
287 public:
288 // This slot contains the number of slots at the top of the frame that need to
289 // be scanned by the GC.
290 static constexpr int kGCScanSlotLimitOffset =
292
293 // The stack pointer at the moment of the JS function call.
294 static constexpr int kGCSPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
295
296 // Returned for a successful completion of the WasmToJS call (no exception).
297 static constexpr int kSuccess = 1;
298};
299
300class WasmInterpreterCWasmEntryConstants : public TypedFrameConstants {
301 public:
302 // FP-relative:
303 static constexpr int kCEntryFPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
304 static constexpr int kSPFPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
306};
307#endif // V8_ENABLE_DRUMBRAKE
308
309class WasmExitFrameConstants : public WasmFrameConstants {
310 public:
311 // FP-relative.
312 static const int kCallingPCOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
314};
315
316// Fixed frame slots used by the js-to-wasm wrapper.
317class JSToWasmWrapperFrameConstants : public TypedFrameConstants {
318 public:
319 // FP-relative.
320 static constexpr int kResultArrayParamOffset = 2 * kSystemPointerSize;
321 // A WasmTrustedInstanceData or WasmImportData depending on the callee.
322 static constexpr int kImplicitArgOffset = 3 * kSystemPointerSize;
323
324 // Contains RawPtr to stack-allocated buffer.
325 static constexpr int kWrapperBufferOffset =
327
328 // Offsets into the wrapper buffer for values passed from Torque to the
329 // assembly builtin.
330 static constexpr size_t kWrapperBufferReturnCount = 0;
331 static constexpr size_t kWrapperBufferRefReturnCount = 4;
332 static constexpr size_t kWrapperBufferSigRepresentationArray = 8;
333 static constexpr size_t kWrapperBufferStackReturnBufferSize = 16;
334 static constexpr size_t kWrapperBufferCallTarget = 24;
335 static constexpr size_t kWrapperBufferParamStart = 32;
336 static constexpr size_t kWrapperBufferParamEnd = 40;
337
338 // Offsets into the wrapper buffer for values passed from the assembly builtin
339 // to Torque.
340 static constexpr size_t kWrapperBufferStackReturnBufferStart = 16;
341 static constexpr size_t kWrapperBufferFPReturnRegister1 = 24;
342 static constexpr size_t kWrapperBufferFPReturnRegister2 = 32;
343 static constexpr size_t kWrapperBufferGPReturnRegister1 = 40;
344 static constexpr size_t kWrapperBufferGPReturnRegister2 =
345 kWrapperBufferGPReturnRegister1 + kSystemPointerSize;
346
347 // Size of the wrapper buffer
348 static constexpr int kWrapperBufferSize =
349 kWrapperBufferGPReturnRegister2 + kSystemPointerSize;
350 static_assert(kWrapperBufferParamEnd + kSystemPointerSize <=
351 kWrapperBufferSize);
352};
353
354// Fixed frame slots used by the ReturnPromiseOnSuspendAsm wrapper
355// and the WasmResume wrapper.
356class StackSwitchFrameConstants : public JSToWasmWrapperFrameConstants {
357 public:
358 // StackSwitching stack layout
359 // ------+-----------------+----------------------
360 // | return addr |
361 // fp |- - - - - - - - -| -------------------|
362 // | fp | |
363 // fp-p |- - - - - - - - -| |
364 // | frame marker | | no GC scan
365 // fp-2p |- - - - - - - - -| |
366 // | scan_count | |
367 // fp-3p |- - - - - - - - -| -------------------|
368 // | wasm_instance | |
369 // fp-4p |- - - - - - - - -| | fixed GC scan
370 // | result_array | |
371 // fp-5p |- - - - - - - - -| -------------------|
372 // | .... | <- spill_slot_limit |
373 // | spill slots | | GC scan scan_count slots
374 // | .... | <- spill_slot_base--|
375 // |- - - - - - - - -| |
376 // This slot contains the number of slots at the top of the frame that need to
377 // be scanned by the GC.
378 static constexpr int kGCScanSlotCountOffset =
380 // Tagged pointer to WasmTrustedInstanceData or WasmImportData.
381 static constexpr int kImplicitArgOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2);
382 // Tagged pointer to a JS Array for result values.
383 static constexpr int kResultArrayOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3);
384
385 static constexpr int kLastSpillOffset = kResultArrayOffset;
386 static constexpr int kNumSpillSlots = 4;
387};
388
389class WasmToJSWrapperConstants {
390 public:
391 // FP-relative.
392 static constexpr size_t kSignatureOffset = 2 * kSystemPointerSize;
393};
394
395#if V8_ENABLE_DRUMBRAKE
396class BuiltinWasmInterpreterWrapperConstants : public TypedFrameConstants {
397 public:
398 // This slot contains the number of slots at the top of the frame that need to
399 // be scanned by the GC.
400 static constexpr int kGCScanSlotCountOffset =
402 // The number of parameters passed to this function.
403 static constexpr int kInParamCountOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
404 // The number of parameters according to the signature.
405 static constexpr int kParamCountOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2);
406 // The number of return values according to the siganture.
407 static constexpr int kReturnCountOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3);
408 // `reps_` of wasm::FunctionSig.
409 static constexpr int kSigRepsOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(4);
410 // The current valuetype in the function signature being converted.
411 static constexpr int kValueTypesArrayStartOffset =
413 // Array of arguments/return values.
414 static constexpr int kArgRetsAddressOffset =
416 // Whether the array is for arguments or return values.
417 static constexpr int kArgRetsIsArgsOffset =
419 // The index of the argument or return value being converted.
420 static constexpr int kCurrentIndexOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(8);
421 // Precomputed signature data.
422 static constexpr int kSignatureDataOffset =
424};
425#endif // V8_ENABLE_DRUMBRAKE
426#endif // V8_ENABLE_WEBASSEMBLY
427
429 public:
430 // FP-relative.
432 static constexpr int kFrameSPtoFPDeltaAtDeoptimize =
434 static constexpr int kBuiltinContextOffset =
437
438 // The argument count is in the first allocatable register, stored below the
439 // fixed part of the frame and therefore is not part of the fixed frame size.
442
443 // Returns the number of padding stack slots needed when we have
444 // 'register_count' register slots.
445 // This is needed on some architectures to ensure the stack pointer is
446 // aligned.
447 static int PaddingSlotCount(int register_count);
448};
449
451 public:
452 // FP-relative.
454 static constexpr int kLastExitFrameField = kSPOffset;
456
457 // FP-relative displacement of the caller's SP. It points just
458 // below the saved PC.
460};
461#define EXIT_FRAME_PUSHED_VALUE_OFFSET(x) \
462 FRAME_PUSHED_VALUE_OFFSET(ExitFrameConstants, x)
463#define DEFINE_EXIT_FRAME_SIZES(x) DEFINE_FRAME_SIZES(ExitFrameConstants, x);
464
465// Behaves like an exit frame but with extra arguments (target, new target and
466// JS arguments count), followed by JS arguments passed to the JS function
467// (receiver and etc.).
468//
469// slot JS frame
470// +-----------------+--------------------------------
471// -n-1-k| parameter n | ^
472// |- - - - - - - - -| |
473// -n-k | parameter n-1 | Caller
474// ... | ... | frame slots
475// -2-k | parameter 1 | (slot < 0)
476// |- - - - - - - - -| |
477// -1-k | receiver | v
478// -----+-----------------+--------------------------------
479// -k | extra arg k-1 | ^
480// |- - - - - - - - -| |
481// -k+1 | extra arg k-2 | Extra arguments passed
482// ... | ... | to CPP builtin
483// -2 | extra arg 1 | k := kNumExtraArgs
484// |- - - - - - - - -| |
485// -1 | extra arg 0 | v
486// -----+-----------------+--------------------------------
487// 0 | return addr | ^ ^
488// |- - - - - - - - -| | |
489// 1 | saved frame ptr | ExitFrame |
490// |- - - - - - - - -| Header <-- frame ptr |
491// 2 | [Constant Pool] | | |
492// |- - - - - - - - -| | |
493// 2+cp |Frame Type Marker| | if a constant pool |
494// |- - - - - - - - -| | is used, cp = 1, |
495// 3+cp | caller SP | v otherwise, cp = 0 |
496// |-----------------+---- |
497// 4+cp | ... | ^ Callee
498// |- - - - - - - - -| | frame slots
499// ... | C function args | Frame slots (slot >= 0)
500// |- - - - - - - - -| | |
501// | | v |
502// -----+-----------------+----- <-- stack ptr -------------
503//
505 public:
506 // The following constants must be in sync with BuiltinArguments' extra
507 // arguments layout. This is guaraneed by static_asserts elsewhere.
508 static constexpr int kNewTargetIndex = 0;
509 static constexpr int kTargetIndex = 1;
510 static constexpr int kArgcIndex = 2;
511 // TODO(ishell): this padding is required only on Arm64.
512 static constexpr int kPaddingIndex = 3;
513 static constexpr int kNumExtraArgs = 4;
514 static constexpr int kNumExtraArgsWithReceiver = kNumExtraArgs + 1;
515
516 // BuiltinArguments' arguments_ array.
518 static constexpr int kTargetOffset =
520 static constexpr int kNewTargetOffset =
522 static constexpr int kArgcOffset =
524
525 // JS arguments.
526 static constexpr int kReceiverOffset =
528
529 static constexpr int kFirstArgumentOffset =
531};
532
533// Behaves like an exit frame but with v8::FunctionCallbackInfo's implicit
534// arguments (FCI), followed by JS arguments passed to the JS function
535// (receiver and etc.).
536//
537// slot JS frame
538// +-----------------+--------------------------------
539// -n-1-k| parameter n | ^
540// |- - - - - - - - -| |
541// -n-k | parameter n-1 | Caller
542// ... | ... | frame slots
543// -2-k | parameter 1 | (slot < 0)
544// |- - - - - - - - -| |
545// -1-k | receiver | v
546// -----+-----------------+--------------------------------
547// -k | FCI slot k-1 | ^
548// |- - - - - - - - -| |
549// -k+1 | FCI slot k-2 | v8::FunctionCallbackInfo's
550// ... | ... | FCI::implicit_args[k]
551// -2 | FCI slot 1 | k := FCI::kArgsLength
552// |- - - - - - - - -| |
553// -1 | FCI slot 0 | v
554// -----+-----------------+--------------------------------
555// 0 | return addr | ^ ^
556// |- - - - - - - - -| | |
557// 1 | saved frame ptr | ExitFrame |
558// |- - - - - - - - -| Header <-- frame ptr |
559// 2 | [Constant Pool] | | |
560// |- - - - - - - - -| | |
561// 2+cp |Frame Type Marker| | if a constant pool |
562// |- - - - - - - - -| | is used, cp = 1, |
563// 3+cp | caller SP | v otherwise, cp = 0 |
564// |-----------------+---- |
565// 4+cp | FCI::argc_ | ^ Callee
566// |- - - - - - - - -| | frame slots
567// 5+cp | FCI::values_ | | (slot >= 0)
568// |- - - - - - - - -| | |
569// 6+cp | FCI::imp._args_ | Frame slots |
570// |- - - - - - - - -| | |
571// ... | C function args | | |
572// |- - - - - - - - -| | |
573// | | v |
574// -----+-----------------+----- <-- stack ptr -------------
575//
577 public:
578 // The following constants must be in sync with v8::FunctionCallbackInfo's
579 // layout. This is guaraneed by static_asserts elsewhere.
580 static constexpr int kFunctionCallbackInfoContextIndex = 2;
582 static constexpr int kFunctionCallbackInfoTargetIndex = 4;
583 static constexpr int kFunctionCallbackInfoNewTargetIndex = 5;
584 static constexpr int kFunctionCallbackInfoArgsLength = 6;
585
586 // FP-relative.
587 // v8::FunctionCallbackInfo struct (implicit_args_, args_, argc_) is pushed
588 // on top of the ExitFrame.
591 static constexpr int kFCIImplicitArgsOffset =
593
595 static_assert(kSPOffset - kSystemPointerSize == kFCIArgcOffset);
596
597 // v8::FunctionCallbackInfo's struct allocated right below the exit frame.
599
600 // v8::FunctionCallbackInfo's implicit_args array.
602 static constexpr int kTargetOffset =
605 static constexpr int kNewTargetOffset =
608 static constexpr int kContextOffset =
611 static constexpr int kReturnValueOffset =
614
615 // JS arguments.
616 static constexpr int kReceiverOffset =
619
620 static constexpr int kFirstArgumentOffset =
622};
623
624// Behaves like an exit frame but with v8::PropertyCallbackInfo's (PCI)
625// fields allocated in GC-ed area of the exit frame, followed by zero or
626// more parameters (required by some callback kinds).
627//
628// slot JS frame
629// +-----------------+--------------------------------
630// -n-1-k| parameter n | ^
631// |- - - - - - - - -| |
632// -n-k | parameter n-1 | Caller
633// ... | ... | frame slots
634// -2-k | parameter 1 | (slot < 0)
635// |- - - - - - - - -| |
636// -1-k | parameter 0 | v
637// -----+-----------------+--------------------------------
638// -k | PCI slot k-1 | ^
639// |- - - - - - - - -| |
640// -k+1 | PCI slot k-2 | v8::PropertyCallbackInfo's
641// ... | ... | PCI::args[k]
642// -2 | PCI slot 1 | k := PCI::kArgsLength
643// |- - - - - - - - -| |
644// -1 | PCI slot 0 | v
645// -----+-----------------+-------------------------------- <-- PCI object
646// 0 | return addr | ^ ^
647// |- - - - - - - - -| | |
648// 1 | saved frame ptr | ExitFrame |
649// |- - - - - - - - -| Header <-- frame ptr |
650// 2 | [Constant Pool] | | |
651// |- - - - - - - - -| | |
652// 2+cp |Frame Type Marker| | if a constant pool |
653// |- - - - - - - - -| | is used, cp = 1, |
654// 3+cp | caller SP | v otherwise, cp = 0 |
655// |-----------------+---- |
656// 4+cp | | ^ Callee
657// |- - - - - - - - -| | frame slots
658// ... | C function args | Frame slots (slot >= 0)
659// |- - - - - - - - -| | |
660// | | v |
661// -----+-----------------+----- <-- stack ptr -------------
662//
664 public:
665 // The following constants must be in sync with v8::PropertyCallbackInfo's
666 // layout. This is guaraneed by static_asserts elsewhere.
667 static constexpr int kPropertyCallbackInfoPropertyKeyIndex = 0;
668 static constexpr int kPropertyCallbackInfoHolderIndex = 2;
669 static constexpr int kPropertyCallbackInfoReturnValueIndex = 5;
670 static constexpr int kPropertyCallbackInfoReceiverIndex = 7;
671 static constexpr int kPropertyCallbackInfoArgsLength = 8;
672
673 // FP-relative.
674
675 // v8::PropertyCallbackInfo's args array.
676 static constexpr int kArgsArrayOffset = kFixedFrameSizeAboveFp;
677 static constexpr int kPropertyNameOffset =
678 kArgsArrayOffset +
679 kPropertyCallbackInfoPropertyKeyIndex * kSystemPointerSize;
680 static constexpr int kReturnValueOffset =
681 kArgsArrayOffset +
682 kPropertyCallbackInfoReturnValueIndex * kSystemPointerSize;
683 static constexpr int kReceiverOffset =
684 kArgsArrayOffset +
685 kPropertyCallbackInfoReceiverIndex * kSystemPointerSize;
686 static constexpr int kHolderOffset =
687 kArgsArrayOffset + kPropertyCallbackInfoHolderIndex * kSystemPointerSize;
688
689 // v8::PropertyCallbackInfo's address is equal to address of the args_ array.
690 static constexpr int kPropertyCallbackInfoOffset = kArgsArrayOffset;
691};
692
693// Unoptimized frames are used for interpreted and baseline-compiled JavaScript
694// frames. They are a "standard" frame, with an additional fixed header for the
695// BytecodeArray, bytecode offset (if running interpreted), feedback vector (if
696// running baseline code), and then the interpreter register file.
697//
698// slot JS frame
699// +-----------------+--------------------------------
700// -n-1 | parameter n | ^
701// |- - - - - - - - -| |
702// -n | parameter n-1 | Caller
703// ... | ... | frame slots
704// -2 | parameter 1 | (slot < 0)
705// |- - - - - - - - -| |
706// -1 | parameter 0 | v
707// -----+-----------------+--------------------------------
708// 0 | return addr | ^ ^
709// |- - - - - - - - -| | |
710// 1 | saved frame ptr | Fixed |
711// |- - - - - - - - -| Header <-- frame ptr |
712// 2 | [Constant Pool] | | |
713// |- - - - - - - - -| | |
714// 2+cp | Context | | if a constant pool |
715// |- - - - - - - - -| | is used, cp = 1, |
716// 3+cp | JSFunction | | otherwise, cp = 0 |
717// |- - - - - - - - -| | |
718// 4+cp | argc | v |
719// +-----------------+---- |
720// 5+cp | BytecodeArray | ^ |
721// |- - - - - - - - -| | |
722// 6+cp | offset / cell | Unoptimized code header |
723// |- - - - - - - - -| | |
724// 7+cp | FBV | v |
725// +-----------------+---- |
726// 8+cp | register 0 | ^ Callee
727// |- - - - - - - - -| | frame slots
728// 9+cp | register 1 | Register file (slot >= 0)
729// ... | ... | | |
730// | register n-1 | | |
731// |- - - - - - - - -| | |
732// 9+cp+n| register n | v v
733// -----+-----------------+----- <-- stack ptr -------------
734//
736 public:
737 // FP-relative.
738 static constexpr int kBytecodeArrayFromFp =
740 static constexpr int kBytecodeOffsetOrFeedbackCellFromFp =
742 static constexpr int kFeedbackVectorFromFp =
745
746 static constexpr int kFirstParamFromFp =
747 StandardFrameConstants::kCallerSPOffset;
748 static constexpr int kRegisterFileFromFp =
749 -kFixedFrameSizeFromFp - kSystemPointerSize;
750 static constexpr int kExpressionsOffset = kRegisterFileFromFp;
751
752 // Expression index for {JavaScriptFrame::GetExpressionAddress}.
753 static constexpr int kBytecodeArrayExpressionIndex = -3;
754 static constexpr int kBytecodeOffsetOrFeedbackCellExpressionIndex = -2;
755 static constexpr int kFeedbackVectorExpressionIndex = -1;
756 static constexpr int kRegisterFileExpressionIndex = 0;
757
758 // Returns the number of stack slots needed for 'register_count' registers.
759 // This is needed because some architectures must pad the stack frame with
760 // additional stack slots to ensure the stack pointer is aligned.
761 static int RegisterStackSlotCount(int register_count);
762};
763
764// Interpreter frames are unoptimized frames that are being executed by the
765// interpreter. In this case, the "offset or cell" slot contains the bytecode
766// offset of the currently executing bytecode.
768 public:
769 static constexpr int kBytecodeOffsetExpressionIndex =
770 kBytecodeOffsetOrFeedbackCellExpressionIndex;
771
772 static constexpr int kBytecodeOffsetFromFp =
773 kBytecodeOffsetOrFeedbackCellFromFp;
774};
775
776// Sparkplug frames are unoptimized frames that are being executed by
777// sparkplug-compiled baseline code. base. In this case, the "offset or cell"
778// slot contains the closure feedback cell.
780 public:
781 static constexpr int kFeedbackCellExpressionIndex =
782 kBytecodeOffsetOrFeedbackCellExpressionIndex;
783
784 static constexpr int kFeedbackCellFromFp =
785 kBytecodeOffsetOrFeedbackCellFromFp;
786};
787
788inline static int FPOffsetToFrameSlot(int frame_offset) {
790 frame_offset / kSystemPointerSize;
791}
792
793inline static int FrameSlotToFPOffset(int slot) {
796}
797
798} // namespace internal
799} // namespace v8
800
801#if V8_TARGET_ARCH_IA32
803#elif V8_TARGET_ARCH_X64
805#elif V8_TARGET_ARCH_ARM64
807#elif V8_TARGET_ARCH_ARM
809#elif V8_TARGET_ARCH_PPC64
811#elif V8_TARGET_ARCH_MIPS64
813#elif V8_TARGET_ARCH_LOONG64
815#elif V8_TARGET_ARCH_S390X
817#elif V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64
819#else
820#error Unsupported target architecture.
821#endif
822
823#endif // V8_EXECUTION_FRAME_CONSTANTS_H_
static constexpr int kFunctionCallbackInfoReturnValueIndex
static constexpr int kContextOrFrameTypeSize
static constexpr int kContextOrFrameTypeOffset
static constexpr int kConstantPoolOffset
static constexpr int kFixedSlotCountAboveFp
static constexpr int kFixedFrameSizeAboveFp
static constexpr int kNewTargetOrImplicitReceiverOffset
static constexpr int kCallerSPDisplacement
static constexpr int kLastExitFrameField
static constexpr int kFirstPushedFrameValueOffset
static constexpr int kFirstPushedFrameValueOffset
static constexpr int kFixedFrameSizeFromFp
static constexpr int kFrameTypeOffset
static constexpr int kFixedSlotCountFromFp
#define V8_EMBEDDED_CONSTANT_POOL_BOOL
Definition globals.h:81
#define STANDARD_FRAME_EXTRA_PUSHED_VALUE_OFFSET(x)
#define TYPED_FRAME_PUSHED_VALUE_OFFSET(x)
#define DEFINE_EXIT_FRAME_SIZES(x)
#define EXIT_FRAME_PUSHED_VALUE_OFFSET(x)
#define DEFINE_TYPED_FRAME_SIZES(count)
static int FPOffsetToFrameSlot(int frame_offset)
constexpr int kPCOnStackSize
Definition globals.h:412
constexpr int kFPOnStackSize
Definition globals.h:413
constexpr int kSystemPointerSize
Definition globals.h:410
static int FrameSlotToFPOffset(int slot)