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

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

Issue 794663002: Revert of Avoid number range holes in bitset types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/cctest/types-fuzz.h » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "src/hydrogen-types.h" 7 #include "src/hydrogen-types.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 TypeHandle type2 = T.Constant(value2); 287 TypeHandle type2 = T.Constant(value2);
288 CHECK(Equal(type1, type2) == (*value1 == *value2)); 288 CHECK(Equal(type1, type2) == (*value1 == *value2));
289 } 289 }
290 } 290 }
291 291
292 // Typing of numbers 292 // Typing of numbers
293 Factory* fac = isolate->factory(); 293 Factory* fac = isolate->factory();
294 CHECK(T.Constant(fac->NewNumber(0))->Is(T.UnsignedSmall)); 294 CHECK(T.Constant(fac->NewNumber(0))->Is(T.UnsignedSmall));
295 CHECK(T.Constant(fac->NewNumber(1))->Is(T.UnsignedSmall)); 295 CHECK(T.Constant(fac->NewNumber(1))->Is(T.UnsignedSmall));
296 CHECK(T.Constant(fac->NewNumber(0x3fffffff))->Is(T.UnsignedSmall)); 296 CHECK(T.Constant(fac->NewNumber(0x3fffffff))->Is(T.UnsignedSmall));
297 CHECK(T.Constant(fac->NewNumber(-1))->Is(T.NegativeSignedSmall)); 297 CHECK(T.Constant(fac->NewNumber(-1))->Is(T.OtherSignedSmall));
298 CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.NegativeSignedSmall)); 298 CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.OtherSignedSmall));
299 CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.NegativeSignedSmall)); 299 CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.OtherSignedSmall));
300 if (SmiValuesAre31Bits()) { 300 if (SmiValuesAre31Bits()) {
301 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32)); 301 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.OtherUnsigned31));
302 CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall)); 302 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.OtherUnsigned31));
303 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32)); 303 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSigned32));
304 CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall)); 304 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSigned32));
305 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32)); 305 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32));
306 CHECK(
307 !T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSignedSmall));
308 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSigned32));
309 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff - 1))
310 ->Is(T.NegativeSignedSmall));
311 } else { 306 } else {
312 CHECK(SmiValuesAre32Bits()); 307 CHECK(SmiValuesAre32Bits());
313 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall)); 308 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
314 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall)); 309 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
315 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32)); 310 CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.OtherUnsigned31));
316 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32)); 311 CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.OtherUnsigned31));
317 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSignedSmall)); 312 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSignedSmall));
318 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSignedSmall)); 313 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSignedSmall));
319 CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 1)) 314 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSignedSmall));
320 ->Is(T.NegativeSignedSmall)); 315 CHECK(!T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSigned32));
321 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32)); 316 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSigned32));
322 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSigned32)); 317 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32));
323 CHECK(
324 T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.NegativeSigned32));
325 } 318 }
326 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.Unsigned32)); 319 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.OtherUnsigned32));
327 CHECK(!T.Constant(fac->NewNumber(0x80000000u))->Is(T.NonNegativeSigned32)); 320 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.OtherUnsigned32));
328 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.Unsigned32)); 321 CHECK(T.Constant(fac->NewNumber(0xffffffffu+1.0))->Is(T.OtherNumber));
329 CHECK(!T.Constant(fac->NewNumber(0xffffffffu))->Is(T.NonNegativeSigned32)); 322 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-2.0))->Is(T.OtherNumber));
330 CHECK(T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.PlainNumber)); 323 CHECK(T.Constant(fac->NewNumber(0.1))->Is(T.OtherNumber));
331 CHECK(!T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.Integral32)); 324 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber));
332 CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 2.0))->Is(T.PlainNumber)); 325 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber));
333 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff - 2.0))->Is(T.Integral32));
334 CHECK(T.Constant(fac->NewNumber(0.1))->Is(T.PlainNumber));
335 CHECK(!T.Constant(fac->NewNumber(0.1))->Is(T.Integral32));
336 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.PlainNumber));
337 CHECK(!T.Constant(fac->NewNumber(-10.1))->Is(T.Integral32));
338 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.PlainNumber));
339 CHECK(!T.Constant(fac->NewNumber(10e60))->Is(T.Integral32));
340 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); 326 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero));
341 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN)); 327 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN));
342 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.PlainNumber)); 328 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber));
343 CHECK(!T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.Integral32)); 329 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber));
344 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.PlainNumber));
345 CHECK(!T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.Integral32));
346 } 330 }
347 331
348 void Range() { 332 void Range() {
349 // Constructor 333 // Constructor
350 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { 334 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) {
351 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { 335 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) {
352 i::Handle<i::Object> min = *i; 336 i::Handle<i::Object> min = *i;
353 i::Handle<i::Object> max = *j; 337 i::Handle<i::Object> max = *j;
354 if (min->Number() > max->Number()) std::swap(min, max); 338 if (min->Number() > max->Number()) std::swap(min, max);
355 TypeHandle type = T.Range(min, max); 339 TypeHandle type = T.Range(min, max);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 897 }
914 } 898 }
915 } 899 }
916 900
917 // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber)) 901 // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber))
918 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 902 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
919 TypeHandle type = *it; 903 TypeHandle type = *it;
920 if (type->IsRange()) { 904 if (type->IsRange()) {
921 TypeHandle lub = Rep::BitsetType::New( 905 TypeHandle lub = Rep::BitsetType::New(
922 Rep::BitsetType::Lub(type), T.region()); 906 Rep::BitsetType::Lub(type), T.region());
923 CHECK(lub->Is(T.PlainNumber)); 907 CHECK(lub->Is(T.Union(T.Integral32, T.OtherNumber)));
924 } 908 }
925 } 909 }
926 910
927 911
928 // Subtyping between concrete basic types 912 // Subtyping between concrete basic types
929 913
930 CheckUnordered(T.Boolean, T.Null); 914 CheckUnordered(T.Boolean, T.Null);
931 CheckUnordered(T.Undefined, T.Null); 915 CheckUnordered(T.Undefined, T.Null);
932 CheckUnordered(T.Boolean, T.Undefined); 916 CheckUnordered(T.Boolean, T.Undefined);
933 917
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 2068 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
2085 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 2069 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
2086 } 2070 }
2087 2071
2088 2072
2089 TEST(HTypeFromType) { 2073 TEST(HTypeFromType) {
2090 CcTest::InitializeVM(); 2074 CcTest::InitializeVM();
2091 ZoneTests().HTypeFromType(); 2075 ZoneTests().HTypeFromType();
2092 HeapTests().HTypeFromType(); 2076 HeapTests().HTypeFromType();
2093 } 2077 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/cctest/types-fuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698