Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index de3254a2721cfc12c599f6a83639fed48928d2bf..d8819620b26e9bcd40cd284ebf4ac7e47a6d9cf5 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1894,7 +1894,8 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
AllocationSiteMode mode) : |
builder_(builder), |
Michael Starzinger
2013/05/23 09:16:49
nit: Indentation is off.
mvstanton
2013/05/23 14:46:05
Done.
|
kind_(kind), |
- allocation_site_payload_(allocation_site_payload) { |
+ allocation_site_payload_(allocation_site_payload), |
+ constructor_function_(NULL) { |
if (mode == DONT_TRACK_ALLOCATION_SITE) { |
mode_ = mode; |
} else { |
@@ -1903,6 +1904,17 @@ HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
} |
+HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
+ ElementsKind kind, |
+ HValue* constructor_function) : |
+ builder_(builder), |
Michael Starzinger
2013/05/23 09:16:49
nit: Indentation is off.
mvstanton
2013/05/23 14:46:05
Done.
|
+ kind_(kind), |
+ mode_(DONT_TRACK_ALLOCATION_SITE), |
+ allocation_site_payload_(NULL), |
+ constructor_function_(constructor_function) { |
+} |
+ |
+ |
HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
HInstruction* native_context = builder()->BuildGetNativeContext(context); |
int offset = Context::kHeaderSize + |
@@ -1915,6 +1927,15 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
} |
+HValue* HGraphBuilder::JSArrayBuilder::InternalEmitMapCode() { |
+ // Find the map near the constructor function |
+ HValue* initial_map = AddInstruction(new(zone()) |
+ HLoadNamedField(constructor_function_, true, Representation::Tagged(), |
+ JSFunction::kPrototypeOrInitialMapOffset)); |
+ return initial_map; |
+} |
+ |
+ |
HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize( |
HValue* length_node) { |
HValue* context = builder()->environment()->LookupContext(); |
@@ -2001,7 +2022,12 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, |
AddInstruction(new_object); |
// Fill in the fields: map, properties, length |
- HValue* map = EmitMapCode(context); |
+ HValue* map; |
+ if (constructor_function_ != NULL) { |
+ map = InternalEmitMapCode(); |
+ } else { |
+ map = EmitMapCode(context); |
+ } |
elements_location_ = builder()->BuildJSArrayHeader(new_object, |
map, |
mode_, |