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 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 isolate()->heap()->AllocateJSObjectFromMap( | 1625 isolate()->heap()->AllocateJSObjectFromMap( |
1626 *map, | 1626 *map, |
1627 pretenure, | 1627 pretenure, |
1628 alloc_props, | 1628 alloc_props, |
1629 allocation_site.is_null() ? NULL : *allocation_site), | 1629 allocation_site.is_null() ? NULL : *allocation_site), |
1630 JSObject); | 1630 JSObject); |
1631 } | 1631 } |
1632 | 1632 |
1633 | 1633 |
1634 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1634 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
| 1635 ObjectStrength strength, |
1635 PretenureFlag pretenure) { | 1636 PretenureFlag pretenure) { |
1636 Context* native_context = isolate()->context()->native_context(); | 1637 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); |
1637 JSFunction* array_function = native_context->array_function(); | 1638 if (map == nullptr) { |
1638 Map* map = array_function->initial_map(); | 1639 DCHECK(strength == WEAK); |
1639 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind); | 1640 Context* native_context = isolate()->context()->native_context(); |
1640 if (transition_map != NULL) map = transition_map; | 1641 JSFunction* array_function = native_context->array_function(); |
| 1642 map = array_function->initial_map(); |
| 1643 } |
1641 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); | 1644 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); |
1642 } | 1645 } |
1643 | 1646 |
1644 | 1647 |
1645 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1648 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
1646 int length, | 1649 int length, |
1647 int capacity, | 1650 int capacity, |
| 1651 ObjectStrength strength, |
1648 ArrayStorageAllocationMode mode, | 1652 ArrayStorageAllocationMode mode, |
1649 PretenureFlag pretenure) { | 1653 PretenureFlag pretenure) { |
1650 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); | 1654 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1651 NewJSArrayStorage(array, length, capacity, mode); | 1655 NewJSArrayStorage(array, length, capacity, mode); |
1652 return array; | 1656 return array; |
1653 } | 1657 } |
1654 | 1658 |
1655 | 1659 |
1656 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, | 1660 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
1657 ElementsKind elements_kind, | 1661 ElementsKind elements_kind, |
1658 int length, | 1662 int length, |
| 1663 ObjectStrength strength, |
1659 PretenureFlag pretenure) { | 1664 PretenureFlag pretenure) { |
1660 DCHECK(length <= elements->length()); | 1665 DCHECK(length <= elements->length()); |
1661 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); | 1666 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1662 | 1667 |
1663 array->set_elements(*elements); | 1668 array->set_elements(*elements); |
1664 array->set_length(Smi::FromInt(length)); | 1669 array->set_length(Smi::FromInt(length)); |
1665 JSObject::ValidateElements(array); | 1670 JSObject::ValidateElements(array); |
1666 return array; | 1671 return array; |
1667 } | 1672 } |
1668 | 1673 |
1669 | 1674 |
1670 void Factory::NewJSArrayStorage(Handle<JSArray> array, | 1675 void Factory::NewJSArrayStorage(Handle<JSArray> array, |
1671 int length, | 1676 int length, |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 return Handle<Object>::null(); | 2445 return Handle<Object>::null(); |
2441 } | 2446 } |
2442 | 2447 |
2443 | 2448 |
2444 Handle<Object> Factory::ToBoolean(bool value) { | 2449 Handle<Object> Factory::ToBoolean(bool value) { |
2445 return value ? true_value() : false_value(); | 2450 return value ? true_value() : false_value(); |
2446 } | 2451 } |
2447 | 2452 |
2448 | 2453 |
2449 } } // namespace v8::internal | 2454 } } // namespace v8::internal |
OLD | NEW |