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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 cache->Update(descriptors, name, number); 2174 cache->Update(descriptors, name, number);
2175 } 2175 }
2176 if (number != DescriptorArray::kNotFound) { 2176 if (number != DescriptorArray::kNotFound) {
2177 result->DescriptorResult(holder, descriptors->GetDetails(number), number); 2177 result->DescriptorResult(holder, descriptors->GetDetails(number), number);
2178 } else { 2178 } else {
2179 result->NotFound(); 2179 result->NotFound();
2180 } 2180 }
2181 } 2181 }
2182 2182
2183 2183
2184 // If |map| is contained in |maps_list|, returns |map|; otherwise returns NULL. 2184 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) {
2185 static bool ContainsMap(MapList* maps_list, Map* map) { 2185 ASSERT(!map.is_null());
2186 for (int i = 0; i < maps_list->length(); ++i) { 2186 for (int i = 0; i < maps->length(); ++i) {
2187 if (maps_list->at(i) == map) return true; 2187 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true;
2188 } 2188 }
2189 return false; 2189 return false;
2190 } 2190 }
2191 2191
2192 2192
2193 Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) { 2193 template <class T>
2194 MapList raw_candidates(candidates->length()); 2194 static Handle<T> MaybeNull(T* p) {
2195 Map* result = FindTransitionedMap(UnwrapHandleList(&raw_candidates, 2195 if (p == NULL) return Handle<T>::null();
2196 candidates)); 2196 return Handle<T>(p);
2197 return (result == NULL) ? Handle<Map>::null() : Handle<Map>(result);
2198 } 2197 }
2199 2198
2200 2199
2201 Map* Map::FindTransitionedMap(MapList* candidates) { 2200 Handle<Map> Map::FindTransitionedMap(MapHandleList* candidates) {
2202 ElementsKind elms_kind = elements_kind(); 2201 ElementsKind elms_kind = elements_kind();
2203 if (elms_kind == FAST_DOUBLE_ELEMENTS) { 2202 if (elms_kind == FAST_DOUBLE_ELEMENTS) {
2204 bool dummy = true; 2203 bool dummy = true;
2205 Map* fast_map = LookupElementsTransitionMap(FAST_ELEMENTS, &dummy); 2204 Handle<Map> fast_map =
2206 if (fast_map == NULL) return NULL; 2205 MaybeNull(LookupElementsTransitionMap(FAST_ELEMENTS, &dummy));
2207 if (ContainsMap(candidates, fast_map)) return fast_map; 2206 if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
2208 return NULL; 2207 return fast_map;
2208 }
2209 return Handle<Map>::null();
2209 } 2210 }
2210 if (elms_kind == FAST_SMI_ONLY_ELEMENTS) { 2211 if (elms_kind == FAST_SMI_ONLY_ELEMENTS) {
2211 bool dummy = true; 2212 bool dummy = true;
2212 Map* double_map = LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &dummy); 2213 Handle<Map> double_map =
2214 MaybeNull(LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &dummy));
2213 // In the current implementation, if the DOUBLE map doesn't exist, the 2215 // In the current implementation, if the DOUBLE map doesn't exist, the
2214 // FAST map can't exist either. 2216 // FAST map can't exist either.
2215 if (double_map == NULL) return NULL; 2217 if (double_map.is_null()) return Handle<Map>::null();
2216 Map* fast_map = double_map->LookupElementsTransitionMap(FAST_ELEMENTS, 2218 Handle<Map> fast_map =
2217 &dummy); 2219 MaybeNull(double_map->LookupElementsTransitionMap(FAST_ELEMENTS,
2218 if (fast_map != NULL && ContainsMap(candidates, fast_map)) return fast_map; 2220 &dummy));
2221 if (!fast_map.is_null() && ContainsMap(candidates, fast_map)) {
2222 return fast_map;
2223 }
2219 if (ContainsMap(candidates, double_map)) return double_map; 2224 if (ContainsMap(candidates, double_map)) return double_map;
2220 } 2225 }
2221 return NULL; 2226 return Handle<Map>::null();
2222 } 2227 }
2223 2228
2224
2225 static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents, 2229 static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents,
2226 ElementsKind elements_kind) { 2230 ElementsKind elements_kind) {
2227 if (descriptor_contents->IsMap()) { 2231 if (descriptor_contents->IsMap()) {
2228 Map* map = Map::cast(descriptor_contents); 2232 Map* map = Map::cast(descriptor_contents);
2229 if (map->elements_kind() == elements_kind) { 2233 if (map->elements_kind() == elements_kind) {
2230 return map; 2234 return map;
2231 } 2235 }
2232 return NULL; 2236 return NULL;
2233 } 2237 }
2234 2238
(...skipping 10399 matching lines...) Expand 10 before | Expand all | Expand 10 after
12634 if (break_point_objects()->IsUndefined()) return 0; 12638 if (break_point_objects()->IsUndefined()) return 0;
12635 // Single break point. 12639 // Single break point.
12636 if (!break_point_objects()->IsFixedArray()) return 1; 12640 if (!break_point_objects()->IsFixedArray()) return 1;
12637 // Multiple break points. 12641 // Multiple break points.
12638 return FixedArray::cast(break_point_objects())->length(); 12642 return FixedArray::cast(break_point_objects())->length();
12639 } 12643 }
12640 #endif // ENABLE_DEBUGGER_SUPPORT 12644 #endif // ENABLE_DEBUGGER_SUPPORT
12641 12645
12642 12646
12643 } } // namespace v8::internal 12647 } } // namespace v8::internal
OLDNEW
« 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