@@ -5995,59 +5995,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
5995
5995
Handle<AllocationSite> site;
5996
5996
Handle<LiteralsArray> literals (environment ()->closure ()->literals (),
5997
5997
isolate ());
5998
- bool uninitialized = false ;
5999
5998
Handle<Object> literals_cell (literals->literal (expr->literal_index ()),
6000
5999
isolate ());
6001
6000
Handle<JSObject> boilerplate_object;
6002
- if (literals_cell->IsUndefined ()) {
6003
- uninitialized = true ;
6004
- Handle<Object> raw_boilerplate;
6005
- ASSIGN_RETURN_ON_EXCEPTION_VALUE (
6006
- isolate (), raw_boilerplate,
6007
- Runtime::CreateArrayLiteralBoilerplate (isolate (), literals,
6008
- expr->constant_elements ()),
6009
- Bailout (kArrayBoilerplateCreationFailed ));
6010
-
6011
- boilerplate_object = Handle<JSObject>::cast (raw_boilerplate);
6012
- AllocationSiteCreationContext creation_context (isolate ());
6013
- site = creation_context.EnterNewScope ();
6014
- if (JSObject::DeepWalk (boilerplate_object, &creation_context).is_null ()) {
6015
- return Bailout (kArrayBoilerplateCreationFailed );
6016
- }
6017
- creation_context.ExitScope (site, boilerplate_object);
6018
- literals->set_literal (expr->literal_index (), *site);
6019
-
6020
- if (boilerplate_object->elements ()->map () ==
6021
- isolate ()->heap ()->fixed_cow_array_map ()) {
6022
- isolate ()->counters ()->cow_arrays_created_runtime ()->Increment ();
6023
- }
6024
- } else {
6001
+ if (!literals_cell->IsUndefined ()) {
6025
6002
DCHECK (literals_cell->IsAllocationSite ());
6026
6003
site = Handle<AllocationSite>::cast (literals_cell);
6027
6004
boilerplate_object = Handle<JSObject>(
6028
6005
JSObject::cast (site->transition_info ()), isolate ());
6029
6006
}
6030
6007
6031
- DCHECK (!boilerplate_object.is_null ());
6032
- DCHECK (site->SitePointsToLiteral ());
6033
-
6034
- ElementsKind boilerplate_elements_kind =
6035
- boilerplate_object->GetElementsKind ();
6008
+ ElementsKind boilerplate_elements_kind = expr->constant_elements_kind ();
6009
+ if (!boilerplate_object.is_null ()) {
6010
+ boilerplate_elements_kind = boilerplate_object->GetElementsKind ();
6011
+ }
6036
6012
6037
6013
// Check whether to use fast or slow deep-copying for boilerplate.
6038
6014
int max_properties = kMaxFastLiteralProperties ;
6039
- if (IsFastLiteral ( boilerplate_object,
6040
- kMaxFastLiteralDepth ,
6015
+ if (! boilerplate_object. is_null () &&
6016
+ IsFastLiteral (boilerplate_object, kMaxFastLiteralDepth ,
6041
6017
&max_properties)) {
6018
+ DCHECK (site->SitePointsToLiteral ());
6042
6019
AllocationSiteUsageContext site_context (isolate (), site, false );
6043
6020
site_context.EnterNewScope ();
6044
6021
literal = BuildFastLiteral (boilerplate_object, &site_context);
6045
6022
site_context.ExitScope (site, boilerplate_object);
6046
6023
} else {
6047
6024
NoObservableSideEffectsScope no_effects (this );
6048
- // Boilerplate already exists and constant elements are never accessed,
6049
- // pass an empty fixed array to the runtime function instead.
6050
- Handle<FixedArray> constants = isolate ()->factory ()->empty_fixed_array ();
6025
+ Handle<FixedArray> constants = expr->constant_elements ();
6051
6026
int literal_index = expr->literal_index ();
6052
6027
int flags = expr->ComputeFlags (true );
6053
6028
@@ -6058,7 +6033,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
6058
6033
literal = Add<HCallRuntime>(Runtime::FunctionForId (function_id), 4 );
6059
6034
6060
6035
// Register to deopt if the boilerplate ElementsKind changes.
6061
- top_info ()->dependencies ()->AssumeTransitionStable (site);
6036
+ if (!site.is_null ()) {
6037
+ top_info ()->dependencies ()->AssumeTransitionStable (site);
6038
+ }
6062
6039
}
6063
6040
6064
6041
// The array is expected in the bailout environment during computation
@@ -6090,9 +6067,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
6090
6067
case FAST_HOLEY_ELEMENTS:
6091
6068
case FAST_DOUBLE_ELEMENTS:
6092
6069
case FAST_HOLEY_DOUBLE_ELEMENTS: {
6093
- HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr ,
6094
- boilerplate_elements_kind);
6095
- instr->SetUninitialized (uninitialized);
6070
+ Add<HStoreKeyed>(elements, key, value, nullptr ,
6071
+ boilerplate_elements_kind);
6096
6072
break ;
6097
6073
}
6098
6074
default :
0 commit comments