| 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 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 isolate()->heap()->AllocateJSObjectFromMap( | 1630 isolate()->heap()->AllocateJSObjectFromMap( |
| 1631 *map, | 1631 *map, |
| 1632 pretenure, | 1632 pretenure, |
| 1633 alloc_props, | 1633 alloc_props, |
| 1634 allocation_site.is_null() ? NULL : *allocation_site), | 1634 allocation_site.is_null() ? NULL : *allocation_site), |
| 1635 JSObject); | 1635 JSObject); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 | 1638 |
| 1639 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1639 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
| 1640 ObjectStrength strength, |
| 1640 PretenureFlag pretenure) { | 1641 PretenureFlag pretenure) { |
| 1641 Context* native_context = isolate()->context()->native_context(); | 1642 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); |
| 1642 JSFunction* array_function = native_context->array_function(); | 1643 if (map == nullptr) { |
| 1643 Map* map = array_function->initial_map(); | 1644 DCHECK(strength == WEAK); |
| 1644 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind); | 1645 Context* native_context = isolate()->context()->native_context(); |
| 1645 if (transition_map != NULL) map = transition_map; | 1646 JSFunction* array_function = native_context->array_function(); |
| 1647 map = array_function->initial_map(); |
| 1648 } |
| 1646 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); | 1649 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); |
| 1647 } | 1650 } |
| 1648 | 1651 |
| 1649 | 1652 |
| 1650 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1653 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, |
| 1651 int length, | 1654 int capacity, ObjectStrength strength, |
| 1652 int capacity, | |
| 1653 ArrayStorageAllocationMode mode, | 1655 ArrayStorageAllocationMode mode, |
| 1654 PretenureFlag pretenure) { | 1656 PretenureFlag pretenure) { |
| 1655 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); | 1657 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
| 1656 NewJSArrayStorage(array, length, capacity, mode); | 1658 NewJSArrayStorage(array, length, capacity, mode); |
| 1657 return array; | 1659 return array; |
| 1658 } | 1660 } |
| 1659 | 1661 |
| 1660 | 1662 |
| 1661 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, | 1663 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
| 1662 ElementsKind elements_kind, | 1664 ElementsKind elements_kind, |
| 1663 int length, | 1665 int length, |
| 1666 ObjectStrength strength, |
| 1664 PretenureFlag pretenure) { | 1667 PretenureFlag pretenure) { |
| 1665 DCHECK(length <= elements->length()); | 1668 DCHECK(length <= elements->length()); |
| 1666 Handle<JSArray> array = NewJSArray(elements_kind, pretenure); | 1669 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
| 1667 | 1670 |
| 1668 array->set_elements(*elements); | 1671 array->set_elements(*elements); |
| 1669 array->set_length(Smi::FromInt(length)); | 1672 array->set_length(Smi::FromInt(length)); |
| 1670 JSObject::ValidateElements(array); | 1673 JSObject::ValidateElements(array); |
| 1671 return array; | 1674 return array; |
| 1672 } | 1675 } |
| 1673 | 1676 |
| 1674 | 1677 |
| 1675 void Factory::NewJSArrayStorage(Handle<JSArray> array, | 1678 void Factory::NewJSArrayStorage(Handle<JSArray> array, |
| 1676 int length, | 1679 int length, |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2464 return Handle<Object>::null(); | 2467 return Handle<Object>::null(); |
| 2465 } | 2468 } |
| 2466 | 2469 |
| 2467 | 2470 |
| 2468 Handle<Object> Factory::ToBoolean(bool value) { | 2471 Handle<Object> Factory::ToBoolean(bool value) { |
| 2469 return value ? true_value() : false_value(); | 2472 return value ? true_value() : false_value(); |
| 2470 } | 2473 } |
| 2471 | 2474 |
| 2472 | 2475 |
| 2473 } } // namespace v8::internal | 2476 } } // namespace v8::internal |
| OLD | NEW |