| OLD | NEW |
| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return handle(Type::Intersect(type1, type2), isolate_); | 185 return handle(Type::Intersect(type1, type2), isolate_); |
| 186 } | 186 } |
| 187 | 187 |
| 188 private: | 188 private: |
| 189 Isolate* isolate_; | 189 Isolate* isolate_; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 | 192 |
| 193 TEST(Bitset) { | 193 TEST(Bitset) { |
| 194 CcTest::InitializeVM(); | 194 CcTest::InitializeVM(); |
| 195 Isolate* isolate = Isolate::Current(); | 195 Isolate* isolate = CcTest::i_isolate(); |
| 196 HandleScope scope(isolate); | 196 HandleScope scope(isolate); |
| 197 HandlifiedTypes T(isolate); | 197 HandlifiedTypes T(isolate); |
| 198 | 198 |
| 199 CHECK(IsBitset(*T.None)); | 199 CHECK(IsBitset(*T.None)); |
| 200 CHECK(IsBitset(*T.Any)); | 200 CHECK(IsBitset(*T.Any)); |
| 201 CHECK(IsBitset(*T.String)); | 201 CHECK(IsBitset(*T.String)); |
| 202 CHECK(IsBitset(*T.Object)); | 202 CHECK(IsBitset(*T.Object)); |
| 203 | 203 |
| 204 CHECK(IsBitset(Type::Union(T.String, T.Number))); | 204 CHECK(IsBitset(Type::Union(T.String, T.Number))); |
| 205 CHECK(IsBitset(Type::Union(T.String, T.Receiver))); | 205 CHECK(IsBitset(Type::Union(T.String, T.Receiver))); |
| 206 CHECK(IsBitset(Type::Optional(T.Object))); | 206 CHECK(IsBitset(Type::Optional(T.Object))); |
| 207 | 207 |
| 208 CHECK_EQ(0, AsBitset(*T.None)); | 208 CHECK_EQ(0, AsBitset(*T.None)); |
| 209 CHECK_EQ(AsBitset(*T.Number) | AsBitset(*T.String), | 209 CHECK_EQ(AsBitset(*T.Number) | AsBitset(*T.String), |
| 210 AsBitset(Type::Union(T.String, T.Number))); | 210 AsBitset(Type::Union(T.String, T.Number))); |
| 211 CHECK_EQ(AsBitset(*T.Receiver), | 211 CHECK_EQ(AsBitset(*T.Receiver), |
| 212 AsBitset(Type::Union(T.Receiver, T.Object))); | 212 AsBitset(Type::Union(T.Receiver, T.Object))); |
| 213 CHECK_EQ(AsBitset(*T.String) | AsBitset(*T.Undefined), | 213 CHECK_EQ(AsBitset(*T.String) | AsBitset(*T.Undefined), |
| 214 AsBitset(Type::Optional(T.String))); | 214 AsBitset(Type::Optional(T.String))); |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 TEST(Class) { | 218 TEST(Class) { |
| 219 CcTest::InitializeVM(); | 219 CcTest::InitializeVM(); |
| 220 Isolate* isolate = Isolate::Current(); | 220 Isolate* isolate = CcTest::i_isolate(); |
| 221 HandleScope scope(isolate); | 221 HandleScope scope(isolate); |
| 222 HandlifiedTypes T(isolate); | 222 HandlifiedTypes T(isolate); |
| 223 | 223 |
| 224 CHECK(IsClass(*T.ObjectClass)); | 224 CHECK(IsClass(*T.ObjectClass)); |
| 225 CHECK(IsClass(*T.ArrayClass)); | 225 CHECK(IsClass(*T.ArrayClass)); |
| 226 | 226 |
| 227 CHECK(*T.object_map == AsClass(*T.ObjectClass)); | 227 CHECK(*T.object_map == AsClass(*T.ObjectClass)); |
| 228 CHECK(*T.array_map == AsClass(*T.ArrayClass)); | 228 CHECK(*T.array_map == AsClass(*T.ArrayClass)); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 TEST(Constant) { | 232 TEST(Constant) { |
| 233 CcTest::InitializeVM(); | 233 CcTest::InitializeVM(); |
| 234 Isolate* isolate = Isolate::Current(); | 234 Isolate* isolate = CcTest::i_isolate(); |
| 235 HandleScope scope(isolate); | 235 HandleScope scope(isolate); |
| 236 HandlifiedTypes T(isolate); | 236 HandlifiedTypes T(isolate); |
| 237 | 237 |
| 238 CHECK(IsConstant(*T.Integer31Constant)); | 238 CHECK(IsConstant(*T.Integer31Constant)); |
| 239 CHECK(IsConstant(*T.ObjectConstant1)); | 239 CHECK(IsConstant(*T.ObjectConstant1)); |
| 240 CHECK(IsConstant(*T.ObjectConstant2)); | 240 CHECK(IsConstant(*T.ObjectConstant2)); |
| 241 CHECK(IsConstant(*T.ArrayConstant1)); | 241 CHECK(IsConstant(*T.ArrayConstant1)); |
| 242 CHECK(IsConstant(*T.ArrayConstant2)); | 242 CHECK(IsConstant(*T.ArrayConstant2)); |
| 243 | 243 |
| 244 CHECK(*T.smi == AsConstant(*T.Integer31Constant)); | 244 CHECK(*T.smi == AsConstant(*T.Integer31Constant)); |
| 245 CHECK(*T.object1 == AsConstant(*T.ObjectConstant1)); | 245 CHECK(*T.object1 == AsConstant(*T.ObjectConstant1)); |
| 246 CHECK(*T.object2 == AsConstant(*T.ObjectConstant2)); | 246 CHECK(*T.object2 == AsConstant(*T.ObjectConstant2)); |
| 247 CHECK(*T.object1 != AsConstant(*T.ObjectConstant2)); | 247 CHECK(*T.object1 != AsConstant(*T.ObjectConstant2)); |
| 248 CHECK(*T.array == AsConstant(*T.ArrayConstant1)); | 248 CHECK(*T.array == AsConstant(*T.ArrayConstant1)); |
| 249 CHECK(*T.array == AsConstant(*T.ArrayConstant2)); | 249 CHECK(*T.array == AsConstant(*T.ArrayConstant2)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 TEST(Is) { | 253 TEST(Is) { |
| 254 CcTest::InitializeVM(); | 254 CcTest::InitializeVM(); |
| 255 Isolate* isolate = Isolate::Current(); | 255 Isolate* isolate = CcTest::i_isolate(); |
| 256 HandleScope scope(isolate); | 256 HandleScope scope(isolate); |
| 257 HandlifiedTypes T(isolate); | 257 HandlifiedTypes T(isolate); |
| 258 | 258 |
| 259 // Reflexivity | 259 // Reflexivity |
| 260 CHECK(T.None->Is(T.None)); | 260 CHECK(T.None->Is(T.None)); |
| 261 CHECK(T.Any->Is(T.Any)); | 261 CHECK(T.Any->Is(T.Any)); |
| 262 CHECK(T.Object->Is(T.Object)); | 262 CHECK(T.Object->Is(T.Object)); |
| 263 | 263 |
| 264 CHECK(T.ObjectClass->Is(T.ObjectClass)); | 264 CHECK(T.ObjectClass->Is(T.ObjectClass)); |
| 265 CHECK(T.ObjectConstant1->Is(T.ObjectConstant1)); | 265 CHECK(T.ObjectConstant1->Is(T.ObjectConstant1)); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 CheckUnordered(T.ObjectConstant1, T.ObjectClass); | 325 CheckUnordered(T.ObjectConstant1, T.ObjectClass); |
| 326 CheckUnordered(T.ObjectConstant2, T.ObjectClass); | 326 CheckUnordered(T.ObjectConstant2, T.ObjectClass); |
| 327 CheckUnordered(T.ObjectConstant1, T.ArrayClass); | 327 CheckUnordered(T.ObjectConstant1, T.ArrayClass); |
| 328 CheckUnordered(T.ObjectConstant2, T.ArrayClass); | 328 CheckUnordered(T.ObjectConstant2, T.ArrayClass); |
| 329 CheckUnordered(T.ArrayConstant1, T.ObjectClass); | 329 CheckUnordered(T.ArrayConstant1, T.ObjectClass); |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 TEST(Maybe) { | 333 TEST(Maybe) { |
| 334 CcTest::InitializeVM(); | 334 CcTest::InitializeVM(); |
| 335 Isolate* isolate = Isolate::Current(); | 335 Isolate* isolate = CcTest::i_isolate(); |
| 336 HandleScope scope(isolate); | 336 HandleScope scope(isolate); |
| 337 HandlifiedTypes T(isolate); | 337 HandlifiedTypes T(isolate); |
| 338 | 338 |
| 339 CheckOverlap(T.Any, T.Any); | 339 CheckOverlap(T.Any, T.Any); |
| 340 CheckOverlap(T.Object, T.Object); | 340 CheckOverlap(T.Object, T.Object); |
| 341 | 341 |
| 342 CheckOverlap(T.Oddball, T.Any); | 342 CheckOverlap(T.Oddball, T.Any); |
| 343 CheckOverlap(T.Boolean, T.Oddball); | 343 CheckOverlap(T.Boolean, T.Oddball); |
| 344 CheckOverlap(T.Null, T.Oddball); | 344 CheckOverlap(T.Null, T.Oddball); |
| 345 CheckOverlap(T.Undefined, T.Oddball); | 345 CheckOverlap(T.Undefined, T.Oddball); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 CheckDisjoint(T.ObjectConstant1, T.ObjectClass); | 396 CheckDisjoint(T.ObjectConstant1, T.ObjectClass); |
| 397 CheckDisjoint(T.ObjectConstant2, T.ObjectClass); | 397 CheckDisjoint(T.ObjectConstant2, T.ObjectClass); |
| 398 CheckDisjoint(T.ObjectConstant1, T.ArrayClass); | 398 CheckDisjoint(T.ObjectConstant1, T.ArrayClass); |
| 399 CheckDisjoint(T.ObjectConstant2, T.ArrayClass); | 399 CheckDisjoint(T.ObjectConstant2, T.ArrayClass); |
| 400 CheckDisjoint(T.ArrayConstant1, T.ObjectClass); | 400 CheckDisjoint(T.ArrayConstant1, T.ObjectClass); |
| 401 } | 401 } |
| 402 | 402 |
| 403 | 403 |
| 404 TEST(Union) { | 404 TEST(Union) { |
| 405 CcTest::InitializeVM(); | 405 CcTest::InitializeVM(); |
| 406 Isolate* isolate = Isolate::Current(); | 406 Isolate* isolate = CcTest::i_isolate(); |
| 407 HandleScope scope(isolate); | 407 HandleScope scope(isolate); |
| 408 HandlifiedTypes T(isolate); | 408 HandlifiedTypes T(isolate); |
| 409 | 409 |
| 410 // Bitset-bitset | 410 // Bitset-bitset |
| 411 CHECK(IsBitset(Type::Union(T.Object, T.Number))); | 411 CHECK(IsBitset(Type::Union(T.Object, T.Number))); |
| 412 CHECK(IsBitset(Type::Union(T.Object, T.Object))); | 412 CHECK(IsBitset(Type::Union(T.Object, T.Object))); |
| 413 CHECK(IsBitset(Type::Union(T.Any, T.None))); | 413 CHECK(IsBitset(Type::Union(T.Any, T.None))); |
| 414 | 414 |
| 415 CheckEqual(T.Union(T.None, T.Number), T.Number); | 415 CheckEqual(T.Union(T.None, T.Number), T.Number); |
| 416 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver); | 416 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 T.Union(T.ObjectConstant1, T.ArrayConstant2)), | 562 T.Union(T.ObjectConstant1, T.ArrayConstant2)), |
| 563 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1)); | 563 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1)); |
| 564 CheckEqual( | 564 CheckEqual( |
| 565 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Integer31, T.Array)), | 565 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Integer31, T.Array)), |
| 566 T.Union(T.Number, T.Array)); | 566 T.Union(T.Number, T.Array)); |
| 567 } | 567 } |
| 568 | 568 |
| 569 | 569 |
| 570 TEST(Intersect) { | 570 TEST(Intersect) { |
| 571 CcTest::InitializeVM(); | 571 CcTest::InitializeVM(); |
| 572 Isolate* isolate = Isolate::Current(); | 572 Isolate* isolate = CcTest::i_isolate(); |
| 573 HandleScope scope(isolate); | 573 HandleScope scope(isolate); |
| 574 HandlifiedTypes T(isolate); | 574 HandlifiedTypes T(isolate); |
| 575 | 575 |
| 576 // Bitset-bitset | 576 // Bitset-bitset |
| 577 CHECK(IsBitset(Type::Intersect(T.Object, T.Number))); | 577 CHECK(IsBitset(Type::Intersect(T.Object, T.Number))); |
| 578 CHECK(IsBitset(Type::Intersect(T.Object, T.Object))); | 578 CHECK(IsBitset(Type::Intersect(T.Object, T.Object))); |
| 579 CHECK(IsBitset(Type::Intersect(T.Any, T.None))); | 579 CHECK(IsBitset(Type::Intersect(T.Any, T.None))); |
| 580 | 580 |
| 581 CheckEqual(T.Intersect(T.None, T.Number), T.None); | 581 CheckEqual(T.Intersect(T.None, T.Number), T.None); |
| 582 CheckEqual(T.Intersect(T.Object, T.Proxy), T.None); | 582 CheckEqual(T.Intersect(T.Object, T.Proxy), T.None); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), | 701 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), |
| 702 T.Union( | 702 T.Union( |
| 703 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))), | 703 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))), |
| 704 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 704 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 705 CheckEqual( | 705 CheckEqual( |
| 706 T.Intersect( | 706 T.Intersect( |
| 707 T.Union(T.ObjectConstant2, T.ArrayConstant1), | 707 T.Union(T.ObjectConstant2, T.ArrayConstant1), |
| 708 T.Union(T.ObjectConstant1, T.ArrayConstant2)), | 708 T.Union(T.ObjectConstant1, T.ArrayConstant2)), |
| 709 T.ArrayConstant1); | 709 T.ArrayConstant1); |
| 710 } | 710 } |
| OLD | NEW |