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 "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 | 10 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 bool allocate_properties = true, | 383 bool allocate_properties = true, |
384 Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null()); | 384 Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null()); |
385 | 385 |
386 // JS modules are pretenured. | 386 // JS modules are pretenured. |
387 Handle<JSModule> NewJSModule(Handle<Context> context, | 387 Handle<JSModule> NewJSModule(Handle<Context> context, |
388 Handle<ScopeInfo> scope_info); | 388 Handle<ScopeInfo> scope_info); |
389 | 389 |
390 // JS arrays are pretenured when allocated by the parser. | 390 // JS arrays are pretenured when allocated by the parser. |
391 | 391 |
392 // Create a JSArray with no elements. | 392 // Create a JSArray with no elements. |
393 Handle<JSArray> NewJSArray( | 393 Handle<JSArray> NewJSArray(ElementsKind elements_kind, |
394 ElementsKind elements_kind, | 394 Strength strength = Strength::WEAK, |
395 ObjectStrength strength = WEAK, | 395 PretenureFlag pretenure = NOT_TENURED); |
396 PretenureFlag pretenure = NOT_TENURED); | |
397 | 396 |
398 // Create a JSArray with a specified length and elements initialized | 397 // Create a JSArray with a specified length and elements initialized |
399 // according to the specified mode. | 398 // according to the specified mode. |
400 Handle<JSArray> NewJSArray( | 399 Handle<JSArray> NewJSArray( |
401 ElementsKind elements_kind, int length, int capacity, | 400 ElementsKind elements_kind, int length, int capacity, |
402 ObjectStrength strength = WEAK, | 401 Strength strength = Strength::WEAK, |
403 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS, | 402 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS, |
404 PretenureFlag pretenure = NOT_TENURED); | 403 PretenureFlag pretenure = NOT_TENURED); |
405 | 404 |
406 Handle<JSArray> NewJSArray( | 405 Handle<JSArray> NewJSArray( |
407 int capacity, | 406 int capacity, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
408 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, | 407 Strength strength = Strength::WEAK, |
409 ObjectStrength strength = WEAK, | |
410 PretenureFlag pretenure = NOT_TENURED) { | 408 PretenureFlag pretenure = NOT_TENURED) { |
411 if (capacity != 0) { | 409 if (capacity != 0) { |
412 elements_kind = GetHoleyElementsKind(elements_kind); | 410 elements_kind = GetHoleyElementsKind(elements_kind); |
413 } | 411 } |
414 return NewJSArray(elements_kind, 0, capacity, strength, | 412 return NewJSArray(elements_kind, 0, capacity, strength, |
415 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure); | 413 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure); |
416 } | 414 } |
417 | 415 |
418 // Create a JSArray with the given elements. | 416 // Create a JSArray with the given elements. |
419 Handle<JSArray> NewJSArrayWithElements( | 417 Handle<JSArray> NewJSArrayWithElements(Handle<FixedArrayBase> elements, |
420 Handle<FixedArrayBase> elements, | 418 ElementsKind elements_kind, int length, |
421 ElementsKind elements_kind, | 419 Strength strength = Strength::WEAK, |
422 int length, | 420 PretenureFlag pretenure = NOT_TENURED); |
423 ObjectStrength strength = WEAK, | |
424 PretenureFlag pretenure = NOT_TENURED); | |
425 | 421 |
426 Handle<JSArray> NewJSArrayWithElements( | 422 Handle<JSArray> NewJSArrayWithElements( |
427 Handle<FixedArrayBase> elements, | 423 Handle<FixedArrayBase> elements, |
428 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, | 424 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
429 ObjectStrength strength = WEAK, | 425 Strength strength = Strength::WEAK, |
430 PretenureFlag pretenure = NOT_TENURED) { | 426 PretenureFlag pretenure = NOT_TENURED) { |
431 return NewJSArrayWithElements(elements, elements_kind, elements->length(), | 427 return NewJSArrayWithElements(elements, elements_kind, elements->length(), |
432 strength, pretenure); | 428 strength, pretenure); |
433 } | 429 } |
434 | 430 |
435 void NewJSArrayStorage( | 431 void NewJSArrayStorage( |
436 Handle<JSArray> array, | 432 Handle<JSArray> array, |
437 int length, | 433 int length, |
438 int capacity, | 434 int capacity, |
439 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS); | 435 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 // Reinitialize a JSProxy into an (empty) JS object of respective type and | 738 // Reinitialize a JSProxy into an (empty) JS object of respective type and |
743 // size, but keeping the original prototype. The receiver must have at least | 739 // size, but keeping the original prototype. The receiver must have at least |
744 // the size of the new object. The object is reinitialized and behaves as an | 740 // the size of the new object. The object is reinitialized and behaves as an |
745 // object that has been freshly allocated. | 741 // object that has been freshly allocated. |
746 void ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, int size); | 742 void ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, int size); |
747 }; | 743 }; |
748 | 744 |
749 } } // namespace v8::internal | 745 } } // namespace v8::internal |
750 | 746 |
751 #endif // V8_FACTORY_H_ | 747 #endif // V8_FACTORY_H_ |
OLD | NEW |