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

Side by Side Diff: src/objects.h

Issue 1694403002: [runtime] Move heap-object type check helpers to HeapObject with wrapper on Object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: drop the dcheck Created 4 years, 10 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
« no previous file with comments | « src/heap/mark-compact-inl.h ('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 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/allocation.h" 10 #include "src/allocation.h"
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 #else 861 #else
862 #define DECLARE_VERIFIER(Name) 862 #define DECLARE_VERIFIER(Name)
863 #endif 863 #endif
864 864
865 #ifdef OBJECT_PRINT 865 #ifdef OBJECT_PRINT
866 #define DECLARE_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT 866 #define DECLARE_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT
867 #else 867 #else
868 #define DECLARE_PRINTER(Name) 868 #define DECLARE_PRINTER(Name)
869 #endif 869 #endif
870 870
871
872 #define OBJECT_TYPE_LIST(V) \ 871 #define OBJECT_TYPE_LIST(V) \
873 V(Smi) \ 872 V(Smi) \
873 V(LayoutDescriptor) \
874 V(HeapObject) \ 874 V(HeapObject) \
875 V(Primitive) \
875 V(Number) 876 V(Number)
876 877
877 #define HEAP_OBJECT_TYPE_LIST(V) \ 878 #define HEAP_OBJECT_TYPE_LIST(V) \
878 V(HeapNumber) \ 879 V(HeapNumber) \
879 V(MutableHeapNumber) \ 880 V(MutableHeapNumber) \
880 V(Simd128Value) \ 881 V(Simd128Value) \
881 V(Float32x4) \ 882 V(Float32x4) \
882 V(Int32x4) \ 883 V(Int32x4) \
883 V(Uint32x4) \ 884 V(Uint32x4) \
884 V(Bool32x4) \ 885 V(Bool32x4) \
(...skipping 28 matching lines...) Expand all
913 V(FixedFloat64Array) \ 914 V(FixedFloat64Array) \
914 V(FixedUint8ClampedArray) \ 915 V(FixedUint8ClampedArray) \
915 V(ByteArray) \ 916 V(ByteArray) \
916 V(BytecodeArray) \ 917 V(BytecodeArray) \
917 V(FreeSpace) \ 918 V(FreeSpace) \
918 V(JSReceiver) \ 919 V(JSReceiver) \
919 V(JSObject) \ 920 V(JSObject) \
920 V(JSContextExtensionObject) \ 921 V(JSContextExtensionObject) \
921 V(JSGeneratorObject) \ 922 V(JSGeneratorObject) \
922 V(JSModule) \ 923 V(JSModule) \
923 V(LayoutDescriptor) \
924 V(Map) \ 924 V(Map) \
925 V(DescriptorArray) \ 925 V(DescriptorArray) \
926 V(TransitionArray) \ 926 V(TransitionArray) \
927 V(LiteralsArray) \ 927 V(LiteralsArray) \
928 V(TypeFeedbackMetadata) \ 928 V(TypeFeedbackMetadata) \
929 V(TypeFeedbackVector) \ 929 V(TypeFeedbackVector) \
930 V(DeoptimizationInputData) \ 930 V(DeoptimizationInputData) \
931 V(DeoptimizationOutputData) \ 931 V(DeoptimizationOutputData) \
932 V(DependentCode) \ 932 V(DependentCode) \
933 V(HandlerTable) \ 933 V(HandlerTable) \
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 V(JSWeakSet) \ 966 V(JSWeakSet) \
967 V(JSRegExp) \ 967 V(JSRegExp) \
968 V(HashTable) \ 968 V(HashTable) \
969 V(Dictionary) \ 969 V(Dictionary) \
970 V(StringTable) \ 970 V(StringTable) \
971 V(NormalizedMapCache) \ 971 V(NormalizedMapCache) \
972 V(CompilationCacheTable) \ 972 V(CompilationCacheTable) \
973 V(CodeCacheHashTable) \ 973 V(CodeCacheHashTable) \
974 V(PolymorphicCodeCacheHashTable) \ 974 V(PolymorphicCodeCacheHashTable) \
975 V(MapCache) \ 975 V(MapCache) \
976 V(Primitive) \
977 V(JSGlobalObject) \ 976 V(JSGlobalObject) \
978 V(JSGlobalProxy) \ 977 V(JSGlobalProxy) \
979 V(UndetectableObject) \ 978 V(UndetectableObject) \
980 V(AccessCheckNeeded) \ 979 V(AccessCheckNeeded) \
980 V(Callable) \
981 V(Function) \
982 V(Constructor) \
983 V(TemplateInfo) \
984 V(Filler) \
985 V(FixedArrayBase) \
986 V(External) \
987 V(Struct) \
981 V(Cell) \ 988 V(Cell) \
982 V(PropertyCell) \ 989 V(PropertyCell) \
983 V(WeakCell) \ 990 V(WeakCell) \
984 V(ObjectHashTable) \ 991 V(ObjectHashTable) \
985 V(WeakHashTable) \ 992 V(WeakHashTable) \
986 V(OrderedHashTable) 993 V(OrderedHashTable)
987 994
995 #define ODDBALL_LIST(V) \
996 V(Undefined) \
997 V(Null) \
998 V(TheHole) \
999 V(Exception) \
1000 V(Uninitialized) \
1001 V(True) \
1002 V(False) \
1003 V(ArgumentsMarker)
1004
988 // The element types selection for CreateListFromArrayLike. 1005 // The element types selection for CreateListFromArrayLike.
989 enum class ElementTypes { kAll, kStringAndSymbol }; 1006 enum class ElementTypes { kAll, kStringAndSymbol };
990 1007
991 // Object is the abstract superclass for all classes in the 1008 // Object is the abstract superclass for all classes in the
992 // object hierarchy. 1009 // object hierarchy.
993 // Object does not use any virtual functions to avoid the 1010 // Object does not use any virtual functions to avoid the
994 // allocation of the C++ vtable. 1011 // allocation of the C++ vtable.
995 // Since both Smi and HeapObject are subclasses of Object no 1012 // Since both Smi and HeapObject are subclasses of Object no
996 // data members can be present in Object. 1013 // data members can be present in Object.
997 class Object { 1014 class Object {
998 public: 1015 public:
999 // Type testing. 1016 // Type testing.
1000 bool IsObject() const { return true; } 1017 bool IsObject() const { return true; }
1001 1018
1002 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); 1019 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
1003 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1020 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1004 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1021 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1022 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
1005 #undef IS_TYPE_FUNCTION_DECL 1023 #undef IS_TYPE_FUNCTION_DECL
1006 1024
1007 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas 1025 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
1008 // a keyed store is of the form a[expression] = foo. 1026 // a keyed store is of the form a[expression] = foo.
1009 enum StoreFromKeyed { 1027 enum StoreFromKeyed {
1010 MAY_BE_STORE_FROM_KEYED, 1028 MAY_BE_STORE_FROM_KEYED,
1011 CERTAINLY_NOT_STORE_FROM_KEYED 1029 CERTAINLY_NOT_STORE_FROM_KEYED
1012 }; 1030 };
1013 1031
1014 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW }; 1032 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW };
1015 1033
1016 #define RETURN_FAILURE(isolate, should_throw, call) \ 1034 #define RETURN_FAILURE(isolate, should_throw, call) \
1017 do { \ 1035 do { \
1018 if ((should_throw) == DONT_THROW) { \ 1036 if ((should_throw) == DONT_THROW) { \
1019 return Just(false); \ 1037 return Just(false); \
1020 } else { \ 1038 } else { \
1021 isolate->Throw(*isolate->factory()->call); \ 1039 isolate->Throw(*isolate->factory()->call); \
1022 return Nothing<bool>(); \ 1040 return Nothing<bool>(); \
1023 } \ 1041 } \
1024 } while (false) 1042 } while (false)
1025 1043
1026 #define MAYBE_RETURN(call, value) \ 1044 #define MAYBE_RETURN(call, value) \
1027 do { \ 1045 do { \
1028 if ((call).IsNothing()) return value; \ 1046 if ((call).IsNothing()) return value; \
1029 } while (false) 1047 } while (false)
1030 1048
1031 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) 1049 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
1032 1050
1033 INLINE(bool IsFixedArrayBase() const);
1034 INLINE(bool IsExternal() const);
1035
1036 INLINE(bool IsStruct() const);
1037 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1051 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1038 INLINE(bool Is##Name() const); 1052 INLINE(bool Is##Name() const);
1039 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1053 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1040 #undef DECLARE_STRUCT_PREDICATE 1054 #undef DECLARE_STRUCT_PREDICATE
1041 1055
1042 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. 1056 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray.
1043 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); 1057 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object);
1044 1058
1045 // Test for JSBoundFunction or JSFunction.
1046 INLINE(bool IsFunction() const);
1047
1048 // ES6, section 7.2.3 IsCallable.
1049 INLINE(bool IsCallable() const);
1050
1051 // ES6, section 7.2.4 IsConstructor.
1052 INLINE(bool IsConstructor() const);
1053
1054 INLINE(bool IsTemplateInfo()) const;
1055 INLINE(bool IsNameDictionary() const); 1059 INLINE(bool IsNameDictionary() const);
1056 INLINE(bool IsGlobalDictionary() const); 1060 INLINE(bool IsGlobalDictionary() const);
1057 INLINE(bool IsSeededNumberDictionary() const); 1061 INLINE(bool IsSeededNumberDictionary() const);
1058 INLINE(bool IsUnseededNumberDictionary() const); 1062 INLINE(bool IsUnseededNumberDictionary() const);
1059 INLINE(bool IsOrderedHashSet() const); 1063 INLINE(bool IsOrderedHashSet() const);
1060 INLINE(bool IsOrderedHashMap() const); 1064 INLINE(bool IsOrderedHashMap() const);
1061 static bool IsPromise(Handle<Object> object); 1065 static bool IsPromise(Handle<Object> object);
1062 1066
1063 // Oddball testing.
1064 INLINE(bool IsUndefined() const);
1065 INLINE(bool IsNull() const);
1066 INLINE(bool IsTheHole() const);
1067 INLINE(bool IsException() const);
1068 INLINE(bool IsUninitialized() const);
1069 INLINE(bool IsTrue() const);
1070 INLINE(bool IsFalse() const);
1071 INLINE(bool IsArgumentsMarker() const);
1072
1073 // Filler objects (fillers and free space objects).
1074 INLINE(bool IsFiller() const);
1075
1076 // Extract the number. 1067 // Extract the number.
1077 inline double Number() const; 1068 inline double Number() const;
1078 INLINE(bool IsNaN() const); 1069 INLINE(bool IsNaN() const);
1079 INLINE(bool IsMinusZero() const); 1070 INLINE(bool IsMinusZero() const);
1080 bool ToInt32(int32_t* value); 1071 bool ToInt32(int32_t* value);
1081 bool ToUint32(uint32_t* value); 1072 bool ToUint32(uint32_t* value);
1082 1073
1083 inline Representation OptimalRepresentation(); 1074 inline Representation OptimalRepresentation();
1084 1075
1085 inline ElementsKind OptimalElementsKind(); 1076 inline ElementsKind OptimalElementsKind();
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 // necessarily contain a map pointer. 1516 // necessarily contain a map pointer.
1526 inline MapWord map_word() const; 1517 inline MapWord map_word() const;
1527 inline void set_map_word(MapWord map_word); 1518 inline void set_map_word(MapWord map_word);
1528 1519
1529 // The Heap the object was allocated in. Used also to access Isolate. 1520 // The Heap the object was allocated in. Used also to access Isolate.
1530 inline Heap* GetHeap() const; 1521 inline Heap* GetHeap() const;
1531 1522
1532 // Convenience method to get current isolate. 1523 // Convenience method to get current isolate.
1533 inline Isolate* GetIsolate() const; 1524 inline Isolate* GetIsolate() const;
1534 1525
1526 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
1527 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1528 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
1529 #undef IS_TYPE_FUNCTION_DECL
1530 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1531 INLINE(bool Is##Name() const);
1532 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1533 #undef DECLARE_STRUCT_PREDICATE
1534
1535 // Converts an address to a HeapObject pointer. 1535 // Converts an address to a HeapObject pointer.
1536 static inline HeapObject* FromAddress(Address address) { 1536 static inline HeapObject* FromAddress(Address address) {
1537 DCHECK_TAG_ALIGNED(address); 1537 DCHECK_TAG_ALIGNED(address);
1538 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); 1538 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
1539 } 1539 }
1540 1540
1541 // Returns the address of this HeapObject. 1541 // Returns the address of this HeapObject.
1542 inline Address address() { 1542 inline Address address() {
1543 return reinterpret_cast<Address>(this) - kHeapObjectTag; 1543 return reinterpret_cast<Address>(this) - kHeapObjectTag;
1544 } 1544 }
(...skipping 2829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 static Handle<NormalizedMapCache> New(Isolate* isolate); 4374 static Handle<NormalizedMapCache> New(Isolate* isolate);
4375 4375
4376 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map, 4376 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map,
4377 PropertyNormalizationMode mode); 4377 PropertyNormalizationMode mode);
4378 void Set(Handle<Map> fast_map, Handle<Map> normalized_map); 4378 void Set(Handle<Map> fast_map, Handle<Map> normalized_map);
4379 4379
4380 void Clear(); 4380 void Clear();
4381 4381
4382 DECLARE_CAST(NormalizedMapCache) 4382 DECLARE_CAST(NormalizedMapCache)
4383 4383
4384 static inline bool IsNormalizedMapCache(const Object* obj); 4384 static inline bool IsNormalizedMapCache(const HeapObject* obj);
4385 4385
4386 DECLARE_VERIFIER(NormalizedMapCache) 4386 DECLARE_VERIFIER(NormalizedMapCache)
4387 private: 4387 private:
4388 static const int kEntries = 64; 4388 static const int kEntries = 64;
4389 4389
4390 static inline int GetIndex(Handle<Map> map); 4390 static inline int GetIndex(Handle<Map> map);
4391 4391
4392 // The following declarations hide base class methods. 4392 // The following declarations hide base class methods.
4393 Object* get(int index); 4393 Object* get(int index);
4394 void set(int index, Object* value); 4394 void set(int index, Object* value);
(...skipping 5153 matching lines...) Expand 10 before | Expand all | Expand 10 after
9548 static const int kToNumberOffset = kToStringOffset + kPointerSize; 9548 static const int kToNumberOffset = kToStringOffset + kPointerSize;
9549 static const int kTypeOfOffset = kToNumberOffset + kPointerSize; 9549 static const int kTypeOfOffset = kToNumberOffset + kPointerSize;
9550 static const int kKindOffset = kTypeOfOffset + kPointerSize; 9550 static const int kKindOffset = kTypeOfOffset + kPointerSize;
9551 static const int kSize = kKindOffset + kPointerSize; 9551 static const int kSize = kKindOffset + kPointerSize;
9552 9552
9553 static const byte kFalse = 0; 9553 static const byte kFalse = 0;
9554 static const byte kTrue = 1; 9554 static const byte kTrue = 1;
9555 static const byte kNotBooleanMask = ~1; 9555 static const byte kNotBooleanMask = ~1;
9556 static const byte kTheHole = 2; 9556 static const byte kTheHole = 2;
9557 static const byte kNull = 3; 9557 static const byte kNull = 3;
9558 static const byte kArgumentMarker = 4; 9558 static const byte kArgumentsMarker = 4;
9559 static const byte kUndefined = 5; 9559 static const byte kUndefined = 5;
9560 static const byte kUninitialized = 6; 9560 static const byte kUninitialized = 6;
9561 static const byte kOther = 7; 9561 static const byte kOther = 7;
9562 static const byte kException = 8; 9562 static const byte kException = 8;
9563 9563
9564 typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize, 9564 typedef FixedBodyDescriptor<kToStringOffset, kTypeOfOffset + kPointerSize,
9565 kSize> BodyDescriptor; 9565 kSize> BodyDescriptor;
9566 9566
9567 STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset); 9567 STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
9568 STATIC_ASSERT(kNull == Internals::kNullOddballKind); 9568 STATIC_ASSERT(kNull == Internals::kNullOddballKind);
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
10851 } 10851 }
10852 return value; 10852 return value;
10853 } 10853 }
10854 }; 10854 };
10855 10855
10856 10856
10857 } // NOLINT, false-positive due to second-order macros. 10857 } // NOLINT, false-positive due to second-order macros.
10858 } // NOLINT, false-positive due to second-order macros. 10858 } // NOLINT, false-positive due to second-order macros.
10859 10859
10860 #endif // V8_OBJECTS_H_ 10860 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact-inl.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698