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 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 isolate()->heap()->AllocateJSObjectFromMap( | 1602 isolate()->heap()->AllocateJSObjectFromMap( |
1603 *map, | 1603 *map, |
1604 pretenure, | 1604 pretenure, |
1605 alloc_props, | 1605 alloc_props, |
1606 allocation_site.is_null() ? NULL : *allocation_site), | 1606 allocation_site.is_null() ? NULL : *allocation_site), |
1607 JSObject); | 1607 JSObject); |
1608 } | 1608 } |
1609 | 1609 |
1610 | 1610 |
1611 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, | 1611 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, |
1612 ObjectStrength strength, | 1612 Strength strength, |
1613 PretenureFlag pretenure) { | 1613 PretenureFlag pretenure) { |
1614 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); | 1614 Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); |
1615 if (map == nullptr) { | 1615 if (map == nullptr) { |
1616 DCHECK(strength == WEAK); | 1616 DCHECK(strength == Strength::WEAK); |
1617 Context* native_context = isolate()->context()->native_context(); | 1617 Context* native_context = isolate()->context()->native_context(); |
1618 JSFunction* array_function = native_context->array_function(); | 1618 JSFunction* array_function = native_context->array_function(); |
1619 map = array_function->initial_map(); | 1619 map = array_function->initial_map(); |
1620 } | 1620 } |
1621 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); | 1621 return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); |
1622 } | 1622 } |
1623 | 1623 |
1624 | 1624 |
1625 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, | 1625 Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, |
1626 int capacity, ObjectStrength strength, | 1626 int capacity, Strength strength, |
1627 ArrayStorageAllocationMode mode, | 1627 ArrayStorageAllocationMode mode, |
1628 PretenureFlag pretenure) { | 1628 PretenureFlag pretenure) { |
1629 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); | 1629 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1630 NewJSArrayStorage(array, length, capacity, mode); | 1630 NewJSArrayStorage(array, length, capacity, mode); |
1631 return array; | 1631 return array; |
1632 } | 1632 } |
1633 | 1633 |
1634 | 1634 |
1635 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, | 1635 Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
1636 ElementsKind elements_kind, | 1636 ElementsKind elements_kind, |
1637 int length, | 1637 int length, Strength strength, |
1638 ObjectStrength strength, | |
1639 PretenureFlag pretenure) { | 1638 PretenureFlag pretenure) { |
1640 DCHECK(length <= elements->length()); | 1639 DCHECK(length <= elements->length()); |
1641 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); | 1640 Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); |
1642 | 1641 |
1643 array->set_elements(*elements); | 1642 array->set_elements(*elements); |
1644 array->set_length(Smi::FromInt(length)); | 1643 array->set_length(Smi::FromInt(length)); |
1645 JSObject::ValidateElements(array); | 1644 JSObject::ValidateElements(array); |
1646 return array; | 1645 return array; |
1647 } | 1646 } |
1648 | 1647 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 } | 2430 } |
2432 | 2431 |
2433 | 2432 |
2434 Handle<Object> Factory::ToBoolean(bool value) { | 2433 Handle<Object> Factory::ToBoolean(bool value) { |
2435 return value ? true_value() : false_value(); | 2434 return value ? true_value() : false_value(); |
2436 } | 2435 } |
2437 | 2436 |
2438 | 2437 |
2439 } // namespace internal | 2438 } // namespace internal |
2440 } // namespace v8 | 2439 } // namespace v8 |
OLD | NEW |