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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1460 |
1461 if (new_length == 0) { | 1461 if (new_length == 0) { |
1462 // If the length of a slow array is reset to zero, we clear | 1462 // If the length of a slow array is reset to zero, we clear |
1463 // the array and flush backing storage. This has the added | 1463 // the array and flush backing storage. This has the added |
1464 // benefit that the array returns to fast mode. | 1464 // benefit that the array returns to fast mode. |
1465 JSObject::ResetElements(array); | 1465 JSObject::ResetElements(array); |
1466 } else { | 1466 } else { |
1467 DisallowHeapAllocation no_gc; | 1467 DisallowHeapAllocation no_gc; |
1468 // Remove elements that should be deleted. | 1468 // Remove elements that should be deleted. |
1469 int removed_entries = 0; | 1469 int removed_entries = 0; |
1470 Object* the_hole_value = isolate->heap()->the_hole_value(); | 1470 Handle<Object> the_hole_value = isolate->factory()->the_hole_value(); |
1471 for (int i = 0; i < capacity; i++) { | 1471 for (int i = 0; i < capacity; i++) { |
1472 Object* key = dict->KeyAt(i); | 1472 Object* key = dict->KeyAt(i); |
1473 if (key->IsNumber()) { | 1473 if (key->IsNumber()) { |
1474 uint32_t number = static_cast<uint32_t>(key->Number()); | 1474 uint32_t number = static_cast<uint32_t>(key->Number()); |
1475 if (new_length <= number && number < old_length) { | 1475 if (new_length <= number && number < old_length) { |
1476 dict->SetEntry(i, the_hole_value, the_hole_value); | 1476 dict->SetEntry(i, the_hole_value, the_hole_value); |
1477 removed_entries++; | 1477 removed_entries++; |
1478 } | 1478 } |
1479 } | 1479 } |
1480 } | 1480 } |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 UNREACHABLE(); | 2014 UNREACHABLE(); |
2015 break; | 2015 break; |
2016 } | 2016 } |
2017 | 2017 |
2018 array->set_elements(*elms); | 2018 array->set_elements(*elms); |
2019 array->set_length(Smi::FromInt(number_of_elements)); | 2019 array->set_length(Smi::FromInt(number_of_elements)); |
2020 return array; | 2020 return array; |
2021 } | 2021 } |
2022 | 2022 |
2023 } } // namespace v8::internal | 2023 } } // namespace v8::internal |
OLD | NEW |