OLD | NEW |
---|---|
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 Loading... | |
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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1553 | 1556 |
1554 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); | 1557 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); |
1555 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1558 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1556 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) | 1559 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL) |
1557 #undef IS_TYPE_FUNCTION_DECL | 1560 #undef IS_TYPE_FUNCTION_DECL |
1558 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ | 1561 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
1559 INLINE(bool Is##Name() const); | 1562 INLINE(bool Is##Name() const); |
1560 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1563 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
1561 #undef DECLARE_STRUCT_PREDICATE | 1564 #undef DECLARE_STRUCT_PREDICATE |
1562 | 1565 |
1566 INLINE(bool IsTheHole(Isolate* isolate) const); | |
Michael Starzinger
2016/06/06 08:55:08
The predicates are already declared on the {Object
| |
1567 INLINE(bool IsUndefined(Isolate* isolate) const); | |
1568 | |
1563 // Converts an address to a HeapObject pointer. | 1569 // Converts an address to a HeapObject pointer. |
1564 static inline HeapObject* FromAddress(Address address) { | 1570 static inline HeapObject* FromAddress(Address address) { |
1565 DCHECK_TAG_ALIGNED(address); | 1571 DCHECK_TAG_ALIGNED(address); |
1566 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1572 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
1567 } | 1573 } |
1568 | 1574 |
1569 // Returns the address of this HeapObject. | 1575 // Returns the address of this HeapObject. |
1570 inline Address address() { | 1576 inline Address address() { |
1571 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1577 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
1572 } | 1578 } |
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3868 | 3874 |
3869 int HashToEntry(int hash) { | 3875 int HashToEntry(int hash) { |
3870 int bucket = HashToBucket(hash); | 3876 int bucket = HashToBucket(hash); |
3871 Object* entry = this->get(kHashTableStartIndex + bucket); | 3877 Object* entry = this->get(kHashTableStartIndex + bucket); |
3872 return Smi::cast(entry)->value(); | 3878 return Smi::cast(entry)->value(); |
3873 } | 3879 } |
3874 | 3880 |
3875 int KeyToFirstEntry(Object* key) { | 3881 int KeyToFirstEntry(Object* key) { |
3876 Object* hash = key->GetHash(); | 3882 Object* hash = key->GetHash(); |
3877 // If the object does not have an identity hash, it was never used as a key | 3883 // If the object does not have an identity hash, it was never used as a key |
3878 if (hash->IsUndefined()) return kNotFound; | 3884 if (hash->IsUndefined(GetIsolate())) return kNotFound; |
3879 return HashToEntry(Smi::cast(hash)->value()); | 3885 return HashToEntry(Smi::cast(hash)->value()); |
3880 } | 3886 } |
3881 | 3887 |
3882 int NextChainEntry(int entry) { | 3888 int NextChainEntry(int entry) { |
3883 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); | 3889 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); |
3884 return Smi::cast(next_entry)->value(); | 3890 return Smi::cast(next_entry)->value(); |
3885 } | 3891 } |
3886 | 3892 |
3887 // use KeyAt(i)->IsTheHole() to determine if this is a deleted entry. | 3893 // use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry. |
3888 Object* KeyAt(int entry) { | 3894 Object* KeyAt(int entry) { |
3889 DCHECK_LT(entry, this->UsedCapacity()); | 3895 DCHECK_LT(entry, this->UsedCapacity()); |
3890 return get(EntryToIndex(entry)); | 3896 return get(EntryToIndex(entry)); |
3891 } | 3897 } |
3892 | 3898 |
3893 bool IsObsolete() { | 3899 bool IsObsolete() { |
3894 return !get(kNextTableIndex)->IsSmi(); | 3900 return !get(kNextTableIndex)->IsSmi(); |
3895 } | 3901 } |
3896 | 3902 |
3897 // The next newer table. This is only valid if the table is obsolete. | 3903 // 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 Loading... | |
10783 } | 10789 } |
10784 return value; | 10790 return value; |
10785 } | 10791 } |
10786 }; | 10792 }; |
10787 | 10793 |
10788 | 10794 |
10789 } // NOLINT, false-positive due to second-order macros. | 10795 } // NOLINT, false-positive due to second-order macros. |
10790 } // NOLINT, false-positive due to second-order macros. | 10796 } // NOLINT, false-positive due to second-order macros. |
10791 | 10797 |
10792 #endif // V8_OBJECTS_H_ | 10798 #endif // V8_OBJECTS_H_ |
OLD | NEW |