Commit f56685d0 authored by yangguo's avatar yangguo Committed by Commit bot

Revert of Compiling an array literal should be context-independent. (patchset...

Revert of Compiling an array literal should be context-independent. (patchset #5 id:80001 of https://codereview.chromium.org/2479123002/ )

Reason for revert:
speculative revert to fix https://uberchromegw.corp.google.com/i/client.v8/builders/V8%20Mac%20GC%20Stress/builds/9646/steps/Mjsunit%20%28flakes%29/logs/debug-scopes

Original issue's description:
> Compiling an array literal should be context-independent.
>
> We are removing use of the debugger context. When the debugger triggers
> compilation, we may not have a context from which to create a JSArray.
>
> R=ishell@chromium.org

TBR=ishell@chromium.org,verwaest@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2481363009
Cr-Commit-Position: refs/heads/master@{#40906}
parent 5af14e24
......@@ -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<FixedArray> fixed_array =
isolate->factory()->NewFixedArrayWithHoles(constants_length);
// Allocate a fixed array to hold all the object literals.
Handle<JSArray> 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<FixedArrayBase> 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<FixedArrayBase> 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<FixedArray> 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);
......
......@@ -973,12 +973,6 @@ class ElementsAccessorBase : public ElementsAccessor {
packed_size, copy_size);
}
void CopyElements(Handle<FixedArrayBase> source, ElementsKind source_kind,
Handle<FixedArrayBase> destination, int size) {
Subclass::CopyElementsImpl(*source, 0, *destination, source_kind, 0,
kPackedSizeNotKnown, size);
}
Handle<SeededNumberDictionary> Normalize(Handle<JSObject> object) final {
return Subclass::NormalizeImpl(object, handle(object->elements()));
}
......
......@@ -170,10 +170,6 @@ class ElementsAccessor {
Handle<Object> value, uint32_t start,
uint32_t length) = 0;
virtual void CopyElements(Handle<FixedArrayBase> source,
ElementsKind source_kind,
Handle<FixedArrayBase> destination, int size) = 0;
protected:
friend class LookupIterator;
......
{
id : <messageId>
result : {
locations : [
[0] : {
columnNumber : 0
lineNumber : 0
scriptId : <scriptId>
}
[1] : {
columnNumber : 6
lineNumber : 0
scriptId : <scriptId>
}
[2] : {
columnNumber : 7
lineNumber : 0
scriptId : <scriptId>
}
[3] : {
columnNumber : 8
lineNumber : 0
scriptId : <scriptId>
}
]
}
}
// 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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment