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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // we should never hit this case. | 463 // we should never hit this case. |
464 ASSERT(to_add <= (Smi::kMaxValue - len)); | 464 ASSERT(to_add <= (Smi::kMaxValue - len)); |
465 | 465 |
466 int new_length = len + to_add; | 466 int new_length = len + to_add; |
467 | 467 |
468 Handle<FixedDoubleArray> new_elms; | 468 Handle<FixedDoubleArray> new_elms; |
469 | 469 |
470 if (new_length > elms_len) { | 470 if (new_length > elms_len) { |
471 // New backing storage is needed. | 471 // New backing storage is needed. |
472 int capacity = new_length + (new_length >> 1) + 16; | 472 int capacity = new_length + (new_length >> 1) + 16; |
473 new_elms = isolate->factory()->NewFixedDoubleArray(capacity); | 473 // Create new backing store; since capacity > 0, we can |
| 474 // safely cast to FixedDoubleArray. |
| 475 new_elms = Handle<FixedDoubleArray>::cast( |
| 476 isolate->factory()->NewFixedDoubleArray(capacity)); |
474 | 477 |
475 ElementsAccessor* accessor = array->GetElementsAccessor(); | 478 ElementsAccessor* accessor = array->GetElementsAccessor(); |
476 accessor->CopyElements( | 479 accessor->CopyElements( |
477 elms_obj, 0, kind, new_elms, 0, | 480 elms_obj, 0, kind, new_elms, 0, |
478 ElementsAccessor::kCopyToEndAndInitializeToHole); | 481 ElementsAccessor::kCopyToEndAndInitializeToHole); |
479 | 482 |
480 } else { | 483 } else { |
481 // to_add is > 0 and new_length <= elms_len, so elms_obj cannot be the | 484 // to_add is > 0 and new_length <= elms_len, so elms_obj cannot be the |
482 // empty_fixed_array. | 485 // empty_fixed_array. |
483 new_elms = Handle<FixedDoubleArray>::cast(elms_obj); | 486 new_elms = Handle<FixedDoubleArray>::cast(elms_obj); |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 } | 1737 } |
1735 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1738 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1736 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1739 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1737 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1740 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
1738 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1741 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1739 #undef DEFINE_BUILTIN_ACCESSOR_C | 1742 #undef DEFINE_BUILTIN_ACCESSOR_C |
1740 #undef DEFINE_BUILTIN_ACCESSOR_A | 1743 #undef DEFINE_BUILTIN_ACCESSOR_A |
1741 | 1744 |
1742 | 1745 |
1743 } } // namespace v8::internal | 1746 } } // namespace v8::internal |
OLD | NEW |