Commit 2439c967 authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[turbofan] Refactor allocation sites for fast literal creation.

Bug: v8:7790
Change-Id: I6a6347d7394ddeacbb185a2e6e5187898bfca2dc
Reviewed-on: https://chromium-review.googlesource.com/1106173Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53868}
parent d020584a
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "src/compiler/js-create-lowering.h" #include "src/compiler/js-create-lowering.h"
#include "src/allocation-site-scopes.h"
#include "src/code-factory.h" #include "src/code-factory.h"
#include "src/compilation-dependencies.h" #include "src/compilation-dependencies.h"
#include "src/compiler/access-builder.h" #include "src/compiler/access-builder.h"
...@@ -1201,6 +1200,17 @@ Reduction JSCreateLowering::ReduceJSCreatePromise(Node* node) { ...@@ -1201,6 +1200,17 @@ Reduction JSCreateLowering::ReduceJSCreatePromise(Node* node) {
return Changed(node); return Changed(node);
} }
void AssumeAllocationSiteTransitionDeepDependencies(
CompilationDependencies* dependencies, Isolate* isolate,
Handle<AllocationSite> site) {
while (true) {
dependencies->AssumeTransitionStable(site);
if (!site->nested_site()->IsAllocationSite()) break;
site = handle(AllocationSite::cast(site->nested_site()), isolate);
}
CHECK_EQ(site->nested_site(), Smi::kZero);
}
Reduction JSCreateLowering::ReduceJSCreateLiteralArrayOrObject(Node* node) { Reduction JSCreateLowering::ReduceJSCreateLiteralArrayOrObject(Node* node) {
DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray ||
node->opcode() == IrOpcode::kJSCreateLiteralObject); node->opcode() == IrOpcode::kJSCreateLiteralObject);
...@@ -1215,11 +1225,15 @@ Reduction JSCreateLowering::ReduceJSCreateLiteralArrayOrObject(Node* node) { ...@@ -1215,11 +1225,15 @@ Reduction JSCreateLowering::ReduceJSCreateLiteralArrayOrObject(Node* node) {
Handle<JSObject> boilerplate(site->boilerplate(), isolate()); Handle<JSObject> boilerplate(site->boilerplate(), isolate());
int max_properties = kMaxFastLiteralProperties; int max_properties = kMaxFastLiteralProperties;
if (IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { if (IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
AllocationSiteUsageContext site_context(isolate(), site, false); PretenureFlag pretenure = NOT_TENURED;
site_context.EnterNewScope(); if (FLAG_allocation_site_pretenuring) {
pretenure = site->GetPretenureMode();
dependencies()->AssumeTenuringDecision(site);
}
AssumeAllocationSiteTransitionDeepDependencies(dependencies(), isolate(),
site);
Node* value = effect = Node* value = effect =
AllocateFastLiteral(effect, control, boilerplate, &site_context); AllocateFastLiteral(effect, control, boilerplate, pretenure);
site_context.ExitScope(site, boilerplate);
ReplaceWithValue(node, value, effect, control); ReplaceWithValue(node, value, effect, control);
return Replace(value); return Replace(value);
} }
...@@ -1701,22 +1715,9 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control, ...@@ -1701,22 +1715,9 @@ Node* JSCreateLowering::AllocateElements(Node* effect, Node* control,
return a.Finish(); return a.Finish();
} }
Node* JSCreateLowering::AllocateFastLiteral( Node* JSCreateLowering::AllocateFastLiteral(Node* effect, Node* control,
Node* effect, Node* control, Handle<JSObject> boilerplate, Handle<JSObject> boilerplate,
AllocationSiteUsageContext* site_context) { PretenureFlag pretenure) {
Handle<AllocationSite> current_site(*site_context->current(), isolate());
dependencies()->AssumeTransitionStable(current_site);
PretenureFlag pretenure = NOT_TENURED;
if (FLAG_allocation_site_pretenuring) {
Handle<AllocationSite> top_site(*site_context->top(), isolate());
pretenure = top_site->GetPretenureMode();
if (current_site.is_identical_to(top_site)) {
// We install a dependency for pretenuring only on the outermost literal.
dependencies()->AssumeTenuringDecision(top_site);
}
}
// Setup the properties backing store. // Setup the properties backing store.
Node* properties = jsgraph()->EmptyFixedArrayConstant(); Node* properties = jsgraph()->EmptyFixedArrayConstant();
...@@ -1748,10 +1749,8 @@ Node* JSCreateLowering::AllocateFastLiteral( ...@@ -1748,10 +1749,8 @@ Node* JSCreateLowering::AllocateFastLiteral(
if (boilerplate_value->IsJSObject()) { if (boilerplate_value->IsJSObject()) {
Handle<JSObject> boilerplate_object = Handle<JSObject> boilerplate_object =
Handle<JSObject>::cast(boilerplate_value); Handle<JSObject>::cast(boilerplate_value);
Handle<AllocationSite> current_site = site_context->EnterNewScope(); value = effect =
value = effect = AllocateFastLiteral(effect, control, AllocateFastLiteral(effect, control, boilerplate_object, pretenure);
boilerplate_object, site_context);
site_context->ExitScope(current_site, boilerplate_object);
} else if (property_details.representation().IsDouble()) { } else if (property_details.representation().IsDouble()) {
double number = Handle<HeapNumber>::cast(boilerplate_value)->value(); double number = Handle<HeapNumber>::cast(boilerplate_value)->value();
// Allocate a mutable HeapNumber box and store the value into it. // Allocate a mutable HeapNumber box and store the value into it.
...@@ -1785,8 +1784,8 @@ Node* JSCreateLowering::AllocateFastLiteral( ...@@ -1785,8 +1784,8 @@ Node* JSCreateLowering::AllocateFastLiteral(
} }
// Setup the elements backing store. // Setup the elements backing store.
Node* elements = AllocateFastLiteralElements(effect, control, boilerplate, Node* elements =
pretenure, site_context); AllocateFastLiteralElements(effect, control, boilerplate, pretenure);
if (elements->op()->EffectOutputCount() > 0) effect = elements; if (elements->op()->EffectOutputCount() > 0) effect = elements;
// Actually allocate and initialize the object. // Actually allocate and initialize the object.
...@@ -1810,7 +1809,7 @@ Node* JSCreateLowering::AllocateFastLiteral( ...@@ -1810,7 +1809,7 @@ Node* JSCreateLowering::AllocateFastLiteral(
Node* JSCreateLowering::AllocateFastLiteralElements( Node* JSCreateLowering::AllocateFastLiteralElements(
Node* effect, Node* control, Handle<JSObject> boilerplate, Node* effect, Node* control, Handle<JSObject> boilerplate,
PretenureFlag pretenure, AllocationSiteUsageContext* site_context) { PretenureFlag pretenure) {
Handle<FixedArrayBase> boilerplate_elements(boilerplate->elements(), Handle<FixedArrayBase> boilerplate_elements(boilerplate->elements(),
isolate()); isolate());
...@@ -1855,10 +1854,8 @@ Node* JSCreateLowering::AllocateFastLiteralElements( ...@@ -1855,10 +1854,8 @@ Node* JSCreateLowering::AllocateFastLiteralElements(
if (element_value->IsJSObject()) { if (element_value->IsJSObject()) {
Handle<JSObject> boilerplate_object = Handle<JSObject> boilerplate_object =
Handle<JSObject>::cast(element_value); Handle<JSObject>::cast(element_value);
Handle<AllocationSite> current_site = site_context->EnterNewScope();
elements_values[i] = effect = AllocateFastLiteral( elements_values[i] = effect = AllocateFastLiteral(
effect, control, boilerplate_object, site_context); effect, control, boilerplate_object, pretenure);
site_context->ExitScope(current_site, boilerplate_object);
} else { } else {
elements_values[i] = jsgraph()->Constant(element_value); elements_values[i] = jsgraph()->Constant(element_value);
} }
......
...@@ -98,11 +98,10 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -98,11 +98,10 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
PretenureFlag pretenure); PretenureFlag pretenure);
Node* AllocateFastLiteral(Node* effect, Node* control, Node* AllocateFastLiteral(Node* effect, Node* control,
Handle<JSObject> boilerplate, Handle<JSObject> boilerplate,
AllocationSiteUsageContext* site_context); PretenureFlag pretenure);
Node* AllocateFastLiteralElements(Node* effect, Node* control, Node* AllocateFastLiteralElements(Node* effect, Node* control,
Handle<JSObject> boilerplate, Handle<JSObject> boilerplate,
PretenureFlag pretenure, PretenureFlag pretenure);
AllocationSiteUsageContext* site_context);
Node* AllocateLiteralRegExp(Node* effect, Node* control, Node* AllocateLiteralRegExp(Node* effect, Node* control,
Handle<JSRegExp> boilerplate); Handle<JSRegExp> boilerplate);
......
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