OLD | NEW |
---|---|
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 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2078 cache->Update(descriptors, name, number); | 2078 cache->Update(descriptors, name, number); |
2079 } | 2079 } |
2080 if (number != DescriptorArray::kNotFound) { | 2080 if (number != DescriptorArray::kNotFound) { |
2081 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 2081 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
2082 } else { | 2082 } else { |
2083 result->NotFound(); | 2083 result->NotFound(); |
2084 } | 2084 } |
2085 } | 2085 } |
2086 | 2086 |
2087 | 2087 |
2088 // If |map| is contained in |maps_list|, returns |map|; otherwise returns NULL. | |
2089 Map* GetMapIfPresent(Map* map, MapList* maps_list) { | |
2090 for (int i = 0; i < maps_list->length(); ++i) { | |
2091 if (maps_list->at(i) == map) return map; | |
2092 } | |
2093 return NULL; | |
2094 } | |
2095 | |
2096 | |
2097 Map* Map::FindTransitionedMap(MapList* candidates) { | |
2098 ElementsKind elms_kind = elements_kind(); | |
2099 if (elms_kind == FAST_DOUBLE_ELEMENTS) { | |
2100 bool dummy = true; | |
2101 Map* fast_map = LookupElementsTransitionMap(FAST_ELEMENTS, &dummy); | |
2102 if (fast_map == NULL) return NULL; | |
2103 return GetMapIfPresent(fast_map, candidates); | |
danno
2011/10/17 12:36:05
I think it might be clearer is you re-wrote GetMap
Jakob Kummerow
2011/10/18 08:13:09
Done.
| |
2104 } | |
2105 if (elms_kind == FAST_SMI_ONLY_ELEMENTS) { | |
2106 bool dummy = true; | |
2107 Map* double_map = LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &dummy); | |
2108 // In the current implementation, if the DOUBLE map doesn't exist, the | |
2109 // FAST map can't exist either. | |
2110 if (double_map == NULL) return NULL; | |
2111 Map* fast_map = double_map->LookupElementsTransitionMap(FAST_ELEMENTS, | |
2112 &dummy); | |
2113 if (fast_map == NULL) { | |
2114 return GetMapIfPresent(double_map, candidates); | |
2115 } | |
2116 // Both double_map and fast_map are non-NULL. Return fast_map if it's in | |
2117 // maps_list, double_map otherwise. | |
2118 Map* fast_map_present = GetMapIfPresent(fast_map, candidates); | |
2119 if (fast_map_present != NULL) return fast_map_present; | |
danno
2011/10/17 12:36:05
fast_map_present is the same as fast_map, except a
Jakob Kummerow
2011/10/18 08:13:09
Done.
| |
2120 return GetMapIfPresent(double_map, candidates); | |
2121 } | |
2122 return NULL; | |
2123 } | |
2124 | |
2125 | |
2088 static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents, | 2126 static Map* GetElementsTransitionMapFromDescriptor(Object* descriptor_contents, |
2089 ElementsKind elements_kind) { | 2127 ElementsKind elements_kind) { |
2090 if (descriptor_contents->IsMap()) { | 2128 if (descriptor_contents->IsMap()) { |
2091 Map* map = Map::cast(descriptor_contents); | 2129 Map* map = Map::cast(descriptor_contents); |
2092 if (map->elements_kind() == elements_kind) { | 2130 if (map->elements_kind() == elements_kind) { |
2093 return map; | 2131 return map; |
2094 } | 2132 } |
2095 return NULL; | 2133 return NULL; |
2096 } | 2134 } |
2097 | 2135 |
(...skipping 7208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9306 } | 9344 } |
9307 } | 9345 } |
9308 } | 9346 } |
9309 // All possible cases have been handled above. Add a return to avoid the | 9347 // All possible cases have been handled above. Add a return to avoid the |
9310 // complaints from the compiler. | 9348 // complaints from the compiler. |
9311 UNREACHABLE(); | 9349 UNREACHABLE(); |
9312 return isolate->heap()->null_value(); | 9350 return isolate->heap()->null_value(); |
9313 } | 9351 } |
9314 | 9352 |
9315 | 9353 |
9354 MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind( | |
9355 ElementsKind to_kind) { | |
9356 ElementsKind from_kind = map()->elements_kind(); | |
9357 if (from_kind == FAST_SMI_ONLY_ELEMENTS) { | |
9358 FixedArray* elms = FixedArray::cast(elements()); | |
9359 uint32_t capacity = static_cast<uint32_t>(elms->length()); | |
9360 uint32_t length = capacity; | |
9361 if (IsJSArray()) { | |
9362 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&length)); | |
9363 } | |
9364 if (to_kind == FAST_DOUBLE_ELEMENTS) { | |
9365 return SetFastDoubleElementsCapacityAndLength(capacity, length); | |
9366 } else if (to_kind == FAST_ELEMENTS) { | |
9367 MaybeObject* maybe_new_map = GetElementsTransitionMap(FAST_ELEMENTS); | |
9368 Map* new_map; | |
9369 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | |
9370 set_map(new_map); | |
9371 return this; | |
9372 } | |
9373 } else if (from_kind == FAST_DOUBLE_ELEMENTS && to_kind == FAST_ELEMENTS) { | |
9374 FixedDoubleArray* elms = FixedDoubleArray::cast(elements()); | |
9375 uint32_t capacity = static_cast<uint32_t>(elms->length()); | |
9376 uint32_t length = capacity; | |
9377 if (IsJSArray()) { | |
9378 CHECK(JSArray::cast(this)->length()->ToArrayIndex(&length)); | |
9379 } | |
9380 return SetFastElementsCapacityAndLength( | |
9381 capacity, length, kDontAllowSmiOnlyElements); | |
9382 } | |
danno
2011/10/17 12:36:05
This code should be unreachable, right? Perhaps an
Jakob Kummerow
2011/10/18 08:13:09
This should indeed be unreachable, but we have mjs
| |
9383 return Failure::Exception(); | |
danno
2011/10/17 12:36:05
Is returning an exception failure really OK? Does
Jakob Kummerow
2011/10/18 08:13:09
Returning Failure::Exception is the way other meth
| |
9384 } | |
9385 | |
9386 | |
9316 MaybeObject* JSArray::JSArrayUpdateLengthFromIndex(uint32_t index, | 9387 MaybeObject* JSArray::JSArrayUpdateLengthFromIndex(uint32_t index, |
9317 Object* value) { | 9388 Object* value) { |
9318 uint32_t old_len = 0; | 9389 uint32_t old_len = 0; |
9319 CHECK(length()->ToArrayIndex(&old_len)); | 9390 CHECK(length()->ToArrayIndex(&old_len)); |
9320 // Check to see if we need to update the length. For now, we make | 9391 // Check to see if we need to update the length. For now, we make |
9321 // sure that the length stays within 32-bits (unsigned). | 9392 // sure that the length stays within 32-bits (unsigned). |
9322 if (index >= old_len && index != 0xffffffff) { | 9393 if (index >= old_len && index != 0xffffffff) { |
9323 Object* len; | 9394 Object* len; |
9324 { MaybeObject* maybe_len = | 9395 { MaybeObject* maybe_len = |
9325 GetHeap()->NumberFromDouble(static_cast<double>(index) + 1); | 9396 GetHeap()->NumberFromDouble(static_cast<double>(index) + 1); |
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12248 if (break_point_objects()->IsUndefined()) return 0; | 12319 if (break_point_objects()->IsUndefined()) return 0; |
12249 // Single break point. | 12320 // Single break point. |
12250 if (!break_point_objects()->IsFixedArray()) return 1; | 12321 if (!break_point_objects()->IsFixedArray()) return 1; |
12251 // Multiple break points. | 12322 // Multiple break points. |
12252 return FixedArray::cast(break_point_objects())->length(); | 12323 return FixedArray::cast(break_point_objects())->length(); |
12253 } | 12324 } |
12254 #endif // ENABLE_DEBUGGER_SUPPORT | 12325 #endif // ENABLE_DEBUGGER_SUPPORT |
12255 | 12326 |
12256 | 12327 |
12257 } } // namespace v8::internal | 12328 } } // namespace v8::internal |
OLD | NEW |