Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: src/hydrogen.cc

Issue 12114054: Supporting AllocationSiteInfo for Nested arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some updates Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 00207c142f44d528805a7172698ae09cf21388a2..ebbee398709736179f4cba94f2adfb216d28c0ab 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5522,10 +5522,16 @@ static bool LookupSetter(Handle<Map> map,
static bool IsFastLiteral(Handle<JSObject> boilerplate,
int max_depth,
int* max_properties,
- int* total_size) {
+ int* total_size,
+ AllocationSiteMode mode) {
ASSERT(max_depth >= 0 && *max_properties >= 0);
if (max_depth == 0) return false;
+ if (mode == TRACK_ALLOCATION_SITE &&
+ boilerplate->ShouldTrackAllocationInfo()) {
+ *total_size += AllocationSiteInfo::kSize;
+ }
+
Handle<FixedArrayBase> elements(boilerplate->elements());
if (elements->length() > 0 &&
elements->map() != boilerplate->GetHeap()->fixed_cow_array_map()) {
@@ -5542,7 +5548,8 @@ static bool IsFastLiteral(Handle<JSObject> boilerplate,
if (!IsFastLiteral(value_object,
max_depth - 1,
max_properties,
- total_size)) {
+ total_size,
+ mode)) {
return false;
}
}
@@ -5566,7 +5573,8 @@ static bool IsFastLiteral(Handle<JSObject> boilerplate,
if (!IsFastLiteral(value_object,
max_depth - 1,
max_properties,
- total_size)) {
+ total_size,
+ mode)) {
return false;
}
}
@@ -5586,29 +5594,45 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
HValue* context = environment()->LookupContext();
HInstruction* literal;
+ // We don't want to use AllocationSiteInfo when the object literal is
+ // declared at global scope without a surrounding loop, that means it's
+ // literal arrays will never be re-created, and therefore don't benefit from
+ // site info.
+ AllocationSiteMode mode = FLAG_track_allocation_sites && !IsOneTimeCode()
+ ? TRACK_ALLOCATION_SITE
+ : DONT_TRACK_ALLOCATION_SITE;
+
// Check whether to use fast or slow deep-copying for boilerplate.
int total_size = 0;
int max_properties = HFastLiteral::kMaxLiteralProperties;
- Handle<Object> boilerplate(closure->literals()->get(expr->literal_index()));
- if (boilerplate->IsJSObject() &&
- IsFastLiteral(Handle<JSObject>::cast(boilerplate),
+ Handle<Object> original_boilerplate(closure->literals()->get(
+ expr->literal_index()));
+ if (original_boilerplate->IsJSObject() &&
+ IsFastLiteral(Handle<JSObject>::cast(original_boilerplate),
HFastLiteral::kMaxLiteralDepth,
&max_properties,
- &total_size)) {
- Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate);
+ &total_size,
+ mode)) {
+ // Copy the boilerplate to prevent unsavory sharing between fullcodegen and
+ // crankshaft.
+ Handle<JSObject> original_boilerplate_object =
+ Handle<JSObject>::cast(original_boilerplate);
+ Handle<JSObject> boilerplate = DeepCopy(original_boilerplate_object);
literal = new(zone()) HFastLiteral(context,
- boilerplate_object,
+ boilerplate,
+ original_boilerplate_object,
total_size,
expr->literal_index(),
expr->depth(),
- DONT_TRACK_ALLOCATION_SITE);
+ mode);
} else {
literal = new(zone()) HObjectLiteral(context,
expr->constant_properties(),
expr->fast_elements(),
expr->literal_index(),
expr->depth(),
- expr->has_function());
+ expr->has_function(),
+ mode);
}
// The object is expected in the bailout environment during computation
@@ -5693,9 +5717,12 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
HValue* context = environment()->LookupContext();
HInstruction* literal;
+ AllocationSiteMode mode = FLAG_track_allocation_sites && !IsOneTimeCode()
+ ? TRACK_ALLOCATION_SITE
+ : DONT_TRACK_ALLOCATION_SITE;
+
Handle<FixedArray> literals(environment()->closure()->literals());
Handle<Object> raw_boilerplate(literals->get(expr->literal_index()));
-
if (raw_boilerplate->IsUndefined()) {
raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate(
isolate(), literals, expr->constant_elements());
@@ -5709,35 +5736,32 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
}
}
- Handle<JSObject> boilerplate = Handle<JSObject>::cast(raw_boilerplate);
+ Handle<JSObject> original_boilerplate =
+ Handle<JSObject>::cast(raw_boilerplate);
ElementsKind boilerplate_elements_kind =
- Handle<JSObject>::cast(boilerplate)->GetElementsKind();
-
- // TODO(mvstanton): This heuristic is only a temporary solution. In the
- // end, we want to quit creating allocation site info after a certain number
- // of GCs for a call site.
- AllocationSiteMode mode = AllocationSiteInfo::GetMode(
- boilerplate_elements_kind);
+ original_boilerplate->GetElementsKind();
// Check whether to use fast or slow deep-copying for boilerplate.
int total_size = 0;
int max_properties = HFastLiteral::kMaxLiteralProperties;
- if (IsFastLiteral(boilerplate,
+ if (IsFastLiteral(original_boilerplate,
HFastLiteral::kMaxLiteralDepth,
&max_properties,
- &total_size)) {
- if (mode == TRACK_ALLOCATION_SITE) {
- total_size += AllocationSiteInfo::kSize;
- }
+ &total_size,
+ mode)) {
+ // Copy the boilerplate to prevent unsavory sharing between fullcodegen and
+ // crankshaft.
+ Handle<JSObject> boilerplate = DeepCopy(original_boilerplate);
literal = new(zone()) HFastLiteral(context,
boilerplate,
+ original_boilerplate,
total_size,
expr->literal_index(),
expr->depth(),
mode);
} else {
literal = new(zone()) HArrayLiteral(context,
- boilerplate,
+ original_boilerplate,
length,
expr->literal_index(),
expr->depth(),

Powered by Google App Engine
This is Rietveld 408576698