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

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: reducing old cmpare patterns 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 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 3869
3864 int HashToEntry(int hash) { 3870 int HashToEntry(int hash) {
3865 int bucket = HashToBucket(hash); 3871 int bucket = HashToBucket(hash);
3866 Object* entry = this->get(kHashTableStartIndex + bucket); 3872 Object* entry = this->get(kHashTableStartIndex + bucket);
3867 return Smi::cast(entry)->value(); 3873 return Smi::cast(entry)->value();
3868 } 3874 }
3869 3875
3870 int KeyToFirstEntry(Object* key) { 3876 int KeyToFirstEntry(Object* key) {
3871 Object* hash = key->GetHash(); 3877 Object* hash = key->GetHash();
3872 // If the object does not have an identity hash, it was never used as a key 3878 // If the object does not have an identity hash, it was never used as a key
3873 if (hash->IsUndefined()) return kNotFound; 3879 if (hash->IsUndefined(GetIsolate())) return kNotFound;
ulan 2016/06/01 19:01:44 Before it was doing 2 loads hash->map->instance_ty
3874 return HashToEntry(Smi::cast(hash)->value()); 3880 return HashToEntry(Smi::cast(hash)->value());
3875 } 3881 }
3876 3882
3877 int NextChainEntry(int entry) { 3883 int NextChainEntry(int entry) {
3878 Object* next_entry = get(EntryToIndex(entry) + kChainOffset); 3884 Object* next_entry = get(EntryToIndex(entry) + kChainOffset);
3879 return Smi::cast(next_entry)->value(); 3885 return Smi::cast(next_entry)->value();
3880 } 3886 }
3881 3887
3882 // use KeyAt(i)->IsTheHole() to determine if this is a deleted entry. 3888 // use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry.
3883 Object* KeyAt(int entry) { 3889 Object* KeyAt(int entry) {
3884 DCHECK_LT(entry, this->UsedCapacity()); 3890 DCHECK_LT(entry, this->UsedCapacity());
3885 return get(EntryToIndex(entry)); 3891 return get(EntryToIndex(entry));
3886 } 3892 }
3887 3893
3888 bool IsObsolete() { 3894 bool IsObsolete() {
3889 return !get(kNextTableIndex)->IsSmi(); 3895 return !get(kNextTableIndex)->IsSmi();
3890 } 3896 }
3891 3897
3892 // The next newer table. This is only valid if the table is obsolete. 3898 // The next newer table. This is only valid if the table is obsolete.
(...skipping 6900 matching lines...) Expand 10 before | Expand all | Expand 10 after
10793 } 10799 }
10794 return value; 10800 return value;
10795 } 10801 }
10796 }; 10802 };
10797 10803
10798 10804
10799 } // NOLINT, false-positive due to second-order macros. 10805 } // NOLINT, false-positive due to second-order macros.
10800 } // NOLINT, false-positive due to second-order macros. 10806 } // NOLINT, false-positive due to second-order macros.
10801 10807
10802 #endif // V8_OBJECTS_H_ 10808 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/objects.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698