Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index 0663a1374507b4231ec045d683f2676435e4ab48..39e023b36a67bfc9268fc78289292041a680de95 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -1617,6 +1617,7 @@ void HGraphBuilder::BuildCopyElements(HValue* context, |
| HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
| HValue* boilerplate, |
| + HValue* allocation_site, |
| AllocationSiteMode mode, |
| ElementsKind kind, |
| int length) { |
| @@ -1657,7 +1658,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) { |
| @@ -1745,15 +1746,16 @@ void HGraphBuilder::BuildCompareNil( |
| HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, |
| int previous_object_size, |
| - HValue* payload) { |
| - HInnerAllocatedObject* alloc_site = new(zone()) |
| + HValue* alloc_site) { |
| + HInnerAllocatedObject* alloc_site_info = new(zone()) |
| HInnerAllocatedObject(previous_object, previous_object_size); |
| - AddInstruction(alloc_site); |
| - 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; |
| + AddInstruction(alloc_site_info); |
| + Handle<Map> alloc_site_info_map( |
| + isolate()->heap()->allocation_site_info_map()); |
| + AddStoreMapConstant(alloc_site_info, alloc_site_info_map); |
| + HObjectAccess access = HObjectAccess::ForAllocationSiteInfoPayload(); |
| + AddStore(alloc_site_info, access, alloc_site); |
| + return alloc_site_info; |
| } |
| @@ -1787,7 +1789,7 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
| constructor_function_(NULL) { |
| mode_ = disable_allocation_sites |
| ? DONT_TRACK_ALLOCATION_SITE |
| - : AllocationSiteInfo::GetMode(kind); |
| + : AllocationSite::GetMode(kind); |
| } |
| @@ -5880,10 +5882,11 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
| Handle<JSObject>::cast(original_boilerplate); |
| Handle<JSObject> boilerplate_object = |
| DeepCopy(original_boilerplate_object); |
| - |
| + Handle<FixedArray> literals(closure->literals(), isolate()); |
|
Hannes Payer (out of office)
2013/06/25 16:35:07
Literals can be removed.
mvstanton
2013/07/02 13:55:11
Done.
|
| literal = BuildFastLiteral(context, |
| boilerplate_object, |
| original_boilerplate_object, |
| + Handle<Object>::null(), |
| data_size, |
| pointer_size, |
| DONT_TRACK_ALLOCATION_SITE); |
| @@ -5997,23 +6000,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()); |
| - |
| - 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/06/25 16:35:07
why can't you reuse the allocation site generated
mvstanton
2013/07/02 13:55:11
The reason is that we don't create the AllocationS
|
| + /* |
| + 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 = |
| @@ -6022,7 +6050,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. |
| @@ -6042,6 +6070,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
| literal = BuildFastLiteral(context, |
| boilerplate_object, |
| original_boilerplate_object, |
| + site, |
| data_size, |
| pointer_size, |
| mode); |
| @@ -9954,6 +9983,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) { |
| @@ -9979,8 +10009,8 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
| HType::JSObject(), |
| flags)); |
| int offset = 0; |
| - BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, |
| - &offset, mode); |
| + BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, |
| + allocation_site, result, &offset, mode); |
| return result; |
| } |
| @@ -9988,11 +10018,28 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
| void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
| Handle<JSObject> boilerplate_object, |
| Handle<JSObject> original_boilerplate_object, |
| + Handle<Object> allocation_site_object, |
| HInstruction* target, |
| int* 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()); |
| @@ -10028,9 +10075,7 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
| boilerplate_object->map()->CanTrackAllocationSite()) { |
| elements_offset += AllocationSiteInfo::kSize; |
| *offset += AllocationSiteInfo::kSize; |
| - HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( |
| - original_boilerplate_object, Representation::Tagged())); |
| - BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); |
| + BuildCreateAllocationSiteInfo(target, JSArray::kSize, allocation_site); |
| } |
| } |
| @@ -10126,11 +10171,10 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
| isolate())); |
| HInstruction* value_instruction = |
| AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
| - |
| AddStore(object_properties, access, value_instruction); |
| - |
| - BuildEmitDeepCopy(value_object, original_value_object, target, |
| - offset, DONT_TRACK_ALLOCATION_SITE); |
| + BuildEmitDeepCopy(value_object, original_value_object, |
| + Handle<Object>::null(), target, offset, |
| + DONT_TRACK_ALLOCATION_SITE); |
| } else { |
| Representation representation = details.representation(); |
| HInstruction* value_instruction = AddInstruction(new(zone) HConstant( |
| @@ -10237,8 +10281,9 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray( |
| AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
| AddInstruction(new(zone) HStoreKeyed( |
| object_elements, key_constant, value_instruction, kind)); |
| - BuildEmitDeepCopy(value_object, original_value_object, target, |
| - offset, DONT_TRACK_ALLOCATION_SITE); |
| + BuildEmitDeepCopy(value_object, original_value_object, |
| + Handle<Object>::null(), target, |
| + offset, DONT_TRACK_ALLOCATION_SITE); |
| } else { |
| HInstruction* value_instruction = |
| AddInstruction(new(zone) HLoadKeyed( |