@@ -6044,60 +6044,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
6044
6044
Handle <AllocationSite> site;
6045
6045
Handle <LiteralsArray> literals (environment ()->closure ()->literals (),
6046
6046
isolate ());
6047
- bool uninitialized = false;
6048
6047
Handle <Object> literals_cell (literals->literal (expr->literal_index ()),
6049
6048
isolate ());
6050
6049
Handle <JSObject> boilerplate_object;
6051
- if (literals_cell->IsUndefined()) {
6052
- uninitialized = true;
6053
- Handle<Object> raw_boilerplate;
6054
- ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6055
- isolate(), raw_boilerplate,
6056
- Runtime::CreateArrayLiteralBoilerplate(
6057
- isolate(), literals, expr->constant_elements(),
6058
- is_strong(function_language_mode())),
6059
- Bailout(kArrayBoilerplateCreationFailed));
6060
-
6061
- boilerplate_object = Handle<JSObject>::cast(raw_boilerplate);
6062
- AllocationSiteCreationContext creation_context(isolate());
6063
- site = creation_context.EnterNewScope();
6064
- if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) {
6065
- return Bailout(kArrayBoilerplateCreationFailed);
6066
- }
6067
- creation_context.ExitScope(site, boilerplate_object);
6068
- literals->set_literal(expr->literal_index(), *site);
6069
-
6070
- if (boilerplate_object->elements()->map() ==
6071
- isolate()->heap()->fixed_cow_array_map()) {
6072
- isolate()->counters()->cow_arrays_created_runtime()->Increment();
6073
- }
6074
- } else {
6050
+ if (!literals_cell->IsUndefined ()) {
6075
6051
DCHECK (literals_cell->IsAllocationSite ());
6076
6052
site = Handle <AllocationSite>::cast (literals_cell);
6077
6053
boilerplate_object = Handle <JSObject>(
6078
6054
JSObject::cast (site->transition_info ()), isolate ());
6079
6055
}
6080
6056
6081
- DCHECK(!boilerplate_object.is_null());
6082
- DCHECK(site->SitePointsToLiteral());
6083
-
6084
- ElementsKind boilerplate_elements_kind =
6085
- boilerplate_object->GetElementsKind();
6057
+ ElementsKind boilerplate_elements_kind = expr->constant_elements_kind ();
6058
+ if (!boilerplate_object.is_null ()) {
6059
+ boilerplate_elements_kind = boilerplate_object->GetElementsKind ();
6060
+ }
6086
6061
6087
6062
// Check whether to use fast or slow deep-copying for boilerplate.
6088
6063
int max_properties = kMaxFastLiteralProperties ;
6089
- if (IsFastLiteral( boilerplate_object,
6090
- kMaxFastLiteralDepth,
6064
+ if (! boilerplate_object. is_null () &&
6065
+ IsFastLiteral (boilerplate_object, kMaxFastLiteralDepth ,
6091
6066
&max_properties)) {
6067
+ DCHECK (site->SitePointsToLiteral ());
6092
6068
AllocationSiteUsageContext site_context (isolate (), site, false );
6093
6069
site_context.EnterNewScope ();
6094
6070
literal = BuildFastLiteral (boilerplate_object, &site_context);
6095
6071
site_context.ExitScope (site, boilerplate_object);
6096
6072
} else {
6097
6073
NoObservableSideEffectsScope no_effects (this );
6098
- // Boilerplate already exists and constant elements are never accessed,
6099
- // pass an empty fixed array to the runtime function instead.
6100
- Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
6074
+ Handle <FixedArray> constants = expr->constant_elements ();
6101
6075
int literal_index = expr->literal_index ();
6102
6076
int flags = expr->ComputeFlags (true );
6103
6077
@@ -6108,7 +6082,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
6108
6082
literal = Add<HCallRuntime>(Runtime::FunctionForId (function_id), 4 );
6109
6083
6110
6084
// Register to deopt if the boilerplate ElementsKind changes.
6111
- top_info()->dependencies()->AssumeTransitionStable(site);
6085
+ if (!site.is_null ()) {
6086
+ top_info ()->dependencies ()->AssumeTransitionStable (site);
6087
+ }
6112
6088
}
6113
6089
6114
6090
// The array is expected in the bailout environment during computation
@@ -6140,9 +6116,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
6140
6116
case FAST_HOLEY_ELEMENTS:
6141
6117
case FAST_DOUBLE_ELEMENTS:
6142
6118
case FAST_HOLEY_DOUBLE_ELEMENTS: {
6143
- HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr,
6144
- boilerplate_elements_kind);
6145
- instr->SetUninitialized(uninitialized);
6119
+ Add<HStoreKeyed>(elements, key, value, nullptr ,
6120
+ boilerplate_elements_kind);
6146
6121
break ;
6147
6122
}
6148
6123
default :
0 commit comments