OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 if (capacity == 0) { | 1640 if (capacity == 0) { |
1641 array->set_length(Smi::FromInt(0)); | 1641 array->set_length(Smi::FromInt(0)); |
1642 array->set_elements(*empty_fixed_array()); | 1642 array->set_elements(*empty_fixed_array()); |
1643 return; | 1643 return; |
1644 } | 1644 } |
1645 | 1645 |
1646 HandleScope inner_scope(isolate()); | 1646 HandleScope inner_scope(isolate()); |
1647 Handle<FixedArrayBase> elms; | 1647 Handle<FixedArrayBase> elms; |
1648 ElementsKind elements_kind = array->GetElementsKind(); | 1648 ElementsKind elements_kind = array->GetElementsKind(); |
1649 if (IsFastDoubleElementsKind(elements_kind)) { | 1649 if (IsFastDoubleElementsKind(elements_kind)) { |
1650 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 1650 switch (mode) { |
1651 elms = NewFixedDoubleArray(capacity); | 1651 case DONT_INITIALIZE_ARRAY_ELEMENTS: |
1652 } else { | 1652 elms = NewFixedDoubleArray(capacity); |
1653 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 1653 break; |
1654 elms = NewFixedDoubleArrayWithHoles(capacity); | 1654 case INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE: |
| 1655 elms = NewFixedDoubleArrayWithHoles(capacity); |
| 1656 break; |
| 1657 case INITIALIZE_ARRAY_ELEMENTS_WITH_UNDEFINED: |
| 1658 UNREACHABLE(); |
| 1659 break; |
1655 } | 1660 } |
1656 } else { | 1661 } else { |
1657 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind)); | 1662 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind)); |
1658 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { | 1663 switch (mode) { |
1659 elms = NewUninitializedFixedArray(capacity); | 1664 case DONT_INITIALIZE_ARRAY_ELEMENTS: |
1660 } else { | 1665 elms = NewUninitializedFixedArray(capacity); |
1661 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 1666 break; |
1662 elms = NewFixedArrayWithHoles(capacity); | 1667 case INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE: |
| 1668 elms = NewFixedArrayWithHoles(capacity); |
| 1669 break; |
| 1670 case INITIALIZE_ARRAY_ELEMENTS_WITH_UNDEFINED: |
| 1671 elms = NewFixedArray(capacity); |
| 1672 break; |
1663 } | 1673 } |
1664 } | 1674 } |
1665 | 1675 |
1666 array->set_elements(*elms); | 1676 array->set_elements(*elms); |
1667 array->set_length(Smi::FromInt(length)); | 1677 array->set_length(Smi::FromInt(length)); |
1668 } | 1678 } |
1669 | 1679 |
1670 | 1680 |
1671 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( | 1681 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
1672 Handle<JSFunction> function) { | 1682 Handle<JSFunction> function) { |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 } | 2388 } |
2379 | 2389 |
2380 | 2390 |
2381 Handle<Object> Factory::ToBoolean(bool value) { | 2391 Handle<Object> Factory::ToBoolean(bool value) { |
2382 return value ? true_value() : false_value(); | 2392 return value ? true_value() : false_value(); |
2383 } | 2393 } |
2384 | 2394 |
2385 | 2395 |
2386 } // namespace internal | 2396 } // namespace internal |
2387 } // namespace v8 | 2397 } // namespace v8 |
OLD | NEW |