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 switch (mode) { | 1650 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
1651 case DONT_INITIALIZE_ARRAY_ELEMENTS: | 1651 elms = NewFixedDoubleArray(capacity); |
1652 elms = NewFixedDoubleArray(capacity); | 1652 } else { |
1653 break; | 1653 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
1654 case INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE: | 1654 elms = NewFixedDoubleArrayWithHoles(capacity); |
1655 elms = NewFixedDoubleArrayWithHoles(capacity); | |
1656 break; | |
1657 case INITIALIZE_ARRAY_ELEMENTS_WITH_UNDEFINED: | |
1658 UNREACHABLE(); | |
1659 break; | |
1660 } | 1655 } |
1661 } else { | 1656 } else { |
1662 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind)); | 1657 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind)); |
1663 switch (mode) { | 1658 if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) { |
1664 case DONT_INITIALIZE_ARRAY_ELEMENTS: | 1659 elms = NewUninitializedFixedArray(capacity); |
1665 elms = NewUninitializedFixedArray(capacity); | 1660 } else { |
1666 break; | 1661 DCHECK(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
1667 case INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE: | 1662 elms = NewFixedArrayWithHoles(capacity); |
1668 elms = NewFixedArrayWithHoles(capacity); | |
1669 break; | |
1670 case INITIALIZE_ARRAY_ELEMENTS_WITH_UNDEFINED: | |
1671 elms = NewFixedArray(capacity); | |
1672 break; | |
1673 } | 1663 } |
1674 } | 1664 } |
1675 | 1665 |
1676 array->set_elements(*elms); | 1666 array->set_elements(*elms); |
1677 array->set_length(Smi::FromInt(length)); | 1667 array->set_length(Smi::FromInt(length)); |
1678 } | 1668 } |
1679 | 1669 |
1680 | 1670 |
1681 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( | 1671 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
1682 Handle<JSFunction> function) { | 1672 Handle<JSFunction> function) { |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 } | 2378 } |
2389 | 2379 |
2390 | 2380 |
2391 Handle<Object> Factory::ToBoolean(bool value) { | 2381 Handle<Object> Factory::ToBoolean(bool value) { |
2392 return value ? true_value() : false_value(); | 2382 return value ? true_value() : false_value(); |
2393 } | 2383 } |
2394 | 2384 |
2395 | 2385 |
2396 } // namespace internal | 2386 } // namespace internal |
2397 } // namespace v8 | 2387 } // namespace v8 |
OLD | NEW |