Commit d4843937 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Revert "[cleanup] Create virtual FrameWithJSLinkages"

This reverts commit 5afa3add.

Reason for revert: Seems to break CFI, see https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20-%20cfi/26994

Original change's description:
> [cleanup] Create virtual FrameWithJSLinkages
>
> - CommonFrameWithJSLinkage
> - TypedFrameWithJSLinkage
>
> Change-Id: Ib70967c6b8bc9129d7562ec5587076e66312ca25
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2480562
> Commit-Queue: Victor Gomes <victorgomes@chromium.org>
> Reviewed-by: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#70609}

TBR=ishell@chromium.org,victorgomes@chromium.org

Change-Id: I5d3a16a3010e41896448cb9462d7cc2a0813ca63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2484705Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70612}
parent 3082bf8b
...@@ -97,14 +97,6 @@ inline Address* StackFrame::ResolveReturnAddressLocation(Address* pc_address) { ...@@ -97,14 +97,6 @@ inline Address* StackFrame::ResolveReturnAddressLocation(Address* pc_address) {
inline TypedFrame::TypedFrame(StackFrameIteratorBase* iterator) inline TypedFrame::TypedFrame(StackFrameIteratorBase* iterator)
: CommonFrame(iterator) {} : CommonFrame(iterator) {}
inline CommonFrameWithJSLinkage::CommonFrameWithJSLinkage(
StackFrameIteratorBase* iterator)
: CommonFrame(iterator) {}
inline TypedFrameWithJSLinkage::TypedFrameWithJSLinkage(
StackFrameIteratorBase* iterator)
: CommonFrameWithJSLinkage(iterator) {}
inline NativeFrame::NativeFrame(StackFrameIteratorBase* iterator) inline NativeFrame::NativeFrame(StackFrameIteratorBase* iterator)
: TypedFrame(iterator) {} : TypedFrame(iterator) {}
...@@ -183,16 +175,16 @@ inline bool CommonFrame::IsArgumentsAdaptorFrame(Address fp) { ...@@ -183,16 +175,16 @@ inline bool CommonFrame::IsArgumentsAdaptorFrame(Address fp) {
return frame_type == StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR); return frame_type == StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR);
} }
inline bool CommonFrameWithJSLinkage::IsConstructFrame(Address fp) { inline bool CommonFrame::IsConstructFrame(Address fp) {
intptr_t frame_type = intptr_t frame_type =
base::Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset); base::Memory<intptr_t>(fp + TypedFrameConstants::kFrameTypeOffset);
return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT); return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT);
} }
inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator) inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator)
: CommonFrameWithJSLinkage(iterator) {} : CommonFrame(iterator) {}
Address CommonFrameWithJSLinkage::GetParameterSlot(int index) const { Address JavaScriptFrame::GetParameterSlot(int index) const {
DCHECK_LE(-1, index); DCHECK_LE(-1, index);
#ifdef V8_NO_ARGUMENTS_ADAPTOR #ifdef V8_NO_ARGUMENTS_ADAPTOR
DCHECK_LT(index, DCHECK_LT(index,
...@@ -205,12 +197,6 @@ Address CommonFrameWithJSLinkage::GetParameterSlot(int index) const { ...@@ -205,12 +197,6 @@ Address CommonFrameWithJSLinkage::GetParameterSlot(int index) const {
return caller_sp() + parameter_offset; return caller_sp() + parameter_offset;
} }
#ifdef V8_NO_ARGUMENTS_ADAPTOR
inline int CommonFrameWithJSLinkage::GetActualArgumentCount() const {
return 0;
}
#endif
inline void JavaScriptFrame::set_receiver(Object value) { inline void JavaScriptFrame::set_receiver(Object value) {
base::Memory<Address>(GetParameterSlot(-1)) = value.ptr(); base::Memory<Address>(GetParameterSlot(-1)) = value.ptr();
} }
...@@ -240,7 +226,7 @@ inline ArgumentsAdaptorFrame::ArgumentsAdaptorFrame( ...@@ -240,7 +226,7 @@ inline ArgumentsAdaptorFrame::ArgumentsAdaptorFrame(
} }
inline BuiltinFrame::BuiltinFrame(StackFrameIteratorBase* iterator) inline BuiltinFrame::BuiltinFrame(StackFrameIteratorBase* iterator)
: TypedFrameWithJSLinkage(iterator) {} : TypedFrame(iterator) {}
inline WasmFrame::WasmFrame(StackFrameIteratorBase* iterator) inline WasmFrame::WasmFrame(StackFrameIteratorBase* iterator)
: TypedFrame(iterator) {} : TypedFrame(iterator) {}
...@@ -278,7 +264,7 @@ inline BuiltinContinuationFrame::BuiltinContinuationFrame( ...@@ -278,7 +264,7 @@ inline BuiltinContinuationFrame::BuiltinContinuationFrame(
inline JavaScriptBuiltinContinuationFrame::JavaScriptBuiltinContinuationFrame( inline JavaScriptBuiltinContinuationFrame::JavaScriptBuiltinContinuationFrame(
StackFrameIteratorBase* iterator) StackFrameIteratorBase* iterator)
: TypedFrameWithJSLinkage(iterator) {} : JavaScriptFrame(iterator) {}
inline JavaScriptBuiltinContinuationWithCatchFrame:: inline JavaScriptBuiltinContinuationWithCatchFrame::
JavaScriptBuiltinContinuationWithCatchFrame( JavaScriptBuiltinContinuationWithCatchFrame(
......
...@@ -156,13 +156,6 @@ StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) { ...@@ -156,13 +156,6 @@ StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void TypedFrameWithJSLinkage::Iterate(RootVisitor* v) const {
IterateExpressions(v);
IteratePc(v, pc_address(), constant_pool_address(), LookupCode());
}
// -------------------------------------------------------------------------
void JavaScriptFrameIterator::Advance() { void JavaScriptFrameIterator::Advance() {
do { do {
iterator_.Advance(); iterator_.Advance();
...@@ -1097,9 +1090,7 @@ bool JavaScriptFrame::HasInlinedFrames() const { ...@@ -1097,9 +1090,7 @@ bool JavaScriptFrame::HasInlinedFrames() const {
return functions.size() > 1; return functions.size() > 1;
} }
Code CommonFrameWithJSLinkage::unchecked_code() const { Code JavaScriptFrame::unchecked_code() const { return function().code(); }
return function().code();
}
int OptimizedFrame::ComputeParametersCount() const { int OptimizedFrame::ComputeParametersCount() const {
Code code = LookupCode(); Code code = LookupCode();
...@@ -1132,12 +1123,7 @@ void JavaScriptFrame::GetFunctions( ...@@ -1132,12 +1123,7 @@ void JavaScriptFrame::GetFunctions(
} }
} }
bool CommonFrameWithJSLinkage::IsConstructor() const { void JavaScriptFrame::Summarize(std::vector<FrameSummary>* functions) const {
return IsConstructFrame(caller_fp());
}
void CommonFrameWithJSLinkage::Summarize(
std::vector<FrameSummary>* functions) const {
DCHECK(functions->empty()); DCHECK(functions->empty());
Code code = LookupCode(); Code code = LookupCode();
int offset = static_cast<int>(pc() - code.InstructionStart()); int offset = static_cast<int>(pc() - code.InstructionStart());
...@@ -1162,7 +1148,7 @@ Object JavaScriptFrame::unchecked_function() const { ...@@ -1162,7 +1148,7 @@ Object JavaScriptFrame::unchecked_function() const {
return function_slot_object(); return function_slot_object();
} }
Object CommonFrameWithJSLinkage::receiver() const { return GetParameter(-1); } Object JavaScriptFrame::receiver() const { return GetParameter(-1); }
Object JavaScriptFrame::context() const { Object JavaScriptFrame::context() const {
const int offset = StandardFrameConstants::kContextOffset; const int offset = StandardFrameConstants::kContextOffset;
...@@ -1175,7 +1161,7 @@ Script JavaScriptFrame::script() const { ...@@ -1175,7 +1161,7 @@ Script JavaScriptFrame::script() const {
return Script::cast(function().shared().script()); return Script::cast(function().shared().script());
} }
int CommonFrameWithJSLinkage::LookupExceptionHandlerInTable( int JavaScriptFrame::LookupExceptionHandlerInTable(
int* stack_depth, HandlerTable::CatchPrediction* prediction) { int* stack_depth, HandlerTable::CatchPrediction* prediction) {
DCHECK(!LookupCode().has_handler_table()); DCHECK(!LookupCode().has_handler_table());
DCHECK(!LookupCode().is_optimized_code()); DCHECK(!LookupCode().is_optimized_code());
...@@ -1270,11 +1256,11 @@ void JavaScriptFrame::CollectFunctionAndOffsetForICStats(JSFunction function, ...@@ -1270,11 +1256,11 @@ void JavaScriptFrame::CollectFunctionAndOffsetForICStats(JSFunction function,
} }
} }
Object CommonFrameWithJSLinkage::GetParameter(int index) const { Object JavaScriptFrame::GetParameter(int index) const {
return Object(Memory<Address>(GetParameterSlot(index))); return Object(Memory<Address>(GetParameterSlot(index)));
} }
int CommonFrameWithJSLinkage::ComputeParametersCount() const { int JavaScriptFrame::ComputeParametersCount() const {
DCHECK(can_access_heap_objects() && DCHECK(can_access_heap_objects() &&
isolate()->heap()->gc_state() == Heap::NOT_IN_GC); isolate()->heap()->gc_state() == Heap::NOT_IN_GC);
return function().shared().internal_formal_parameter_count(); return function().shared().internal_formal_parameter_count();
...@@ -1287,7 +1273,7 @@ int JavaScriptFrame::GetActualArgumentCount() const { ...@@ -1287,7 +1273,7 @@ int JavaScriptFrame::GetActualArgumentCount() const {
} }
#endif #endif
Handle<FixedArray> CommonFrameWithJSLinkage::GetParameters() const { Handle<FixedArray> JavaScriptFrame::GetParameters() const {
if (V8_LIKELY(!FLAG_detailed_error_stack_trace)) { if (V8_LIKELY(!FLAG_detailed_error_stack_trace)) {
return isolate()->factory()->empty_fixed_array(); return isolate()->factory()->empty_fixed_array();
} }
...@@ -1301,11 +1287,6 @@ Handle<FixedArray> CommonFrameWithJSLinkage::GetParameters() const { ...@@ -1301,11 +1287,6 @@ Handle<FixedArray> CommonFrameWithJSLinkage::GetParameters() const {
return parameters; return parameters;
} }
JSFunction JavaScriptBuiltinContinuationFrame::function() const {
const int offset = BuiltinContinuationFrameConstants::kFunctionOffset;
return JSFunction::cast(Object(base::Memory<Address>(fp() + offset)));
}
int JavaScriptBuiltinContinuationFrame::ComputeParametersCount() const { int JavaScriptBuiltinContinuationFrame::ComputeParametersCount() const {
// Assert that the first allocatable register is also the argument count // Assert that the first allocatable register is also the argument count
// register. // register.
...@@ -1789,11 +1770,6 @@ Code ArgumentsAdaptorFrame::unchecked_code() const { ...@@ -1789,11 +1770,6 @@ Code ArgumentsAdaptorFrame::unchecked_code() const {
return isolate()->builtins()->builtin(Builtins::kArgumentsAdaptorTrampoline); return isolate()->builtins()->builtin(Builtins::kArgumentsAdaptorTrampoline);
} }
JSFunction BuiltinFrame::function() const {
const int offset = BuiltinFrameConstants::kFunctionOffset;
return JSFunction::cast(Object(base::Memory<Address>(fp() + offset)));
}
int BuiltinFrame::ComputeParametersCount() const { int BuiltinFrame::ComputeParametersCount() const {
const int offset = BuiltinFrameConstants::kLengthOffset; const int offset = BuiltinFrameConstants::kLengthOffset;
return Smi::ToInt(Object(base::Memory<Address>(fp() + offset))); return Smi::ToInt(Object(base::Memory<Address>(fp() + offset)));
......
...@@ -14,14 +14,11 @@ ...@@ -14,14 +14,11 @@
// //
// Frame inheritance hierarchy (please keep in sync with frame-constants.h): // Frame inheritance hierarchy (please keep in sync with frame-constants.h):
// - CommonFrame // - CommonFrame
// - CommonFrameWithJSLinkage
// - JavaScriptFrame (aka StandardFrame) // - JavaScriptFrame (aka StandardFrame)
// - InterpretedFrame // - InterpretedFrame
// - OptimizedFrame // - OptimizedFrame
// - ArgumentsAdaptorFrame (technically a TypedFrame) // - ArgumentsAdaptorFrame (technically a TypedFrame)
// - TypedFrameWithJSLinkage // - JavaScriptBuiltinContinuationFrame (*)
// - BuiltinFrame
// - JavaScriptBuiltinContinuationFrame
// - JavaScriptBuiltinContinuationWithCatchFrame // - JavaScriptBuiltinContinuationWithCatchFrame
// - TypedFrame // - TypedFrame
// - NativeFrame // - NativeFrame
...@@ -32,6 +29,7 @@ ...@@ -32,6 +29,7 @@
// - StubFrame // - StubFrame
// - JsToWasmFrame // - JsToWasmFrame
// - CWasmEntryFrame // - CWasmEntryFrame
// - BuiltinFrame
// - Internal // - Internal
// - ConstructFrame // - ConstructFrame
// - BuiltinContinuationFrame // - BuiltinContinuationFrame
...@@ -40,6 +38,11 @@ ...@@ -40,6 +38,11 @@
// - WasmDebugBreakFrame // - WasmDebugBreakFrame
// - WasmCompileLazyFrame // - WasmCompileLazyFrame
// //
// (*) This is actually a BuiltinContinuationFrame with JS arguments.
//
// TODO(victorgomes): Create a class to access JS arguments and change
// BuiltinContinuationFrame to be of type TypedFrame.
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -466,8 +469,7 @@ class V8_EXPORT_PRIVATE FrameSummary { ...@@ -466,8 +469,7 @@ class V8_EXPORT_PRIVATE FrameSummary {
class CommonFrame : public StackFrame { class CommonFrame : public StackFrame {
public: public:
// Accessors. // Accessors.
virtual Object context() virtual Object context() const;
const; // TODO(victorgomes): CommonFrames don't have context.
virtual int position() const; virtual int position() const;
// Access the expressions in the stack frame including locals. // Access the expressions in the stack frame including locals.
...@@ -515,6 +517,10 @@ class CommonFrame : public StackFrame { ...@@ -515,6 +517,10 @@ class CommonFrame : public StackFrame {
// an arguments adaptor frame. // an arguments adaptor frame.
static inline bool IsArgumentsAdaptorFrame(Address fp); static inline bool IsArgumentsAdaptorFrame(Address fp);
// Determines if the standard frame for the given frame pointer is a
// construct frame.
static inline bool IsConstructFrame(Address fp);
// Used by OptimizedFrames and StubFrames. // Used by OptimizedFrames and StubFrames.
void IterateCompiledFrame(RootVisitor* v) const; void IterateCompiledFrame(RootVisitor* v) const;
...@@ -532,74 +538,35 @@ class TypedFrame : public CommonFrame { ...@@ -532,74 +538,35 @@ class TypedFrame : public CommonFrame {
inline explicit TypedFrame(StackFrameIteratorBase* iterator); inline explicit TypedFrame(StackFrameIteratorBase* iterator);
}; };
class CommonFrameWithJSLinkage : public CommonFrame { class JavaScriptFrame : public CommonFrame {
public: public:
// Accessors. Type type() const override = 0;
virtual JSFunction function() const = 0;
// Access the parameters.
virtual Object receiver() const;
virtual Object GetParameter(int index) const;
virtual int ComputeParametersCount() const;
Handle<FixedArray> GetParameters() const;
#ifdef V8_NO_ARGUMENTS_ADAPTOR
virtual int GetActualArgumentCount() const;
#endif
// Determine the code for the frame.
Code unchecked_code() const override;
// Lookup exception handler for current {pc}, returns -1 if none found. Also
// returns data associated with the handler site specific to the frame type:
// - OptimizedFrame : Data is not used and will not return a value.
// - InterpretedFrame: Data is the register index holding the context.
virtual int LookupExceptionHandlerInTable(
int* data, HandlerTable::CatchPrediction* prediction);
// Check if this frame is a constructor frame invoked through 'new'.
virtual bool IsConstructor() const;
// Summarize Frame
void Summarize(std::vector<FrameSummary>* frames) const override; void Summarize(std::vector<FrameSummary>* frames) const override;
protected:
inline explicit CommonFrameWithJSLinkage(StackFrameIteratorBase* iterator);
// Determines if the standard frame for the given frame pointer is a
// construct frame.
static inline bool IsConstructFrame(Address fp);
inline Address GetParameterSlot(int index) const;
};
class TypedFrameWithJSLinkage : public CommonFrameWithJSLinkage {
public:
void Iterate(RootVisitor* v) const override;
protected:
inline explicit TypedFrameWithJSLinkage(StackFrameIteratorBase* iterator);
};
class JavaScriptFrame : public CommonFrameWithJSLinkage {
public:
Type type() const override = 0;
// Accessors. // Accessors.
JSFunction function() const override; virtual JSFunction function() const;
Object unchecked_function() const; Object unchecked_function() const;
Script script() const; Object receiver() const;
Object context() const override; Object context() const override;
Script script() const;
inline void set_receiver(Object value);
// Access the parameters.
inline Address GetParameterSlot(int index) const;
Object GetParameter(int index) const;
virtual int ComputeParametersCount() const;
#ifdef V8_NO_ARGUMENTS_ADAPTOR #ifdef V8_NO_ARGUMENTS_ADAPTOR
int GetActualArgumentCount() const override; int GetActualArgumentCount() const;
#endif #endif
Handle<FixedArray> GetParameters() const;
inline void set_receiver(Object value);
// Debugger access. // Debugger access.
void SetParameterValue(int index, Object value) const; void SetParameterValue(int index, Object value) const;
// Check if this frame is a constructor frame invoked through 'new'. // Check if this frame is a constructor frame invoked through 'new'.
bool IsConstructor() const override; bool IsConstructor() const;
// Determines whether this frame includes inlined activations. To get details // Determines whether this frame includes inlined activations. To get details
// about the inlined frames use {GetFunctions} and {Summarize}. // about the inlined frames use {GetFunctions} and {Summarize}.
...@@ -617,11 +584,21 @@ class JavaScriptFrame : public CommonFrameWithJSLinkage { ...@@ -617,11 +584,21 @@ class JavaScriptFrame : public CommonFrameWithJSLinkage {
void Print(StringStream* accumulator, PrintMode mode, void Print(StringStream* accumulator, PrintMode mode,
int index) const override; int index) const override;
// Determine the code for the frame.
Code unchecked_code() const override;
// Return a list with {SharedFunctionInfo} objects of this frame. // Return a list with {SharedFunctionInfo} objects of this frame.
virtual void GetFunctions(std::vector<SharedFunctionInfo>* functions) const; virtual void GetFunctions(std::vector<SharedFunctionInfo>* functions) const;
void GetFunctions(std::vector<Handle<SharedFunctionInfo>>* functions) const; void GetFunctions(std::vector<Handle<SharedFunctionInfo>>* functions) const;
// Lookup exception handler for current {pc}, returns -1 if none found. Also
// returns data associated with the handler site specific to the frame type:
// - OptimizedFrame : Data is not used and will not return a value.
// - InterpretedFrame: Data is the register index holding the context.
virtual int LookupExceptionHandlerInTable(
int* data, HandlerTable::CatchPrediction* prediction);
// Architecture-specific register description. // Architecture-specific register description.
static Register fp_register(); static Register fp_register();
static Register context_register(); static Register context_register();
...@@ -918,7 +895,7 @@ class ArgumentsAdaptorFrame : public JavaScriptFrame { ...@@ -918,7 +895,7 @@ class ArgumentsAdaptorFrame : public JavaScriptFrame {
// Builtin frames are built for builtins with JavaScript linkage, such as // Builtin frames are built for builtins with JavaScript linkage, such as
// various standard library functions (i.e. Math.asin, Math.floor, etc.). // various standard library functions (i.e. Math.asin, Math.floor, etc.).
class BuiltinFrame final : public TypedFrameWithJSLinkage { class BuiltinFrame final : public TypedFrame {
public: public:
Type type() const final { return BUILTIN; } Type type() const final { return BUILTIN; }
...@@ -926,9 +903,7 @@ class BuiltinFrame final : public TypedFrameWithJSLinkage { ...@@ -926,9 +903,7 @@ class BuiltinFrame final : public TypedFrameWithJSLinkage {
DCHECK(frame->is_builtin()); DCHECK(frame->is_builtin());
return static_cast<BuiltinFrame*>(frame); return static_cast<BuiltinFrame*>(frame);
} }
int ComputeParametersCount() const;
JSFunction function() const override;
int ComputeParametersCount() const override;
protected: protected:
inline explicit BuiltinFrame(StackFrameIteratorBase* iterator); inline explicit BuiltinFrame(StackFrameIteratorBase* iterator);
...@@ -1128,7 +1103,7 @@ class BuiltinContinuationFrame : public InternalFrame { ...@@ -1128,7 +1103,7 @@ class BuiltinContinuationFrame : public InternalFrame {
friend class StackFrameIteratorBase; friend class StackFrameIteratorBase;
}; };
class JavaScriptBuiltinContinuationFrame : public TypedFrameWithJSLinkage { class JavaScriptBuiltinContinuationFrame : public JavaScriptFrame {
public: public:
Type type() const override { return JAVA_SCRIPT_BUILTIN_CONTINUATION; } Type type() const override { return JAVA_SCRIPT_BUILTIN_CONTINUATION; }
...@@ -1137,7 +1112,6 @@ class JavaScriptBuiltinContinuationFrame : public TypedFrameWithJSLinkage { ...@@ -1137,7 +1112,6 @@ class JavaScriptBuiltinContinuationFrame : public TypedFrameWithJSLinkage {
return static_cast<JavaScriptBuiltinContinuationFrame*>(frame); return static_cast<JavaScriptBuiltinContinuationFrame*>(frame);
} }
JSFunction function() const override;
int ComputeParametersCount() const override; int ComputeParametersCount() const override;
intptr_t GetSPToFPDelta() const; intptr_t GetSPToFPDelta() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment