Commit a6737a72 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[sparkplug] Load undefined to accumulator in Prologue

Since we always call the out-of-line Prologue, we can preload the
accumulator in there with undefined instead of having to emit an
undefined load in every Sparkplug code header.

Change-Id: Ie0385316b0ee8bf96cd0069cda0496d05a4fb1eb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2933144Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74919}
parent a589277c
......@@ -31,7 +31,11 @@ void BaselineCompiler::PrologueFillFrame() {
// Inlined register frame fill
interpreter::Register new_target_or_generator_register =
bytecode_->incoming_new_target_or_generator_register();
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
if (FLAG_debug_code) {
__ masm()->CompareRoot(kInterpreterAccumulatorRegister,
RootIndex::kUndefinedValue);
__ masm()->Assert(eq, AbortReason::kUnexpectedValue);
}
int register_count = bytecode_->register_count();
// Magic value
const int kLoopUnrollSize = 8;
......
......@@ -32,7 +32,11 @@ void BaselineCompiler::PrologueFillFrame() {
// Inlined register frame fill
interpreter::Register new_target_or_generator_register =
bytecode_->incoming_new_target_or_generator_register();
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
if (FLAG_debug_code) {
__ masm()->CompareRoot(kInterpreterAccumulatorRegister,
RootIndex::kUndefinedValue);
__ masm()->Assert(eq, AbortReason::kUnexpectedValue);
}
int register_count = bytecode_->register_count();
// Magic value
const int kLoopUnrollSize = 8;
......
......@@ -30,7 +30,11 @@ void BaselineCompiler::PrologueFillFrame() {
// Inlined register frame fill
interpreter::Register new_target_or_generator_register =
bytecode_->incoming_new_target_or_generator_register();
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
if (FLAG_debug_code) {
__ masm()->CompareRoot(kInterpreterAccumulatorRegister,
RootIndex::kUndefinedValue);
__ masm()->Assert(equal, AbortReason::kUnexpectedValue);
}
int register_count = bytecode_->register_count();
// Magic value
const int kLoopUnrollSize = 8;
......
......@@ -30,7 +30,11 @@ void BaselineCompiler::PrologueFillFrame() {
// Inlined register frame fill
interpreter::Register new_target_or_generator_register =
bytecode_->incoming_new_target_or_generator_register();
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
if (FLAG_debug_code) {
__ masm()->Cmp(kInterpreterAccumulatorRegister,
isolate_->factory()->undefined_value());
__ masm()->Assert(equal, AbortReason::kUnexpectedValue);
}
int register_count = bytecode_->register_count();
// Magic value
const int kLoopUnrollSize = 8;
......
......@@ -1154,6 +1154,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
}
// Do "fast" return to the caller pc in lr.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
__ bind(&has_optimized_code_or_marker);
......@@ -1184,6 +1185,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
__ RecordComment("]");
}
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
}
......
......@@ -1274,7 +1274,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
BaselineOutOfLinePrologueDescriptor::kJavaScriptCallArgCount);
// We'll use the bytecode for both code age/OSR resetting, and pushing onto
// the frame, so load it into a register.
Register bytecodeArray = descriptor.GetRegisterParameter(
Register bytecode_array = descriptor.GetRegisterParameter(
BaselineOutOfLinePrologueDescriptor::kInterpreterBytecodeArray);
// Reset code age and the OSR arming. The OSR field and BytecodeAgeOffset
......@@ -1283,10 +1283,10 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset ==
BytecodeArray::kOsrNestingLevelOffset + kCharSize);
STATIC_ASSERT(BytecodeArray::kNoAgeBytecodeAge == 0);
__ Strh(wzr, FieldMemOperand(bytecodeArray,
__ Strh(wzr, FieldMemOperand(bytecode_array,
BytecodeArray::kOsrNestingLevelOffset));
__ Push(argc, bytecodeArray);
__ Push(argc, bytecode_array);
// Baseline code frames store the feedback vector where interpreter would
// store the bytecode offset.
......@@ -1297,9 +1297,6 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
// Our stack is currently aligned. We have have to push something along with
// the feedback vector to keep it that way -- we may as well start
// initialising the register frame.
// TODO(v8:11429,leszeks): Consider guaranteeing that this call leaves
// `undefined` in the accumulator register, to skip the load in the baseline
// code.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Push(feedback_vector, kInterpreterAccumulatorRegister);
__ RecordComment("]");
......@@ -1326,7 +1323,11 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
}
// Do "fast" return to the caller pc in lr.
// TODO(v8:11429): Document this frame setup better.
if (FLAG_debug_code) {
// The accumulator should already be "undefined", we don't have to load it.
__ CompareRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Assert(eq, AbortReason::kUnexpectedValue);
}
__ Ret();
__ bind(&has_optimized_code_or_marker);
......@@ -1355,6 +1356,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
__ Pop(new_target, padreg);
__ RecordComment("]");
}
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
}
......
......@@ -1744,6 +1744,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
// Push the return address back onto the stack for return.
__ PushReturnAddressFrom(return_address, scratch);
// Return to caller pushed pc, without any frame teardown.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
__ bind(&has_optimized_code_or_marker);
......@@ -1778,6 +1779,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
}
// Return to caller pushed pc, without any frame teardown.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
__ RecordComment("]");
}
......
......@@ -1726,6 +1726,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
// Push the return address back onto the stack for return.
__ PushReturnAddressFrom(return_address);
// Return to caller pushed pc, without any frame teardown.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
__ bind(&has_optimized_code_or_marker);
......@@ -1760,6 +1761,7 @@ void Builtins::Generate_BaselineOutOfLinePrologue(MacroAssembler* masm) {
}
// Return to caller pushed pc, without any frame teardown.
__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
__ Ret();
__ RecordComment("]");
}
......
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