@@ -6044,60 +6044,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
60446044 Handle<AllocationSite> site;
60456045 Handle<LiteralsArray> literals (environment ()->closure ()->literals (),
60466046 isolate ());
6047- bool uninitialized = false ;
60486047 Handle<Object> literals_cell (literals->literal (expr->literal_index ()),
60496048 isolate ());
60506049 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 ()) {
60756051 DCHECK (literals_cell->IsAllocationSite ());
60766052 site = Handle<AllocationSite>::cast (literals_cell);
60776053 boilerplate_object = Handle<JSObject>(
60786054 JSObject::cast (site->transition_info ()), isolate ());
60796055 }
60806056
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+ }
60866061
60876062 // Check whether to use fast or slow deep-copying for boilerplate.
60886063 int max_properties = kMaxFastLiteralProperties ;
6089- if (IsFastLiteral ( boilerplate_object,
6090- kMaxFastLiteralDepth ,
6064+ if (! boilerplate_object. is_null () &&
6065+ IsFastLiteral (boilerplate_object, kMaxFastLiteralDepth ,
60916066 &max_properties)) {
6067+ DCHECK (site->SitePointsToLiteral ());
60926068 AllocationSiteUsageContext site_context (isolate (), site, false );
60936069 site_context.EnterNewScope ();
60946070 literal = BuildFastLiteral (boilerplate_object, &site_context);
60956071 site_context.ExitScope (site, boilerplate_object);
60966072 } else {
60976073 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 ();
61016075 int literal_index = expr->literal_index ();
61026076 int flags = expr->ComputeFlags (true );
61036077
@@ -6108,7 +6082,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
61086082 literal = Add<HCallRuntime>(Runtime::FunctionForId (function_id), 4 );
61096083
61106084 // 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+ }
61126088 }
61136089
61146090 // The array is expected in the bailout environment during computation
@@ -6140,9 +6116,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
61406116 case FAST_HOLEY_ELEMENTS:
61416117 case FAST_DOUBLE_ELEMENTS:
61426118 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);
61466121 break ;
61476122 }
61486123 default :
0 commit comments