Commit d7211216 authored by mvstanton's avatar mvstanton Committed by Commit bot

Quit creating array literal boilerplates from Crankshaft.

It's such a corner case.

BUG=

Review URL: https://codereview.chromium.org/1865013002

Cr-Commit-Position: refs/heads/master@{#35346}
parent ad1784e5
...@@ -6000,59 +6000,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -6000,59 +6000,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Handle<AllocationSite> site; Handle<AllocationSite> site;
Handle<LiteralsArray> literals(environment()->closure()->literals(), Handle<LiteralsArray> literals(environment()->closure()->literals(),
isolate()); isolate());
bool uninitialized = false;
Handle<Object> literals_cell(literals->literal(expr->literal_index()), Handle<Object> literals_cell(literals->literal(expr->literal_index()),
isolate()); isolate());
Handle<JSObject> boilerplate_object; Handle<JSObject> boilerplate_object;
if (literals_cell->IsUndefined()) { if (!literals_cell->IsUndefined()) {
uninitialized = true;
Handle<Object> raw_boilerplate;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate(), raw_boilerplate,
Runtime::CreateArrayLiteralBoilerplate(isolate(), literals,
expr->constant_elements()),
Bailout(kArrayBoilerplateCreationFailed));
boilerplate_object = Handle<JSObject>::cast(raw_boilerplate);
AllocationSiteCreationContext creation_context(isolate());
site = creation_context.EnterNewScope();
if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) {
return Bailout(kArrayBoilerplateCreationFailed);
}
creation_context.ExitScope(site, boilerplate_object);
literals->set_literal(expr->literal_index(), *site);
if (boilerplate_object->elements()->map() ==
isolate()->heap()->fixed_cow_array_map()) {
isolate()->counters()->cow_arrays_created_runtime()->Increment();
}
} else {
DCHECK(literals_cell->IsAllocationSite()); DCHECK(literals_cell->IsAllocationSite());
site = Handle<AllocationSite>::cast(literals_cell); site = Handle<AllocationSite>::cast(literals_cell);
boilerplate_object = Handle<JSObject>( boilerplate_object = Handle<JSObject>(
JSObject::cast(site->transition_info()), isolate()); JSObject::cast(site->transition_info()), isolate());
} }
DCHECK(!boilerplate_object.is_null()); ElementsKind boilerplate_elements_kind = expr->constant_elements_kind();
DCHECK(site->SitePointsToLiteral()); if (!boilerplate_object.is_null()) {
boilerplate_elements_kind = boilerplate_object->GetElementsKind();
ElementsKind boilerplate_elements_kind = }
boilerplate_object->GetElementsKind();
// Check whether to use fast or slow deep-copying for boilerplate. // Check whether to use fast or slow deep-copying for boilerplate.
int max_properties = kMaxFastLiteralProperties; int max_properties = kMaxFastLiteralProperties;
if (IsFastLiteral(boilerplate_object, if (!boilerplate_object.is_null() &&
kMaxFastLiteralDepth, IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth,
&max_properties)) { &max_properties)) {
DCHECK(site->SitePointsToLiteral());
AllocationSiteUsageContext site_context(isolate(), site, false); AllocationSiteUsageContext site_context(isolate(), site, false);
site_context.EnterNewScope(); site_context.EnterNewScope();
literal = BuildFastLiteral(boilerplate_object, &site_context); literal = BuildFastLiteral(boilerplate_object, &site_context);
site_context.ExitScope(site, boilerplate_object); site_context.ExitScope(site, boilerplate_object);
} else { } else {
NoObservableSideEffectsScope no_effects(this); NoObservableSideEffectsScope no_effects(this);
// Boilerplate already exists and constant elements are never accessed, Handle<FixedArray> constants = expr->constant_elements();
// pass an empty fixed array to the runtime function instead.
Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
int literal_index = expr->literal_index(); int literal_index = expr->literal_index();
int flags = expr->ComputeFlags(true); int flags = expr->ComputeFlags(true);
...@@ -6063,7 +6038,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -6063,7 +6038,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
// Register to deopt if the boilerplate ElementsKind changes. // Register to deopt if the boilerplate ElementsKind changes.
top_info()->dependencies()->AssumeTransitionStable(site); if (!site.is_null()) {
top_info()->dependencies()->AssumeTransitionStable(site);
}
} }
// The array is expected in the bailout environment during computation // The array is expected in the bailout environment during computation
...@@ -6095,9 +6072,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -6095,9 +6072,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
case FAST_HOLEY_ELEMENTS: case FAST_HOLEY_ELEMENTS:
case FAST_DOUBLE_ELEMENTS: case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS: { case FAST_HOLEY_DOUBLE_ELEMENTS: {
HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr, Add<HStoreKeyed>(elements, key, value, nullptr,
boilerplate_elements_kind); boilerplate_elements_kind);
instr->SetUninitialized(uninitialized);
break; break;
} }
default: default:
......
...@@ -109,7 +109,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( ...@@ -109,7 +109,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
return boilerplate; return boilerplate;
} }
MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
Isolate* isolate, Handle<LiteralsArray> literals, Isolate* isolate, Handle<LiteralsArray> literals,
Handle<FixedArray> elements) { Handle<FixedArray> elements) {
// Create the JSArray. // Create the JSArray.
...@@ -191,8 +191,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( ...@@ -191,8 +191,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS: case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
return CreateObjectLiteralBoilerplate(isolate, literals, elements, false); return CreateObjectLiteralBoilerplate(isolate, literals, elements, false);
case CompileTimeValue::ARRAY_LITERAL: case CompileTimeValue::ARRAY_LITERAL:
return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, return CreateArrayLiteralBoilerplate(isolate, literals, elements);
elements);
default: default:
UNREACHABLE(); UNREACHABLE();
return MaybeHandle<Object>(); return MaybeHandle<Object>();
...@@ -280,7 +279,7 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( ...@@ -280,7 +279,7 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
Handle<Object> boilerplate; Handle<Object> boilerplate;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, boilerplate, isolate, boilerplate,
Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements), CreateArrayLiteralBoilerplate(isolate, literals, elements),
AllocationSite); AllocationSite);
AllocationSiteCreationContext creation_context(isolate); AllocationSiteCreationContext creation_context(isolate);
......
...@@ -1125,11 +1125,6 @@ class Runtime : public AllStatic { ...@@ -1125,11 +1125,6 @@ class Runtime : public AllStatic {
ElementsKind* fixed_elements_kind, ElementsKind* fixed_elements_kind,
size_t* element_size); size_t* element_size);
// Used in runtime.cc and hydrogen's VisitArrayLiteral.
MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
Isolate* isolate, Handle<LiteralsArray> literals,
Handle<FixedArray> elements);
static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate, static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
Handle<Object>); Handle<Object>);
}; };
......
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