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 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 isolate()->heap()->AllocateJSObjectFromMap( | 1626 isolate()->heap()->AllocateJSObjectFromMap( |
1627 *map, | 1627 *map, |
1628 pretenure, | 1628 pretenure, |
1629 alloc_props, | 1629 alloc_props, |
1630 allocation_site.is_null() ? NULL : *allocation_site), | 1630 allocation_site.is_null() ? NULL : *allocation_site), |
1631 JSObject); | 1631 JSObject); |
1632 } | 1632 } |
1633 | 1633 |
1634 | 1634 |
1635 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1635 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
1636 ObjectStrength strength, | 1636 Strength strength, |
1637 PretenureFlag pretenure) { | 1637 PretenureFlag pretenure) { |
1638 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); | 1638 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); |
1639 if (map == nullptr) { | 1639 if (map == nullptr) { |
1640 DCHECK(strength == WEAK); | 1640 DCHECK(strength == Strength::WEAK); |
1641 Context* native_context = isolate()->context()->native_context(); | 1641 Context* native_context = isolate()->context()->native_context(); |
1642 JSFunction* array_function = native_context->array_function(); | 1642 JSFunction* array_function = native_context->array_function(); |
1643 map = array_function->initial_map(); | 1643 map = array_function->initial_map(); |
1644 } | 1644 } |
1645 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); | 1645 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); |
1646 } | 1646 } |
1647 | 1647 |
1648 | 1648 |
1649 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, | 1649 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, |
1650 int capacity, ObjectStrength strength, | 1650 int capacity, Strength strength, |
1651 ArrayStorageAllocationMode mode, | 1651 ArrayStorageAllocationMode mode, |
1652 PretenureFlag pretenure) { | 1652 PretenureFlag pretenure) { |
1653 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); | 1653 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1654 NewJSArrayStorage(array, length, capacity, mode); | 1654 NewJSArrayStorage(array, length, capacity, mode); |
1655 return array; | 1655 return array; |
1656 } | 1656 } |
1657 | 1657 |
1658 | 1658 |
1659 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, | 1659 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
1660 ElementsKind elements_kind, | 1660 ElementsKind elements_kind, |
1661 int length, | 1661 int length, Strength strength, |
1662 ObjectStrength strength, | |
1663 PretenureFlag pretenure) { | 1662 PretenureFlag pretenure) { |
1664 DCHECK(length <= elements->length()); | 1663 DCHECK(length <= elements->length()); |
1665 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); | 1664 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1666 | 1665 |
1667 array->set_elements(*elements); | 1666 array->set_elements(*elements); |
1668 array->set_length(Smi::FromInt(length)); | 1667 array->set_length(Smi::FromInt(length)); |
1669 JSObject::ValidateElements(array); | 1668 JSObject::ValidateElements(array); |
1670 return array; | 1669 return array; |
1671 } | 1670 } |
1672 | 1671 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2455 } | 2454 } |
2456 | 2455 |
2457 | 2456 |
2458 Handle<Object> Factory::ToBoolean(bool value) { | 2457 Handle<Object> Factory::ToBoolean(bool value) { |
2459 return value ? true_value() : false_value(); | 2458 return value ? true_value() : false_value(); |
2460 } | 2459 } |
2461 | 2460 |
2462 | 2461 |
2463 } // namespace internal | 2462 } // namespace internal |
2464 } // namespace v8 | 2463 } // namespace v8 |
OLD | NEW |