From c10ade917a0891eaad206c21c6d31eed322d573e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 9 Jul 2016 14:51:21 +0200 Subject: [PATCH] deps: back-port d721121 from v8 upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/issues/7454 PR-URL: https://github.com/nodejs/node/pull/7633 Reviewed-By: Fedor Indutny Reviewed-By: Michaƫl Zasso --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/crankshaft/hydrogen.cc | 53 +++++++------------------ deps/v8/src/runtime/runtime-literals.cc | 9 ++--- deps/v8/src/runtime/runtime.h | 5 --- 4 files changed, 19 insertions(+), 50 deletions(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 39a537df5720aa..c30ace1e885cf1 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 0 #define V8_BUILD_NUMBER 71 -#define V8_PATCH_LEVEL 54 +#define V8_PATCH_LEVEL 55 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/crankshaft/hydrogen.cc b/deps/v8/src/crankshaft/hydrogen.cc index 4e34d177254076..ea20a971de961a 100644 --- a/deps/v8/src/crankshaft/hydrogen.cc +++ b/deps/v8/src/crankshaft/hydrogen.cc @@ -6044,60 +6044,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { Handle site; Handle literals(environment()->closure()->literals(), isolate()); - bool uninitialized = false; Handle literals_cell(literals->literal(expr->literal_index()), isolate()); Handle boilerplate_object; - if (literals_cell->IsUndefined()) { - uninitialized = true; - Handle raw_boilerplate; - ASSIGN_RETURN_ON_EXCEPTION_VALUE( - isolate(), raw_boilerplate, - Runtime::CreateArrayLiteralBoilerplate( - isolate(), literals, expr->constant_elements(), - is_strong(function_language_mode())), - Bailout(kArrayBoilerplateCreationFailed)); - - boilerplate_object = Handle::cast(raw_boilerplate); - AllocationSiteCreationContext creation_context(isolate()); - site = creation_context.EnterNewScope(); - if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) { - return Bailout(kArrayBoilerplateCreationFailed); - } - creation_context.ExitScope(site, boilerplate_object); - literals->set_literal(expr->literal_index(), *site); - - if (boilerplate_object->elements()->map() == - isolate()->heap()->fixed_cow_array_map()) { - isolate()->counters()->cow_arrays_created_runtime()->Increment(); - } - } else { + if (!literals_cell->IsUndefined()) { DCHECK(literals_cell->IsAllocationSite()); site = Handle::cast(literals_cell); boilerplate_object = Handle( JSObject::cast(site->transition_info()), isolate()); } - DCHECK(!boilerplate_object.is_null()); - DCHECK(site->SitePointsToLiteral()); - - ElementsKind boilerplate_elements_kind = - boilerplate_object->GetElementsKind(); + ElementsKind boilerplate_elements_kind = expr->constant_elements_kind(); + if (!boilerplate_object.is_null()) { + boilerplate_elements_kind = boilerplate_object->GetElementsKind(); + } // Check whether to use fast or slow deep-copying for boilerplate. int max_properties = kMaxFastLiteralProperties; - if (IsFastLiteral(boilerplate_object, - kMaxFastLiteralDepth, + if (!boilerplate_object.is_null() && + IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, &max_properties)) { + DCHECK(site->SitePointsToLiteral()); AllocationSiteUsageContext site_context(isolate(), site, false); site_context.EnterNewScope(); literal = BuildFastLiteral(boilerplate_object, &site_context); site_context.ExitScope(site, boilerplate_object); } else { NoObservableSideEffectsScope no_effects(this); - // Boilerplate already exists and constant elements are never accessed, - // pass an empty fixed array to the runtime function instead. - Handle constants = isolate()->factory()->empty_fixed_array(); + Handle constants = expr->constant_elements(); int literal_index = expr->literal_index(); int flags = expr->ComputeFlags(true); @@ -6108,7 +6082,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { literal = Add(Runtime::FunctionForId(function_id), 4); // Register to deopt if the boilerplate ElementsKind changes. - top_info()->dependencies()->AssumeTransitionStable(site); + if (!site.is_null()) { + top_info()->dependencies()->AssumeTransitionStable(site); + } } // The array is expected in the bailout environment during computation @@ -6140,9 +6116,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { case FAST_HOLEY_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: { - HStoreKeyed* instr = Add(elements, key, value, nullptr, - boilerplate_elements_kind); - instr->SetUninitialized(uninitialized); + Add(elements, key, value, nullptr, + boilerplate_elements_kind); break; } default: diff --git a/deps/v8/src/runtime/runtime-literals.cc b/deps/v8/src/runtime/runtime-literals.cc index e73095720eb9cd..d1e4e4670ec86e 100644 --- a/deps/v8/src/runtime/runtime-literals.cc +++ b/deps/v8/src/runtime/runtime-literals.cc @@ -138,7 +138,7 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( } -MaybeHandle Runtime::CreateArrayLiteralBoilerplate( +static MaybeHandle CreateArrayLiteralBoilerplate( Isolate* isolate, Handle literals, Handle elements, bool is_strong) { // Create the JSArray. @@ -225,8 +225,8 @@ MUST_USE_RESULT static MaybeHandle CreateLiteralBoilerplate( return CreateObjectLiteralBoilerplate(isolate, literals, elements, false, kHasNoFunctionLiteral, is_strong); case CompileTimeValue::ARRAY_LITERAL: - return Runtime::CreateArrayLiteralBoilerplate(isolate, literals, - elements, is_strong); + return CreateArrayLiteralBoilerplate(isolate, literals, + elements, is_strong); default: UNREACHABLE(); return MaybeHandle(); @@ -318,8 +318,7 @@ MUST_USE_RESULT static MaybeHandle GetLiteralAllocationSite( Handle boilerplate; ASSIGN_RETURN_ON_EXCEPTION( isolate, boilerplate, - Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements, - is_strong), + CreateArrayLiteralBoilerplate(isolate, literals, elements, is_strong), AllocationSite); AllocationSiteCreationContext creation_context(isolate); diff --git a/deps/v8/src/runtime/runtime.h b/deps/v8/src/runtime/runtime.h index 7019c3bf041907..36412d2ffc08f1 100644 --- a/deps/v8/src/runtime/runtime.h +++ b/deps/v8/src/runtime/runtime.h @@ -1148,11 +1148,6 @@ class Runtime : public AllStatic { ElementsKind* fixed_elements_kind, size_t* element_size); - // Used in runtime.cc and hydrogen's VisitArrayLiteral. - MUST_USE_RESULT static MaybeHandle CreateArrayLiteralBoilerplate( - Isolate* isolate, Handle literals, - Handle elements, bool is_strong); - static MaybeHandle GetInternalProperties(Isolate* isolate, Handle); };