Commit 5d0714ff authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[sparkplug] Use EnterFrame/LeaveFrame with StackFrame::BASELINE

Using StackFrame::MANUAL was a bit of a hack to avoid frame markers to
be pushed, but manual in FrameScope means Enter/LeaveFrame aren't
called at all.  This decouples those things.

Bug: v8:11429
Change-Id: Ie1603bb3c6858f0b97a75e4bb0b9bd1244de6cce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2707205
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72909}
parent 3a997519
...@@ -481,7 +481,7 @@ void BaselineCompiler::Prologue() { ...@@ -481,7 +481,7 @@ void BaselineCompiler::Prologue() {
__ masm()->Mov(kInterpreterBytecodeArrayRegister, Operand(bytecode_)); __ masm()->Mov(kInterpreterBytecodeArrayRegister, Operand(bytecode_));
DCHECK_EQ(kJSFunctionRegister, kJavaScriptCallTargetRegister); DCHECK_EQ(kJSFunctionRegister, kJavaScriptCallTargetRegister);
// Enter the frame here, since CallBuiltin will override lr. // Enter the frame here, since CallBuiltin will override lr.
__ masm()->EnterFrame(StackFrame::MANUAL); __ masm()->EnterFrame(StackFrame::BASELINE);
CallBuiltin(Builtins::kBaselineOutOfLinePrologue, kContextRegister, CallBuiltin(Builtins::kBaselineOutOfLinePrologue, kContextRegister,
kJSFunctionRegister, kJavaScriptCallArgCountRegister, kJSFunctionRegister, kJavaScriptCallArgCountRegister,
kInterpreterBytecodeArrayRegister); kInterpreterBytecodeArrayRegister);
...@@ -617,7 +617,7 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) { ...@@ -617,7 +617,7 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) {
__ Bind(&corrected_args_count); __ Bind(&corrected_args_count);
// Leave the frame (also dropping the register file). // Leave the frame (also dropping the register file).
__ masm()->LeaveFrame(StackFrame::MANUAL); __ masm()->LeaveFrame(StackFrame::BASELINE);
// Drop receiver + arguments. // Drop receiver + arguments.
__ masm()->Add(params_size, params_size, 1); // Include the receiver. __ masm()->Add(params_size, params_size, 1); // Include the receiver.
......
...@@ -485,7 +485,7 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) { ...@@ -485,7 +485,7 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) {
__ Bind(&corrected_args_count); __ Bind(&corrected_args_count);
// Leave the frame (also dropping the register file). // Leave the frame (also dropping the register file).
__ masm()->LeaveFrame(StackFrame::MANUAL); __ masm()->LeaveFrame(StackFrame::BASELINE);
// Drop receiver + arguments. // Drop receiver + arguments.
Register return_pc = scratch; Register return_pc = scratch;
......
...@@ -1651,7 +1651,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) { ...@@ -1651,7 +1651,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
// set-up frame once we're done setting it up. // set-up frame once we're done setting it up.
__ PopReturnAddressTo(return_address); __ PopReturnAddressTo(return_address);
FrameScope frame_scope(masm, StackFrame::MANUAL); FrameScope frame_scope(masm, StackFrame::MANUAL);
__ EnterFrame(StackFrame::MANUAL); __ EnterFrame(StackFrame::BASELINE);
__ Push(descriptor.GetRegisterParameter( __ Push(descriptor.GetRegisterParameter(
BaselineOutOfLinePrologueDescriptor::kCalleeContext)); // Callee's BaselineOutOfLinePrologueDescriptor::kCalleeContext)); // Callee's
......
...@@ -2497,7 +2497,7 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) { ...@@ -2497,7 +2497,7 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
// sp[1] : type // sp[1] : type
// sp[0] : cp // sp[0] : cp
} else { } else {
DCHECK_EQ(type, StackFrame::MANUAL); DCHECK(StackFrame::IsJavaScript(type));
// Just push a minimal "machine frame", saving the frame pointer and return // Just push a minimal "machine frame", saving the frame pointer and return
// address, without any markers. // address, without any markers.
Push<TurboAssembler::kSignLR>(lr, fp); Push<TurboAssembler::kSignLR>(lr, fp);
......
...@@ -3228,7 +3228,7 @@ void TurboAssembler::Prologue() { ...@@ -3228,7 +3228,7 @@ void TurboAssembler::Prologue() {
void TurboAssembler::EnterFrame(StackFrame::Type type) { void TurboAssembler::EnterFrame(StackFrame::Type type) {
pushq(rbp); pushq(rbp);
movq(rbp, rsp); movq(rbp, rsp);
if (type != StackFrame::MANUAL) { if (!StackFrame::IsJavaScript(type)) {
Push(Immediate(StackFrame::TypeToMarker(type))); Push(Immediate(StackFrame::TypeToMarker(type)));
} }
} }
...@@ -3237,7 +3237,7 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) { ...@@ -3237,7 +3237,7 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) {
// TODO(v8:11429): Consider passing BASELINE instead, and checking for // TODO(v8:11429): Consider passing BASELINE instead, and checking for
// IsJSFrame or similar. Could then unify with manual frame leaves in the // IsJSFrame or similar. Could then unify with manual frame leaves in the
// interpreter too. // interpreter too.
if (emit_debug_code() && type != StackFrame::MANUAL) { if (emit_debug_code() && !StackFrame::IsJavaScript(type)) {
cmpq(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset), cmpq(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(type))); Immediate(StackFrame::TypeToMarker(type)));
Check(equal, AbortReason::kStackFrameTypesMustMatch); Check(equal, AbortReason::kStackFrameTypesMustMatch);
......
...@@ -233,12 +233,12 @@ class StackFrame { ...@@ -233,12 +233,12 @@ class StackFrame {
bool is_construct() const { return type() == CONSTRUCT; } bool is_construct() const { return type() == CONSTRUCT; }
bool is_builtin_exit() const { return type() == BUILTIN_EXIT; } bool is_builtin_exit() const { return type() == BUILTIN_EXIT; }
bool is_java_script() const { static bool IsJavaScript(Type t) {
STATIC_ASSERT(INTERPRETED + 1 == BASELINE); STATIC_ASSERT(INTERPRETED + 1 == BASELINE);
STATIC_ASSERT(BASELINE + 1 == OPTIMIZED); STATIC_ASSERT(BASELINE + 1 == OPTIMIZED);
Type t = type();
return t >= INTERPRETED && t <= OPTIMIZED; return t >= INTERPRETED && t <= OPTIMIZED;
} }
bool is_java_script() const { return IsJavaScript(type()); }
bool is_wasm_to_js() const { return type() == WASM_TO_JS; } bool is_wasm_to_js() const { return type() == WASM_TO_JS; }
bool is_js_to_wasm() const { return type() == JS_TO_WASM; } bool is_js_to_wasm() const { return type() == JS_TO_WASM; }
......
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