| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 922 #ifdef OBJECT_PRINT | 922 #ifdef OBJECT_PRINT | 
| 923 #define DECLARE_PRINTER(Name) void Name##Print(FILE* out = stdout); | 923 #define DECLARE_PRINTER(Name) void Name##Print(FILE* out = stdout); | 
| 924 #else | 924 #else | 
| 925 #define DECLARE_PRINTER(Name) | 925 #define DECLARE_PRINTER(Name) | 
| 926 #endif | 926 #endif | 
| 927 | 927 | 
| 928 class MaybeObject BASE_EMBEDDED { | 928 class MaybeObject BASE_EMBEDDED { | 
| 929  public: | 929  public: | 
| 930   inline bool IsFailure(); | 930   inline bool IsFailure(); | 
| 931   inline bool IsRetryAfterGC(); | 931   inline bool IsRetryAfterGC(); | 
| 932   inline bool IsException(); |  | 
| 933   inline bool ToObject(Object** obj) { | 932   inline bool ToObject(Object** obj) { | 
| 934     if (IsFailure()) return false; | 933     if (IsFailure()) return false; | 
| 935     *obj = reinterpret_cast<Object*>(this); | 934     *obj = reinterpret_cast<Object*>(this); | 
| 936     return true; | 935     return true; | 
| 937   } | 936   } | 
| 938   inline Object* ToObjectUnchecked() { | 937   inline Object* ToObjectUnchecked() { | 
| 939     // TODO(jkummerow): Turn this back into an ASSERT when we can be certain | 938     // TODO(jkummerow): Turn this back into an ASSERT when we can be certain | 
| 940     // that it never fires in Release mode in the wild. | 939     // that it never fires in Release mode in the wild. | 
| 941     CHECK(!IsFailure()); | 940     CHECK(!IsFailure()); | 
| 942     return reinterpret_cast<Object*>(this); | 941     return reinterpret_cast<Object*>(this); | 
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1658 | 1657 | 
| 1659   static const int kMinValue = | 1658   static const int kMinValue = | 
| 1660       (static_cast<unsigned int>(-1)) << (kSmiValueSize - 1); | 1659       (static_cast<unsigned int>(-1)) << (kSmiValueSize - 1); | 
| 1661   static const int kMaxValue = -(kMinValue + 1); | 1660   static const int kMaxValue = -(kMinValue + 1); | 
| 1662 | 1661 | 
| 1663  private: | 1662  private: | 
| 1664   DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); | 1663   DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); | 
| 1665 }; | 1664 }; | 
| 1666 | 1665 | 
| 1667 | 1666 | 
| 1668 // Failure is used for reporting out of memory situations and | 1667 // Failure is mainly used for reporting a situation requiring a GC. | 
| 1669 // propagating exceptions through the runtime system.  Failure objects | 1668 // Failure objects are transient and cannot occur as part of the object graph. | 
| 1670 // are transient and cannot occur as part of the object graph. |  | 
| 1671 // | 1669 // | 
| 1672 // Failures are a single word, encoded as follows: | 1670 // Failures are a single word, encoded as follows: | 
| 1673 // +-------------------------+---+--+--+ | 1671 // +-------------------------+---+--+--+ | 
| 1674 // |.........unused..........|sss|tt|11| | 1672 // |.........unused..........|sss|tt|11| | 
| 1675 // +-------------------------+---+--+--+ | 1673 // +-------------------------+---+--+--+ | 
| 1676 //                          7 6 4 32 10 | 1674 //                          7 6 4 32 10 | 
| 1677 // | 1675 // | 
| 1678 // | 1676 // | 
| 1679 // The low two bits, 0-1, are the failure tag, 11.  The next two bits, | 1677 // The low two bits, 0-1, are the failure tag, 11.  The next two bits, | 
| 1680 // 2-3, are a failure type tag 'tt' with possible values: | 1678 // 2-3, are a failure type tag 'tt' with possible values: | 
| 1681 //   00 RETRY_AFTER_GC | 1679 //   00 RETRY_AFTER_GC | 
| 1682 //   01 EXCEPTION |  | 
| 1683 //   10 INTERNAL_ERROR |  | 
| 1684 //   11 OUT_OF_MEMORY_EXCEPTION |  | 
| 1685 // | 1680 // | 
| 1686 // The next three bits, 4-6, are an allocation space tag 'sss'.  The | 1681 // The next three bits, 4-6, are an allocation space tag 'sss'.  The | 
| 1687 // allocation space tag is 000 for all failure types except | 1682 // allocation space tag is 000 for all failure types except | 
| 1688 // RETRY_AFTER_GC.  For RETRY_AFTER_GC, the possible values are the | 1683 // RETRY_AFTER_GC.  For RETRY_AFTER_GC, the possible values are the | 
| 1689 // allocation spaces (the encoding is found in globals.h). | 1684 // allocation spaces (the encoding is found in globals.h). | 
| 1690 | 1685 | 
| 1691 // Failure type tag info. | 1686 // Failure type tag info. | 
| 1692 const int kFailureTypeTagSize = 2; | 1687 const int kFailureTypeTagSize = 2; | 
| 1693 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; | 1688 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; | 
| 1694 | 1689 | 
| 1695 class Failure: public MaybeObject { | 1690 class Failure: public MaybeObject { | 
| 1696  public: | 1691  public: | 
| 1697   // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. |  | 
| 1698   enum Type { | 1692   enum Type { | 
| 1699     RETRY_AFTER_GC = 0, | 1693     RETRY_AFTER_GC = 0 | 
| 1700     EXCEPTION = 1,       // Returning this marker tells the real exception |  | 
| 1701                          // is in Isolate::pending_exception. |  | 
| 1702     INTERNAL_ERROR = 2, |  | 
| 1703     OUT_OF_MEMORY_EXCEPTION = 3 |  | 
| 1704   }; | 1694   }; | 
| 1705 | 1695 | 
| 1706   inline Type type() const; | 1696   inline Type type() const; | 
| 1707 | 1697 | 
| 1708   // Returns the space that needs to be collected for RetryAfterGC failures. | 1698   // Returns the space that needs to be collected for RetryAfterGC failures. | 
| 1709   inline AllocationSpace allocation_space() const; | 1699   inline AllocationSpace allocation_space() const; | 
| 1710 | 1700 | 
| 1711   static inline Failure* RetryAfterGC(AllocationSpace space); | 1701   static inline Failure* RetryAfterGC(AllocationSpace space); | 
| 1712   static inline Failure* RetryAfterGC();  // NEW_SPACE | 1702   static inline Failure* RetryAfterGC();  // NEW_SPACE | 
| 1713   static inline Failure* Exception(); |  | 
| 1714   static inline Failure* InternalError(); |  | 
| 1715   // Casting. | 1703   // Casting. | 
| 1716   static inline Failure* cast(MaybeObject* object); | 1704   static inline Failure* cast(MaybeObject* object); | 
| 1717 | 1705 | 
| 1718   // Dispatched behavior. | 1706   // Dispatched behavior. | 
| 1719   void FailurePrint(FILE* out = stdout); | 1707   void FailurePrint(FILE* out = stdout); | 
| 1720   void FailurePrint(StringStream* accumulator); | 1708   void FailurePrint(StringStream* accumulator); | 
| 1721 | 1709 | 
| 1722   DECLARE_VERIFIER(Failure) | 1710   DECLARE_VERIFIER(Failure) | 
| 1723 | 1711 | 
| 1724  private: | 1712  private: | 
| (...skipping 9563 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 11288     } else { | 11276     } else { | 
| 11289       value &= ~(1 << bit_position); | 11277       value &= ~(1 << bit_position); | 
| 11290     } | 11278     } | 
| 11291     return value; | 11279     return value; | 
| 11292   } | 11280   } | 
| 11293 }; | 11281 }; | 
| 11294 | 11282 | 
| 11295 } }  // namespace v8::internal | 11283 } }  // namespace v8::internal | 
| 11296 | 11284 | 
| 11297 #endif  // V8_OBJECTS_H_ | 11285 #endif  // V8_OBJECTS_H_ | 
| OLD | NEW | 
|---|