Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: src/objects.cc

Issue 8373030: Use handle lists in Map::FindTransitionedMap. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 8db40f098b7cd1ef6e43ec2e014538fb4aa762b6..11e2d4de606825898dffeb8b556f3d78c53cb437 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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()) {
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698