Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc442e0

Browse filesBrowse files
bnoordhuisofrobots
authored andcommitted
deps: cherry-pick d721121 from v8 upstream
Original commit message: Quit creating array literal boilerplates from Crankshaft. It's such a corner case. BUG= Review URL: https://codereview.chromium.org/1865013002 Cr-Commit-Position: refs/heads/master@{#35346} Fixes: #7454 PR-URL: #7632 Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
1 parent 9a4b338 commit fc442e0
Copy full SHA for fc442e0

File tree

Expand file treeCollapse file tree

3 files changed

+17
-47
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-47
lines changed
Open diff view settings
Collapse file

‎deps/v8/src/crankshaft/hydrogen.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/crankshaft/hydrogen.cc
+14-38Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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:
Collapse file

‎deps/v8/src/runtime/runtime-literals.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/runtime/runtime-literals.cc
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
109109
return boilerplate;
110110
}
111111

112-
MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
112+
static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
113113
Isolate* isolate, Handle<LiteralsArray> literals,
114114
Handle<FixedArray> elements) {
115115
// Create the JSArray.
@@ -191,8 +191,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
191191
case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
192192
return CreateObjectLiteralBoilerplate(isolate, literals, elements, false);
193193
case CompileTimeValue::ARRAY_LITERAL:
194-
return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
195-
elements);
194+
return CreateArrayLiteralBoilerplate(isolate, literals, elements);
196195
default:
197196
UNREACHABLE();
198197
return MaybeHandle<Object>();
@@ -280,7 +279,7 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
280279
Handle<Object> boilerplate;
281280
ASSIGN_RETURN_ON_EXCEPTION(
282281
isolate, boilerplate,
283-
Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements),
282+
CreateArrayLiteralBoilerplate(isolate, literals, elements),
284283
AllocationSite);
285284

286285
AllocationSiteCreationContext creation_context(isolate);
Collapse file

‎deps/v8/src/runtime/runtime.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/runtime/runtime.h
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,6 @@ class Runtime : public AllStatic {
11301130
ElementsKind* fixed_elements_kind,
11311131
size_t* element_size);
11321132

1133-
// Used in runtime.cc and hydrogen's VisitArrayLiteral.
1134-
MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
1135-
Isolate* isolate, Handle<LiteralsArray> literals,
1136-
Handle<FixedArray> elements);
1137-
11381133
static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
11391134
Handle<Object>);
11401135
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.