| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 MaybeObject* JSObject::EnsureCanContainElements(Object** objects, | 1260 MaybeObject* JSObject::EnsureCanContainElements(Object** objects, |
| 1261 uint32_t count, | 1261 uint32_t count, |
| 1262 EnsureElementsMode mode) { | 1262 EnsureElementsMode mode) { |
| 1263 ElementsKind current_kind = map()->elements_kind(); | 1263 ElementsKind current_kind = map()->elements_kind(); |
| 1264 ElementsKind target_kind = current_kind; | 1264 ElementsKind target_kind = current_kind; |
| 1265 ASSERT(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); | 1265 ASSERT(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); |
| 1266 bool is_holey = IsFastHoleyElementsKind(current_kind); | 1266 bool is_holey = IsFastHoleyElementsKind(current_kind); |
| 1267 if (current_kind == FAST_HOLEY_ELEMENTS) return this; | 1267 if (current_kind == FAST_HOLEY_ELEMENTS) return this; |
| 1268 Heap* heap = GetHeap(); | 1268 Heap* heap = GetHeap(); |
| 1269 Object* the_hole = heap->the_hole_value(); | 1269 Object* the_hole = heap->the_hole_value(); |
| 1270 Object* heap_number_map = heap->heap_number_map(); | |
| 1271 for (uint32_t i = 0; i < count; ++i) { | 1270 for (uint32_t i = 0; i < count; ++i) { |
| 1272 Object* current = *objects++; | 1271 Object* current = *objects++; |
| 1273 if (current == the_hole) { | 1272 if (current == the_hole) { |
| 1274 is_holey = true; | 1273 is_holey = true; |
| 1275 target_kind = GetHoleyElementsKind(target_kind); | 1274 target_kind = GetHoleyElementsKind(target_kind); |
| 1276 } else if (!current->IsSmi()) { | 1275 } else if (!current->IsSmi()) { |
| 1277 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && | 1276 if (mode == ALLOW_CONVERTED_DOUBLE_ELEMENTS && current->IsNumber()) { |
| 1278 HeapObject::cast(current)->map() == heap_number_map && | 1277 if (IsFastSmiElementsKind(target_kind)) { |
| 1279 IsFastSmiElementsKind(target_kind)) { | |
| 1280 if (is_holey) { | |
| 1281 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS; | |
| 1282 } else { | |
| 1283 target_kind = FAST_DOUBLE_ELEMENTS; | |
| 1284 } | |
| 1285 } else { | |
| 1286 if (!current->IsNumber()) { | |
| 1287 if (is_holey) { | 1278 if (is_holey) { |
| 1288 target_kind = FAST_HOLEY_ELEMENTS; | 1279 target_kind = FAST_HOLEY_DOUBLE_ELEMENTS; |
| 1289 break; | |
| 1290 } else { | 1280 } else { |
| 1291 target_kind = FAST_ELEMENTS; | 1281 target_kind = FAST_DOUBLE_ELEMENTS; |
| 1292 } | 1282 } |
| 1293 } | 1283 } |
| 1284 } else if (is_holey) { |
| 1285 target_kind = FAST_HOLEY_ELEMENTS; |
| 1286 break; |
| 1287 } else { |
| 1288 target_kind = FAST_ELEMENTS; |
| 1294 } | 1289 } |
| 1295 } | 1290 } |
| 1296 } | 1291 } |
| 1297 | 1292 |
| 1298 if (target_kind != current_kind) { | 1293 if (target_kind != current_kind) { |
| 1299 return TransitionElementsKind(target_kind); | 1294 return TransitionElementsKind(target_kind); |
| 1300 } | 1295 } |
| 1301 return this; | 1296 return this; |
| 1302 } | 1297 } |
| 1303 | 1298 |
| (...skipping 3789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5093 #undef WRITE_UINT32_FIELD | 5088 #undef WRITE_UINT32_FIELD |
| 5094 #undef READ_SHORT_FIELD | 5089 #undef READ_SHORT_FIELD |
| 5095 #undef WRITE_SHORT_FIELD | 5090 #undef WRITE_SHORT_FIELD |
| 5096 #undef READ_BYTE_FIELD | 5091 #undef READ_BYTE_FIELD |
| 5097 #undef WRITE_BYTE_FIELD | 5092 #undef WRITE_BYTE_FIELD |
| 5098 | 5093 |
| 5099 | 5094 |
| 5100 } } // namespace v8::internal | 5095 } } // namespace v8::internal |
| 5101 | 5096 |
| 5102 #endif // V8_OBJECTS_INL_H_ | 5097 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |