| Index: test/cctest/test-types.cc
|
| diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
|
| index 6840c9f1e0dd649261b76165bcb8fec67dbc6e9c..1955f2b81e479a362fd7ee24b77bcdc754104d10 100644
|
| --- a/test/cctest/test-types.cc
|
| +++ b/test/cctest/test-types.cc
|
| @@ -35,61 +35,43 @@ using namespace v8::internal;
|
| template<class Type, class TypeHandle, class Region>
|
| class Types {
|
| public:
|
| - Types(Region* region, Isolate* isolate) :
|
| - Representation(Type::Representation(region)),
|
| - Semantic(Type::Semantic(region)),
|
| - None(Type::None(region)),
|
| - Any(Type::Any(region)),
|
| - Boolean(Type::Boolean(region)),
|
| - Null(Type::Null(region)),
|
| - Undefined(Type::Undefined(region)),
|
| - Number(Type::Number(region)),
|
| - SignedSmall(Type::SignedSmall(region)),
|
| - Signed32(Type::Signed32(region)),
|
| - Float(Type::Float(region)),
|
| - Name(Type::Name(region)),
|
| - UniqueName(Type::UniqueName(region)),
|
| - String(Type::String(region)),
|
| - InternalizedString(Type::InternalizedString(region)),
|
| - Symbol(Type::Symbol(region)),
|
| - Receiver(Type::Receiver(region)),
|
| - Object(Type::Object(region)),
|
| - Array(Type::Array(region)),
|
| - Function(Type::Function(region)),
|
| - Proxy(Type::Proxy(region)),
|
| - object_map(isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize)),
|
| - array_map(isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize)),
|
| - region_(region) {
|
| + Types(Region* region, Isolate* isolate) : region_(region) {
|
| + static const size_t kMaxTypes = 300;
|
| + types.reserve(kMaxTypes);
|
| +
|
| + #define DECLARE_TYPE(name, value) \
|
| + name = Type::name(region); \
|
| + types.push_back(name);
|
| + BITSET_TYPE_LIST(DECLARE_TYPE)
|
| + #undef DECLARE_TYPE
|
| +
|
| + object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize);
|
| + array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize);
|
| + ObjectClass = Type::Class(object_map, region);
|
| + ArrayClass = Type::Class(array_map, region);
|
| + types.push_back(ObjectClass);
|
| + types.push_back(ArrayClass);
|
| +
|
| smi = handle(Smi::FromInt(666), isolate);
|
| signed32 = isolate->factory()->NewHeapNumber(0x40000000);
|
| object1 = isolate->factory()->NewJSObjectFromMap(object_map);
|
| object2 = isolate->factory()->NewJSObjectFromMap(object_map);
|
| array = isolate->factory()->NewJSArray(20);
|
| - ObjectClass = Type::Class(object_map, region);
|
| - ArrayClass = Type::Class(array_map, region);
|
| + values.push_back(smi);
|
| + values.push_back(signed32);
|
| + values.push_back(object1);
|
| + values.push_back(object2);
|
| + values.push_back(array);
|
| SmiConstant = Type::Constant(smi, region);
|
| Signed32Constant = Type::Constant(signed32, region);
|
| ObjectConstant1 = Type::Constant(object1, region);
|
| ObjectConstant2 = Type::Constant(object2, region);
|
| ArrayConstant1 = Type::Constant(array, region);
|
| ArrayConstant2 = Type::Constant(array, region);
|
| -
|
| - objects.push_back(smi);
|
| - objects.push_back(signed32);
|
| - objects.push_back(object1);
|
| - objects.push_back(object2);
|
| - objects.push_back(array);
|
| -
|
| - static const size_t kMaxTypes = 300;
|
| - types.reserve(kMaxTypes);
|
| -#define PUSH_BACK_BITSET_TYPE(type, value) \
|
| - types.push_back(Type::type(region));
|
| - BITSET_TYPE_LIST(PUSH_BACK_BITSET_TYPE)
|
| -#undef PUSH_BACK_BITSET_TYPE
|
| - types.push_back(ObjectClass);
|
| - types.push_back(ArrayClass);
|
| - for (ObjectVector::iterator it = objects.begin(); it != objects.end(); ++it)
|
| + for (ObjectVector::iterator it = values.begin(); it != values.end(); ++it) {
|
| types.push_back(Type::Constant(*it, region));
|
| + }
|
| +
|
| while (types.size() < kMaxTypes) {
|
| size_t i = rand() % types.size();
|
| size_t j = rand() % types.size();
|
| @@ -97,27 +79,9 @@ class Types {
|
| }
|
| }
|
|
|
| - TypeHandle Representation;
|
| - TypeHandle Semantic;
|
| - TypeHandle None;
|
| - TypeHandle Any;
|
| - TypeHandle Boolean;
|
| - TypeHandle Null;
|
| - TypeHandle Undefined;
|
| - TypeHandle Number;
|
| - TypeHandle SignedSmall;
|
| - TypeHandle Signed32;
|
| - TypeHandle Float;
|
| - TypeHandle Name;
|
| - TypeHandle UniqueName;
|
| - TypeHandle String;
|
| - TypeHandle InternalizedString;
|
| - TypeHandle Symbol;
|
| - TypeHandle Receiver;
|
| - TypeHandle Object;
|
| - TypeHandle Array;
|
| - TypeHandle Function;
|
| - TypeHandle Proxy;
|
| + #define DECLARE_TYPE(name, value) TypeHandle name;
|
| + BITSET_TYPE_LIST(DECLARE_TYPE)
|
| + #undef DECLARE_TYPE
|
|
|
| TypeHandle ObjectClass;
|
| TypeHandle ArrayClass;
|
| @@ -142,7 +106,7 @@ class Types {
|
| TypeVector types;
|
|
|
| typedef std::vector<Handle<i::Object> > ObjectVector;
|
| - ObjectVector objects;
|
| + ObjectVector values;
|
|
|
| TypeHandle Of(Handle<i::Object> obj) {
|
| return Type::Of(obj, region_);
|
| @@ -230,14 +194,14 @@ struct HeapRep {
|
|
|
| template<class Type, class TypeHandle, class Region, class Rep>
|
| struct Tests : Rep {
|
| + typedef Types<Type, TypeHandle, Region> TypesInstance;
|
| + typedef typename TypesInstance::TypeVector::iterator TypeIterator;
|
| + typedef typename TypesInstance::ObjectVector::iterator ObjectIterator;
|
| +
|
| Isolate* isolate;
|
| HandleScope scope;
|
| Zone zone;
|
| - Types<Type, TypeHandle, Region> T;
|
| - typedef typename Types<Type, TypeHandle, Region>::TypeVector::iterator
|
| - TypeIterator;
|
| - typedef typename Types<Type, TypeHandle, Region>::ObjectVector::iterator
|
| - ObjectIterator;
|
| + TypesInstance T;
|
|
|
| Tests() :
|
| isolate(CcTest::i_isolate()),
|
| @@ -515,7 +479,7 @@ struct Tests : Rep {
|
| void Contains() {
|
| // T->Contains(O) iff Constant(O)->Is(T) for all T,O
|
| for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
|
| - for (ObjectIterator ot = T.objects.begin(); ot != T.objects.end(); ++ot) {
|
| + for (ObjectIterator ot = T.values.begin(); ot != T.values.end(); ++ot) {
|
| TypeHandle type = *it;
|
| Handle<i::Object> obj = *ot;
|
| CHECK(type->Contains(obj) == T.Constant(obj)->Is(type));
|
| @@ -524,7 +488,7 @@ struct Tests : Rep {
|
|
|
| // Of(O)->Is(T) implies T->Contains(O) for all T,O
|
| for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
|
| - for (ObjectIterator ot = T.objects.begin(); ot != T.objects.end(); ++ot) {
|
| + for (ObjectIterator ot = T.values.begin(); ot != T.values.end(); ++ot) {
|
| TypeHandle type = *it;
|
| Handle<i::Object> obj = *ot;
|
| CHECK(!T.Of(obj)->Is(type) || type->Contains(obj));
|
| @@ -539,7 +503,7 @@ struct Tests : Rep {
|
| CHECK(type->Maybe(type) || !type->IsInhabited());
|
| }
|
|
|
| - // Commutativity
|
| + // Symmetry
|
| for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
|
| for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
|
| TypeHandle type1 = *it1;
|
|
|