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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <vector> | 28 #include <vector> |
29 | 29 |
| 30 #include "src/base/utils/random-number-generator.h" |
30 #include "src/hydrogen-types.h" | 31 #include "src/hydrogen-types.h" |
31 #include "src/types.h" | 32 #include "src/types.h" |
32 #include "src/utils/random-number-generator.h" | |
33 #include "test/cctest/cctest.h" | 33 #include "test/cctest/cctest.h" |
34 | 34 |
35 using namespace v8::internal; | 35 using namespace v8::internal; |
36 | 36 |
37 // Testing auxiliaries (breaking the Type abstraction). | 37 // Testing auxiliaries (breaking the Type abstraction). |
38 struct ZoneRep { | 38 struct ZoneRep { |
39 typedef void* Struct; | 39 typedef void* Struct; |
40 | 40 |
41 static bool IsStruct(Type* t, int tag) { | 41 static bool IsStruct(Type* t, int tag) { |
42 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; | 42 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 return type; | 332 return type; |
333 } | 333 } |
334 } | 334 } |
335 UNREACHABLE(); | 335 UNREACHABLE(); |
336 } | 336 } |
337 | 337 |
338 Region* region() { return region_; } | 338 Region* region() { return region_; } |
339 | 339 |
340 private: | 340 private: |
341 Region* region_; | 341 Region* region_; |
342 RandomNumberGenerator rng_; | 342 v8::base::RandomNumberGenerator rng_; |
343 }; | 343 }; |
344 | 344 |
345 | 345 |
346 template<class Type, class TypeHandle, class Region, class Rep> | 346 template<class Type, class TypeHandle, class Region, class Rep> |
347 struct Tests : Rep { | 347 struct Tests : Rep { |
348 typedef Types<Type, TypeHandle, Region> TypesInstance; | 348 typedef Types<Type, TypeHandle, Region> TypesInstance; |
349 typedef typename TypesInstance::TypeVector::iterator TypeIterator; | 349 typedef typename TypesInstance::TypeVector::iterator TypeIterator; |
350 typedef typename TypesInstance::MapVector::iterator MapIterator; | 350 typedef typename TypesInstance::MapVector::iterator MapIterator; |
351 typedef typename TypesInstance::ValueVector::iterator ValueIterator; | 351 typedef typename TypesInstance::ValueVector::iterator ValueIterator; |
352 | 352 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32)); | 576 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32)); |
577 } | 577 } |
578 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.OtherUnsigned32)); | 578 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.OtherUnsigned32)); |
579 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.OtherUnsigned32)); | 579 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.OtherUnsigned32)); |
580 CHECK(T.Constant(fac->NewNumber(0xffffffffu+1.0))->Is(T.OtherNumber)); | 580 CHECK(T.Constant(fac->NewNumber(0xffffffffu+1.0))->Is(T.OtherNumber)); |
581 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-2.0))->Is(T.OtherNumber)); | 581 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-2.0))->Is(T.OtherNumber)); |
582 CHECK(T.Constant(fac->NewNumber(0.1))->Is(T.OtherNumber)); | 582 CHECK(T.Constant(fac->NewNumber(0.1))->Is(T.OtherNumber)); |
583 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber)); | 583 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber)); |
584 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber)); | 584 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber)); |
585 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); | 585 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); |
586 CHECK(T.Constant(fac->NewNumber(OS::nan_value()))->Is(T.NaN)); | 586 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN)); |
587 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber)); | 587 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber)); |
588 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber)); | 588 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber)); |
589 } | 589 } |
590 | 590 |
591 void Array() { | 591 void Array() { |
592 // Constructor | 592 // Constructor |
593 for (int i = 0; i < 20; ++i) { | 593 for (int i = 0; i < 20; ++i) { |
594 TypeHandle type = T.Random(); | 594 TypeHandle type = T.Random(); |
595 TypeHandle array = T.Array1(type); | 595 TypeHandle array = T.Array1(type); |
596 CHECK(this->IsArray(array)); | 596 CHECK(this->IsArray(array)); |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 1933 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
1934 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 1934 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
1935 } | 1935 } |
1936 | 1936 |
1937 | 1937 |
1938 TEST(HTypeFromType) { | 1938 TEST(HTypeFromType) { |
1939 CcTest::InitializeVM(); | 1939 CcTest::InitializeVM(); |
1940 ZoneTests().HTypeFromType(); | 1940 ZoneTests().HTypeFromType(); |
1941 HeapTests().HTypeFromType(); | 1941 HeapTests().HTypeFromType(); |
1942 } | 1942 } |
OLD | NEW |