Skip to content

Commit dafdcb3

Browse files
committed
deps: back-port 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
1 parent 3b767b8 commit dafdcb3

File tree

4 files changed

+19
-50
lines changed

4 files changed

+19
-50
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 0
1313
#define V8_BUILD_NUMBER 71
14-
#define V8_PATCH_LEVEL 54
14+
#define V8_PATCH_LEVEL 55
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/crankshaft/hydrogen.cc

+14-39
Original file line numberDiff line numberDiff line change
@@ -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:

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
138138
}
139139

140140

141-
MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
141+
static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
142142
Isolate* isolate, Handle<LiteralsArray> literals,
143143
Handle<FixedArray> elements, bool is_strong) {
144144
// Create the JSArray.
@@ -225,8 +225,8 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
225225
return CreateObjectLiteralBoilerplate(isolate, literals, elements, false,
226226
kHasNoFunctionLiteral, is_strong);
227227
case CompileTimeValue::ARRAY_LITERAL:
228-
return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
229-
elements, is_strong);
228+
return CreateArrayLiteralBoilerplate(isolate, literals,
229+
elements, is_strong);
230230
default:
231231
UNREACHABLE();
232232
return MaybeHandle<Object>();
@@ -318,8 +318,7 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
318318
Handle<Object> boilerplate;
319319
ASSIGN_RETURN_ON_EXCEPTION(
320320
isolate, boilerplate,
321-
Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements,
322-
is_strong),
321+
CreateArrayLiteralBoilerplate(isolate, literals, elements, is_strong),
323322
AllocationSite);
324323

325324
AllocationSiteCreationContext creation_context(isolate);

deps/v8/src/runtime/runtime.h

-5
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,6 @@ class Runtime : public AllStatic {
11481148
ElementsKind* fixed_elements_kind,
11491149
size_t* element_size);
11501150

1151-
// Used in runtime.cc and hydrogen's VisitArrayLiteral.
1152-
MUST_USE_RESULT static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
1153-
Isolate* isolate, Handle<LiteralsArray> literals,
1154-
Handle<FixedArray> elements, bool is_strong);
1155-
11561151
static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
11571152
Handle<Object>);
11581153
};

0 commit comments

Comments
 (0)