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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 | 131 |
132 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) { | 132 Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) { |
133 DCHECK(0 <= size); | 133 DCHECK(0 <= size); |
134 CALL_HEAP_FUNCTION( | 134 CALL_HEAP_FUNCTION( |
135 isolate(), | 135 isolate(), |
136 isolate()->heap()->AllocateFixedArray(size, pretenure), | 136 isolate()->heap()->AllocateFixedArray(size, pretenure), |
137 FixedArray); | 137 FixedArray); |
138 } | 138 } |
139 | 139 |
| 140 MaybeHandle<FixedArray> Factory::TryNewFixedArray(int size, |
| 141 PretenureFlag pretenure) { |
| 142 DCHECK(0 <= size); |
| 143 AllocationResult allocation = |
| 144 isolate()->heap()->AllocateFixedArray(size, pretenure); |
| 145 Object* array = NULL; |
| 146 if (!allocation.To(&array)) return MaybeHandle<FixedArray>(); |
| 147 return Handle<FixedArray>(FixedArray::cast(array), isolate()); |
| 148 } |
140 | 149 |
141 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, | 150 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, |
142 PretenureFlag pretenure) { | 151 PretenureFlag pretenure) { |
143 DCHECK(0 <= size); | 152 DCHECK(0 <= size); |
144 CALL_HEAP_FUNCTION( | 153 CALL_HEAP_FUNCTION( |
145 isolate(), | 154 isolate(), |
146 isolate()->heap()->AllocateFixedArrayWithFiller(size, | 155 isolate()->heap()->AllocateFixedArrayWithFiller(size, |
147 pretenure, | 156 pretenure, |
148 *the_hole_value()), | 157 *the_hole_value()), |
149 FixedArray); | 158 FixedArray); |
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); | 2716 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
2708 iterator->set_initial_next(*next); | 2717 iterator->set_initial_next(*next); |
2709 iterator->set_array(*array); | 2718 iterator->set_array(*array); |
2710 iterator->set_index(0); | 2719 iterator->set_index(0); |
2711 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); | 2720 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
2712 return iterator; | 2721 return iterator; |
2713 } | 2722 } |
2714 | 2723 |
2715 } // namespace internal | 2724 } // namespace internal |
2716 } // namespace v8 | 2725 } // namespace v8 |
OLD | NEW |