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

Unified Diff: src/types.h

Issue 509343002: Better typing and type verification (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Drop typedness from graph Created 6 years, 3 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
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index cca8b3167b4bb9b86773d7fcf40959490a9164f0..fcbdad9128efc7d70e262362b246cd9ed2148391 100644
--- a/src/types.h
+++ b/src/types.h
@@ -204,8 +204,9 @@ namespace internal {
V(Detectable, kDetectableReceiver | kNumber | kName) \
V(Object, kDetectableObject | kUndetectable) \
V(Receiver, kObject | kProxy) \
- V(NonNumber, kBoolean | kName | kNull | kReceiver | \
- kUndefined | kInternal) \
+ V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \
+ kReceiver) \
+ V(NonNumber, kUnique | kString | kInternal) \
V(Any, -1)
#define BITSET_TYPE_LIST(V) \
@@ -223,6 +224,7 @@ namespace internal {
// typedef Struct;
// typedef Region;
// template<class> struct Handle { typedef type; } // No template typedefs...
+// template<class T> static Handle<T>::type null_handle();
// template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t)
// template<class T> static Handle<T>::type cast(Handle<Type>::type);
// static bool is_bitset(Type*);
@@ -330,6 +332,12 @@ class TypeImpl : public Config::Base {
static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg);
+ static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) {
+ return BitsetType::New(type1->AsBitset() | type2->AsBitset());
+ }
+ static TypeImpl* Intersect(TypeImpl* type1, TypeImpl* type2) {
+ return BitsetType::New(type1->AsBitset() & type2->AsBitset());
+ }
static TypeHandle Of(double value, Region* region) {
return Config::from_bitset(BitsetType::Lub(value), region);
@@ -858,6 +866,7 @@ struct ZoneTypeConfig {
return region->isolate();
}
+ template<class T> static inline T* null_handle();
template<class T> static inline T* handle(T* type);
template<class T> static inline T* cast(Type* type);
@@ -905,6 +914,7 @@ struct HeapTypeConfig {
return region;
}
+ template<class T> static inline i::Handle<T> null_handle();
template<class T> static inline i::Handle<T> handle(T* type);
template<class T> static inline i::Handle<T> cast(i::Handle<Type> type);
@@ -953,7 +963,9 @@ struct BoundsImpl {
TypeHandle lower;
TypeHandle upper;
- BoundsImpl() {}
+ BoundsImpl() : // Make sure accessing uninitialized bounds crashes big-time.
+ lower(Config::template null_handle<Type>()),
+ upper(Config::template null_handle<Type>()) {}
explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {}
BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) {
DCHECK(lower->Is(upper));
« src/compiler/js-graph.cc ('K') | « src/compiler/verifier.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698