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
This commit is contained in:
ulan@chromium.org 2011-10-24 13:45:19 +00:00
parent 9ad3058756
commit f630ff0c67
2 changed files with 31 additions and 27 deletions

View File

@ -4095,21 +4095,21 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
}
// Elements_kind transition support.
MapList transition_target(maps->length());
MapHandleList transition_target(maps->length());
// Collect possible transition targets.
MapList possible_transitioned_maps(maps->length());
MapHandleList 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);
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 =
Handle<Map> transitioned_map =
map->FindTransitionedMap(&possible_transitioned_maps);
transition_target.Add(transitioned_map);
}
@ -4119,9 +4119,9 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
for (int i = 0; i < maps->length(); ++i) {
Handle<Map> map = maps->at(i);
ASSERT(map->IsMap());
if (transition_target.at(i) != NULL) {
if (!transition_target.at(i).is_null()) {
object = AddInstruction(new(zone()) HTransitionElementsKind(
object, map, Handle<Map>(transition_target.at(i))));
object, map, transition_target.at(i)));
} else {
type_todo[map->elements_kind()] = true;
if (map->elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) {

View File

@ -2181,47 +2181,51 @@ void Map::LookupInDescriptors(JSObject* holder,
}
// If |map| is contained in |maps_list|, returns |map|; otherwise returns NULL.
static bool ContainsMap(MapList* maps_list, Map* map) {
for (int i = 0; i < maps_list->length(); ++i) {
if (maps_list->at(i) == map) return true;
static bool ContainsMap(MapHandleList* maps, Handle<Map> map) {
ASSERT(!map.is_null());
for (int i = 0; i < maps->length(); ++i) {
if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true;
}
return false;
}
Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) {
MapList raw_candidates(candidates->length());
Map* result = FindTransitionedMap(UnwrapHandleList(&raw_candidates,
candidates));
return (result == NULL) ? Handle<Map>::null() : Handle<Map>(result);
template <class T>
static Handle<T> MaybeNull(T* p) {
if (p == NULL) return Handle<T>::null();
return Handle<T>(p);
}
Map* Map::FindTransitionedMap(MapList* candidates) {
Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) {
ElementsKind elms_kind = elements_kind();
if (elms_kind == FAST_DOUBLE_ELEMENTS) {
bool dummy = true;
Map* fast_map = LookupElementsTransitionMap(FAST_ELEMENTS, &dummy);
if (fast_map == NULL) return NULL;
if (ContainsMap(candidates, fast_map)) return fast_map;
return NULL;
Handle<Map> fast_map =
MaybeNull(LookupElementsTransitionMap(FAST_ELEMENTS, &dummy));
if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
return fast_map;
}
return Handle<Map>::null();
}
if (elms_kind == FAST_SMI_ONLY_ELEMENTS) {
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
// FAST map can't exist either.
if (double_map == NULL) return NULL;
Map* fast_map = double_map->LookupElementsTransitionMap(FAST_ELEMENTS,
&dummy);
if (fast_map != NULL && ContainsMap(candidates, fast_map)) return fast_map;
if (double_map.is_null()) return Handle<Map>::null();
Handle<Map> fast_map =
MaybeNull(double_map->LookupElementsTransitionMap(FAST_ELEMENTS,
&dummy));
if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
return fast_map;
}
if (ContainsMap(candidates, double_map)) return double_map;
}
return NULL;
return Handle<Map>::null();
}
static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents,
ElementsKind elements_kind) {
if (descriptor_contents->IsMap()) {