summaryrefslogtreecommitdiff
path: root/deps/v8/src/frames.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/frames.h')
-rw-r--r--deps/v8/src/frames.h249
1 files changed, 197 insertions, 52 deletions
diff --git a/deps/v8/src/frames.h b/deps/v8/src/frames.h
index f33eb16741..f6806d7563 100644
--- a/deps/v8/src/frames.h
+++ b/deps/v8/src/frames.h
@@ -97,13 +97,15 @@ class StackHandler BASE_EMBEDDED {
DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler);
};
-
#define STACK_FRAME_TYPE_LIST(V) \
V(ENTRY, EntryFrame) \
V(ENTRY_CONSTRUCT, EntryConstructFrame) \
V(EXIT, ExitFrame) \
V(JAVA_SCRIPT, JavaScriptFrame) \
V(OPTIMIZED, OptimizedFrame) \
+ V(WASM, WasmFrame) \
+ V(WASM_TO_JS, WasmToJsFrame) \
+ V(JS_TO_WASM, JsToWasmFrame) \
V(INTERPRETED, InterpretedFrame) \
V(STUB, StubFrame) \
V(STUB_FAILURE_TRAMPOLINE, StubFailureTrampolineFrame) \
@@ -137,77 +139,179 @@ class StackHandler BASE_EMBEDDED {
// |- - - - - - - - -| Header <-- frame ptr |
// 2 | [Constant Pool] | | |
// |- - - - - - - - -| | |
-// 2+cp | Context | | if a constant pool |
-// |- - - - - - - - -| | is used, cp = 1, |
-// 3+cp |JSFunction/Marker| v otherwise, cp = 0 |
-// +-----------------+---- |
-// 4+cp | | ^ Callee
+// 2+cp |Context/Frm. Type| v if a constant pool |
+// |-----------------+---- is used, cp = 1, |
+// 3+cp | | ^ otherwise, cp = 0 |
+// |- - - - - - - - -| | |
+// 4+cp | | | Callee
// |- - - - - - - - -| | frame slots
// ... | | Frame slots (slot >= 0)
// |- - - - - - - - -| | |
// | | v |
// -----+-----------------+----- <-- stack ptr -------------
//
-
-class StandardFrameConstants : public AllStatic {
+class CommonFrameConstants : public AllStatic {
public:
+ static const int kCallerFPOffset = 0 * kPointerSize;
+ static const int kCallerPCOffset = kCallerFPOffset + 1 * kFPOnStackSize;
+ static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize;
+
// Fixed part of the frame consists of return address, caller fp,
// constant pool (if FLAG_enable_embedded_constant_pool), context, and
// function. StandardFrame::IterateExpressions assumes that kLastObjectOffset
// is the last object pointer.
- static const int kCPSlotSize =
- FLAG_enable_embedded_constant_pool ? kPointerSize : 0;
- static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize;
static const int kFixedFrameSizeAboveFp = kPCOnStackSize + kFPOnStackSize;
- static const int kFixedFrameSize =
- kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp;
static const int kFixedSlotCountAboveFp =
kFixedFrameSizeAboveFp / kPointerSize;
- static const int kFixedSlotCount = kFixedFrameSize / kPointerSize;
+ static const int kCPSlotSize =
+ FLAG_enable_embedded_constant_pool ? kPointerSize : 0;
static const int kCPSlotCount = kCPSlotSize / kPointerSize;
- static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize;
- static const int kMarkerOffset = -2 * kPointerSize - kCPSlotSize;
- static const int kContextOffset = -1 * kPointerSize - kCPSlotSize;
static const int kConstantPoolOffset = kCPSlotSize ? -1 * kPointerSize : 0;
- static const int kCallerFPOffset = 0 * kPointerSize;
- static const int kCallerPCOffset = +1 * kFPOnStackSize;
- static const int kCallerSPOffset = kCallerPCOffset + 1 * kPCOnStackSize;
+ static const int kContextOrFrameTypeSize = kPointerSize;
+ static const int kContextOrFrameTypeOffset =
+ -(kCPSlotSize + kContextOrFrameTypeSize);
+};
+// StandardFrames are used for interpreted, full-codegen and optimized
+// JavaScript frames. They always have a context below the saved fp/constant
+// pool and below that the JSFunction of the executing function.
+//
+// slot JS frame
+// +-----------------+--------------------------------
+// -n-1 | parameter 0 | ^
+// |- - - - - - - - -| |
+// -n | | Caller
+// ... | ... | frame slots
+// -2 | parameter n-1 | (slot < 0)
+// |- - - - - - - - -| |
+// -1 | parameter n | v
+// -----+-----------------+--------------------------------
+// 0 | return addr | ^ ^
+// |- - - - - - - - -| | |
+// 1 | saved frame ptr | Fixed |
+// |- - - - - - - - -| Header <-- frame ptr |
+// 2 | [Constant Pool] | | |
+// |- - - - - - - - -| | |
+// 2+cp | Context | | if a constant pool |
+// |- - - - - - - - -| | is used, cp = 1, |
+// 3+cp | JSFunction | v otherwise, cp = 0 |
+// +-----------------+---- |
+// 4+cp | | ^ Callee
+// |- - - - - - - - -| | frame slots
+// ... | | Frame slots (slot >= 0)
+// |- - - - - - - - -| | |
+// | | v |
+// -----+-----------------+----- <-- stack ptr -------------
+//
+class StandardFrameConstants : public CommonFrameConstants {
+ public:
+ static const int kFixedFrameSizeFromFp = 2 * kPointerSize + kCPSlotSize;
+ static const int kFixedFrameSize =
+ kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp;
+ static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize;
+ static const int kFixedSlotCount = kFixedFrameSize / kPointerSize;
+ static const int kContextOffset = kContextOrFrameTypeOffset;
+ static const int kFunctionOffset = -2 * kPointerSize - kCPSlotSize;
+ static const int kExpressionsOffset = -3 * kPointerSize - kCPSlotSize;
static const int kLastObjectOffset = kContextOffset;
};
+// TypedFrames have a SMI type maker value below the saved FP/constant pool to
+// distinguish them from StandardFrames, which have a context in that position
+// instead.
+//
+// slot JS frame
+// +-----------------+--------------------------------
+// -n-1 | parameter 0 | ^
+// |- - - - - - - - -| |
+// -n | | Caller
+// ... | ... | frame slots
+// -2 | parameter n-1 | (slot < 0)
+// |- - - - - - - - -| |
+// -1 | parameter n | v
+// -----+-----------------+--------------------------------
+// 0 | return addr | ^ ^
+// |- - - - - - - - -| | |
+// 1 | saved frame ptr | Fixed |
+// |- - - - - - - - -| Header <-- frame ptr |
+// 2 | [Constant Pool] | | |
+// |- - - - - - - - -| | |
+// 2+cp |Frame Type Marker| v if a constant pool |
+// |-----------------+---- is used, cp = 1, |
+// 3+cp | | ^ otherwise, cp = 0 |
+// |- - - - - - - - -| | |
+// 4+cp | | | Callee
+// |- - - - - - - - -| | frame slots
+// ... | | Frame slots (slot >= 0)
+// |- - - - - - - - -| | |
+// | | v |
+// -----+-----------------+----- <-- stack ptr -------------
+//
+class TypedFrameConstants : public CommonFrameConstants {
+ public:
+ static const int kFrameTypeSize = kContextOrFrameTypeSize;
+ static const int kFrameTypeOffset = kContextOrFrameTypeOffset;
+ static const int kFixedFrameSizeFromFp = kCPSlotSize + kFrameTypeSize;
+ static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize;
+ static const int kFixedFrameSize =
+ StandardFrameConstants::kFixedFrameSizeAboveFp + kFixedFrameSizeFromFp;
+ static const int kFixedSlotCount = kFixedFrameSize / kPointerSize;
+ static const int kFirstPushedFrameValueOffset =
+ -StandardFrameConstants::kCPSlotSize - kFrameTypeSize - kPointerSize;
+};
-class ArgumentsAdaptorFrameConstants : public AllStatic {
+#define TYPED_FRAME_PUSHED_VALUE_OFFSET(x) \
+ (TypedFrameConstants::kFirstPushedFrameValueOffset - (x)*kPointerSize)
+#define TYPED_FRAME_SIZE(count) \
+ (TypedFrameConstants::kFixedFrameSize + (count)*kPointerSize)
+#define TYPED_FRAME_SIZE_FROM_SP(count) \
+ (TypedFrameConstants::kFixedFrameSizeFromFp + (count)*kPointerSize)
+#define DEFINE_TYPED_FRAME_SIZES(count) \
+ static const int kFixedFrameSize = TYPED_FRAME_SIZE(count); \
+ static const int kFixedSlotCount = kFixedFrameSize / kPointerSize; \
+ static const int kFixedFrameSizeFromFp = TYPED_FRAME_SIZE_FROM_SP(count); \
+ static const int kFixedSlotCountFromFp = kFixedFrameSizeFromFp / kPointerSize
+
+class ArgumentsAdaptorFrameConstants : public TypedFrameConstants {
public:
// FP-relative.
- static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
-
- static const int kFrameSize =
- StandardFrameConstants::kFixedFrameSize + kPointerSize;
+ static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
+ static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
+ DEFINE_TYPED_FRAME_SIZES(2);
};
-
-class InternalFrameConstants : public AllStatic {
+class InternalFrameConstants : public TypedFrameConstants {
public:
// FP-relative.
- static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
+ static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
+ DEFINE_TYPED_FRAME_SIZES(1);
};
+class FrameDropperFrameConstants : public InternalFrameConstants {
+ public:
+ // FP-relative.
+ static const int kFunctionOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
+ DEFINE_TYPED_FRAME_SIZES(2);
+};
-class ConstructFrameConstants : public AllStatic {
+class ConstructFrameConstants : public TypedFrameConstants {
public:
// FP-relative.
- static const int kImplicitReceiverOffset =
- StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize;
- static const int kLengthOffset =
- StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
- static const int kAllocationSiteOffset =
- StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize;
- static const int kCodeOffset =
- StandardFrameConstants::kExpressionsOffset - 0 * kPointerSize;
-
- static const int kFrameSize =
- StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
+ static const int kContextOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
+ static const int kAllocationSiteOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
+ static const int kLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2);
+ static const int kImplicitReceiverOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(3);
+ DEFINE_TYPED_FRAME_SIZES(4);
+};
+
+class StubFailureTrampolineFrameConstants : public InternalFrameConstants {
+ public:
+ static const int kArgumentsArgumentsOffset =
+ TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
+ static const int kArgumentsLengthOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
+ static const int kArgumentsPointerOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(2);
+ static const int kFixedHeaderBottomOffset = kArgumentsPointerOffset;
+ DEFINE_TYPED_FRAME_SIZES(3);
};
@@ -310,6 +414,9 @@ class StackFrame BASE_EMBEDDED {
bool is_exit() const { return type() == EXIT; }
bool is_optimized() const { return type() == OPTIMIZED; }
bool is_interpreted() const { return type() == INTERPRETED; }
+ bool is_wasm() const { return type() == WASM; }
+ bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
+ bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
bool is_internal() const { return type() == INTERNAL; }
bool is_stub_failure_trampoline() const {
@@ -617,8 +724,7 @@ class FrameSummary BASE_EMBEDDED {
bool is_constructor_;
};
-
-class JavaScriptFrame: public StandardFrame {
+class JavaScriptFrame : public StandardFrame {
public:
Type type() const override { return JAVA_SCRIPT; }
@@ -841,6 +947,55 @@ class ArgumentsAdaptorFrame: public JavaScriptFrame {
friend class StackFrameIteratorBase;
};
+class WasmFrame : public StandardFrame {
+ public:
+ Type type() const override { return WASM; }
+
+ // GC support.
+ void Iterate(ObjectVisitor* v) const override;
+
+ // Printing support.
+ void Print(StringStream* accumulator, PrintMode mode,
+ int index) const override;
+
+ // Determine the code for the frame.
+ Code* unchecked_code() const override;
+
+ static WasmFrame* cast(StackFrame* frame) {
+ DCHECK(frame->is_wasm());
+ return static_cast<WasmFrame*>(frame);
+ }
+
+ protected:
+ inline explicit WasmFrame(StackFrameIteratorBase* iterator);
+
+ Address GetCallerStackPointer() const override;
+
+ private:
+ friend class StackFrameIteratorBase;
+};
+
+class WasmToJsFrame : public StubFrame {
+ public:
+ Type type() const override { return WASM_TO_JS; }
+
+ protected:
+ inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator);
+
+ private:
+ friend class StackFrameIteratorBase;
+};
+
+class JsToWasmFrame : public StubFrame {
+ public:
+ Type type() const override { return JS_TO_WASM; }
+
+ protected:
+ inline explicit JsToWasmFrame(StackFrameIteratorBase* iterator);
+
+ private:
+ friend class StackFrameIteratorBase;
+};
class InternalFrame: public StandardFrame {
public:
@@ -869,14 +1024,6 @@ class InternalFrame: public StandardFrame {
class StubFailureTrampolineFrame: public StandardFrame {
public:
- // sizeof(Arguments) - sizeof(Arguments*) is 3 * kPointerSize), but the
- // presubmit script complains about using sizeof() on a type.
- static const int kFirstRegisterParameterFrameOffset =
- StandardFrameConstants::kMarkerOffset - 3 * kPointerSize;
-
- static const int kCallerStackParameterCountFrameOffset =
- StandardFrameConstants::kMarkerOffset - 2 * kPointerSize;
-
Type type() const override { return STUB_FAILURE_TRAMPOLINE; }
// Get the code associated with this frame.
@@ -974,7 +1121,6 @@ class StackFrameIterator: public StackFrameIteratorBase {
DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
};
-
// Iterator that supports iterating through all JavaScript frames.
class JavaScriptFrameIterator BASE_EMBEDDED {
public:
@@ -997,7 +1143,6 @@ class JavaScriptFrameIterator BASE_EMBEDDED {
StackFrameIterator iterator_;
};
-
// NOTE: The stack trace frame iterator is an iterator that only
// traverse proper JavaScript frames; that is JavaScript frames that
// have proper JavaScript functions. This excludes the problematic