Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index b699b43fe38b78dc0098e50657ce8e401befa0f3..503b56c5f44f737f4914e0e8822ea9ba02a823d4 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -1755,11 +1755,12 @@ HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) { |
| HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
| ElementsKind kind, |
| HValue* allocation_site_payload, |
| + HValue* constructor_function, |
| bool disable_allocation_sites) : |
| builder_(builder), |
| kind_(kind), |
| allocation_site_payload_(allocation_site_payload), |
| - constructor_function_(NULL) { |
| + constructor_function_(constructor_function) { |
| mode_ = disable_allocation_sites |
| ? DONT_TRACK_ALLOCATION_SITE |
| : AllocationSiteInfo::GetMode(kind); |
| @@ -1778,17 +1779,23 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
| HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
| - HInstruction* native_context = builder()->BuildGetNativeContext(context); |
| + if (kind_ == FAST_SMI_ELEMENTS) { |
| + // Optimization: the initial Array map is for FAST_SMI_ELEMENTS. |
| + // No need for a context lookup in this case. |
|
danno
2013/06/27 08:53:04
Why not? What is special about smi elements?
mvstanton
2013/06/27 15:33:29
Because the initial map on the constructor is setu
|
| + HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); |
| + return AddInstruction( |
| + builder()->BuildLoadNamedField(constructor_function_, |
| + access, |
| + Representation::Tagged())); |
| + } |
| + HInstruction* native_context = builder()->BuildGetNativeContext(context); |
| HInstruction* index = builder()->AddInstruction(new(zone()) |
| HConstant(Context::JS_ARRAY_MAPS_INDEX)); |
| - |
| HInstruction* map_array = builder()->AddInstruction(new(zone()) |
| HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS)); |
| - |
| HInstruction* kind_index = builder()->AddInstruction(new(zone()) |
| - HConstant(kind_)); |
| - |
| + HConstant(kind_)); |
| return builder()->AddInstruction(new(zone()) |
| HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS)); |
| } |
| @@ -1885,7 +1892,7 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, |
| // Fill in the fields: map, properties, length |
| HValue* map; |
| - if (constructor_function_ != NULL) { |
| + if (allocation_site_payload_ == NULL) { |
| map = EmitInternalMapCode(); |
| } else { |
| map = EmitMapCode(context); |