Commit 718030c4 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Remove context param from some baseline builtins

Remove a couple of cases where builtins called by the baseline code
needed a context parameter, either because the interface descriptor
accidentally included the context, or by adding a trivial context load
from the frame where appropriate.

Bug: v8:11420
Change-Id: I3f34cd452f42dd876255375ae357feb245c78cdc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2848464
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74227}
parent 09f374ac
......@@ -1858,17 +1858,16 @@ void BaselineCompiler::VisitGetTemplateObject() {
}
void BaselineCompiler::VisitCreateClosure() {
using Descriptor =
CallInterfaceDescriptorFor<Builtins::kFastNewClosure>::type;
Register feedback_cell =
Descriptor::GetRegisterParameter(Descriptor::kFeedbackCell);
FastNewClosureBaselineDescriptor::GetRegisterParameter(
FastNewClosureBaselineDescriptor::kFeedbackCell);
LoadClosureFeedbackArray(feedback_cell);
__ LoadFixedArrayElement(feedback_cell, feedback_cell, Index(1));
uint32_t flags = Flag(2);
if (interpreter::CreateClosureFlags::FastNewClosureBit::decode(flags)) {
CallBuiltin<Builtins::kFastNewClosure>(Constant<SharedFunctionInfo>(0),
feedback_cell);
CallBuiltin<Builtins::kFastNewClosureBaseline>(
Constant<SharedFunctionInfo>(0), feedback_cell);
} else {
Runtime::FunctionId function_id =
interpreter::CreateClosureFlags::PretenuredBit::decode(flags)
......
......@@ -1842,6 +1842,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
}
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
__ ldr(kContextRegister,
MemOperand(fp, BaselineFrameConstants::kContextOffset));
return OnStackReplacement(masm, false);
}
......
......@@ -2089,6 +2089,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
}
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
__ ldr(kContextRegister,
MemOperand(fp, BaselineFrameConstants::kContextOffset));
return OnStackReplacement(masm, false);
}
......
......@@ -139,7 +139,7 @@ namespace internal {
\
/* Baseline Compiler */ \
ASM(BaselineOutOfLinePrologue, BaselineOutOfLinePrologue) \
ASM(BaselineOnStackReplacement, ContextOnly) \
ASM(BaselineOnStackReplacement, Void) \
ASM(BaselineLeaveFrame, BaselineLeaveFrame) \
ASM(BaselineEnterAtBytecode, Void) \
ASM(BaselineEnterAtNextBytecode, Void) \
......
......@@ -205,7 +205,7 @@ TF_BUILTIN(GeneratorPrototypeThrow, GeneratorBuiltinsAssembler) {
// TODO(cbruni): Merge with corresponding bytecode handler.
TF_BUILTIN(SuspendGeneratorBaseline, GeneratorBuiltinsAssembler) {
auto generator = Parameter<JSGeneratorObject>(Descriptor::kGeneratorObject);
auto context = Parameter<Context>(Descriptor::kContext);
auto context = LoadContextFromBaseline();
StoreJSGeneratorObjectContext(generator, context);
auto suspend_id = SmiTag(UncheckedParameter<IntPtrT>(Descriptor::kSuspendId));
StoreJSGeneratorObjectContinuation(generator, suspend_id);
......
......@@ -15,6 +15,8 @@ extern runtime CreateObjectLiteral(
namespace constructor {
extern builtin FastNewClosure(
Context, SharedFunctionInfo, FeedbackCell): JSFunction;
extern builtin FastNewObject(Context, JSFunction, JSReceiver): JSObject;
extern enum AllocationSiteMode {
......@@ -42,6 +44,15 @@ extern macro ConstructorBuiltinsAssembler::CreateShallowObjectLiteral(
extern macro ConstructorBuiltinsAssembler::CreateEmptyObjectLiteral(Context):
JSObject;
extern macro LoadContextFromBaseline(): Context;
builtin FastNewClosureBaseline(
sharedFunctionInfo: SharedFunctionInfo,
feedbackCell: FeedbackCell): JSFunction {
const context = LoadContextFromBaseline();
tail FastNewClosure(context, sharedFunctionInfo, feedbackCell);
}
builtin FastNewFunctionContextEval(implicit context: Context)(
scopeInfo: ScopeInfo, slots: uint32): Context {
return FastNewFunctionContext(scopeInfo, slots, context, kEvalScope);
......
......@@ -45,7 +45,7 @@ builtin NumberToString(implicit context: Context)(input: Number): String {
}
// ES6 section 7.1.2 ToBoolean ( argument )
builtin ToBoolean(implicit context: Context)(input: JSAny): Boolean {
builtin ToBoolean(input: JSAny): Boolean {
BranchIfToBooleanIsTrue(input) otherwise return TrueConstant(),
return FalseConstant();
}
......
......@@ -2790,6 +2790,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
}
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
__ mov(kContextRegister,
MemOperand(ebp, BaselineFrameConstants::kContextOffset));
return OnStackReplacement(masm, false);
}
......
......@@ -78,8 +78,8 @@ extern macro LoadContextFromBaseline(): Context;
extern macro LoadFeedbackVectorFromBaseline(): FeedbackVector;
transitioning builtin GetIteratorBaseline(
context: Context, receiver: JSAny, loadSlot: TaggedIndex,
callSlot: TaggedIndex): JSAny {
receiver: JSAny, loadSlot: TaggedIndex, callSlot: TaggedIndex): JSAny {
const context: Context = LoadContextFromBaseline();
const feedback: FeedbackVector = LoadFeedbackVectorFromBaseline();
const iteratorMethod: JSAny =
LoadIC(context, receiver, IteratorSymbolConstant(), loadSlot, feedback);
......
......@@ -1814,6 +1814,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
}
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
__ Ld(kContextRegister,
MemOperand(fp, StandardFrameConstants::kContextOffset));
return OnStackReplacement(masm, false);
}
......
......@@ -2685,6 +2685,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
}
void Builtins::Generate_BaselineOnStackReplacement(MacroAssembler* masm) {
__ movq(kContextRegister,
MemOperand(rbp, BaselineFrameConstants::kContextOffset));
return OnStackReplacement(masm, false);
}
......
......@@ -572,6 +572,12 @@ constexpr EmptyRegisterArray RegisterArray() { return {}; }
static constexpr StackArgumentOrder kStackArgumentOrder = \
StackArgumentOrder::kJS;
#define DEFINE_PARAMETERS_NO_CONTEXT_VARARGS(...) \
DEFINE_PARAMETERS_NO_CONTEXT(__VA_ARGS__) \
static constexpr bool kAllowVarArgs = true; \
static constexpr StackArgumentOrder kStackArgumentOrder = \
StackArgumentOrder::kJS;
#define DEFINE_RESULT_AND_PARAMETERS_NO_CONTEXT(return_count, ...) \
DEFINE_RESULT_AND_PARAMETERS(return_count, ##__VA_ARGS__) \
static constexpr bool kNoContext = true;
......@@ -807,7 +813,7 @@ class StoreDescriptor : public StaticCallInterfaceDescriptor<StoreDescriptor> {
};
class StoreBaselineDescriptor
: public StaticCallInterfaceDescriptor<StoreDescriptor> {
: public StaticCallInterfaceDescriptor<StoreBaselineDescriptor> {
public:
DEFINE_PARAMETERS_NO_CONTEXT(kReceiver, kName, kValue, kSlot)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kReceiver
......@@ -1158,7 +1164,7 @@ class CallWithSpreadDescriptor
class CallWithSpread_BaselineDescriptor
: public StaticCallInterfaceDescriptor<CallWithSpread_BaselineDescriptor> {
public:
DEFINE_PARAMETERS_VARARGS(kTarget, kArgumentsCount, kSpread, kSlot)
DEFINE_PARAMETERS_NO_CONTEXT_VARARGS(kTarget, kArgumentsCount, kSpread, kSlot)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kTarget
MachineType::Int32(), // kArgumentsCount
MachineType::AnyTagged(), // kSpread
......@@ -1241,7 +1247,7 @@ class ConstructWithSpread_BaselineDescriptor
public:
// Note: kSlot comes before kSpread since as an untagged value it must be
// passed in a register.
DEFINE_JS_PARAMETERS(kSlot, kSpread)
DEFINE_JS_PARAMETERS_NO_CONTEXT(kSlot, kSpread)
DEFINE_JS_PARAMETER_TYPES(MachineType::UintPtr(), // kSlot
MachineType::AnyTagged()) // kSpread
DECLARE_DESCRIPTOR(ConstructWithSpread_BaselineDescriptor)
......@@ -1661,7 +1667,7 @@ class ResumeGeneratorDescriptor final
class ResumeGeneratorBaselineDescriptor final
: public StaticCallInterfaceDescriptor<ResumeGeneratorBaselineDescriptor> {
public:
DEFINE_PARAMETERS(kGeneratorObject, kRegisterCount)
DEFINE_PARAMETERS_NO_CONTEXT(kGeneratorObject, kRegisterCount)
DEFINE_RESULT_AND_PARAMETER_TYPES(
MachineType::TaggedSigned(), // return type
MachineType::AnyTagged(), // kGeneratorObject
......@@ -1673,8 +1679,8 @@ class ResumeGeneratorBaselineDescriptor final
class SuspendGeneratorBaselineDescriptor final
: public StaticCallInterfaceDescriptor<SuspendGeneratorBaselineDescriptor> {
public:
DEFINE_PARAMETERS(kGeneratorObject, kSuspendId, kBytecodeOffset,
kRegisterCount)
DEFINE_PARAMETERS_NO_CONTEXT(kGeneratorObject, kSuspendId, kBytecodeOffset,
kRegisterCount)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kGeneratorObject
MachineType::IntPtr(), // kSuspendId
MachineType::IntPtr(), // kBytecodeOffset
......@@ -1847,7 +1853,7 @@ class BinaryOp_WithFeedbackDescriptor
class CallTrampoline_BaselineDescriptor
: public StaticCallInterfaceDescriptor<CallTrampoline_BaselineDescriptor> {
public:
DEFINE_PARAMETERS_VARARGS(kFunction, kActualArgumentsCount, kSlot)
DEFINE_PARAMETERS_NO_CONTEXT_VARARGS(kFunction, kActualArgumentsCount, kSlot)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kFunction
MachineType::Int32(), // kActualArgumentsCount
MachineType::UintPtr()) // kSlot
......@@ -1921,7 +1927,7 @@ class UnaryOp_WithFeedbackDescriptor
class UnaryOp_BaselineDescriptor
: public StaticCallInterfaceDescriptor<UnaryOp_BaselineDescriptor> {
public:
DEFINE_PARAMETERS(kValue, kSlot)
DEFINE_PARAMETERS_NO_CONTEXT(kValue, kSlot)
DEFINE_PARAMETER_TYPES(MachineType::AnyTagged(), // kValue
MachineType::UintPtr()) // kSlot
DECLARE_DESCRIPTOR(UnaryOp_BaselineDescriptor)
......
......@@ -3669,8 +3669,7 @@ Node* EffectControlLinearizer::LowerToBoolean(Node* node) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), callable.descriptor(),
callable.descriptor().GetStackParameterCount(), flags, properties);
return __ Call(call_descriptor, __ HeapConstant(callable.code()), obj,
__ NoContextConstant());
return __ Call(call_descriptor, __ HeapConstant(callable.code()), obj);
}
Node* EffectControlLinearizer::LowerArgumentsLength(Node* node) {
......
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