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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 602 } |
603 | 603 |
604 | 604 |
605 // Calls the FUNCTION_CALL function and retries it up to three times | 605 // Calls the FUNCTION_CALL function and retries it up to three times |
606 // to guarantee that any allocations performed during the call will | 606 // to guarantee that any allocations performed during the call will |
607 // succeed if there's enough memory. | 607 // succeed if there's enough memory. |
608 | 608 |
609 // Warning: Do not use the identifiers __object__, __maybe_object__ or | 609 // Warning: Do not use the identifiers __object__, __maybe_object__ or |
610 // __scope__ in a call to this macro. | 610 // __scope__ in a call to this macro. |
611 | 611 |
| 612 #define RETURN_OBJECT_UNLESS_EXCEPTION(ISOLATE, RETURN_VALUE, RETURN_EMPTY) \ |
| 613 if (__maybe_object__->ToObject(&__object__)) { \ |
| 614 if (__object__ == (ISOLATE)->heap()->exception()) { RETURN_EMPTY; } \ |
| 615 RETURN_VALUE; \ |
| 616 } |
| 617 |
612 #define CALL_AND_RETRY(ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ | 618 #define CALL_AND_RETRY(ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ |
613 do { \ | 619 do { \ |
614 MaybeObject* __maybe_object__ = FUNCTION_CALL; \ | 620 MaybeObject* __maybe_object__ = FUNCTION_CALL; \ |
615 Object* __object__ = NULL; \ | 621 Object* __object__ = NULL; \ |
616 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 622 RETURN_OBJECT_UNLESS_EXCEPTION(ISOLATE, RETURN_VALUE, RETURN_EMPTY) \ |
617 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 623 ASSERT(__maybe_object__->IsRetryAfterGC()); \ |
618 (ISOLATE)->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \ | 624 (ISOLATE)->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \ |
619 allocation_space(), \ | 625 allocation_space(), \ |
620 "allocation failure"); \ | 626 "allocation failure"); \ |
621 __maybe_object__ = FUNCTION_CALL; \ | 627 __maybe_object__ = FUNCTION_CALL; \ |
622 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 628 RETURN_OBJECT_UNLESS_EXCEPTION(ISOLATE, RETURN_VALUE, RETURN_EMPTY) \ |
623 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 629 ASSERT(__maybe_object__->IsRetryAfterGC()); \ |
624 (ISOLATE)->counters()->gc_last_resort_from_handles()->Increment(); \ | 630 (ISOLATE)->counters()->gc_last_resort_from_handles()->Increment(); \ |
625 (ISOLATE)->heap()->CollectAllAvailableGarbage("last resort gc"); \ | 631 (ISOLATE)->heap()->CollectAllAvailableGarbage("last resort gc"); \ |
626 { \ | 632 { \ |
627 AlwaysAllocateScope __scope__(ISOLATE); \ | 633 AlwaysAllocateScope __scope__(ISOLATE); \ |
628 __maybe_object__ = FUNCTION_CALL; \ | 634 __maybe_object__ = FUNCTION_CALL; \ |
629 } \ | 635 } \ |
630 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 636 RETURN_OBJECT_UNLESS_EXCEPTION(ISOLATE, RETURN_VALUE, RETURN_EMPTY) \ |
631 if (__maybe_object__->IsRetryAfterGC()) { \ | 637 ASSERT(__maybe_object__->IsRetryAfterGC()); \ |
632 /* TODO(1181417): Fix this. */ \ | 638 /* TODO(1181417): Fix this. */ \ |
633 v8::internal::Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);\ | 639 v8::internal::Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); \ |
634 } \ | |
635 RETURN_EMPTY; \ | 640 RETURN_EMPTY; \ |
636 } while (false) | 641 } while (false) |
637 | 642 |
638 #define CALL_AND_RETRY_OR_DIE( \ | 643 #define CALL_AND_RETRY_OR_DIE( \ |
639 ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ | 644 ISOLATE, FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ |
640 CALL_AND_RETRY( \ | 645 CALL_AND_RETRY( \ |
641 ISOLATE, \ | 646 ISOLATE, \ |
642 FUNCTION_CALL, \ | 647 FUNCTION_CALL, \ |
643 RETURN_VALUE, \ | 648 RETURN_VALUE, \ |
644 RETURN_EMPTY) | 649 RETURN_EMPTY) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 797 |
793 | 798 |
794 double GCTracer::SizeOfHeapObjects() { | 799 double GCTracer::SizeOfHeapObjects() { |
795 return (static_cast<double>(heap_->SizeOfObjects())) / MB; | 800 return (static_cast<double>(heap_->SizeOfObjects())) / MB; |
796 } | 801 } |
797 | 802 |
798 | 803 |
799 } } // namespace v8::internal | 804 } } // namespace v8::internal |
800 | 805 |
801 #endif // V8_HEAP_INL_H_ | 806 #endif // V8_HEAP_INL_H_ |
OLD | NEW |