@@ -5995,59 +5995,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
59955995 Handle<AllocationSite> site;
59965996 Handle<LiteralsArray> literals (environment ()->closure ()->literals (),
59975997 isolate ());
5998- bool uninitialized = false ;
59995998 Handle<Object> literals_cell (literals->literal (expr->literal_index ()),
60005999 isolate ());
60016000 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 ()) {
60256002 DCHECK (literals_cell->IsAllocationSite ());
60266003 site = Handle<AllocationSite>::cast (literals_cell);
60276004 boilerplate_object = Handle<JSObject>(
60286005 JSObject::cast (site->transition_info ()), isolate ());
60296006 }
60306007
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+ }
60366012
60376013 // Check whether to use fast or slow deep-copying for boilerplate.
60386014 int max_properties = kMaxFastLiteralProperties ;
6039- if (IsFastLiteral ( boilerplate_object,
6040- kMaxFastLiteralDepth ,
6015+ if (! boilerplate_object. is_null () &&
6016+ IsFastLiteral (boilerplate_object, kMaxFastLiteralDepth ,
60416017 &max_properties)) {
6018+ DCHECK (site->SitePointsToLiteral ());
60426019 AllocationSiteUsageContext site_context (isolate (), site, false );
60436020 site_context.EnterNewScope ();
60446021 literal = BuildFastLiteral (boilerplate_object, &site_context);
60456022 site_context.ExitScope (site, boilerplate_object);
60466023 } else {
60476024 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 ();
60516026 int literal_index = expr->literal_index ();
60526027 int flags = expr->ComputeFlags (true );
60536028
@@ -6058,7 +6033,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
60586033 literal = Add<HCallRuntime>(Runtime::FunctionForId (function_id), 4 );
60596034
60606035 // 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+ }
60626039 }
60636040
60646041 // The array is expected in the bailout environment during computation
@@ -6090,9 +6067,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
60906067 case FAST_HOLEY_ELEMENTS:
60916068 case FAST_DOUBLE_ELEMENTS:
60926069 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);
60966072 break ;
60976073 }
60986074 default :
0 commit comments