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/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 FixedArray); | 178 FixedArray); |
179 } | 179 } |
180 | 180 |
181 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) { | 181 Handle<FixedArray> Factory::NewUninitializedFixedArray(int size) { |
182 CALL_HEAP_FUNCTION( | 182 CALL_HEAP_FUNCTION( |
183 isolate(), | 183 isolate(), |
184 isolate()->heap()->AllocateUninitializedFixedArray(size), | 184 isolate()->heap()->AllocateUninitializedFixedArray(size), |
185 FixedArray); | 185 FixedArray); |
186 } | 186 } |
187 | 187 |
| 188 Handle<BoilerplateDescription> Factory::NewBoilerplateDescription( |
| 189 int boilerplate, int all_properties, bool has_seen_proto) { |
| 190 DCHECK_GE(all_properties, boilerplate); |
| 191 |
| 192 int backing_store_size = all_properties - (has_seen_proto ? 1 : 0); |
| 193 DCHECK_GE(backing_store_size, 0); |
| 194 bool has_different_size_backing_store = boilerplate != backing_store_size; |
| 195 |
| 196 // Space for name and value for every boilerplate property. |
| 197 int size = 2 * boilerplate; |
| 198 |
| 199 if (has_different_size_backing_store) { |
| 200 // An extra entry for the backing store size. |
| 201 size++; |
| 202 } |
| 203 |
| 204 Handle<BoilerplateDescription> description = |
| 205 Handle<BoilerplateDescription>::cast(NewFixedArray(size, TENURED)); |
| 206 |
| 207 if (has_different_size_backing_store) { |
| 208 DCHECK((boilerplate != all_properties) || has_seen_proto); |
| 209 description->set_backing_store_size(isolate(), backing_store_size); |
| 210 } |
| 211 return description; |
| 212 } |
188 | 213 |
189 Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int size, | 214 Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int size, |
190 PretenureFlag pretenure) { | 215 PretenureFlag pretenure) { |
191 DCHECK(0 <= size); | 216 DCHECK(0 <= size); |
192 CALL_HEAP_FUNCTION( | 217 CALL_HEAP_FUNCTION( |
193 isolate(), | 218 isolate(), |
194 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), | 219 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), |
195 FixedArrayBase); | 220 FixedArrayBase); |
196 } | 221 } |
197 | 222 |
(...skipping 2588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 Handle<AccessorInfo> prototype = | 2811 Handle<AccessorInfo> prototype = |
2787 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2812 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2788 Descriptor d = Descriptor::AccessorConstant( | 2813 Descriptor d = Descriptor::AccessorConstant( |
2789 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); | 2814 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); |
2790 map->AppendDescriptor(&d); | 2815 map->AppendDescriptor(&d); |
2791 } | 2816 } |
2792 } | 2817 } |
2793 | 2818 |
2794 } // namespace internal | 2819 } // namespace internal |
2795 } // namespace v8 | 2820 } // namespace v8 |
OLD | NEW |