Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Revert of Compiling an array literal should be context-independent. (…
Browse files Browse the repository at this point in the history
…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}
  • Loading branch information
hashseed authored and Commit bot committed Nov 10, 2016
1 parent 5af14e2 commit f56685d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 69 deletions.
36 changes: 16 additions & 20 deletions src/ast/ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions src/elements.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down
4 changes: 0 additions & 4 deletions src/elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions test/inspector/debugger/get-possible-breakpoints-array-literal.js

This file was deleted.

0 comments on commit f56685d

Please sign in to comment.