Chromium Code Reviews

Side by Side Diff: test/cctest/compiler/test-js-typed-lowering.cc

Issue 795713003: Steps towards unification of number bitset and range types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix BitsetType::Max for OtherNumber with missing representation Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 148 matching lines...)
159 CHECK_EQ(IrOpcode::kHeapConstant, result->opcode()); 159 CHECK_EQ(IrOpcode::kHeapConstant, result->opcode());
160 Handle<Object> value = OpParameter<Unique<Object> >(result).handle(); 160 Handle<Object> value = OpParameter<Unique<Object> >(result).handle();
161 CHECK_EQ(*expected, *value); 161 CHECK_EQ(*expected, *value);
162 } 162 }
163 }; 163 };
164 164
165 static Type* kStringTypes[] = {Type::InternalizedString(), Type::OtherString(), 165 static Type* kStringTypes[] = {Type::InternalizedString(), Type::OtherString(),
166 Type::String()}; 166 Type::String()};
167 167
168 168
169 static Type* kInt32Types[] = { 169 static Type* kInt32Types[] = {Type::Unsigned30(), Type::Negative32(),
170 Type::UnsignedSmall(), Type::NegativeSigned32(), 170 Type::Unsigned31(), Type::Signed31(),
171 Type::NonNegativeSigned32(), Type::SignedSmall(), 171 Type::Signed32(), Type::Unsigned32(),
172 Type::Signed32(), Type::Unsigned32(), 172 Type::Integral32()};
173 Type::Integral32()};
174 173
175 174
176 static Type* kNumberTypes[] = { 175 static Type* kNumberTypes[] = {
177 Type::UnsignedSmall(), Type::NegativeSigned32(), 176 Type::Unsigned30(), Type::Negative32(), Type::Unsigned31(),
178 Type::NonNegativeSigned32(), Type::SignedSmall(), 177 Type::Signed31(), Type::Signed32(), Type::Unsigned32(),
179 Type::Signed32(), Type::Unsigned32(), 178 Type::Integral32(), Type::MinusZero(), Type::NaN(),
180 Type::Integral32(), Type::MinusZero(), 179 Type::OrderedNumber(), Type::PlainNumber(), Type::Number()};
181 Type::NaN(), Type::OrderedNumber(),
182 Type::PlainNumber(), Type::Number()};
183 180
184 181
185 static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), 182 static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
186 Type::Number(), Type::String(), Type::Object()}; 183 Type::Number(), Type::String(), Type::Object()};
187 184
188 185
189 static Type* I32Type(bool is_signed) { 186 static Type* I32Type(bool is_signed) {
190 return is_signed ? Type::Signed32() : Type::Unsigned32(); 187 return is_signed ? Type::Signed32() : Type::Unsigned32();
191 } 188 }
192 189
(...skipping 106 matching lines...)
299 void set(int idx, const Operator* op, bool s) { 296 void set(int idx, const Operator* op, bool s) {
300 ops[idx] = op; 297 ops[idx] = op;
301 signedness[idx] = s; 298 signedness[idx] = s;
302 } 299 }
303 }; 300 };
304 301
305 302
306 TEST(Int32BitwiseShifts) { 303 TEST(Int32BitwiseShifts) {
307 JSBitwiseShiftTypedLoweringTester R; 304 JSBitwiseShiftTypedLoweringTester R;
308 305
309 Type* types[] = {Type::SignedSmall(), Type::UnsignedSmall(), 306 Type* types[] = {Type::Signed31(), Type::Unsigned30(), Type::Negative32(),
310 Type::NegativeSigned32(), Type::NonNegativeSigned32(), 307 Type::Unsigned31(), Type::Unsigned32(), Type::Signed32(),
311 Type::Unsigned32(), Type::Signed32(), 308 Type::MinusZero(), Type::NaN(), Type::Undefined(),
312 Type::MinusZero(), Type::NaN(), 309 Type::Null(), Type::Boolean(), Type::Number(),
313 Type::Undefined(), Type::Null(), 310 Type::PlainNumber(), Type::String()};
314 Type::Boolean(), Type::Number(),
315 Type::PlainNumber(), Type::String()};
316 311
317 for (size_t i = 0; i < arraysize(types); ++i) { 312 for (size_t i = 0; i < arraysize(types); ++i) {
318 Node* p0 = R.Parameter(types[i], 0); 313 Node* p0 = R.Parameter(types[i], 0);
319 314
320 for (size_t j = 0; j < arraysize(types); ++j) { 315 for (size_t j = 0; j < arraysize(types); ++j) {
321 Node* p1 = R.Parameter(types[j], 1); 316 Node* p1 = R.Parameter(types[j], 1);
322 317
323 for (int k = 0; k < R.kNumberOps; k += 2) { 318 for (int k = 0; k < R.kNumberOps; k += 2) {
324 Node* add = R.Binop(R.ops[k], p0, p1); 319 Node* add = R.Binop(R.ops[k], p0, p1);
325 Node* r = R.reduce(add); 320 Node* r = R.reduce(add);
(...skipping 39 matching lines...)
365 ops[idx] = op; 360 ops[idx] = op;
366 signedness[idx] = s; 361 signedness[idx] = s;
367 } 362 }
368 }; 363 };
369 364
370 365
371 TEST(Int32BitwiseBinops) { 366 TEST(Int32BitwiseBinops) {
372 JSBitwiseTypedLoweringTester R; 367 JSBitwiseTypedLoweringTester R;
373 368
374 Type* types[] = { 369 Type* types[] = {
375 Type::SignedSmall(), Type::UnsignedSmall(), Type::Unsigned32(), 370 Type::Signed31(), Type::Unsigned30(), Type::Unsigned32(),
376 Type::Signed32(), Type::MinusZero(), Type::NaN(), 371 Type::Signed32(), Type::MinusZero(), Type::NaN(),
377 Type::OrderedNumber(), Type::PlainNumber(), Type::Undefined(), 372 Type::OrderedNumber(), Type::PlainNumber(), Type::Undefined(),
378 Type::Null(), Type::Boolean(), Type::Number(), 373 Type::Null(), Type::Boolean(), Type::Number(),
379 Type::String()}; 374 Type::String()};
380 375
381 for (size_t i = 0; i < arraysize(types); ++i) { 376 for (size_t i = 0; i < arraysize(types); ++i) {
382 Node* p0 = R.Parameter(types[i], 0); 377 Node* p0 = R.Parameter(types[i], 0);
383 378
384 for (size_t j = 0; j < arraysize(types); ++j) { 379 for (size_t j = 0; j < arraysize(types); ++j) {
385 Node* p1 = R.Parameter(types[j], 1); 380 Node* p1 = R.Parameter(types[j], 1);
386 381
387 for (int k = 0; k < R.kNumberOps; k += 2) { 382 for (int k = 0; k < R.kNumberOps; k += 2) {
388 Node* add = R.Binop(R.ops[k], p0, p1); 383 Node* add = R.Binop(R.ops[k], p0, p1);
(...skipping 512 matching lines...)
901 Node* r = n->InputAt(0); 896 Node* r = n->InputAt(0);
902 R->CheckPureBinop(expected, r); 897 R->CheckPureBinop(expected, r);
903 } 898 }
904 } 899 }
905 } 900 }
906 901
907 902
908 TEST(EqualityForNumbers) { 903 TEST(EqualityForNumbers) {
909 JSTypedLoweringTester R; 904 JSTypedLoweringTester R;
910 905
911 Type* simple_number_types[] = {Type::UnsignedSmall(), Type::SignedSmall(), 906 Type* simple_number_types[] = {Type::Unsigned30(), Type::Signed31(),
912 Type::Signed32(), Type::Unsigned32(), 907 Type::Signed32(), Type::Unsigned32(),
913 Type::Number()}; 908 Type::Number()};
914 909
915 910
916 for (size_t i = 0; i < arraysize(simple_number_types); ++i) { 911 for (size_t i = 0; i < arraysize(simple_number_types); ++i) {
917 Node* p0 = R.Parameter(simple_number_types[i], 0); 912 Node* p0 = R.Parameter(simple_number_types[i], 0);
918 913
919 for (size_t j = 0; j < arraysize(simple_number_types); ++j) { 914 for (size_t j = 0; j < arraysize(simple_number_types); ++j) {
920 Node* p1 = R.Parameter(simple_number_types[j], 1); 915 Node* p1 = R.Parameter(simple_number_types[j], 1);
921 916
(...skipping 376 matching lines...)
1298 CHECK_EQ(p1, r->InputAt(0)); 1293 CHECK_EQ(p1, r->InputAt(0));
1299 CHECK_EQ(p0, r->InputAt(1)); 1294 CHECK_EQ(p0, r->InputAt(1));
1300 } else { 1295 } else {
1301 CHECK_EQ(p0, r->InputAt(0)); 1296 CHECK_EQ(p0, r->InputAt(0));
1302 CHECK_EQ(p1, r->InputAt(1)); 1297 CHECK_EQ(p1, r->InputAt(1));
1303 } 1298 }
1304 } 1299 }
1305 } 1300 }
1306 } 1301 }
1307 } 1302 }
OLDNEW

Powered by Google App Engine