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