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

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

Issue 759013003: Avoid number range holes in bitset types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Another rebase 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.OtherSignedSmall)); 297 CHECK(T.Constant(fac->NewNumber(-1))->Is(T.NegativeSignedSmall));
298 CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.OtherSignedSmall)); 298 CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.NegativeSignedSmall));
299 CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.OtherSignedSmall)); 299 CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.NegativeSignedSmall));
300 if (SmiValuesAre31Bits()) { 300 if (SmiValuesAre31Bits()) {
301 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.OtherUnsigned31)); 301 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32));
302 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.OtherUnsigned31)); 302 CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
303 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSigned32)); 303 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32));
304 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSigned32)); 304 CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
305 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32)); 305 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32));
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));
306 } else { 311 } else {
307 CHECK(SmiValuesAre32Bits()); 312 CHECK(SmiValuesAre32Bits());
308 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall)); 313 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
309 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall)); 314 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
310 CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.OtherUnsigned31)); 315 CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32));
311 CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.OtherUnsigned31)); 316 CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32));
312 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSignedSmall)); 317 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSignedSmall));
313 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSignedSmall)); 318 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSignedSmall));
314 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSignedSmall)); 319 CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 1))
315 CHECK(!T.Constant(fac->NewNumber(-0x40000001))->Is(T.OtherSigned32)); 320 ->Is(T.NegativeSignedSmall));
316 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.OtherSigned32)); 321 CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32));
317 CHECK(!T.Constant(fac->NewNumber(-0x7fffffff-1))->Is(T.OtherSigned32)); 322 CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSigned32));
323 CHECK(
324 T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.NegativeSigned32));
318 } 325 }
319 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.OtherUnsigned32)); 326 CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.Unsigned32));
320 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.OtherUnsigned32)); 327 CHECK(!T.Constant(fac->NewNumber(0x80000000u))->Is(T.NonNegativeSigned32));
321 CHECK(T.Constant(fac->NewNumber(0xffffffffu+1.0))->Is(T.OtherNumber)); 328 CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.Unsigned32));
322 CHECK(T.Constant(fac->NewNumber(-0x7fffffff-2.0))->Is(T.OtherNumber)); 329 CHECK(!T.Constant(fac->NewNumber(0xffffffffu))->Is(T.NonNegativeSigned32));
323 CHECK(T.Constant(fac->NewNumber(0.1))->Is(T.OtherNumber)); 330 CHECK(T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.PlainNumber));
324 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber)); 331 CHECK(!T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.Integral32));
325 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber)); 332 CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 2.0))->Is(T.PlainNumber));
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));
326 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); 340 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero));
327 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN)); 341 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN));
328 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber)); 342 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.PlainNumber));
329 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber)); 343 CHECK(!T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.Integral32));
344 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.PlainNumber));
345 CHECK(!T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.Integral32));
330 } 346 }
331 347
332 void Range() { 348 void Range() {
333 // Constructor 349 // Constructor
334 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { 350 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) {
335 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { 351 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) {
336 i::Handle<i::Object> min = *i; 352 i::Handle<i::Object> min = *i;
337 i::Handle<i::Object> max = *j; 353 i::Handle<i::Object> max = *j;
338 if (min->Number() > max->Number()) std::swap(min, max); 354 if (min->Number() > max->Number()) std::swap(min, max);
339 TypeHandle type = T.Range(min, max); 355 TypeHandle type = T.Range(min, max);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 913 }
898 } 914 }
899 } 915 }
900 916
901 // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber)) 917 // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber))
902 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 918 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
903 TypeHandle type = *it; 919 TypeHandle type = *it;
904 if (type->IsRange()) { 920 if (type->IsRange()) {
905 TypeHandle lub = Rep::BitsetType::New( 921 TypeHandle lub = Rep::BitsetType::New(
906 Rep::BitsetType::Lub(type), T.region()); 922 Rep::BitsetType::Lub(type), T.region());
907 CHECK(lub->Is(T.Union(T.Integral32, T.OtherNumber))); 923 CHECK(lub->Is(T.PlainNumber));
908 } 924 }
909 } 925 }
910 926
911 927
912 // Subtyping between concrete basic types 928 // Subtyping between concrete basic types
913 929
914 CheckUnordered(T.Boolean, T.Null); 930 CheckUnordered(T.Boolean, T.Null);
915 CheckUnordered(T.Undefined, T.Null); 931 CheckUnordered(T.Undefined, T.Null);
916 CheckUnordered(T.Boolean, T.Undefined); 932 CheckUnordered(T.Boolean, T.Undefined);
917 933
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 2084 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
2069 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 2085 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
2070 } 2086 }
2071 2087
2072 2088
2073 TEST(HTypeFromType) { 2089 TEST(HTypeFromType) {
2074 CcTest::InitializeVM(); 2090 CcTest::InitializeVM();
2075 ZoneTests().HTypeFromType(); 2091 ZoneTests().HTypeFromType();
2076 HeapTests().HTypeFromType(); 2092 HeapTests().HTypeFromType();
2077 } 2093 }
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