Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1865013002: Quit creating array literal boilerplates from Crankshaft. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | src/runtime/runtime.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 38a9fd0ad88425776d69b9485ac0ea852c81d91d..40a364c6c9aae0a86ac6dd8da6e28f9358ea1cd1 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -5990,59 +5990,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Handle<AllocationSite> site;
Handle<LiteralsArray> literals(environment()->closure()->literals(),
isolate());
- bool uninitialized = false;
Handle<Object> literals_cell(literals->literal(expr->literal_index()),
isolate());
Handle<JSObject> boilerplate_object;
- 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 {
+ if (!literals_cell->IsUndefined()) {
DCHECK(literals_cell->IsAllocationSite());
site = Handle<AllocationSite>::cast(literals_cell);
boilerplate_object = Handle<JSObject>(
JSObject::cast(site->transition_info()), isolate());
}
- DCHECK(!boilerplate_object.is_null());
- DCHECK(site->SitePointsToLiteral());
-
- ElementsKind boilerplate_elements_kind =
- boilerplate_object->GetElementsKind();
+ ElementsKind boilerplate_elements_kind = expr->constant_elements_kind();
+ if (!boilerplate_object.is_null()) {
+ boilerplate_elements_kind = boilerplate_object->GetElementsKind();
+ }
// Check whether to use fast or slow deep-copying for boilerplate.
int max_properties = kMaxFastLiteralProperties;
- if (IsFastLiteral(boilerplate_object,
- kMaxFastLiteralDepth,
+ if (!boilerplate_object.is_null() &&
+ IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth,
&max_properties)) {
+ DCHECK(site->SitePointsToLiteral());
AllocationSiteUsageContext site_context(isolate(), site, false);
site_context.EnterNewScope();
literal = BuildFastLiteral(boilerplate_object, &site_context);
site_context.ExitScope(site, boilerplate_object);
} else {
NoObservableSideEffectsScope no_effects(this);
- // Boilerplate already exists and constant elements are never accessed,
- // pass an empty fixed array to the runtime function instead.
- Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
+ Handle<FixedArray> constants = expr->constant_elements();
int literal_index = expr->literal_index();
int flags = expr->ComputeFlags(true);
@@ -6053,7 +6028,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
// 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
@@ -6085,9 +6062,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
case FAST_HOLEY_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS: {
- HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr,
- boilerplate_elements_kind);
- instr->SetUninitialized(uninitialized);
+ Add<HStoreKeyed>(elements, key, value, nullptr,
+ boilerplate_elements_kind);
break;
}
default:
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | src/runtime/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698