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, ...@@ -1502,12 +1502,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
} }
{ // --- A r r a y --- { // --- A r r a y ---
Handle<JSFunction> array_function = Handle<JSFunction> array_function = InstallFunction(
InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
isolate->initial_object_prototype(), isolate->initial_object_prototype(), Builtins::kArrayConstructor);
Builtins::kArrayCode);
array_function->shared()->DontAdaptArguments(); 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 // This seems a bit hackish, but we need to make sure Array.length
// is 1. // is 1.
...@@ -4308,7 +4307,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, ...@@ -4308,7 +4307,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
factory()->NewJSObject(isolate()->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
Handle<JSFunction> array_function = Handle<JSFunction> array_function =
InstallFunction(target, name, JS_ARRAY_TYPE, JSArray::kSize, prototype, InstallFunction(target, name, JS_ARRAY_TYPE, JSArray::kSize, prototype,
Builtins::kInternalArrayCode); Builtins::kInternalArrayConstructor);
InternalArrayConstructorStub internal_array_constructor_stub(isolate()); InternalArrayConstructorStub internal_array_constructor_stub(isolate());
Handle<Code> code = internal_array_constructor_stub.GetCode(); Handle<Code> code = internal_array_constructor_stub.GetCode();
......
...@@ -66,7 +66,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { ...@@ -66,7 +66,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : number of arguments // -- r0 : number of arguments
// -- lr : return address // -- lr : return address
...@@ -93,7 +93,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -93,7 +93,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : number of arguments // -- r0 : number of arguments
// -- lr : return address // -- lr : return address
......
...@@ -66,13 +66,13 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address, ...@@ -66,13 +66,13 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- x0 : number of arguments // -- x0 : number of arguments
// -- lr : return address // -- lr : return address
// -- sp[...]: constructor arguments // -- sp[...]: constructor arguments
// ----------------------------------- // -----------------------------------
ASM_LOCATION("Builtins::Generate_InternalArrayCode"); ASM_LOCATION("Builtins::Generate_InternalArrayConstructor");
Label generic_array_code; Label generic_array_code;
// Get the InternalArray function. // Get the InternalArray function.
...@@ -93,13 +93,13 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -93,13 +93,13 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- x0 : number of arguments // -- x0 : number of arguments
// -- lr : return address // -- lr : return address
// -- sp[...]: constructor arguments // -- 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; Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
// Get the Array function. // Get the Array function.
......
...@@ -272,8 +272,8 @@ namespace internal { ...@@ -272,8 +272,8 @@ namespace internal {
TFJ(ReturnReceiver, 0) \ TFJ(ReturnReceiver, 0) \
\ \
/* Array */ \ /* Array */ \
ASM(ArrayCode) \ ASM(ArrayConstructor) \
ASM(InternalArrayCode) \ ASM(InternalArrayConstructor) \
CPP(ArrayConcat) \ CPP(ArrayConcat) \
/* ES6 #sec-array.isarray */ \ /* ES6 #sec-array.isarray */ \
TFJ(ArrayIsArray, 1, kArg) \ TFJ(ArrayIsArray, 1, kArg) \
......
...@@ -1826,7 +1826,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { ...@@ -1826,7 +1826,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : argc // -- eax : argc
// -- esp[0] : return address // -- esp[0] : return address
...@@ -1854,7 +1854,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -1854,7 +1854,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : argc // -- eax : argc
// -- esp[0] : return address // -- esp[0] : return address
......
...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { ...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
// -- ra : return address // -- ra : return address
...@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
// -- ra : return address // -- ra : return address
......
...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { ...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
// -- ra : return address // -- ra : return address
...@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -92,7 +92,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments // -- a0 : number of arguments
// -- ra : return address // -- ra : return address
......
...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { ...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r3 : number of arguments // -- r3 : number of arguments
// -- lr : return address // -- lr : return address
...@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r3 : number of arguments // -- r3 : number of arguments
// -- lr : return address // -- lr : return address
......
...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { ...@@ -63,7 +63,7 @@ static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r2 : number of arguments // -- r2 : number of arguments
// -- lr : return address // -- lr : return address
...@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -90,7 +90,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r2 : number of arguments // -- r2 : number of arguments
// -- lr : return address // -- lr : return address
......
...@@ -1809,7 +1809,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { ...@@ -1809,7 +1809,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
} }
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { void Builtins::Generate_InternalArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rax : argc // -- rax : argc
// -- rsp[0] : return address // -- rsp[0] : return address
...@@ -1838,7 +1838,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { ...@@ -1838,7 +1838,7 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
__ TailCallStub(&stub); __ TailCallStub(&stub);
} }
void Builtins::Generate_ArrayCode(MacroAssembler* masm) { void Builtins::Generate_ArrayConstructor(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rax : argc // -- rax : argc
// -- rsp[0] : return address // -- rsp[0] : return address
......
...@@ -64,24 +64,12 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) { ...@@ -64,24 +64,12 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
Node* target = NodeProperties::GetValueInput(node, 0); Node* target = NodeProperties::GetValueInput(node, 0);
CallParameters const& p = CallParametersOf(node->op()); 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. // Turn the {node} into a {JSCreateArray} call.
DCHECK_LE(2u, p.arity()); DCHECK_LE(2u, p.arity());
Handle<AllocationSite> site;
size_t const arity = p.arity() - 2; size_t const arity = p.arity() - 2;
NodeProperties::ReplaceValueInput(node, target, 0); NodeProperties::ReplaceValueInput(node, target, 0);
NodeProperties::ReplaceValueInput(node, target, 1); 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)); NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
return Changed(node); return Changed(node);
} }
...@@ -1235,6 +1223,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) { ...@@ -1235,6 +1223,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
// Check for known builtin functions. // Check for known builtin functions.
switch (shared->code()->builtin_index()) { switch (shared->code()->builtin_index()) {
case Builtins::kArrayConstructor:
return ReduceArrayConstructor(node);
case Builtins::kBooleanConstructor: case Builtins::kBooleanConstructor:
return ReduceBooleanConstructor(node); return ReduceBooleanConstructor(node);
case Builtins::kFunctionPrototypeApply: case Builtins::kFunctionPrototypeApply:
...@@ -1267,11 +1257,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) { ...@@ -1267,11 +1257,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
break; break;
} }
// Check for the Array constructor.
if (*function == function->native_context()->array_function()) {
return ReduceArrayConstructor(node);
}
if (!FLAG_runtime_stats && shared->IsApiFunction()) { if (!FLAG_runtime_stats && shared->IsApiFunction()) {
Handle<FunctionTemplateInfo> function_template_info( Handle<FunctionTemplateInfo> function_template_info(
FunctionTemplateInfo::cast(shared->function_data()), isolate()); FunctionTemplateInfo::cast(shared->function_data()), isolate());
...@@ -1330,21 +1315,7 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) { ...@@ -1330,21 +1315,7 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
} }
Handle<Object> feedback(nexus.GetFeedback(), isolate()); Handle<Object> feedback(nexus.GetFeedback(), isolate());
if (feedback->IsAllocationSite()) { if (feedback->IsWeakCell()) {
// 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()) {
// Check if we want to use CallIC feedback here. // Check if we want to use CallIC feedback here.
if (!ShouldUseCallICFeedback(target)) return NoChange(); if (!ShouldUseCallICFeedback(target)) return NoChange();
......
...@@ -480,7 +480,7 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) { ...@@ -480,7 +480,7 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kObjectPrototypePropertyIsEnumerable: case Builtins::kObjectPrototypePropertyIsEnumerable:
case Builtins::kObjectPrototypeToString: case Builtins::kObjectPrototypeToString:
// Array builtins. // Array builtins.
case Builtins::kArrayCode: case Builtins::kArrayConstructor:
case Builtins::kArrayIndexOf: case Builtins::kArrayIndexOf:
case Builtins::kArrayPrototypeValues: case Builtins::kArrayPrototypeValues:
case Builtins::kArrayIncludes: case Builtins::kArrayIncludes:
......
...@@ -4755,7 +4755,7 @@ class ContextExtension : public Struct { ...@@ -4755,7 +4755,7 @@ class ContextExtension : public Struct {
enum BuiltinFunctionId { enum BuiltinFunctionId {
kInvalidBuiltinFunctionId = -1, kInvalidBuiltinFunctionId = -1,
kArrayCode, kArrayConstructor,
#define DECL_FUNCTION_ID(ignored1, ignore2, name) k##name, #define DECL_FUNCTION_ID(ignored1, ignore2, name) k##name,
FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID) FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
ATOMIC_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