Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: cherry-pick d721121 from v8 upstream #7632

Merged
merged 1 commit into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 14 additions & 38 deletions deps/v8/src/crankshaft/hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5995,59 +5995,34 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Handle<AllocationSite> site;
Handle<LiteralsArray> literals(environment()->closure()->literals(),
isolate());
bool uninitialized = false;
Handle<Object> literals_cell(literals->literal(expr->literal_index()),
isolate());
Handle<JSObject> boilerplate_object;
if (literals_cell->IsUndefined()) {
uninitialized = true;
Handle<Object> raw_boilerplate;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate(), raw_boilerplate,
Runtime::CreateArrayLiteralBoilerplate(isolate(), literals,
expr->constant_elements()),
Bailout(kArrayBoilerplateCreationFailed));

boilerplate_object = Handle<JSObject>::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<AllocationSite>::cast(literals_cell);
boilerplate_object = Handle<JSObject>(
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<FixedArray> constants = isolate()->factory()->empty_fixed_array();
Handle<FixedArray> constants = expr->constant_elements();
int literal_index = expr->literal_index();
int flags = expr->ComputeFlags(true);

Expand All @@ -6058,7 +6033,9 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
literal = Add<HCallRuntime>(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
Expand Down Expand Up @@ -6090,9 +6067,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
case FAST_HOLEY_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS: {
HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr,
boilerplate_elements_kind);
instr->SetUninitialized(uninitialized);
Add<HStoreKeyed>(elements, key, value, nullptr,
boilerplate_elements_kind);
break;
}
default:
Expand Down
7 changes: 3 additions & 4 deletions deps/v8/src/runtime/runtime-literals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
return boilerplate;
}

MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
static MaybeHandle<Object> CreateArrayLiteralBoilerplate(
Isolate* isolate, Handle<LiteralsArray> literals,
Handle<FixedArray> elements) {
// Create the JSArray.
Expand Down Expand Up @@ -191,8 +191,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
return CreateObjectLiteralBoilerplate(isolate, literals, elements, false);
case CompileTimeValue::ARRAY_LITERAL:
return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
elements);
return CreateArrayLiteralBoilerplate(isolate, literals, elements);
default:
UNREACHABLE();
return MaybeHandle<Object>();
Expand Down Expand Up @@ -280,7 +279,7 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
Handle<Object> boilerplate;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, boilerplate,
Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements),
CreateArrayLiteralBoilerplate(isolate, literals, elements),
AllocationSite);

AllocationSiteCreationContext creation_context(isolate);
Expand Down
5 changes: 0 additions & 5 deletions deps/v8/src/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,11 +1130,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<Object> CreateArrayLiteralBoilerplate(
Isolate* isolate, Handle<LiteralsArray> literals,
Handle<FixedArray> elements);

static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
Handle<Object>);
};
Expand Down