Commit f630ff0c authored by ulan@chromium.org's avatar ulan@chromium.org

Use handle lists in Map::FindTransitionedMap.

BUG=
TEST=

Review URL: http://codereview.chromium.org/8373030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9757 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9ad30587
...@@ -4095,21 +4095,21 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, ...@@ -4095,21 +4095,21 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
} }
// Elements_kind transition support. // Elements_kind transition support.
MapList transition_target(maps->length()); MapHandleList transition_target(maps->length());
// Collect possible transition targets. // Collect possible transition targets.
MapList possible_transitioned_maps(maps->length()); MapHandleList possible_transitioned_maps(maps->length());
for (int i = 0; i < maps->length(); ++i) { for (int i = 0; i < maps->length(); ++i) {
Handle<Map> map = maps->at(i); Handle<Map> map = maps->at(i);
ElementsKind elements_kind = map->elements_kind(); ElementsKind elements_kind = map->elements_kind();
if (elements_kind == FAST_DOUBLE_ELEMENTS || if (elements_kind == FAST_DOUBLE_ELEMENTS ||
elements_kind == FAST_ELEMENTS) { elements_kind == FAST_ELEMENTS) {
possible_transitioned_maps.Add(*map); possible_transitioned_maps.Add(map);
} }
} }
// Get transition target for each map (NULL == no transition). // Get transition target for each map (NULL == no transition).
for (int i = 0; i < maps->length(); ++i) { for (int i = 0; i < maps->length(); ++i) {
Handle<Map> map = maps->at(i); Handle<Map> map = maps->at(i);
Map* transitioned_map = Handle<Map> transitioned_map =
map->FindTransitionedMap(&possible_transitioned_maps); map->FindTransitionedMap(&possible_transitioned_maps);
transition_target.Add(transitioned_map); transition_target.Add(transitioned_map);
} }
...@@ -4119,9 +4119,9 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, ...@@ -4119,9 +4119,9 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
for (int i = 0; i < maps->length(); ++i) { for (int i = 0; i < maps->length(); ++i) {
Handle<Map> map = maps->at(i); Handle<Map> map = maps->at(i);
ASSERT(map->IsMap()); ASSERT(map->IsMap());
if (transition_target.at(i) != NULL) { if (!transition_target.at(i).is_null()) {
object = AddInstruction(new(zone()) HTransitionElementsKind( object = AddInstruction(new(zone()) HTransitionElementsKind(
object, map, Handle<Map>(transition_target.at(i)))); object, map, transition_target.at(i)));
} else { } else {
type_todo[map->elements_kind()] = true; type_todo[map->elements_kind()] = true;
if (map->elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { if (map->elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) {
......
...@@ -2181,47 +2181,51 @@ void Map::LookupInDescriptors(JSObject* holder, ...@@ -2181,47 +2181,51 @@ void Map::LookupInDescriptors(JSObject* holder,
} }
// If |map| is contained in |maps_list|, returns |map|; otherwise returns NULL. static bool ContainsMap(MapHandleList* maps, Handle<Map> map) {
static bool ContainsMap(MapList* maps_list, Map* map) { ASSERT(!map.is_null());
for (int i = 0; i < maps_list->length(); ++i) { for (int i = 0; i < maps->length(); ++i) {
if (maps_list->at(i) == map) return true; if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true;
} }
return false; return false;
} }
Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) { template <class T>
MapList raw_candidates(candidates->length()); static Handle<T> MaybeNull(T* p) {
Map* result = FindTransitionedMap(UnwrapHandleList(&raw_candidates, if (p == NULL) return Handle<T>::null();
candidates)); return Handle<T>(p);
return (result == NULL) ? Handle<Map>::null() : Handle<Map>(result);
} }
Map* Map::FindTransitionedMap(MapList* candidates) { Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) {
ElementsKind elms_kind = elements_kind(); ElementsKind elms_kind = elements_kind();
if (elms_kind == FAST_DOUBLE_ELEMENTS) { if (elms_kind == FAST_DOUBLE_ELEMENTS) {
bool dummy = true; bool dummy = true;
Map* fast_map = LookupElementsTransitionMap(FAST_ELEMENTS, &dummy); Handle<Map> fast_map =
if (fast_map == NULL) return NULL; MaybeNull(LookupElementsTransitionMap(FAST_ELEMENTS, &dummy));
if (ContainsMap(candidates, fast_map)) return fast_map; if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
return NULL; return fast_map;
}
return Handle<Map>::null();
} }
if (elms_kind == FAST_SMI_ONLY_ELEMENTS) { if (elms_kind == FAST_SMI_ONLY_ELEMENTS) {
bool dummy = true; bool dummy = true;
Map* double_map = LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &dummy); Handle<Map> double_map =
MaybeNull(LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &dummy));
// In the current implementation, if the DOUBLE map doesn't exist, the // In the current implementation, if the DOUBLE map doesn't exist, the
// FAST map can't exist either. // FAST map can't exist either.
if (double_map == NULL) return NULL; if (double_map.is_null()) return Handle<Map>::null();
Map* fast_map = double_map->LookupElementsTransitionMap(FAST_ELEMENTS, Handle<Map> fast_map =
&dummy); MaybeNull(double_map->LookupElementsTransitionMap(FAST_ELEMENTS,
if (fast_map != NULL && ContainsMap(candidates, fast_map)) return fast_map; &dummy));
if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
return fast_map;
}
if (ContainsMap(candidates, double_map)) return double_map; if (ContainsMap(candidates, double_map)) return double_map;
} }
return NULL; return Handle<Map>::null();
} }
static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents, static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents,
ElementsKind elements_kind) { ElementsKind elements_kind) {
if (descriptor_contents->IsMap()) { if (descriptor_contents->IsMap()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment