Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 0fe0173428534f77253488f03cd10dea7049f436..d8d1153164cd84172d0acc84207a09b0ce5e95ac 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1753,14 +1753,15 @@ HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) { |
HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
- ElementsKind kind, |
- HValue* allocation_site_payload, |
- bool disable_allocation_sites) : |
+ ElementsKind kind, |
+ HValue* allocation_site_payload, |
+ HValue* constructor_function, |
+ AllocationSiteOverrideMode override_mode) : |
builder_(builder), |
kind_(kind), |
allocation_site_payload_(allocation_site_payload), |
- constructor_function_(NULL) { |
- mode_ = disable_allocation_sites |
+ constructor_function_(constructor_function) { |
+ mode_ = override_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_ == GetInitialFastElementsKind()) { |
+ // No need for a context lookup if the kind_ matches the initial |
+ // map, because we can just load the map in that case. |
+ 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); |