Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 432a6bc5fcd63fe08b81bb60ea30c91747a2218e..af3d5a3ad49955451a548d430193fcdf09f062f7 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1576,6 +1576,7 @@ void HGraphBuilder::BuildCopyElements(HValue* context, |
HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
HValue* boilerplate, |
+ HValue* allocation_site, |
AllocationSiteMode mode, |
ElementsKind kind, |
int length) { |
@@ -1612,7 +1613,7 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
// Create an allocation site info if requested. |
if (mode == TRACK_ALLOCATION_SITE) { |
- BuildCreateAllocationSiteInfo(object, JSArray::kSize, boilerplate); |
+ BuildCreateAllocationSiteInfo(object, JSArray::kSize, allocation_site); |
} |
if (length > 0) { |
@@ -1686,14 +1687,15 @@ void HGraphBuilder::BuildCompareNil( |
HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, |
int previous_object_size, |
- HValue* payload) { |
- HInnerAllocatedObject* alloc_site = Add<HInnerAllocatedObject>( |
+ HValue* alloc_site) { |
Hannes Payer (out of office)
2013/07/03 15:26:45
I think we should assert that alloc_site is not Ha
mvstanton
2013/07/05 07:56:14
good idea, but I'll just check for a NULL pointer
|
+ HInnerAllocatedObject* alloc_site_info = Add<HInnerAllocatedObject>( |
previous_object, previous_object_size); |
- Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map()); |
- AddStoreMapConstant(alloc_site, alloc_site_map); |
- HObjectAccess access = HObjectAccess::ForAllocationSitePayload(); |
- AddStore(alloc_site, access, payload); |
- return alloc_site; |
+ Handle<Map> alloc_site_info_map( |
+ isolate()->heap()->allocation_site_info_map()); |
+ AddStoreMapConstant(alloc_site_info, alloc_site_info_map); |
+ HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); |
+ AddStore(alloc_site_info, access, alloc_site); |
+ return alloc_site_info; |
} |
@@ -1726,7 +1728,7 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
constructor_function_(constructor_function) { |
mode_ = override_mode == DISABLE_ALLOCATION_SITES |
? DONT_TRACK_ALLOCATION_SITE |
- : AllocationSiteInfo::GetMode(kind); |
+ : AllocationSite::GetMode(kind); |
} |
@@ -5433,6 +5435,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
literal = BuildFastLiteral(context, |
boilerplate_object, |
original_boilerplate_object, |
+ Handle<Object>::null(), |
data_size, |
pointer_size, |
DONT_TRACK_ALLOCATION_SITE); |
@@ -5540,23 +5543,48 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
HValue* context = environment()->LookupContext(); |
HInstruction* literal; |
+ Handle<AllocationSite> site; |
Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); |
- Handle<Object> raw_boilerplate(literals->get(expr->literal_index()), |
+ Handle<Object> literals_cell(literals->get(expr->literal_index()), |
isolate()); |
Hannes Payer (out of office)
2013/07/03 15:26:45
indent
|
- |
- if (raw_boilerplate->IsUndefined()) { |
+ Handle<Object> raw_boilerplate; |
+ if (literals_cell->IsUndefined()) { |
raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( |
isolate(), literals, expr->constant_elements()); |
if (raw_boilerplate.is_null()) { |
return Bailout("array boilerplate creation failed"); |
} |
- literals->set(expr->literal_index(), *raw_boilerplate); |
+ |
+ site = isolate()->factory()->NewAllocationSite(); |
+ |
+ // We'll want to copy any useful information (statistics?) in the |
+ // AllocationSite from the full code gen |
Hannes Payer (out of office)
2013/07/03 15:26:45
Is the uncommented code still needed? What about t
mvstanton
2013/07/05 07:56:14
Okay, I went ahead and removed this block, I reali
|
+ /* |
+ Handle<FixedArray> fullcode_literals(info()->closure()->literals(), isolate()); |
+ Handle<Object> fullcode_literals_cell(fullcode_literals->get(expr->literal_index()), |
+ isolate()); |
+ if (!fullcode_literals_cell->IsUndefined()) { |
+ Handle<AllocationSite> old_site = Handle<AllocationSite>::cast(fullcode_literals_cell); |
+ // Extract info... |
+ } |
+ */ |
+ |
+ site->set_payload(*raw_boilerplate); |
+ literals->set(expr->literal_index(), *site); |
+ |
if (JSObject::cast(*raw_boilerplate)->elements()->map() == |
isolate()->heap()->fixed_cow_array_map()) { |
isolate()->counters()->cow_arrays_created_runtime()->Increment(); |
} |
+ } else { |
+ ASSERT(literals_cell->IsAllocationSite()); |
+ site = Handle<AllocationSite>::cast(literals_cell); |
+ raw_boilerplate = Handle<Object>(site->payload(), isolate()); |
} |
+ ASSERT(!raw_boilerplate.is_null()); |
+ ASSERT(site->IsLiteralSite()); |
+ |
Handle<JSObject> original_boilerplate_object = |
Handle<JSObject>::cast(raw_boilerplate); |
ElementsKind boilerplate_elements_kind = |
@@ -5565,7 +5593,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
// 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( |
+ AllocationSiteMode mode = AllocationSite::GetMode( |
boilerplate_elements_kind); |
// Check whether to use fast or slow deep-copying for boilerplate. |
@@ -5585,6 +5613,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
literal = BuildFastLiteral(context, |
boilerplate_object, |
original_boilerplate_object, |
+ site, |
data_size, |
pointer_size, |
mode); |
@@ -9421,6 +9450,7 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
HValue* context, |
Handle<JSObject> boilerplate_object, |
Handle<JSObject> original_boilerplate_object, |
+ Handle<Object> allocation_site, |
int data_size, |
int pointer_size, |
AllocationSiteMode mode) { |
@@ -9458,8 +9488,9 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
int offset = 0; |
int data_offset = 0; |
- BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, target, |
- &offset, data_target, &data_offset, mode); |
+ BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, |
+ allocation_site, target, &offset, data_target, |
+ &data_offset, mode); |
return target; |
} |
@@ -9467,11 +9498,30 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
Handle<JSObject> boilerplate_object, |
Handle<JSObject> original_boilerplate_object, |
+ Handle<Object> allocation_site_object, |
HInstruction* target, |
int* offset, |
HInstruction* data_target, |
int* data_offset, |
AllocationSiteMode mode) { |
+ Zone* zone = this->zone(); |
+ |
+ bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && |
+ boilerplate_object->map()->CanTrackAllocationSite(); |
+ |
+ // If using allocation sites, then the payload on the site should already |
+ // be filled in as a valid (boilerplate) array. |
+ ASSERT(!create_allocation_site_info || |
+ AllocationSite::cast(*allocation_site_object)->IsLiteralSite()); |
+ |
+ HInstruction* allocation_site = NULL; |
+ |
+ if (create_allocation_site_info) { |
+ allocation_site = AddInstruction(new(zone) HConstant( |
+ allocation_site_object, Representation::Tagged())); |
+ } |
+ |
+ // Only elements backing stores for non-COW arrays need to be copied. |
Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
Handle<FixedArrayBase> original_elements( |
original_boilerplate_object->elements()); |
@@ -9517,9 +9567,7 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
boilerplate_object->map()->CanTrackAllocationSite()) { |
elements_offset += AllocationSiteInfo::kSize; |
*offset += AllocationSiteInfo::kSize; |
- HInstruction* original_boilerplate = |
- Add<HConstant>(original_boilerplate_object); |
- BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); |
+ BuildCreateAllocationSiteInfo(target, JSArray::kSize, allocation_site); |
} |
} |
@@ -9617,9 +9665,10 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
*offset); |
AddStore(object_properties, access, value_instruction); |
- |
- BuildEmitDeepCopy(value_object, original_value_object, target, |
- offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); |
+ BuildEmitDeepCopy(value_object, original_value_object, |
+ Handle<Object>::null(), target, |
+ offset, data_target, data_offset, |
+ DONT_TRACK_ALLOCATION_SITE); |
} else { |
Representation representation = details.representation(); |
HInstruction* value_instruction = Add<HConstant>(value); |
@@ -9726,8 +9775,10 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray( |
HInstruction* value_instruction = Add<HInnerAllocatedObject>(target, |
*offset); |
Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
- BuildEmitDeepCopy(value_object, original_value_object, target, |
- offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE); |
+ BuildEmitDeepCopy(value_object, original_value_object, |
+ Handle<Object>::null(), target, |
+ offset, data_target, data_offset, |
+ DONT_TRACK_ALLOCATION_SITE); |
} else { |
HInstruction* value_instruction = |
Add<HLoadKeyed>(boilerplate_elements, key_constant, |