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

Side by Side Diff: src/objects.h

Issue 2043183003: Replace all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: simplifying checks Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 V(FixedArrayBase) \ 994 V(FixedArrayBase) \
995 V(External) \ 995 V(External) \
996 V(Struct) \ 996 V(Struct) \
997 V(Cell) \ 997 V(Cell) \
998 V(PropertyCell) \ 998 V(PropertyCell) \
999 V(WeakCell) \ 999 V(WeakCell) \
1000 V(ObjectHashTable) \ 1000 V(ObjectHashTable) \
1001 V(WeakHashTable) \ 1001 V(WeakHashTable) \
1002 V(OrderedHashTable) 1002 V(OrderedHashTable)
1003 1003
1004 #define ODDBALL_LIST(V) \ 1004 #define ODDBALL_LIST(V) \
1005 V(Undefined) \ 1005 V(Undefined, undefined_value) \
1006 V(Null) \ 1006 V(Null, null_value) \
1007 V(TheHole) \ 1007 V(TheHole, the_hole_value) \
1008 V(Exception) \ 1008 V(Exception, exception) \
1009 V(Uninitialized) \ 1009 V(Uninitialized, uninitialized_value) \
1010 V(True) \ 1010 V(True, true_value) \
1011 V(False) \ 1011 V(False, false_value) \
1012 V(ArgumentsMarker) \ 1012 V(ArgumentsMarker, arguments_marker) \
1013 V(OptimizedOut) \ 1013 V(OptimizedOut, optimized_out) \
1014 V(StaleRegister) 1014 V(StaleRegister, stale_register)
1015 1015
1016 // The element types selection for CreateListFromArrayLike. 1016 // The element types selection for CreateListFromArrayLike.
1017 enum class ElementTypes { kAll, kStringAndSymbol }; 1017 enum class ElementTypes { kAll, kStringAndSymbol };
1018 1018
1019 // Object is the abstract superclass for all classes in the 1019 // Object is the abstract superclass for all classes in the
1020 // object hierarchy. 1020 // object hierarchy.
1021 // Object does not use any virtual functions to avoid the 1021 // Object does not use any virtual functions to avoid the
1022 // allocation of the C++ vtable. 1022 // allocation of the C++ vtable.
1023 // Since both Smi and HeapObject are subclasses of Object no 1023 // Since both Smi and HeapObject are subclasses of Object no
1024 // data members can be present in Object. 1024 // data members can be present in Object.
1025 class Object { 1025 class Object {
1026 public: 1026 public:
1027 // Type testing. 1027 // Type testing.
1028 bool IsObject() const { return true; } 1028 bool IsObject() const { return true; }
1029 1029
1030 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); 1030 // TODO(cbruni): clean up once isolate-based versions are in place.
Michael Starzinger 2016/06/08 15:58:20 nit: This TODO should actually be addressed by thi
Camillo Bruni 2016/06/10 09:28:57 nah, let's just keep the todos alive a bit longer
1031 #define IS_TYPE_FUNCTION_DECL(Type) INLINE(bool Is##Type() const);
1031 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1032 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1032 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1033 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1034 #undef IS_TYPE_FUNCTION_DECL
1035 #define IS_TYPE_FUNCTION_DECL(Type, Value) \
1036 INLINE(bool Is##Type(Isolate* isolate) const);
1033 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) 1037 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
1034 #undef IS_TYPE_FUNCTION_DECL 1038 #undef IS_TYPE_FUNCTION_DECL
1035 1039
1036 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas 1040 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
1037 // a keyed store is of the form a[expression] = foo. 1041 // a keyed store is of the form a[expression] = foo.
1038 enum StoreFromKeyed { 1042 enum StoreFromKeyed {
1039 MAY_BE_STORE_FROM_KEYED, 1043 MAY_BE_STORE_FROM_KEYED,
1040 CERTAINLY_NOT_STORE_FROM_KEYED 1044 CERTAINLY_NOT_STORE_FROM_KEYED
1041 }; 1045 };
1042 1046
(...skipping 14 matching lines...) Expand all
1057 if ((call).IsNothing()) return value; \ 1061 if ((call).IsNothing()) return value; \
1058 } while (false) 1062 } while (false)
1059 1063
1060 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) 1064 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
1061 1065
1062 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1066 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1063 INLINE(bool Is##Name() const); 1067 INLINE(bool Is##Name() const);
1064 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1068 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1065 #undef DECLARE_STRUCT_PREDICATE 1069 #undef DECLARE_STRUCT_PREDICATE
1066 1070
1067 INLINE(bool IsTheHole(Isolate* isolate) const);
1068 INLINE(bool IsUndefined(Isolate* isolate) const);
1069
1070 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. 1071 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray.
1071 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); 1072 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object);
1072 1073
1073 INLINE(bool IsNameDictionary() const); 1074 INLINE(bool IsNameDictionary() const);
1074 INLINE(bool IsGlobalDictionary() const); 1075 INLINE(bool IsGlobalDictionary() const);
1075 INLINE(bool IsSeededNumberDictionary() const); 1076 INLINE(bool IsSeededNumberDictionary() const);
1076 INLINE(bool IsUnseededNumberDictionary() const); 1077 INLINE(bool IsUnseededNumberDictionary() const);
1077 INLINE(bool IsOrderedHashSet() const); 1078 INLINE(bool IsOrderedHashSet() const);
1078 INLINE(bool IsOrderedHashMap() const); 1079 INLINE(bool IsOrderedHashMap() const);
1079 static bool IsPromise(Handle<Object> object); 1080 static bool IsPromise(Handle<Object> object);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 // necessarily contain a map pointer. 1543 // necessarily contain a map pointer.
1543 inline MapWord map_word() const; 1544 inline MapWord map_word() const;
1544 inline void set_map_word(MapWord map_word); 1545 inline void set_map_word(MapWord map_word);
1545 1546
1546 // The Heap the object was allocated in. Used also to access Isolate. 1547 // The Heap the object was allocated in. Used also to access Isolate.
1547 inline Heap* GetHeap() const; 1548 inline Heap* GetHeap() const;
1548 1549
1549 // Convenience method to get current isolate. 1550 // Convenience method to get current isolate.
1550 inline Isolate* GetIsolate() const; 1551 inline Isolate* GetIsolate() const;
1551 1552
1552 // TODO(cbruni): clean up once isolate-based versions are in place. 1553 // TODO(cbruni): clean up once isolate-based versions are in place.
Michael Starzinger 2016/06/08 15:58:20 nit: This TODO should actually be addressed by thi
1553 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); 1554 #define IS_TYPE_FUNCTION_DECL(Type) INLINE(bool Is##Type() const);
1554 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1555 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1556 #undef IS_TYPE_FUNCTION_DECL
1557
1558 #define IS_TYPE_FUNCTION_DECL(Type, Value) \
1559 INLINE(bool Is##Type(Isolate* isolate) const);
1555 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) 1560 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
1556 #undef IS_TYPE_FUNCTION_DECL 1561 #undef IS_TYPE_FUNCTION_DECL
1562
1557 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1563 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1558 INLINE(bool Is##Name() const); 1564 INLINE(bool Is##Name() const);
1559 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1565 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1560 #undef DECLARE_STRUCT_PREDICATE 1566 #undef DECLARE_STRUCT_PREDICATE
1561 1567
1562 INLINE(bool IsTheHole(Isolate* isolate) const);
1563 INLINE(bool IsUndefined(Isolate* isolate) const);
1564
1565 // Converts an address to a HeapObject pointer. 1568 // Converts an address to a HeapObject pointer.
1566 static inline HeapObject* FromAddress(Address address) { 1569 static inline HeapObject* FromAddress(Address address) {
1567 DCHECK_TAG_ALIGNED(address); 1570 DCHECK_TAG_ALIGNED(address);
1568 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); 1571 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
1569 } 1572 }
1570 1573
1571 // Returns the address of this HeapObject. 1574 // Returns the address of this HeapObject.
1572 inline Address address() { 1575 inline Address address() {
1573 return reinterpret_cast<Address>(this) - kHeapObjectTag; 1576 return reinterpret_cast<Address>(this) - kHeapObjectTag;
1574 } 1577 }
(...skipping 9219 matching lines...) Expand 10 before | Expand all | Expand 10 after
10794 } 10797 }
10795 return value; 10798 return value;
10796 } 10799 }
10797 }; 10800 };
10798 10801
10799 10802
10800 } // NOLINT, false-positive due to second-order macros. 10803 } // NOLINT, false-positive due to second-order macros.
10801 } // NOLINT, false-positive due to second-order macros. 10804 } // NOLINT, false-positive due to second-order macros.
10802 10805
10803 #endif // V8_OBJECTS_H_ 10806 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.cc ('k') | src/objects.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698