OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); | 787 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); |
788 }; | 788 }; |
789 | 789 |
790 | 790 |
791 // Failure is used for reporting out of memory situations and | 791 // Failure is used for reporting out of memory situations and |
792 // propagating exceptions through the runtime system. Failure objects | 792 // propagating exceptions through the runtime system. Failure objects |
793 // are transient and cannot occur as part of the object graph. | 793 // are transient and cannot occur as part of the object graph. |
794 // | 794 // |
795 // Failures are a single word, encoded as follows: | 795 // Failures are a single word, encoded as follows: |
796 // +-------------------------+---+--+--+ | 796 // +-------------------------+---+--+--+ |
797 // |...rrrrrrrrrrrrrrrrrrrrrr|sss|tt|11| | 797 // |.........unused..........|sss|tt|11| |
798 // +-------------------------+---+--+--+ | 798 // +-------------------------+---+--+--+ |
799 // 7 6 4 32 10 | 799 // 7 6 4 32 10 |
800 // | 800 // |
801 // | 801 // |
802 // The low two bits, 0-1, are the failure tag, 11. The next two bits, | 802 // The low two bits, 0-1, are the failure tag, 11. The next two bits, |
803 // 2-3, are a failure type tag 'tt' with possible values: | 803 // 2-3, are a failure type tag 'tt' with possible values: |
804 // 00 RETRY_AFTER_GC | 804 // 00 RETRY_AFTER_GC |
805 // 01 EXCEPTION | 805 // 01 EXCEPTION |
806 // 10 INTERNAL_ERROR | 806 // 10 INTERNAL_ERROR |
807 // 11 OUT_OF_MEMORY_EXCEPTION | 807 // 11 OUT_OF_MEMORY_EXCEPTION |
808 // | 808 // |
809 // The next three bits, 4-6, are an allocation space tag 'sss'. The | 809 // The next three bits, 4-6, are an allocation space tag 'sss'. The |
810 // allocation space tag is 000 for all failure types except | 810 // allocation space tag is 000 for all failure types except |
811 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the | 811 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the |
812 // allocation spaces (the encoding is found in globals.h). | 812 // allocation spaces (the encoding is found in globals.h). |
813 // | |
814 // The remaining bits is the size of the allocation request in units | |
815 // of the pointer size, and is zeroed except for RETRY_AFTER_GC | |
816 // failures. The 25 bits (on a 32 bit platform) gives a representable | |
817 // range of 2^27 bytes (128MB). | |
818 | 813 |
819 // Failure type tag info. | 814 // Failure type tag info. |
820 const int kFailureTypeTagSize = 2; | 815 const int kFailureTypeTagSize = 2; |
821 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; | 816 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; |
822 | 817 |
823 class Failure: public Object { | 818 class Failure: public Object { |
824 public: | 819 public: |
825 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. | 820 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. |
826 enum Type { | 821 enum Type { |
827 RETRY_AFTER_GC = 0, | 822 RETRY_AFTER_GC = 0, |
828 EXCEPTION = 1, // Returning this marker tells the real exception | 823 EXCEPTION = 1, // Returning this marker tells the real exception |
829 // is in Top::pending_exception. | 824 // is in Top::pending_exception. |
830 INTERNAL_ERROR = 2, | 825 INTERNAL_ERROR = 2, |
831 OUT_OF_MEMORY_EXCEPTION = 3 | 826 OUT_OF_MEMORY_EXCEPTION = 3 |
832 }; | 827 }; |
833 | 828 |
834 inline Type type() const; | 829 inline Type type() const; |
835 | 830 |
836 // Returns the space that needs to be collected for RetryAfterGC failures. | 831 // Returns the space that needs to be collected for RetryAfterGC failures. |
837 inline AllocationSpace allocation_space() const; | 832 inline AllocationSpace allocation_space() const; |
838 | 833 |
839 // Returns the number of bytes requested (up to the representable maximum) | |
840 // for RetryAfterGC failures. | |
841 inline int requested() const; | |
842 | |
843 inline bool IsInternalError() const; | 834 inline bool IsInternalError() const; |
844 inline bool IsOutOfMemoryException() const; | 835 inline bool IsOutOfMemoryException() const; |
845 | 836 |
846 static Failure* RetryAfterGC(int requested_bytes, AllocationSpace space); | 837 static inline Failure* RetryAfterGC(AllocationSpace space); |
847 static inline Failure* RetryAfterGC(int requested_bytes); // NEW_SPACE | 838 static inline Failure* RetryAfterGC(); // NEW_SPACE |
848 static inline Failure* Exception(); | 839 static inline Failure* Exception(); |
849 static inline Failure* InternalError(); | 840 static inline Failure* InternalError(); |
850 static inline Failure* OutOfMemoryException(); | 841 static inline Failure* OutOfMemoryException(); |
851 // Casting. | 842 // Casting. |
852 static inline Failure* cast(Object* object); | 843 static inline Failure* cast(Object* object); |
853 | 844 |
854 // Dispatched behavior. | 845 // Dispatched behavior. |
855 void FailurePrint(); | 846 void FailurePrint(); |
856 void FailurePrint(StringStream* accumulator); | 847 void FailurePrint(StringStream* accumulator); |
857 #ifdef DEBUG | 848 #ifdef DEBUG |
(...skipping 4864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5722 } else { | 5713 } else { |
5723 value &= ~(1 << bit_position); | 5714 value &= ~(1 << bit_position); |
5724 } | 5715 } |
5725 return value; | 5716 return value; |
5726 } | 5717 } |
5727 }; | 5718 }; |
5728 | 5719 |
5729 } } // namespace v8::internal | 5720 } } // namespace v8::internal |
5730 | 5721 |
5731 #endif // V8_OBJECTS_H_ | 5722 #endif // V8_OBJECTS_H_ |
OLD | NEW |