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

Side by Side Diff: src/objects.h

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master 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
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/objects.cc » ('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/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 if ((call).IsNothing()) return value; \ 1057 if ((call).IsNothing()) return value; \
1058 } while (false) 1058 } while (false)
1059 1059
1060 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) 1060 #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
1061 1061
1062 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1062 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1063 INLINE(bool Is##Name() const); 1063 INLINE(bool Is##Name() const);
1064 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1064 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1065 #undef DECLARE_STRUCT_PREDICATE 1065 #undef DECLARE_STRUCT_PREDICATE
1066 1066
1067 INLINE(bool IsTheHole(Isolate* isolate) const);
1068 INLINE(bool IsUndefined(Isolate* isolate) const);
1069
1067 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. 1070 // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray.
1068 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); 1071 MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object);
1069 1072
1070 INLINE(bool IsNameDictionary() const); 1073 INLINE(bool IsNameDictionary() const);
1071 INLINE(bool IsGlobalDictionary() const); 1074 INLINE(bool IsGlobalDictionary() const);
1072 INLINE(bool IsSeededNumberDictionary() const); 1075 INLINE(bool IsSeededNumberDictionary() const);
1073 INLINE(bool IsUnseededNumberDictionary() const); 1076 INLINE(bool IsUnseededNumberDictionary() const);
1074 INLINE(bool IsOrderedHashSet() const); 1077 INLINE(bool IsOrderedHashSet() const);
1075 INLINE(bool IsOrderedHashMap() const); 1078 INLINE(bool IsOrderedHashMap() const);
1076 static bool IsPromise(Handle<Object> object); 1079 static bool IsPromise(Handle<Object> object);
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 // necessarily contain a map pointer. 1547 // necessarily contain a map pointer.
1545 inline MapWord map_word() const; 1548 inline MapWord map_word() const;
1546 inline void set_map_word(MapWord map_word); 1549 inline void set_map_word(MapWord map_word);
1547 1550
1548 // The Heap the object was allocated in. Used also to access Isolate. 1551 // The Heap the object was allocated in. Used also to access Isolate.
1549 inline Heap* GetHeap() const; 1552 inline Heap* GetHeap() const;
1550 1553
1551 // Convenience method to get current isolate. 1554 // Convenience method to get current isolate.
1552 inline Isolate* GetIsolate() const; 1555 inline Isolate* GetIsolate() const;
1553 1556
1557 // TODO(cbruni): clean up once isolate-based versions are in place.
1554 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); 1558 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
1555 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) 1559 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
1556 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) 1560 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
1557 #undef IS_TYPE_FUNCTION_DECL 1561 #undef IS_TYPE_FUNCTION_DECL
1558 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ 1562 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
1559 INLINE(bool Is##Name() const); 1563 INLINE(bool Is##Name() const);
1560 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 1564 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
1561 #undef DECLARE_STRUCT_PREDICATE 1565 #undef DECLARE_STRUCT_PREDICATE
1562 1566
1567 INLINE(bool IsTheHole(Isolate* isolate) const);
1568 INLINE(bool IsUndefined(Isolate* isolate) const);
1569
1563 // Converts an address to a HeapObject pointer. 1570 // Converts an address to a HeapObject pointer.
1564 static inline HeapObject* FromAddress(Address address) { 1571 static inline HeapObject* FromAddress(Address address) {
1565 DCHECK_TAG_ALIGNED(address); 1572 DCHECK_TAG_ALIGNED(address);
1566 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); 1573 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
1567 } 1574 }
1568 1575
1569 // Returns the address of this HeapObject. 1576 // Returns the address of this HeapObject.
1570 inline Address address() { 1577 inline Address address() {
1571 return reinterpret_cast<Address>(this) - kHeapObjectTag; 1578 return reinterpret_cast<Address>(this) - kHeapObjectTag;
1572 } 1579 }
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3868 3875
3869 int HashToEntry(int hash) { 3876 int HashToEntry(int hash) {
3870 int bucket = HashToBucket(hash); 3877 int bucket = HashToBucket(hash);
3871 Object* entry = this->get(kHashTableStartIndex + bucket); 3878 Object* entry = this->get(kHashTableStartIndex + bucket);
3872 return Smi::cast(entry)->value(); 3879 return Smi::cast(entry)->value();
3873 } 3880 }
3874 3881
3875 int KeyToFirstEntry(Object* key) { 3882 int KeyToFirstEntry(Object* key) {
3876 Object* hash = key->GetHash(); 3883 Object* hash = key->GetHash();
3877 // If the object does not have an identity hash, it was never used as a key 3884 // If the object does not have an identity hash, it was never used as a key
3878 if (hash->IsUndefined()) return kNotFound; 3885 if (hash->IsUndefined(GetIsolate())) return kNotFound;
3879 return HashToEntry(Smi::cast(hash)->value()); 3886 return HashToEntry(Smi::cast(hash)->value());
3880 } 3887 }
3881 3888
3882 int NextChainEntry(int entry) { 3889 int NextChainEntry(int entry) {
3883 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); 3890 Object* next_entry = get(EntryToIndex(entry) + kChainOffset);
3884 return Smi::cast(next_entry)->value(); 3891 return Smi::cast(next_entry)->value();
3885 } 3892 }
3886 3893
3887 // use KeyAt(i)->IsTheHole() to determine if this is a deleted entry. 3894 // use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry.
3888 Object* KeyAt(int entry) { 3895 Object* KeyAt(int entry) {
3889 DCHECK_LT(entry, this->UsedCapacity()); 3896 DCHECK_LT(entry, this->UsedCapacity());
3890 return get(EntryToIndex(entry)); 3897 return get(EntryToIndex(entry));
3891 } 3898 }
3892 3899
3893 bool IsObsolete() { 3900 bool IsObsolete() {
3894 return !get(kNextTableIndex)->IsSmi(); 3901 return !get(kNextTableIndex)->IsSmi();
3895 } 3902 }
3896 3903
3897 // The next newer table. This is only valid if the table is obsolete. 3904 // The next newer table. This is only valid if the table is obsolete.
(...skipping 6885 matching lines...) Expand 10 before | Expand all | Expand 10 after
10783 } 10790 }
10784 return value; 10791 return value;
10785 } 10792 }
10786 }; 10793 };
10787 10794
10788 10795
10789 } // NOLINT, false-positive due to second-order macros. 10796 } // NOLINT, false-positive due to second-order macros.
10790 } // NOLINT, false-positive due to second-order macros. 10797 } // NOLINT, false-positive due to second-order macros.
10791 10798
10792 #endif // V8_OBJECTS_H_ 10799 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698