Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: src/objects.h

Issue 245963007: Clean up some uses of Failures and MaybeObjects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 1680 // 01 NOT_FOUND
Michael Starzinger 2014/04/23 14:34:52 nit: This NOT_FOUND constant doesn't seem to exist
Yang 2014/04/23 15:07:55 This was there in the first patch set. Forgot to r
1683 // 10 INTERNAL_ERROR
1684 // 11 OUT_OF_MEMORY_EXCEPTION
1685 // 1681 //
1686 // The next three bits, 4-6, are an allocation space tag 'sss'. The 1682 // The next three bits, 4-6, are an allocation space tag 'sss'. The
1687 // allocation space tag is 000 for all failure types except 1683 // allocation space tag is 000 for all failure types except
1688 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the 1684 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the
1689 // allocation spaces (the encoding is found in globals.h). 1685 // allocation spaces (the encoding is found in globals.h).
1690 1686
1691 // Failure type tag info. 1687 // Failure type tag info.
1692 const int kFailureTypeTagSize = 2; 1688 const int kFailureTypeTagSize = 2;
1693 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; 1689 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1;
1694 1690
1695 class Failure: public MaybeObject { 1691 class Failure: public MaybeObject {
1696 public: 1692 public:
1697 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code.
1698 enum Type { 1693 enum Type {
1699 RETRY_AFTER_GC = 0, 1694 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 }; 1695 };
1705 1696
1706 inline Type type() const; 1697 inline Type type() const;
1707 1698
1708 // Returns the space that needs to be collected for RetryAfterGC failures. 1699 // Returns the space that needs to be collected for RetryAfterGC failures.
1709 inline AllocationSpace allocation_space() const; 1700 inline AllocationSpace allocation_space() const;
1710 1701
1711 static inline Failure* RetryAfterGC(AllocationSpace space); 1702 static inline Failure* RetryAfterGC(AllocationSpace space);
1712 static inline Failure* RetryAfterGC(); // NEW_SPACE 1703 static inline Failure* RetryAfterGC(); // NEW_SPACE
1713 static inline Failure* Exception();
1714 static inline Failure* InternalError();
1715 // Casting. 1704 // Casting.
1716 static inline Failure* cast(MaybeObject* object); 1705 static inline Failure* cast(MaybeObject* object);
1717 1706
1718 // Dispatched behavior. 1707 // Dispatched behavior.
1719 void FailurePrint(FILE* out = stdout); 1708 void FailurePrint(FILE* out = stdout);
1720 void FailurePrint(StringStream* accumulator); 1709 void FailurePrint(StringStream* accumulator);
1721 1710
1722 DECLARE_VERIFIER(Failure) 1711 DECLARE_VERIFIER(Failure)
1723 1712
1724 private: 1713 private:
(...skipping 9554 matching lines...) Expand 10 before | Expand all | Expand 10 after
11279 } else { 11268 } else {
11280 value &= ~(1 << bit_position); 11269 value &= ~(1 << bit_position);
11281 } 11270 }
11282 return value; 11271 return value;
11283 } 11272 }
11284 }; 11273 };
11285 11274
11286 } } // namespace v8::internal 11275 } } // namespace v8::internal
11287 11276
11288 #endif // V8_OBJECTS_H_ 11277 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/objects-inl.h » ('j') | src/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698