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

Unified Diff: src/types.h

Issue 1636013002: Replace HeapType with a non-templated FieldType class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tracing of generalizations Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« src/ic/ic.cc ('K') | « src/property.h ('k') | src/types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 7f224090adbd5e03f1a81dfe3d96ac52bb781a58..0c4ef26fff127021332967c838a9e07926687fbe 100644
--- a/src/types.h
+++ b/src/types.h
@@ -143,14 +143,6 @@ namespace internal {
// bitsets. Bit 0 is reserved for tagging. Class is a heap pointer to the
// respective map. Only structured types require allocation.
// Note that the bitset representation is closed under both Union and Intersect.
-//
-// There are two type representations, using different allocation:
-//
-// - class Type (zone-allocated, for compiler and concurrent compilation)
-// - class HeapType (heap-allocated, for persistent types)
-//
-// Both provide the same API, and the Convert method can be used to interconvert
-// them. For zone types, no query method touches the heap, only constructors do.
// -----------------------------------------------------------------------------
@@ -556,10 +548,6 @@ class TypeImpl : public Config::Base {
static inline TypeImpl* cast(typename Config::Base* object);
- template<class OtherTypeImpl>
- static TypeHandle Convert(
- typename OtherTypeImpl::TypeHandle type, Region* region);
-
// Printing.
enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM };
@@ -1090,70 +1078,6 @@ struct ZoneTypeConfig {
typedef TypeImpl<ZoneTypeConfig> Type;
-
-// -----------------------------------------------------------------------------
-// Heap-allocated types; either smis for bitsets, maps for classes, boxes for
-// constants, or fixed arrays for unions.
-
-struct HeapTypeConfig {
- typedef TypeImpl<HeapTypeConfig> Type;
- typedef i::Object Base;
- typedef i::FixedArray Struct;
- typedef i::FixedArray Range;
- typedef i::Isolate Region;
- template<class T> struct Handle { typedef i::Handle<T> type; };
-
- static const int kRangeStructTag = 0xffff;
-
- template<class T> static inline i::Handle<T> null_handle() {
- return i::Handle<T>();
- }
- template<class T> static inline i::Handle<T> handle(T* type);
- template<class T> static inline i::Handle<T> cast(i::Handle<Type> type);
-
- static inline bool is_bitset(Type* type);
- static inline bool is_class(Type* type);
- static inline bool is_struct(Type* type, int tag);
- static inline bool is_range(Type* type);
-
- static inline Type::bitset as_bitset(Type* type);
- static inline i::Handle<i::Map> as_class(Type* type);
- static inline i::Handle<Struct> as_struct(Type* type);
- static inline i::Handle<Range> as_range(Type* type);
-
- static inline Type* from_bitset(Type::bitset);
- static inline i::Handle<Type> from_bitset(Type::bitset, Isolate* isolate);
- static inline i::Handle<Type> from_class(
- i::Handle<i::Map> map, Isolate* isolate);
- static inline i::Handle<Type> from_struct(i::Handle<Struct> structure);
- static inline i::Handle<Type> from_range(i::Handle<Range> range);
-
- static inline i::Handle<Struct> struct_create(
- int tag, int length, Isolate* isolate);
- static inline void struct_shrink(i::Handle<Struct> structure, int length);
- static inline int struct_tag(i::Handle<Struct> structure);
- static inline int struct_length(i::Handle<Struct> structure);
- static inline i::Handle<Type> struct_get(i::Handle<Struct> structure, int i);
- static inline void struct_set(
- i::Handle<Struct> structure, int i, i::Handle<Type> type);
- template<class V>
- static inline i::Handle<V> struct_get_value(
- i::Handle<Struct> structure, int i);
- template<class V>
- static inline void struct_set_value(
- i::Handle<Struct> structure, int i, i::Handle<V> x);
-
- static inline i::Handle<Range> range_create(Isolate* isolate);
- static inline int range_get_bitset(i::Handle<Range> range);
- static inline void range_set_bitset(i::Handle<Range> range, int value);
- static inline double range_get_double(i::Handle<Range> range, int index);
- static inline void range_set_double(i::Handle<Range> range, int index,
- double value, Isolate* isolate);
-};
-
-typedef TypeImpl<HeapTypeConfig> HeapType;
-
-
// -----------------------------------------------------------------------------
// Type bounds. A simple struct to represent a pair of lower/upper types.
@@ -1216,6 +1140,57 @@ struct BoundsImpl {
typedef BoundsImpl<ZoneTypeConfig> Bounds;
+class FieldType : public Object {
+ public:
+ class Iterator;
+
+ // static Handle<FieldType> Create(Isolate* isolate, int length);
+ static FieldType* None();
+ static FieldType* Any();
+ static Handle<FieldType> None(Isolate* isolate);
+ static Handle<FieldType> Any(Isolate* isolate);
+ static FieldType* Class(i::Map* map);
+ static Handle<FieldType> Class(i::Handle<i::Map> map, Isolate* isolate);
+ static FieldType* cast(Object* object);
+
+ bool NowContains(Object* value);
+ bool NowContains(Handle<Object> value);
+ bool IsClass();
+ Handle<i::Map> AsClass();
+ bool IsNone() { return this == None(); }
+ bool IsAny() { return this == Any(); }
+ bool NowStable();
+ bool NowIs(FieldType* other);
+ bool NowIs(Handle<FieldType> other);
+ Type* Convert(Zone* zone);
+ Iterator Classes();
+ int ClassCount() { return IsClass() ? 1 : 0; }
+
+ void PrintTo(std::ostream& os);
+};
+
+class FieldType::Iterator {
+ public:
+ bool Done() const { return done_; }
+ i::Handle<i::Map> Current() {
+ DCHECK(!Done());
+ return map_.ToHandleChecked();
+ }
+ void Advance() {
+ if (!done_) done_ = true;
+ }
+
+ private:
+ friend FieldType;
+
+ Iterator() : done_(true) {}
+ explicit Iterator(MaybeHandle<i::Map> map)
+ : done_(map.is_null()), map_(map) {}
+
+ bool done_;
+ MaybeHandle<i::Map> map_;
+};
+
} // namespace internal
} // namespace v8
« src/ic/ic.cc ('K') | « src/property.h ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698