Commit a715de90 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[sparkplug] Share construct builtin generator between _WithFB and _Baseline

Bug: v8:11429
Change-Id: I9472898ccc07e400fb4c61d80e208bae23223a74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2704665Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72859}
parent 70e6298e
......@@ -40,6 +40,17 @@ class CallOrConstructBuiltinsAssembler : public CodeStubAssembler {
TNode<FunctionTemplateInfo> function_template_info,
TNode<IntPtrT> argc, TNode<Context> context);
void BuildConstruct(TNode<Object> target, TNode<Object> new_target,
TNode<Int32T> argc, const LazyNode<Context>& context,
const LazyNode<HeapObject>& feedback_vector,
TNode<UintPtrT> slot, UpdateFeedbackMode mode);
void BuildConstructWithSpread(TNode<Object> target, TNode<Object> new_target,
TNode<Object> spread, TNode<Int32T> argc,
const LazyNode<Context>& context,
const LazyNode<HeapObject>& feedback_vector,
TNode<UintPtrT> slot, UpdateFeedbackMode mode);
private:
TNode<JSReceiver> GetCompatibleReceiver(TNode<JSReceiver> receiver,
TNode<HeapObject> signature,
......
......@@ -37,31 +37,16 @@ void Builtins::Generate_ConstructFunctionForwardVarargs(MacroAssembler* masm) {
BUILTIN_CODE(masm->isolate(), ConstructFunction));
}
// TODO(v8:11429): Here and below, consider sharing code with Foo_WithFeedback,
// or removing the latter entirely.
TF_BUILTIN(Construct_Baseline, CallOrConstructBuiltinsAssembler) {
auto target = Parameter<Object>(Descriptor::kTarget);
auto new_target = Parameter<Object>(Descriptor::kNewTarget);
auto argc = UncheckedParameter<Int32T>(Descriptor::kActualArgumentsCount);
auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
// TODO(verwaest): Only emit context loads where necessary
auto context = LoadContextFromBaseline();
auto feedback_vector = LoadFeedbackVectorFromBaseline();
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kGuaranteedFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
BIND(&if_construct_generic);
TailCallBuiltin(Builtins::kConstruct, context, target, new_target, argc);
BIND(&if_construct_array);
TailCallBuiltin(Builtins::kArrayConstructorImpl, context, target, new_target,
argc, allocation_site.value());
BuildConstruct(
target, new_target, argc, [=] { return LoadContextFromBaseline(); },
[=] { return LoadFeedbackVectorFromBaseline(); }, slot,
UpdateFeedbackMode::kGuaranteedFeedback);
}
TF_BUILTIN(Construct_WithFeedback, CallOrConstructBuiltinsAssembler) {
......@@ -72,19 +57,31 @@ TF_BUILTIN(Construct_WithFeedback, CallOrConstructBuiltinsAssembler) {
auto feedback_vector = Parameter<FeedbackVector>(Descriptor::kFeedbackVector);
auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
BuildConstruct(
target, new_target, argc, [=] { return context; },
[=] { return feedback_vector; }, slot,
UpdateFeedbackMode::kOptionalFeedback);
}
void CallOrConstructBuiltinsAssembler::BuildConstruct(
TNode<Object> target, TNode<Object> new_target, TNode<Int32T> argc,
const LazyNode<Context>& context,
const LazyNode<HeapObject>& feedback_vector, TNode<UintPtrT> slot,
UpdateFeedbackMode mode) {
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kOptionalFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
TNode<Context> eager_context = context();
CollectConstructFeedback(eager_context, target, new_target, feedback_vector(),
slot, mode, &if_construct_generic,
&if_construct_array, &allocation_site);
BIND(&if_construct_generic);
TailCallBuiltin(Builtins::kConstruct, context, target, new_target, argc);
TailCallBuiltin(Builtins::kConstruct, eager_context, target, new_target,
argc);
BIND(&if_construct_array);
TailCallBuiltin(Builtins::kArrayConstructorImpl, context, target, new_target,
argc, allocation_site.value());
TailCallBuiltin(Builtins::kArrayConstructorImpl, eager_context, target,
new_target, argc, allocation_site.value());
}
TF_BUILTIN(ConstructWithArrayLike, CallOrConstructBuiltinsAssembler) {
......@@ -135,23 +132,11 @@ TF_BUILTIN(ConstructWithSpread_Baseline, CallOrConstructBuiltinsAssembler) {
auto args_count =
UncheckedParameter<Int32T>(Descriptor::kActualArgumentsCount);
auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
// TODO(verwaest): Only emit context loads where necessary
auto context = LoadContextFromBaseline();
auto feedback_vector = LoadFeedbackVectorFromBaseline();
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kGuaranteedFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
BIND(&if_construct_array);
Goto(&if_construct_generic); // Not implemented.
BIND(&if_construct_generic);
CallOrConstructWithSpread(target, new_target, spread, args_count, context);
return BuildConstructWithSpread(
target, new_target, spread, args_count,
[=] { return LoadContextFromBaseline(); },
[=] { return LoadFeedbackVectorFromBaseline(); }, slot,
UpdateFeedbackMode::kGuaranteedFeedback);
}
TF_BUILTIN(ConstructWithSpread_WithFeedback, CallOrConstructBuiltinsAssembler) {
......@@ -164,10 +149,22 @@ TF_BUILTIN(ConstructWithSpread_WithFeedback, CallOrConstructBuiltinsAssembler) {
auto feedback_vector = Parameter<HeapObject>(Descriptor::kFeedbackVector);
auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
return BuildConstructWithSpread(
target, new_target, spread, args_count, [=] { return context; },
[=] { return feedback_vector; }, slot,
UpdateFeedbackMode::kGuaranteedFeedback);
}
void CallOrConstructBuiltinsAssembler::BuildConstructWithSpread(
TNode<Object> target, TNode<Object> new_target, TNode<Object> spread,
TNode<Int32T> argc, const LazyNode<Context>& context,
const LazyNode<HeapObject>& feedback_vector, TNode<UintPtrT> slot,
UpdateFeedbackMode mode) {
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kOptionalFeedback,
TNode<Context> eager_context = context();
CollectConstructFeedback(eager_context, target, new_target, feedback_vector(),
slot, UpdateFeedbackMode::kGuaranteedFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
......@@ -175,7 +172,7 @@ TF_BUILTIN(ConstructWithSpread_WithFeedback, CallOrConstructBuiltinsAssembler) {
Goto(&if_construct_generic); // Not implemented.
BIND(&if_construct_generic);
CallOrConstructWithSpread(target, new_target, spread, args_count, context);
CallOrConstructWithSpread(target, new_target, spread, argc, eager_context);
}
using Node = compiler::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