| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 Handle<SeededNumberDictionary> NewSeededNumberDictionary( | 67 Handle<SeededNumberDictionary> NewSeededNumberDictionary( |
| 68 int at_least_space_for); | 68 int at_least_space_for); |
| 69 | 69 |
| 70 Handle<UnseededNumberDictionary> NewUnseededNumberDictionary( | 70 Handle<UnseededNumberDictionary> NewUnseededNumberDictionary( |
| 71 int at_least_space_for); | 71 int at_least_space_for); |
| 72 | 72 |
| 73 Handle<NameDictionary> NewNameDictionary(int at_least_space_for); | 73 Handle<NameDictionary> NewNameDictionary(int at_least_space_for); |
| 74 | 74 |
| 75 Handle<ObjectHashSet> NewObjectHashSet(int at_least_space_for); | 75 Handle<ObjectHashSet> NewObjectHashSet(int at_least_space_for); |
| 76 | 76 |
| 77 Handle<ObjectHashTable> NewObjectHashTable(int at_least_space_for); | 77 Handle<ObjectHashTable> NewObjectHashTable( |
| 78 int at_least_space_for, |
| 79 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY); |
| 78 | 80 |
| 79 Handle<WeakHashTable> NewWeakHashTable(int at_least_space_for); | 81 Handle<WeakHashTable> NewWeakHashTable(int at_least_space_for); |
| 80 | 82 |
| 81 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors, | 83 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors, |
| 82 int slack = 0); | 84 int slack = 0); |
| 83 Handle<DeoptimizationInputData> NewDeoptimizationInputData( | 85 Handle<DeoptimizationInputData> NewDeoptimizationInputData( |
| 84 int deopt_entry_count, | 86 int deopt_entry_count, |
| 85 PretenureFlag pretenure); | 87 PretenureFlag pretenure); |
| 86 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( | 88 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( |
| 87 int deopt_entry_count, | 89 int deopt_entry_count, |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 Handle<FixedArrayBase> elements, | 336 Handle<FixedArrayBase> elements, |
| 335 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, | 337 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
| 336 PretenureFlag pretenure = NOT_TENURED); | 338 PretenureFlag pretenure = NOT_TENURED); |
| 337 | 339 |
| 338 void SetElementsCapacityAndLength(Handle<JSArray> array, | 340 void SetElementsCapacityAndLength(Handle<JSArray> array, |
| 339 int capacity, | 341 int capacity, |
| 340 int length); | 342 int length); |
| 341 | 343 |
| 342 void SetContent(Handle<JSArray> array, Handle<FixedArrayBase> elements); | 344 void SetContent(Handle<JSArray> array, Handle<FixedArrayBase> elements); |
| 343 | 345 |
| 346 Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function); |
| 347 |
| 344 Handle<JSArrayBuffer> NewJSArrayBuffer(); | 348 Handle<JSArrayBuffer> NewJSArrayBuffer(); |
| 345 | 349 |
| 346 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type); | 350 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type); |
| 347 | 351 |
| 348 Handle<JSDataView> NewJSDataView(); | 352 Handle<JSDataView> NewJSDataView(); |
| 349 | 353 |
| 350 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype); | 354 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype); |
| 351 | 355 |
| 352 // Change the type of the argument into a JS object/function and reinitialize. | 356 // Change the type of the argument into a JS object/function and reinitialize. |
| 353 void BecomeJSObject(Handle<JSReceiver> object); | 357 void BecomeJSObject(Handle<JSReceiver> object); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 PretenureFlag pretenure) { | 581 PretenureFlag pretenure) { |
| 578 if (Smi::IsValid(static_cast<intptr_t>(value))) { | 582 if (Smi::IsValid(static_cast<intptr_t>(value))) { |
| 579 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), | 583 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), |
| 580 isolate()); | 584 isolate()); |
| 581 } else { | 585 } else { |
| 582 return NewNumber(static_cast<double>(value), pretenure); | 586 return NewNumber(static_cast<double>(value), pretenure); |
| 583 } | 587 } |
| 584 } | 588 } |
| 585 | 589 |
| 586 | 590 |
| 587 // Used to "safely" transition from pointer-based runtime code to Handle-based | |
| 588 // runtime code. When a GC happens during the called Handle-based code, a | |
| 589 // failure object is returned to the pointer-based code to cause it abort and | |
| 590 // re-trigger a gc of it's own. Since this double-gc will cause the Handle-based | |
| 591 // code to be called twice, it must be idempotent. | |
| 592 class IdempotentPointerToHandleCodeTrampoline { | |
| 593 public: | |
| 594 explicit IdempotentPointerToHandleCodeTrampoline(Isolate* isolate) | |
| 595 : isolate_(isolate) {} | |
| 596 | |
| 597 template<typename R> | |
| 598 MUST_USE_RESULT MaybeObject* Call(R (*function)()) { | |
| 599 int collections = isolate_->heap()->gc_count(); | |
| 600 (*function)(); | |
| 601 return (collections == isolate_->heap()->gc_count()) | |
| 602 ? isolate_->heap()->true_value() | |
| 603 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 604 } | |
| 605 | |
| 606 template<typename R> | |
| 607 MUST_USE_RESULT MaybeObject* CallWithReturnValue(R (*function)()) { | |
| 608 int collections = isolate_->heap()->gc_count(); | |
| 609 Object* result = (*function)(); | |
| 610 return (collections == isolate_->heap()->gc_count()) | |
| 611 ? result | |
| 612 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 613 } | |
| 614 | |
| 615 template<typename R, typename P1> | |
| 616 MUST_USE_RESULT MaybeObject* Call(R (*function)(P1), P1 p1) { | |
| 617 int collections = isolate_->heap()->gc_count(); | |
| 618 (*function)(p1); | |
| 619 return (collections == isolate_->heap()->gc_count()) | |
| 620 ? isolate_->heap()->true_value() | |
| 621 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 622 } | |
| 623 | |
| 624 template<typename R, typename P1> | |
| 625 MUST_USE_RESULT MaybeObject* CallWithReturnValue( | |
| 626 R (*function)(P1), | |
| 627 P1 p1) { | |
| 628 int collections = isolate_->heap()->gc_count(); | |
| 629 Object* result = (*function)(p1); | |
| 630 return (collections == isolate_->heap()->gc_count()) | |
| 631 ? result | |
| 632 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 633 } | |
| 634 | |
| 635 template<typename R, typename P1, typename P2> | |
| 636 MUST_USE_RESULT MaybeObject* Call( | |
| 637 R (*function)(P1, P2), | |
| 638 P1 p1, | |
| 639 P2 p2) { | |
| 640 int collections = isolate_->heap()->gc_count(); | |
| 641 (*function)(p1, p2); | |
| 642 return (collections == isolate_->heap()->gc_count()) | |
| 643 ? isolate_->heap()->true_value() | |
| 644 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 645 } | |
| 646 | |
| 647 template<typename R, typename P1, typename P2> | |
| 648 MUST_USE_RESULT MaybeObject* CallWithReturnValue( | |
| 649 R (*function)(P1, P2), | |
| 650 P1 p1, | |
| 651 P2 p2) { | |
| 652 int collections = isolate_->heap()->gc_count(); | |
| 653 Object* result = (*function)(p1, p2); | |
| 654 return (collections == isolate_->heap()->gc_count()) | |
| 655 ? result | |
| 656 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 657 } | |
| 658 | |
| 659 template<typename R, typename P1, typename P2, typename P3, typename P4, | |
| 660 typename P5, typename P6, typename P7> | |
| 661 MUST_USE_RESULT MaybeObject* CallWithReturnValue( | |
| 662 R (*function)(P1, P2, P3, P4, P5, P6, P7), | |
| 663 P1 p1, | |
| 664 P2 p2, | |
| 665 P3 p3, | |
| 666 P4 p4, | |
| 667 P5 p5, | |
| 668 P6 p6, | |
| 669 P7 p7) { | |
| 670 int collections = isolate_->heap()->gc_count(); | |
| 671 Handle<Object> result = (*function)(p1, p2, p3, p4, p5, p6, p7); | |
| 672 return (collections == isolate_->heap()->gc_count()) | |
| 673 ? *result | |
| 674 : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); | |
| 675 } | |
| 676 | |
| 677 private: | |
| 678 Isolate* isolate_; | |
| 679 }; | |
| 680 | |
| 681 | |
| 682 } } // namespace v8::internal | 591 } } // namespace v8::internal |
| 683 | 592 |
| 684 #endif // V8_FACTORY_H_ | 593 #endif // V8_FACTORY_H_ |
| OLD | NEW |