diff --git a/src/ast/ast.cc b/src/ast/ast.cc index 6afd2de20412..7fa115524d1a 100644 --- a/src/ast/ast.cc +++ b/src/ast/ast.cc @@ -14,7 +14,6 @@ #include "src/code-stubs.h" #include "src/contexts.h" #include "src/conversions.h" -#include "src/elements.h" #include "src/property-details.h" #include "src/property.h" #include "src/string-stream.h" @@ -581,9 +580,11 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) { if (!constant_elements_.is_null()) return; int constants_length = values()->length(); - ElementsKind kind = FIRST_FAST_ELEMENTS_KIND; - Handle fixed_array = - isolate->factory()->NewFixedArrayWithHoles(constants_length); + + // Allocate a fixed array to hold all the object literals. + Handle array = isolate->factory()->NewJSArray( + FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, + INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); // Fill in the literals. bool is_simple = true; @@ -614,34 +615,29 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) { is_simple = false; } - kind = GetMoreGeneralElementsKind(kind, - boilerplate_value->OptimalElementsKind()); - fixed_array->set(array_index, *boilerplate_value); + JSObject::AddDataElement(array, array_index, boilerplate_value, NONE) + .Assert(); } - if (is_holey) kind = GetHoleyElementsKind(kind); + JSObject::ValidateElements(array); + Handle element_values(array->elements()); // Simple and shallow arrays can be lazily copied, we transform the // elements array to a copy-on-write array. if (is_simple && depth_acc == 1 && array_index > 0 && - IsFastSmiOrObjectElementsKind(kind)) { - fixed_array->set_map(isolate->heap()->fixed_cow_array_map()); - } - - Handle elements = fixed_array; - if (IsFastDoubleElementsKind(kind)) { - ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); - elements = isolate->factory()->NewFixedDoubleArray(constants_length); - // We are copying from non-fast-double to fast-double. - ElementsKind from_kind = TERMINAL_FAST_ELEMENTS_KIND; - accessor->CopyElements(fixed_array, from_kind, elements, constants_length); + array->HasFastSmiOrObjectElements()) { + element_values->set_map(isolate->heap()->fixed_cow_array_map()); } // Remember both the literal's constant values as well as the ElementsKind // in a 2-element FixedArray. Handle literals = isolate->factory()->NewFixedArray(2, TENURED); + + ElementsKind kind = array->GetElementsKind(); + kind = is_holey ? GetHoleyElementsKind(kind) : GetPackedElementsKind(kind); + literals->set(0, Smi::FromInt(kind)); - literals->set(1, *elements); + literals->set(1, *element_values); constant_elements_ = literals; set_is_simple(is_simple); diff --git a/src/elements.cc b/src/elements.cc index 7436e15d688e..83733cb835d3 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -973,12 +973,6 @@ class ElementsAccessorBase : public ElementsAccessor { packed_size, copy_size); } - void CopyElements(Handle source, ElementsKind source_kind, - Handle destination, int size) { - Subclass::CopyElementsImpl(*source, 0, *destination, source_kind, 0, - kPackedSizeNotKnown, size); - } - Handle Normalize(Handle object) final { return Subclass::NormalizeImpl(object, handle(object->elements())); } diff --git a/src/elements.h b/src/elements.h index a4ae6854baf4..76e1aa6f39a3 100644 --- a/src/elements.h +++ b/src/elements.h @@ -170,10 +170,6 @@ class ElementsAccessor { Handle value, uint32_t start, uint32_t length) = 0; - virtual void CopyElements(Handle source, - ElementsKind source_kind, - Handle destination, int size) = 0; - protected: friend class LookupIterator; diff --git a/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt b/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt deleted file mode 100644 index c85832872cd1..000000000000 --- a/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt +++ /dev/null @@ -1,27 +0,0 @@ -{ - id : - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : - } - [1] : { - columnNumber : 6 - lineNumber : 0 - scriptId : - } - [2] : { - columnNumber : 7 - lineNumber : 0 - scriptId : - } - [3] : { - columnNumber : 8 - lineNumber : 0 - scriptId : - } - ] - } -} diff --git a/test/inspector/debugger/get-possible-breakpoints-array-literal.js b/test/inspector/debugger/get-possible-breakpoints-array-literal.js deleted file mode 100644 index e574f69c0142..000000000000 --- a/test/inspector/debugger/get-possible-breakpoints-array-literal.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -Protocol.Debugger.enable(); - -Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId) - .then((scriptId) => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(InspectorTest.completeTest); - -compileAndRunWithOrigin("() => []", "", 0, 0);