Commit b1b595b0 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Remove obsolete JSCall support for AllocationSites.

As of https://chromium-review.googlesource.com/600968 the CallIC no
longer supports AllocationSite feedback for [[Call]], so we can drop
the TurboFan bits that deal with AllocationSites for JSCall nodes as
well. This further simplifies the handling of the Array constructor.

Drive-by-fix: Rename Builtins::kArrayCode to Builtins::kArrayConstructor
for sake of consistency.

Bug: v8:6399
Change-Id: I9e6a684fc00dd72e25f925db5f407c3f3f715873
Reviewed-on: https://chromium-review.googlesource.com/602354
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47194}
parent 018128a4
......@@ -1502,12 +1502,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
}
{ // --- A r r a y ---
Handle<JSFunction> array_function =
InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
isolate->initial_object_prototype(),
Builtins::kArrayCode);
Handle<JSFunction> array_function = InstallFunction(
global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
isolate->initial_object_prototype(), Builtins::kArrayConstructor);
array_function->shared()->DontAdaptArguments();
array_function->shared()->set_builtin_function_id(kArrayCode);
array_function->shared()->set_builtin_function_id(kArrayConstructor);
// This seems a bit hackish, but we need to make sure Array.length
// is 1.
......@@ -4308,7 +4307,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
factory()->NewJSObject(isolate()->object_function(), TENURED);
Handle<JSFunction> array_function =
InstallFunction(target, name, JS_ARRAY_TYPE, JSArray::kSize, prototype,
Builtins::kInternalArrayCode);
Builtins::kInternalArrayConstructor);
InternalArrayConstructorStub internal_array_constructor_stub(isolate());
Handle<Code> code = internal_array_constructor_stub.GetCode();
......
......@@ -66,7 +66,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r0 : number of arguments
// -- lr : return address
......@@ -93,7 +93,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r0 : number of arguments
// -- lr : return address
......
......@@ -66,13 +66,13 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
exit_frame_type == BUILTIN_EXIT);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- x0 : number of arguments
// -- lr : return address
// -- sp[...]: constructor arguments
// -----------------------------------
ASM_LOCATION("Builtins::Generate_InternalArrayCode");
ASM_LOCATION("Builtins::Generate_InternalArrayConstructor");
Label generic_array_code;
// Get the InternalArray function.
......@@ -93,13 +93,13 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- x0 : number of arguments
// -- lr : return address
// -- sp[...]: constructor arguments
// -----------------------------------
ASM_LOCATION("Builtins::Generate_ArrayCode");
ASM_LOCATION("Builtins::Generate_ArrayConstructor");
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
// Get the Array function.
......
......@@ -272,8 +272,8 @@ namespace internal {
TFJ(ReturnReceiver, 0) \
\
/* Array */ \
ASM(ArrayCode) \
ASM(InternalArrayCode) \
ASM(ArrayConstructor) \
ASM(InternalArrayConstructor) \
CPP(ArrayConcat) \
/* ES6 #sec-array.isarray */ \
TFJ(ArrayIsArray, 1, kArg) \
......
......@@ -1826,7 +1826,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- eax : argc
// -- esp[0] : return address
......@@ -1854,7 +1854,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- eax : argc
// -- esp[0] : return address
......
......@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- ra : return address
......@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- ra : return address
......
......@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- ra : return address
......@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
// -- ra : return address
......
......@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : number of arguments
// -- lr : return address
......@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : number of arguments
// -- lr : return address
......
......@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : number of arguments
// -- lr : return address
......@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : number of arguments
// -- lr : return address
......
......@@ -1809,7 +1809,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET);
}
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- rax : argc
// -- rsp[0] : return address
......@@ -1838,7 +1838,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub);
}
void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- rax : argc
// -- rsp[0] : return address
......
......@@ -64,24 +64,12 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
Node* target = NodeProperties::GetValueInput(node, 0);
CallParameters const& p = CallParametersOf(node->op());
// Check if we have an allocation site from the CallIC.
Handle<AllocationSite> site;
if (p.feedback().IsValid()) {
CallICNexus nexus(p.feedback().vector(), p.feedback().slot());
Handle<Object> feedback(nexus.GetFeedback(), isolate());
if (feedback->IsAllocationSite()) {
site = Handle<AllocationSite>::cast(feedback);
}
}
// Turn the {node} into a {JSCreateArray} call.
DCHECK_LE(2u, p.arity());
Handle<AllocationSite> site;
size_t const arity = p.arity() - 2;
NodeProperties::ReplaceValueInput(node, target, 0);
NodeProperties::ReplaceValueInput(node, target, 1);
// TODO(bmeurer): We might need to propagate the tail call mode to
// the JSCreateArray operator, because an Array call in tail call
// position must always properly consume the parent stack frame.
NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
return Changed(node);
}
......@@ -1235,6 +1223,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
// Check for known builtin functions.
switch (shared->code()->builtin_index()) {
case Builtins::kArrayConstructor:
return ReduceArrayConstructor(node);
case Builtins::kBooleanConstructor:
return ReduceBooleanConstructor(node);
case Builtins::kFunctionPrototypeApply:
......@@ -1267,11 +1257,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
break;
}
// Check for the Array constructor.
if (*function == function->native_context()->array_function()) {
return ReduceArrayConstructor(node);
}
if (!FLAG_runtime_stats && shared->IsApiFunction()) {
Handle<FunctionTemplateInfo> function_template_info(
FunctionTemplateInfo::cast(shared->function_data()), isolate());
......@@ -1330,21 +1315,7 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
}
Handle<Object> feedback(nexus.GetFeedback(), isolate());
if (feedback->IsAllocationSite()) {
// Retrieve the Array function from the {node}.
Node* array_function = jsgraph()->HeapConstant(
handle(native_context()->array_function(), isolate()));
// Check that the {target} is still the {array_function}.
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target,
array_function);
effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control);
// Turn the {node} into a {JSCreateArray} call.
NodeProperties::ReplaceValueInput(node, array_function, 0);
NodeProperties::ReplaceEffectInput(node, effect);
return ReduceArrayConstructor(node);
} else if (feedback->IsWeakCell()) {
if (feedback->IsWeakCell()) {
// Check if we want to use CallIC feedback here.
if (!ShouldUseCallICFeedback(target)) return NoChange();
......
......@@ -480,7 +480,7 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kObjectPrototypePropertyIsEnumerable:
case Builtins::kObjectPrototypeToString:
// Array builtins.
case Builtins::kArrayCode:
case Builtins::kArrayConstructor:
case Builtins::kArrayIndexOf:
case Builtins::kArrayPrototypeValues:
case Builtins::kArrayIncludes:
......
......@@ -4755,7 +4755,7 @@ class ContextExtension : public Struct {
enum BuiltinFunctionId {
kInvalidBuiltinFunctionId = -1,
kArrayCode,
kArrayConstructor,
#define DECL_FUNCTION_ID(ignored1, ignore2, name) k##name,
FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
ATOMIC_FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
......
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