Commit 099271a1 authored by verwaest's avatar verwaest Committed by Commit bot

[runtime] Move heap-object type check helpers to HeapObject with wrapper on Object

BUG=

Review URL: https://codereview.chromium.org/1694403002

Cr-Commit-Position: refs/heads/master@{#34034}
parent 4a58b46e
...@@ -2646,7 +2646,7 @@ void Heap::CreateInitialObjects() { ...@@ -2646,7 +2646,7 @@ void Heap::CreateInitialObjects() {
set_arguments_marker( set_arguments_marker(
*factory->NewOddball(factory->arguments_marker_map(), "arguments_marker", *factory->NewOddball(factory->arguments_marker_map(), "arguments_marker",
handle(Smi::FromInt(-4), isolate()), "undefined", handle(Smi::FromInt(-4), isolate()), "undefined",
Oddball::kArgumentMarker)); Oddball::kArgumentsMarker));
set_no_interceptor_result_sentinel(*factory->NewOddball( set_no_interceptor_result_sentinel(*factory->NewOddball(
factory->no_interceptor_result_sentinel_map(), factory->no_interceptor_result_sentinel_map(),
......
...@@ -94,7 +94,7 @@ void MarkCompactCollector::ForceRecordSlot(HeapObject* object, Object** slot, ...@@ -94,7 +94,7 @@ void MarkCompactCollector::ForceRecordSlot(HeapObject* object, Object** slot,
void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) {
if (GetNextCandidate(shared_info) == NULL) { if (GetNextCandidate(shared_info) == nullptr) {
SetNextCandidate(shared_info, shared_function_info_candidates_head_); SetNextCandidate(shared_info, shared_function_info_candidates_head_);
shared_function_info_candidates_head_ = shared_info; shared_function_info_candidates_head_ = shared_info;
} }
...@@ -103,7 +103,7 @@ void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { ...@@ -103,7 +103,7 @@ void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) {
void CodeFlusher::AddCandidate(JSFunction* function) { void CodeFlusher::AddCandidate(JSFunction* function) {
DCHECK(function->code() == function->shared()->code()); DCHECK(function->code() == function->shared()->code());
if (GetNextCandidate(function)->IsUndefined()) { if (function->next_function_link()->IsUndefined()) {
SetNextCandidate(function, jsfunction_candidates_head_); SetNextCandidate(function, jsfunction_candidates_head_);
jsfunction_candidates_head_ = function; jsfunction_candidates_head_ = function;
} }
......
This diff is collapsed.
...@@ -868,10 +868,11 @@ template <class C> inline bool Is(Object* obj); ...@@ -868,10 +868,11 @@ template <class C> inline bool Is(Object* obj);
#define DECLARE_PRINTER(Name) #define DECLARE_PRINTER(Name)
#endif #endif
#define OBJECT_TYPE_LIST(V) \ #define OBJECT_TYPE_LIST(V) \
V(Smi) \ V(Smi) \
V(LayoutDescriptor) \
V(HeapObject) \ V(HeapObject) \
V(Primitive) \
V(Number) V(Number)
#define HEAP_OBJECT_TYPE_LIST(V) \ #define HEAP_OBJECT_TYPE_LIST(V) \
...@@ -920,7 +921,6 @@ template <class C> inline bool Is(Object* obj); ...@@ -920,7 +921,6 @@ template <class C> inline bool Is(Object* obj);
V(JSContextExtensionObject) \ V(JSContextExtensionObject) \
V(JSGeneratorObject) \ V(JSGeneratorObject) \
V(JSModule) \ V(JSModule) \
V(LayoutDescriptor) \
V(Map) \ V(Map) \
V(DescriptorArray) \ V(DescriptorArray) \
V(TransitionArray) \ V(TransitionArray) \
...@@ -973,11 +973,18 @@ template <class C> inline bool Is(Object* obj); ...@@ -973,11 +973,18 @@ template <class C> inline bool Is(Object* obj);
V(CodeCacheHashTable) \ V(CodeCacheHashTable) \
V(PolymorphicCodeCacheHashTable) \ V(PolymorphicCodeCacheHashTable) \
V(MapCache) \ V(MapCache) \
V(Primitive) \
V(JSGlobalObject) \ V(JSGlobalObject) \
V(JSGlobalProxy) \ V(JSGlobalProxy) \
V(UndetectableObject) \ V(UndetectableObject) \
V(AccessCheckNeeded) \ V(AccessCheckNeeded) \
V(Callable) \
V(Function) \
V(Constructor) \
V(TemplateInfo) \
V(Filler) \
V(FixedArrayBase) \
V(External) \
V(Struct) \
V(Cell) \ V(Cell) \
V(PropertyCell) \ V(PropertyCell) \
V(WeakCell) \ V(WeakCell) \
...@@ -985,6 +992,16 @@ template <class C> inline bool Is(Object* obj); ...@@ -985,6 +992,16 @@ template <class C> inline bool Is(Object* obj);
V(WeakHashTable) \ V(WeakHashTable) \
V(OrderedHashTable) V(OrderedHashTable)
#define ODDBALL_LIST(V) \
V(Undefined) \
V(Null) \
V(TheHole) \
V(Exception) \
V(Uninitialized) \
V(True) \
V(False) \
V(ArgumentsMarker)
// The element types selection for CreateListFromArrayLike. // The element types selection for CreateListFromArrayLike.
enum class ElementTypes { kAll, kStringAndSymbol }; enum class ElementTypes { kAll, kStringAndSymbol };
...@@ -1002,6 +1019,7 @@ class Object { ...@@ -1002,6 +1019,7 @@ class Object {
#define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL #undef IS_TYPE_FUNCTION_DECL
// A non-keyed store is of the form a.x = foo or a["x"] = foo whereas // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
...@@ -1030,10 +1048,6 @@ class Object { ...@@ -1030,10 +1048,6 @@ class Object {
#define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>()) #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
INLINE(bool IsFixedArrayBase() const);
INLINE(bool IsExternal() const);
INLINE(bool IsStruct() const);
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
INLINE(bool Is##Name() const); INLINE(bool Is##Name() const);
STRUCT_LIST(DECLARE_STRUCT_PREDICATE) STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
...@@ -1042,16 +1056,6 @@ class Object { ...@@ -1042,16 +1056,6 @@ class Object {
// ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray. // ES6, section 7.2.2 IsArray. NOT to be confused with %_IsArray.
MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object); MUST_USE_RESULT static Maybe<bool> IsArray(Handle<Object> object);
// Test for JSBoundFunction or JSFunction.
INLINE(bool IsFunction() const);
// ES6, section 7.2.3 IsCallable.
INLINE(bool IsCallable() const);
// ES6, section 7.2.4 IsConstructor.
INLINE(bool IsConstructor() const);
INLINE(bool IsTemplateInfo()) const;
INLINE(bool IsNameDictionary() const); INLINE(bool IsNameDictionary() const);
INLINE(bool IsGlobalDictionary() const); INLINE(bool IsGlobalDictionary() const);
INLINE(bool IsSeededNumberDictionary() const); INLINE(bool IsSeededNumberDictionary() const);
...@@ -1060,19 +1064,6 @@ class Object { ...@@ -1060,19 +1064,6 @@ class Object {
INLINE(bool IsOrderedHashMap() const); INLINE(bool IsOrderedHashMap() const);
static bool IsPromise(Handle<Object> object); static bool IsPromise(Handle<Object> object);
// Oddball testing.
INLINE(bool IsUndefined() const);
INLINE(bool IsNull() const);
INLINE(bool IsTheHole() const);
INLINE(bool IsException() const);
INLINE(bool IsUninitialized() const);
INLINE(bool IsTrue() const);
INLINE(bool IsFalse() const);
INLINE(bool IsArgumentsMarker() const);
// Filler objects (fillers and free space objects).
INLINE(bool IsFiller() const);
// Extract the number. // Extract the number.
inline double Number() const; inline double Number() const;
INLINE(bool IsNaN() const); INLINE(bool IsNaN() const);
...@@ -1532,6 +1523,15 @@ class HeapObject: public Object { ...@@ -1532,6 +1523,15 @@ class HeapObject: public Object {
// Convenience method to get current isolate. // Convenience method to get current isolate.
inline Isolate* GetIsolate() const; inline Isolate* GetIsolate() const;
#define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const);
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \
INLINE(bool Is##Name() const);
STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
#undef DECLARE_STRUCT_PREDICATE
// Converts an address to a HeapObject pointer. // Converts an address to a HeapObject pointer.
static inline HeapObject* FromAddress(Address address) { static inline HeapObject* FromAddress(Address address) {
DCHECK_TAG_ALIGNED(address); DCHECK_TAG_ALIGNED(address);
...@@ -4381,7 +4381,7 @@ class NormalizedMapCache: public FixedArray { ...@@ -4381,7 +4381,7 @@ class NormalizedMapCache: public FixedArray {
DECLARE_CAST(NormalizedMapCache) DECLARE_CAST(NormalizedMapCache)
static inline bool IsNormalizedMapCache(const Object* obj); static inline bool IsNormalizedMapCache(const HeapObject* obj);
DECLARE_VERIFIER(NormalizedMapCache) DECLARE_VERIFIER(NormalizedMapCache)
private: private:
...@@ -9555,7 +9555,7 @@ class Oddball: public HeapObject { ...@@ -9555,7 +9555,7 @@ class Oddball: public HeapObject {
static const byte kNotBooleanMask = ~1; static const byte kNotBooleanMask = ~1;
static const byte kTheHole = 2; static const byte kTheHole = 2;
static const byte kNull = 3; static const byte kNull = 3;
static const byte kArgumentMarker = 4; static const byte kArgumentsMarker = 4;
static const byte kUndefined = 5; static const byte kUndefined = 5;
static const byte kUninitialized = 6; static const byte kUninitialized = 6;
static const byte kOther = 7; static const byte kOther = 7;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment