Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 2d471cc294962012df6315462c24cc93101cda96..d68774ec3ba0c690896edf5fde66a617c77ba65e 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -4101,12 +4101,40 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, |
type_todo[i] = false; |
} |
+ // Elements_kind transition support. |
+ MapList transition_target(maps->length()); |
+ if (is_store) { |
+ // Collect possible transition targets. |
+ MapList possible_transitioned_maps(maps->length()); |
+ for (int i = 0; i < maps->length(); ++i) { |
+ Handle<Map> map = maps->at(i); |
+ ElementsKind elements_kind = map->elements_kind(); |
+ if (elements_kind == FAST_DOUBLE_ELEMENTS || |
+ elements_kind == FAST_ELEMENTS) { |
+ possible_transitioned_maps.Add(*map); |
+ } |
+ } |
+ // Get transition target for each map (NULL == no transition). |
+ for (int i = 0; i < maps->length(); ++i) { |
+ Handle<Map> map = maps->at(i); |
+ Map* transitioned_map = |
+ map->FindTransitionedMap(&possible_transitioned_maps); |
+ transition_target.Add(transitioned_map); |
+ } |
+ } |
+ |
for (int i = 0; i < maps->length(); ++i) { |
- ASSERT(maps->at(i)->IsMap()); |
- type_todo[maps->at(i)->elements_kind()] = true; |
- if (maps->at(i)->elements_kind() |
- >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { |
- todo_external_array = true; |
+ Handle<Map> map = maps->at(i); |
+ ASSERT(map->IsMap()); |
+ ASSERT(!is_store || (transition_target.length() == maps->length())); |
+ if (is_store && transition_target.at(i) != NULL) { |
+ object = AddInstruction(new(zone()) HTransitionElementsKind( |
+ object, map, Handle<Map>(transition_target.at(i)))); |
+ } else { |
+ type_todo[map->elements_kind()] = true; |
+ if (map->elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { |
+ todo_external_array = true; |
+ } |
} |
} |