Skip to content
This repository was archived by the owner on Oct 16, 2021. It is now read-only.

Commit b61bcf4

Browse files
bnoordhuisBethGriggs
authored andcommitted
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: nodejs/node#7454 PR-URL: nodejs/node#7633 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
1 parent ec98ebf commit b61bcf4

File tree

4 files changed

+19
-50
lines changed

4 files changed

+19
-50
lines changed

deps/v8z/include/v8-version.h

Lines changed: 1 addition & 1 deletion
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/v8z/src/crankshaft/hydrogen.cc

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6046,60 +6046,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
60466046
Handle<AllocationSite> site;
60476047
Handle<LiteralsArray> literals(environment()->closure()->literals(),
60486048
isolate());
6049-
bool uninitialized = false;
60506049
Handle<Object> literals_cell(literals->literal(expr->literal_index()),
60516050
isolate());
60526051
Handle<JSObject> boilerplate_object;
6053-
if (literals_cell->IsUndefined()) {
6054-
uninitialized = true;
6055-
Handle<Object> raw_boilerplate;
6056-
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6057-
isolate(), raw_boilerplate,
6058-
Runtime::CreateArrayLiteralBoilerplate(
6059-
isolate(), literals, expr->constant_elements(),
6060-
is_strong(function_language_mode())),
6061-
Bailout(kArrayBoilerplateCreationFailed));
6062-
6063-
boilerplate_object = Handle<JSObject>::cast(raw_boilerplate);
6064-
AllocationSiteCreationContext creation_context(isolate());
6065-
site = creation_context.EnterNewScope();
6066-
if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) {
6067-
return Bailout(kArrayBoilerplateCreationFailed);
6068-
}
6069-
creation_context.ExitScope(site, boilerplate_object);
6070-
literals->set_literal(expr->literal_index(), *site);
6071-
6072-
if (boilerplate_object->elements()->map() ==
6073-
isolate()->heap()->fixed_cow_array_map()) {
6074-
isolate()->counters()->cow_arrays_created_runtime()->Increment();
6075-
}
6076-
} else {
6052+
if (!literals_cell->IsUndefined()) {
60776053
DCHECK(literals_cell->IsAllocationSite());
60786054
site = Handle<AllocationSite>::cast(literals_cell);
60796055
boilerplate_object = Handle<JSObject>(
60806056
JSObject::cast(site->transition_info()), isolate());
60816057
}
60826058

6083-
DCHECK(!boilerplate_object.is_null());
6084-
DCHECK(site->SitePointsToLiteral());
6085-
6086-
ElementsKind boilerplate_elements_kind =
6087-
boilerplate_object->GetElementsKind();
6059+
ElementsKind boilerplate_elements_kind = expr->constant_elements_kind();
6060+
if (!boilerplate_object.is_null()) {
6061+
boilerplate_elements_kind = boilerplate_object->GetElementsKind();
6062+
}
60886063

60896064
// Check whether to use fast or slow deep-copying for boilerplate.
60906065
int max_properties = kMaxFastLiteralProperties;
6091-
if (IsFastLiteral(boilerplate_object,
6092-
kMaxFastLiteralDepth,
6066+
if (!boilerplate_object.is_null() &&
6067+
IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth,
60936068
&max_properties)) {
6069+
DCHECK(site->SitePointsToLiteral());
60946070
AllocationSiteUsageContext site_context(isolate(), site, false);
60956071
site_context.EnterNewScope();
60966072
literal = BuildFastLiteral(boilerplate_object, &site_context);
60976073
site_context.ExitScope(site, boilerplate_object);
60986074
} else {
60996075
NoObservableSideEffectsScope no_effects(this);
6100-
// Boilerplate already exists and constant elements are never accessed,
6101-
// pass an empty fixed array to the runtime function instead.
6102-
Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array();
6076+
Handle<FixedArray> constants = expr->constant_elements();
61036077
int literal_index = expr->literal_index();
61046078
int flags = expr->ComputeFlags(true);
61056079

@@ -6110,7 +6084,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
61106084
literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
61116085

61126086
// Register to deopt if the boilerplate ElementsKind changes.
6113-
top_info()->dependencies()->AssumeTransitionStable(site);
6087+
if (!site.is_null()) {
6088+
top_info()->dependencies()->AssumeTransitionStable(site);
6089+
}
61146090
}
61156091

61166092
// The array is expected in the bailout environment during computation
@@ -6142,9 +6118,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
61426118
case FAST_HOLEY_ELEMENTS:
61436119
case FAST_DOUBLE_ELEMENTS:
61446120
case FAST_HOLEY_DOUBLE_ELEMENTS: {
6145-
HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr,
6146-
boilerplate_elements_kind);
6147-
instr->SetUninitialized(uninitialized);
6121+
Add<HStoreKeyed>(elements, key, value, nullptr,
6122+
boilerplate_elements_kind);
61486123
break;
61496124
}
61506125
default:

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

Lines changed: 4 additions & 5 deletions
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/v8z/src/runtime/runtime.h

Lines changed: 0 additions & 5 deletions
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)