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

Side by Side Diff: src/objects.h

Issue 236303015: Remove some uses of MaybeObject methods. (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
« no previous file with comments | « src/isolate.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 #define DECLARE_PRINTER(Name) void Name##Print(FILE* out = stdout); 917 #define DECLARE_PRINTER(Name) void Name##Print(FILE* out = stdout);
918 #else 918 #else
919 #define DECLARE_PRINTER(Name) 919 #define DECLARE_PRINTER(Name)
920 #endif 920 #endif
921 921
922 class MaybeObject BASE_EMBEDDED { 922 class MaybeObject BASE_EMBEDDED {
923 public: 923 public:
924 inline bool IsFailure(); 924 inline bool IsFailure();
925 inline bool IsRetryAfterGC(); 925 inline bool IsRetryAfterGC();
926 inline bool IsException(); 926 inline bool IsException();
927 INLINE(bool IsTheHole());
928 INLINE(bool IsUninitialized());
929 inline bool ToObject(Object** obj) { 927 inline bool ToObject(Object** obj) {
930 if (IsFailure()) return false; 928 if (IsFailure()) return false;
931 *obj = reinterpret_cast<Object*>(this); 929 *obj = reinterpret_cast<Object*>(this);
932 return true; 930 return true;
933 } 931 }
934 inline Failure* ToFailureUnchecked() {
935 ASSERT(IsFailure());
936 return reinterpret_cast<Failure*>(this);
937 }
938 inline Object* ToObjectUnchecked() { 932 inline Object* ToObjectUnchecked() {
939 // TODO(jkummerow): Turn this back into an ASSERT when we can be certain 933 // TODO(jkummerow): Turn this back into an ASSERT when we can be certain
940 // that it never fires in Release mode in the wild. 934 // that it never fires in Release mode in the wild.
941 CHECK(!IsFailure()); 935 CHECK(!IsFailure());
942 return reinterpret_cast<Object*>(this); 936 return reinterpret_cast<Object*>(this);
943 } 937 }
944 inline Object* ToObjectChecked() { 938 inline Object* ToObjectChecked() {
945 CHECK(!IsFailure()); 939 CHECK(!IsFailure());
946 return reinterpret_cast<Object*>(this); 940 return reinterpret_cast<Object*>(this);
947 } 941 }
948 942
949 template<typename T> 943 template<typename T>
950 inline bool To(T** obj) { 944 inline bool To(T** obj) {
951 if (IsFailure()) return false; 945 if (IsFailure()) return false;
952 *obj = T::cast(reinterpret_cast<Object*>(this)); 946 *obj = T::cast(reinterpret_cast<Object*>(this));
953 return true; 947 return true;
954 } 948 }
955 949
956 template<typename T>
957 inline bool ToHandle(Handle<T>* obj, Isolate* isolate) {
958 if (IsFailure()) return false;
959 *obj = handle(T::cast(reinterpret_cast<Object*>(this)), isolate);
960 return true;
961 }
962
963 #ifdef OBJECT_PRINT 950 #ifdef OBJECT_PRINT
964 // Prints this object with details. 951 // Prints this object with details.
965 void Print(); 952 void Print();
966 void Print(FILE* out); 953 void Print(FILE* out);
967 void PrintLn(); 954 void PrintLn();
968 void PrintLn(FILE* out); 955 void PrintLn(FILE* out);
969 #endif 956 #endif
970 #ifdef VERIFY_HEAP 957 #ifdef VERIFY_HEAP
971 // Verifies the object. 958 // Verifies the object.
972 void Verify(); 959 void Verify();
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 // is in Isolate::pending_exception. 1690 // is in Isolate::pending_exception.
1704 INTERNAL_ERROR = 2, 1691 INTERNAL_ERROR = 2,
1705 OUT_OF_MEMORY_EXCEPTION = 3 1692 OUT_OF_MEMORY_EXCEPTION = 3
1706 }; 1693 };
1707 1694
1708 inline Type type() const; 1695 inline Type type() const;
1709 1696
1710 // Returns the space that needs to be collected for RetryAfterGC failures. 1697 // Returns the space that needs to be collected for RetryAfterGC failures.
1711 inline AllocationSpace allocation_space() const; 1698 inline AllocationSpace allocation_space() const;
1712 1699
1713 inline bool IsInternalError() const;
1714
1715 static inline Failure* RetryAfterGC(AllocationSpace space); 1700 static inline Failure* RetryAfterGC(AllocationSpace space);
1716 static inline Failure* RetryAfterGC(); // NEW_SPACE 1701 static inline Failure* RetryAfterGC(); // NEW_SPACE
1717 static inline Failure* Exception(); 1702 static inline Failure* Exception();
1718 static inline Failure* InternalError(); 1703 static inline Failure* InternalError();
1719 // Casting. 1704 // Casting.
1720 static inline Failure* cast(MaybeObject* object); 1705 static inline Failure* cast(MaybeObject* object);
1721 1706
1722 // Dispatched behavior. 1707 // Dispatched behavior.
1723 void FailurePrint(FILE* out = stdout); 1708 void FailurePrint(FILE* out = stdout);
1724 void FailurePrint(StringStream* accumulator); 1709 void FailurePrint(StringStream* accumulator);
(...skipping 9329 matching lines...) Expand 10 before | Expand all | Expand 10 after
11054 } else { 11039 } else {
11055 value &= ~(1 << bit_position); 11040 value &= ~(1 << bit_position);
11056 } 11041 }
11057 return value; 11042 return value;
11058 } 11043 }
11059 }; 11044 };
11060 11045
11061 } } // namespace v8::internal 11046 } } // namespace v8::internal
11062 11047
11063 #endif // V8_OBJECTS_H_ 11048 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698