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 #ifndef V8_FACTORY_H_ | 5 #ifndef V8_FACTORY_H_ |
6 #define V8_FACTORY_H_ | 6 #define V8_FACTORY_H_ |
7 | 7 |
8 #include "isolate.h" | 8 #include "isolate.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 // Interface for handle based allocation. | 13 // Interface for handle based allocation. |
14 | 14 |
15 class Factory V8_FINAL { | 15 class Factory V8_FINAL { |
16 public: | 16 public: |
17 // Allocate a new boxed value. | |
18 Handle<Box> NewBox( | |
19 Handle<Object> value, | |
20 PretenureFlag pretenure = NOT_TENURED); | |
21 | |
22 // Allocates a fixed array initialized with undefined values. | 17 // Allocates a fixed array initialized with undefined values. |
23 Handle<FixedArray> NewFixedArray( | 18 Handle<FixedArray> NewFixedArray( |
24 int size, | 19 int size, |
25 PretenureFlag pretenure = NOT_TENURED); | 20 PretenureFlag pretenure = NOT_TENURED); |
26 | 21 |
27 // Allocate a new fixed array with non-existing entries (the hole). | 22 // Allocate a new fixed array with non-existing entries (the hole). |
28 Handle<FixedArray> NewFixedArrayWithHoles( | 23 Handle<FixedArray> NewFixedArrayWithHoles( |
29 int size, | 24 int size, |
30 PretenureFlag pretenure = NOT_TENURED); | 25 PretenureFlag pretenure = NOT_TENURED); |
31 | 26 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 59 |
65 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors, | 60 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors, |
66 int slack = 0); | 61 int slack = 0); |
67 Handle<DeoptimizationInputData> NewDeoptimizationInputData( | 62 Handle<DeoptimizationInputData> NewDeoptimizationInputData( |
68 int deopt_entry_count, | 63 int deopt_entry_count, |
69 PretenureFlag pretenure); | 64 PretenureFlag pretenure); |
70 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( | 65 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( |
71 int deopt_entry_count, | 66 int deopt_entry_count, |
72 PretenureFlag pretenure); | 67 PretenureFlag pretenure); |
73 | 68 |
| 69 // Create a new boxed value. |
| 70 Handle<Box> NewBox(Handle<Object> value); |
| 71 |
74 // Create a pre-tenured empty AccessorPair. | 72 // Create a pre-tenured empty AccessorPair. |
75 Handle<AccessorPair> NewAccessorPair(); | 73 Handle<AccessorPair> NewAccessorPair(); |
76 | 74 |
77 // Create an empty TypeFeedbackInfo. | 75 // Create an empty TypeFeedbackInfo. |
78 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); | 76 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); |
79 | 77 |
80 Handle<String> InternalizeUtf8String(Vector<const char> str); | 78 Handle<String> InternalizeUtf8String(Vector<const char> str); |
81 Handle<String> InternalizeUtf8String(const char* str) { | 79 Handle<String> InternalizeUtf8String(const char* str) { |
82 return InternalizeUtf8String(CStrVector(str)); | 80 return InternalizeUtf8String(CStrVector(str)); |
83 } | 81 } |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 322 |
325 Handle<JSObject> NewJSObjectFromMapForDeoptimizer( | 323 Handle<JSObject> NewJSObjectFromMapForDeoptimizer( |
326 Handle<Map> map, PretenureFlag pretenure = NOT_TENURED); | 324 Handle<Map> map, PretenureFlag pretenure = NOT_TENURED); |
327 | 325 |
328 // JS modules are pretenured. | 326 // JS modules are pretenured. |
329 Handle<JSModule> NewJSModule(Handle<Context> context, | 327 Handle<JSModule> NewJSModule(Handle<Context> context, |
330 Handle<ScopeInfo> scope_info); | 328 Handle<ScopeInfo> scope_info); |
331 | 329 |
332 // JS arrays are pretenured when allocated by the parser. | 330 // JS arrays are pretenured when allocated by the parser. |
333 | 331 |
| 332 // Create a JSArray with no elements. |
334 Handle<JSArray> NewJSArray( | 333 Handle<JSArray> NewJSArray( |
335 ElementsKind elements_kind, | 334 ElementsKind elements_kind, |
336 PretenureFlag pretenure = NOT_TENURED); | 335 PretenureFlag pretenure = NOT_TENURED); |
337 | 336 |
| 337 // Create a JSArray with a specified length and elements initialized |
| 338 // according to the specified mode. |
338 Handle<JSArray> NewJSArray( | 339 Handle<JSArray> NewJSArray( |
339 ElementsKind elements_kind, | 340 ElementsKind elements_kind, |
340 int length, | 341 int length, |
341 int capacity, | 342 int capacity, |
342 ArrayStorageAllocationMode mode = INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, | 343 ArrayStorageAllocationMode mode = INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, |
343 PretenureFlag pretenure = NOT_TENURED); | 344 PretenureFlag pretenure = NOT_TENURED); |
344 | 345 |
345 Handle<JSArray> NewJSArray( | 346 Handle<JSArray> NewJSArray( |
346 int capacity, | 347 int capacity, |
347 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, | 348 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
348 PretenureFlag pretenure = NOT_TENURED) { | 349 PretenureFlag pretenure = NOT_TENURED) { |
349 if (capacity != 0) { | 350 if (capacity != 0) { |
350 elements_kind = GetHoleyElementsKind(elements_kind); | 351 elements_kind = GetHoleyElementsKind(elements_kind); |
351 } | 352 } |
352 return NewJSArray(elements_kind, 0, capacity, | 353 return NewJSArray(elements_kind, 0, capacity, |
353 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure); | 354 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure); |
354 } | 355 } |
355 | 356 |
356 // Allocate a JSArray with no elements | 357 // Create a JSArray with the given elements. |
357 Handle<JSArray> NewJSArrayWithElements( | 358 Handle<JSArray> NewJSArrayWithElements( |
358 Handle<FixedArrayBase> elements, | 359 Handle<FixedArrayBase> elements, |
359 ElementsKind elements_kind, | 360 ElementsKind elements_kind, |
360 int length, | 361 int length, |
361 PretenureFlag pretenure = NOT_TENURED); | 362 PretenureFlag pretenure = NOT_TENURED); |
362 | 363 |
363 Handle<JSArray> NewJSArrayWithElements( | 364 Handle<JSArray> NewJSArrayWithElements( |
364 Handle<FixedArrayBase> elements, | 365 Handle<FixedArrayBase> elements, |
365 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, | 366 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
366 PretenureFlag pretenure = NOT_TENURED) { | 367 PretenureFlag pretenure = NOT_TENURED) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 611 |
611 // Update the map cache in the native context with (keys, map) | 612 // Update the map cache in the native context with (keys, map) |
612 Handle<MapCache> AddToMapCache(Handle<Context> context, | 613 Handle<MapCache> AddToMapCache(Handle<Context> context, |
613 Handle<FixedArray> keys, | 614 Handle<FixedArray> keys, |
614 Handle<Map> map); | 615 Handle<Map> map); |
615 }; | 616 }; |
616 | 617 |
617 } } // namespace v8::internal | 618 } } // namespace v8::internal |
618 | 619 |
619 #endif // V8_FACTORY_H_ | 620 #endif // V8_FACTORY_H_ |
OLD | NEW |