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

Side by Side Diff: test/cctest/test-types.cc

Issue 232913002: Treat uninitialized as internal type. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 30 matching lines...) Expand all
41 types.reserve(kMaxTypes); 41 types.reserve(kMaxTypes);
42 42
43 #define DECLARE_TYPE(name, value) \ 43 #define DECLARE_TYPE(name, value) \
44 name = Type::name(region); \ 44 name = Type::name(region); \
45 types.push_back(name); 45 types.push_back(name);
46 BITSET_TYPE_LIST(DECLARE_TYPE) 46 BITSET_TYPE_LIST(DECLARE_TYPE)
47 #undef DECLARE_TYPE 47 #undef DECLARE_TYPE
48 48
49 object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize); 49 object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize);
50 array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize); 50 array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize);
51 uninitialized_map = isolate->factory()->uninitialized_map();
51 ObjectClass = Type::Class(object_map, region); 52 ObjectClass = Type::Class(object_map, region);
52 ArrayClass = Type::Class(array_map, region); 53 ArrayClass = Type::Class(array_map, region);
54 UninitializedClass = Type::Class(uninitialized_map, region);
53 55
54 maps.push_back(object_map); 56 maps.push_back(object_map);
55 maps.push_back(array_map); 57 maps.push_back(array_map);
58 maps.push_back(uninitialized_map);
56 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) { 59 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) {
57 types.push_back(Type::Class(*it, region)); 60 types.push_back(Type::Class(*it, region));
58 } 61 }
59 62
60 smi = handle(Smi::FromInt(666), isolate); 63 smi = handle(Smi::FromInt(666), isolate);
61 signed32 = isolate->factory()->NewHeapNumber(0x40000000); 64 signed32 = isolate->factory()->NewHeapNumber(0x40000000);
62 object1 = isolate->factory()->NewJSObjectFromMap(object_map); 65 object1 = isolate->factory()->NewJSObjectFromMap(object_map);
63 object2 = isolate->factory()->NewJSObjectFromMap(object_map); 66 object2 = isolate->factory()->NewJSObjectFromMap(object_map);
64 array = isolate->factory()->NewJSArray(20); 67 array = isolate->factory()->NewJSArray(20);
68 uninitialized = isolate->factory()->uninitialized_value();
65 SmiConstant = Type::Constant(smi, region); 69 SmiConstant = Type::Constant(smi, region);
66 Signed32Constant = Type::Constant(signed32, region); 70 Signed32Constant = Type::Constant(signed32, region);
67 ObjectConstant1 = Type::Constant(object1, region); 71 ObjectConstant1 = Type::Constant(object1, region);
68 ObjectConstant2 = Type::Constant(object2, region); 72 ObjectConstant2 = Type::Constant(object2, region);
69 ArrayConstant = Type::Constant(array, region); 73 ArrayConstant = Type::Constant(array, region);
74 UninitializedConstant = Type::Constant(uninitialized, region);
70 75
71 values.push_back(smi); 76 values.push_back(smi);
72 values.push_back(signed32); 77 values.push_back(signed32);
73 values.push_back(object1); 78 values.push_back(object1);
74 values.push_back(object2); 79 values.push_back(object2);
75 values.push_back(array); 80 values.push_back(array);
81 values.push_back(uninitialized);
76 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { 82 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) {
77 types.push_back(Type::Constant(*it, region)); 83 types.push_back(Type::Constant(*it, region));
78 } 84 }
79 85
80 while (types.size() < kMaxTypes) { 86 while (types.size() < kMaxTypes) {
81 size_t i = rng.NextInt(static_cast<int>(types.size())); 87 size_t i = rng.NextInt(static_cast<int>(types.size()));
82 size_t j = rng.NextInt(static_cast<int>(types.size())); 88 size_t j = rng.NextInt(static_cast<int>(types.size()));
83 if (i != j) types.push_back(Type::Union(types[i], types[j], region)); 89 if (i != j) types.push_back(Type::Union(types[i], types[j], region));
84 } 90 }
85 } 91 }
86 92
87 RandomNumberGenerator rng; 93 RandomNumberGenerator rng;
88 94
89 #define DECLARE_TYPE(name, value) TypeHandle name; 95 #define DECLARE_TYPE(name, value) TypeHandle name;
90 BITSET_TYPE_LIST(DECLARE_TYPE) 96 BITSET_TYPE_LIST(DECLARE_TYPE)
91 #undef DECLARE_TYPE 97 #undef DECLARE_TYPE
92 98
93 TypeHandle ObjectClass; 99 TypeHandle ObjectClass;
94 TypeHandle ArrayClass; 100 TypeHandle ArrayClass;
101 TypeHandle UninitializedClass;
95 102
96 TypeHandle SmiConstant; 103 TypeHandle SmiConstant;
97 TypeHandle Signed32Constant; 104 TypeHandle Signed32Constant;
98 TypeHandle ObjectConstant1; 105 TypeHandle ObjectConstant1;
99 TypeHandle ObjectConstant2; 106 TypeHandle ObjectConstant2;
100 TypeHandle ArrayConstant; 107 TypeHandle ArrayConstant;
108 TypeHandle UninitializedConstant;
101 109
102 Handle<i::Map> object_map; 110 Handle<i::Map> object_map;
103 Handle<i::Map> array_map; 111 Handle<i::Map> array_map;
112 Handle<i::Map> uninitialized_map;
104 113
105 Handle<i::Smi> smi; 114 Handle<i::Smi> smi;
106 Handle<i::HeapNumber> signed32; 115 Handle<i::HeapNumber> signed32;
107 Handle<i::JSObject> object1; 116 Handle<i::JSObject> object1;
108 Handle<i::JSObject> object2; 117 Handle<i::JSObject> object2;
109 Handle<i::JSArray> array; 118 Handle<i::JSArray> array;
119 Handle<i::Oddball> uninitialized;
110 120
111 typedef std::vector<TypeHandle> TypeVector; 121 typedef std::vector<TypeHandle> TypeVector;
112 typedef std::vector<Handle<i::Map> > MapVector; 122 typedef std::vector<Handle<i::Map> > MapVector;
113 typedef std::vector<Handle<i::Object> > ValueVector; 123 typedef std::vector<Handle<i::Object> > ValueVector;
114 TypeVector types; 124 TypeVector types;
115 MapVector maps; 125 MapVector maps;
116 ValueVector values; 126 ValueVector values;
117 127
118 TypeHandle Of(Handle<i::Object> value) { 128 TypeHandle Of(Handle<i::Object> value) {
119 return Type::Of(value, region_); 129 return Type::Of(value, region_);
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 CheckUnordered(T.String, T.Symbol); 551 CheckUnordered(T.String, T.Symbol);
542 CheckUnordered(T.InternalizedString, T.Symbol); 552 CheckUnordered(T.InternalizedString, T.Symbol);
543 553
544 CheckSub(T.Object, T.Receiver); 554 CheckSub(T.Object, T.Receiver);
545 CheckSub(T.Array, T.Object); 555 CheckSub(T.Array, T.Object);
546 CheckSub(T.Function, T.Object); 556 CheckSub(T.Function, T.Object);
547 CheckSub(T.Proxy, T.Receiver); 557 CheckSub(T.Proxy, T.Receiver);
548 CheckUnordered(T.Object, T.Proxy); 558 CheckUnordered(T.Object, T.Proxy);
549 CheckUnordered(T.Array, T.Function); 559 CheckUnordered(T.Array, T.Function);
550 560
561 CheckSub(T.UninitializedClass, T.Internal);
rossberg 2014/04/10 11:39:44 Nit: these should go to the next section
562 CheckSub(T.UninitializedConstant, T.Internal);
563 CheckUnordered(T.UninitializedClass, T.Null);
564 CheckUnordered(T.UninitializedClass, T.Undefined);
565 CheckUnordered(T.UninitializedConstant, T.Null);
566 CheckUnordered(T.UninitializedConstant, T.Undefined);
567
551 // Structural types 568 // Structural types
552 CheckSub(T.ObjectClass, T.Object); 569 CheckSub(T.ObjectClass, T.Object);
553 CheckSub(T.ArrayClass, T.Object); 570 CheckSub(T.ArrayClass, T.Object);
554 CheckUnordered(T.ObjectClass, T.ArrayClass); 571 CheckUnordered(T.ObjectClass, T.ArrayClass);
555 572
556 CheckSub(T.SmiConstant, T.SignedSmall); 573 CheckSub(T.SmiConstant, T.SignedSmall);
557 CheckSub(T.SmiConstant, T.Signed32); 574 CheckSub(T.SmiConstant, T.Signed32);
558 CheckSub(T.SmiConstant, T.Number); 575 CheckSub(T.SmiConstant, T.Number);
559 CheckSub(T.ObjectConstant1, T.Object); 576 CheckSub(T.ObjectConstant1, T.Object);
560 CheckSub(T.ObjectConstant2, T.Object); 577 CheckSub(T.ObjectConstant2, T.Object);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 ZoneTests().Intersect(); 1293 ZoneTests().Intersect();
1277 HeapTests().Intersect(); 1294 HeapTests().Intersect();
1278 } 1295 }
1279 1296
1280 1297
1281 TEST(Convert) { 1298 TEST(Convert) {
1282 CcTest::InitializeVM(); 1299 CcTest::InitializeVM();
1283 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 1300 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
1284 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 1301 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
1285 } 1302 }
OLDNEW
« no previous file with comments | « src/types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698