Commit e8a1c25f authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[objects.h splitting] Move InstanceType and -Checker

BUG=v8:5402,v8:8238

Change-Id: Idd00fc664da8173612266ba7a976b383bb1f728e
Reviewed-on: https://chromium-review.googlesource.com/c/1349329
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57836}
parent 99484e23
...@@ -912,6 +912,7 @@ action("postmortem-metadata") { ...@@ -912,6 +912,7 @@ action("postmortem-metadata") {
"src/objects/fixed-array.h", "src/objects/fixed-array.h",
"src/objects/heap-object-inl.h", "src/objects/heap-object-inl.h",
"src/objects/heap-object.h", "src/objects/heap-object.h",
"src/objects/instance-type.h",
"src/objects/js-array-inl.h", "src/objects/js-array-inl.h",
"src/objects/js-array.h", "src/objects/js-array.h",
"src/objects/js-array-buffer-inl.h", "src/objects/js-array-buffer-inl.h",
...@@ -2292,6 +2293,8 @@ v8_source_set("v8_base") { ...@@ -2292,6 +2293,8 @@ v8_source_set("v8_base") {
"src/objects/hash-table.h", "src/objects/hash-table.h",
"src/objects/heap-object-inl.h", "src/objects/heap-object-inl.h",
"src/objects/heap-object.h", "src/objects/heap-object.h",
"src/objects/instance-type-inl.h",
"src/objects/instance-type.h",
"src/objects/intl-objects.cc", "src/objects/intl-objects.cc",
"src/objects/intl-objects.h", "src/objects/intl-objects.h",
"src/objects/js-array-buffer-inl.h", "src/objects/js-array-buffer-inl.h",
......
...@@ -16,6 +16,7 @@ namespace v8 { ...@@ -16,6 +16,7 @@ namespace v8 {
namespace internal { namespace internal {
// Forward declarations. // Forward declarations.
enum InstanceType : uint16_t;
class ObjectTemplateInfo; class ObjectTemplateInfo;
class TemplateInfo; class TemplateInfo;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/compiler/graph-reducer.h" #include "src/compiler/graph-reducer.h"
#include "src/compiler/per-isolate-compiler-cache.h" #include "src/compiler/per-isolate-compiler-cache.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/js-array-buffer-inl.h" #include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
#include "src/objects/js-regexp-inl.h" #include "src/objects/js-regexp-inl.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "src/handles.h" #include "src/handles.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/builtin-function-id.h" #include "src/objects/builtin-function-id.h"
#include "src/objects/instance-type.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
namespace v8 { namespace v8 {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "src/objects/debug-objects-inl.h" #include "src/objects/debug-objects-inl.h"
#include "src/objects/embedder-data-array-inl.h" #include "src/objects/embedder-data-array-inl.h"
#include "src/objects/frame-array-inl.h" #include "src/objects/frame-array-inl.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h" #include "src/objects/js-collection-inl.h"
#include "src/objects/js-generator-inl.h" #include "src/objects/js-generator-inl.h"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "src/objects/debug-objects.h" #include "src/objects/debug-objects.h"
#include "src/objects/descriptor-array.h" #include "src/objects/descriptor-array.h"
#include "src/objects/dictionary.h" #include "src/objects/dictionary.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/js-generator.h" #include "src/objects/js-generator.h"
#include "src/objects/js-weak-refs.h" #include "src/objects/js-weak-refs.h"
#include "src/objects/literal-objects-inl.h" #include "src/objects/literal-objects-inl.h"
......
...@@ -73,67 +73,6 @@ int PropertyDetails::field_width_in_words() const { ...@@ -73,67 +73,6 @@ int PropertyDetails::field_width_in_words() const {
return representation().IsDouble() ? kDoubleSize / kPointerSize : 1; return representation().IsDouble() ? kDoubleSize / kPointerSize : 1;
} }
namespace InstanceTypeChecker {
// Define type checkers for classes with single instance type.
INSTANCE_TYPE_CHECKERS_SINGLE(INSTANCE_TYPE_CHECKER);
#define TYPED_ARRAY_INSTANCE_TYPE_CHECKER(Type, type, TYPE, ctype) \
INSTANCE_TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
TYPED_ARRAYS(TYPED_ARRAY_INSTANCE_TYPE_CHECKER)
#undef TYPED_ARRAY_INSTANCE_TYPE_CHECKER
#define STRUCT_INSTANCE_TYPE_CHECKER(TYPE, Name, name) \
INSTANCE_TYPE_CHECKER(Name, TYPE)
STRUCT_LIST(STRUCT_INSTANCE_TYPE_CHECKER)
#undef STRUCT_INSTANCE_TYPE_CHECKER
// Define type checkers for classes with ranges of instance types.
#define INSTANCE_TYPE_CHECKER_RANGE(type, first_instance_type, \
last_instance_type) \
V8_INLINE bool Is##type(InstanceType instance_type) { \
return instance_type >= first_instance_type && \
instance_type <= last_instance_type; \
}
INSTANCE_TYPE_CHECKERS_RANGE(INSTANCE_TYPE_CHECKER_RANGE);
#undef INSTANCE_TYPE_CHECKER_RANGE
V8_INLINE bool IsFixedArrayBase(InstanceType instance_type) {
return IsFixedArray(instance_type) || IsFixedDoubleArray(instance_type) ||
IsFixedTypedArrayBase(instance_type) || IsByteArray(instance_type) ||
IsBytecodeArray(instance_type);
}
V8_INLINE bool IsHeapObject(InstanceType instance_type) { return true; }
V8_INLINE bool IsInternalizedString(InstanceType instance_type) {
STATIC_ASSERT(kNotInternalizedTag != 0);
return (instance_type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
(kStringTag | kInternalizedTag);
}
V8_INLINE bool IsJSObject(InstanceType instance_type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
return instance_type >= FIRST_JS_OBJECT_TYPE;
}
V8_INLINE bool IsJSReceiver(InstanceType instance_type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
return instance_type >= FIRST_JS_RECEIVER_TYPE;
}
} // namespace InstanceTypeChecker
// TODO(v8:7786): For instance types that have a single map instance on the
// roots, and when that map is a embedded in the binary, compare against the map
// pointer rather than looking up the instance type.
INSTANCE_TYPE_CHECKERS(TYPE_CHECKER);
#define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype) \
TYPE_CHECKER(Fixed##Type##Array)
TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
#undef TYPED_ARRAY_TYPE_CHECKER
bool HeapObject::IsUncompiledData() const { bool HeapObject::IsUncompiledData() const {
return IsUncompiledDataWithoutPreParsedScope() || return IsUncompiledDataWithoutPreParsedScope() ||
IsUncompiledDataWithPreParsedScope(); IsUncompiledDataWithPreParsedScope();
......
This diff is collapsed.
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
enum InstanceType : uint16_t;
class AllocationSite : public Struct, public NeverReadOnlySpaceObject { class AllocationSite : public Struct, public NeverReadOnlySpaceObject {
public: public:
static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "src/interpreter/bytecode-register.h" #include "src/interpreter/bytecode-register.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/objects/dictionary.h" #include "src/objects/dictionary.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/map-inl.h" #include "src/objects/map-inl.h"
#include "src/objects/maybe-object-inl.h" #include "src/objects/maybe-object-inl.h"
#include "src/objects/smi-inl.h" #include "src/objects/smi-inl.h"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define V8_OBJECTS_FIXED_ARRAY_H_ #define V8_OBJECTS_FIXED_ARRAY_H_
#include "src/maybe-handles.h" #include "src/maybe-handles.h"
#include "src/objects.h" #include "src/objects/instance-type.h"
#include "src/objects/slots.h" #include "src/objects/slots.h"
#include "src/objects/smi.h" #include "src/objects/smi.h"
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_INSTANCE_TYPE_INL_H_
#define V8_OBJECTS_INSTANCE_TYPE_INL_H_
#include "src/objects/map-inl.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
namespace InstanceTypeChecker {
// Define type checkers for classes with single instance type.
INSTANCE_TYPE_CHECKERS_SINGLE(INSTANCE_TYPE_CHECKER);
#define TYPED_ARRAY_INSTANCE_TYPE_CHECKER(Type, type, TYPE, ctype) \
INSTANCE_TYPE_CHECKER(Fixed##Type##Array, FIXED_##TYPE##_ARRAY_TYPE)
TYPED_ARRAYS(TYPED_ARRAY_INSTANCE_TYPE_CHECKER)
#undef TYPED_ARRAY_INSTANCE_TYPE_CHECKER
#define STRUCT_INSTANCE_TYPE_CHECKER(TYPE, Name, name) \
INSTANCE_TYPE_CHECKER(Name, TYPE)
STRUCT_LIST(STRUCT_INSTANCE_TYPE_CHECKER)
#undef STRUCT_INSTANCE_TYPE_CHECKER
// Define type checkers for classes with ranges of instance types.
#define INSTANCE_TYPE_CHECKER_RANGE(type, first_instance_type, \
last_instance_type) \
V8_INLINE bool Is##type(InstanceType instance_type) { \
return instance_type >= first_instance_type && \
instance_type <= last_instance_type; \
}
INSTANCE_TYPE_CHECKERS_RANGE(INSTANCE_TYPE_CHECKER_RANGE);
#undef INSTANCE_TYPE_CHECKER_RANGE
V8_INLINE bool IsFixedArrayBase(InstanceType instance_type) {
return IsFixedArray(instance_type) || IsFixedDoubleArray(instance_type) ||
IsFixedTypedArrayBase(instance_type) || IsByteArray(instance_type) ||
IsBytecodeArray(instance_type);
}
V8_INLINE bool IsHeapObject(InstanceType instance_type) { return true; }
V8_INLINE bool IsInternalizedString(InstanceType instance_type) {
STATIC_ASSERT(kNotInternalizedTag != 0);
return (instance_type & (kIsNotStringMask | kIsNotInternalizedMask)) ==
(kStringTag | kInternalizedTag);
}
V8_INLINE bool IsJSObject(InstanceType instance_type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
return instance_type >= FIRST_JS_OBJECT_TYPE;
}
V8_INLINE bool IsJSReceiver(InstanceType instance_type) {
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
return instance_type >= FIRST_JS_RECEIVER_TYPE;
}
} // namespace InstanceTypeChecker
// TODO(v8:7786): For instance types that have a single map instance on the
// roots, and when that map is a embedded in the binary, compare against the map
// pointer rather than looking up the instance type.
INSTANCE_TYPE_CHECKERS(TYPE_CHECKER);
#define TYPED_ARRAY_TYPE_CHECKER(Type, type, TYPE, ctype) \
TYPE_CHECKER(Fixed##Type##Array)
TYPED_ARRAYS(TYPED_ARRAY_TYPE_CHECKER)
#undef TYPED_ARRAY_TYPE_CHECKER
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_INSTANCE_TYPE_INL_H_
This diff is collapsed.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
enum InstanceType : uint16_t;
class JSGlobalObject; class JSGlobalObject;
class JSGlobalProxy; class JSGlobalProxy;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/api-callbacks-inl.h" #include "src/objects/api-callbacks-inl.h"
#include "src/objects/descriptor-array.h" #include "src/objects/descriptor-array.h"
#include "src/objects/instance-type-inl.h"
#include "src/objects/prototype-info-inl.h" #include "src/objects/prototype-info-inl.h"
#include "src/objects/shared-function-info.h" #include "src/objects/shared-function-info.h"
#include "src/objects/templates-inl.h" #include "src/objects/templates-inl.h"
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
enum InstanceType : uint16_t;
#define VISITOR_ID_LIST(V) \ #define VISITOR_ID_LIST(V) \
V(AllocationSite) \ V(AllocationSite) \
V(BigInt) \ V(BigInt) \
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_OBJECTS_STRING_H_ #define V8_OBJECTS_STRING_H_
#include "src/base/bits.h" #include "src/base/bits.h"
#include "src/objects/instance-type.h"
#include "src/objects/name.h" #include "src/objects/name.h"
#include "src/objects/smi.h" #include "src/objects/smi.h"
#include "src/unicode-decoder.h" #include "src/unicode-decoder.h"
...@@ -17,6 +18,7 @@ namespace v8 { ...@@ -17,6 +18,7 @@ namespace v8 {
namespace internal { namespace internal {
class BigInt; class BigInt;
enum InstanceType : uint16_t;
enum AllowNullsFlag { ALLOW_NULLS, DISALLOW_NULLS }; enum AllowNullsFlag { ALLOW_NULLS, DISALLOW_NULLS };
enum RobustnessFlag { ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL }; enum RobustnessFlag { ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL };
......
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