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

Side by Side Diff: test/unittests/compiler/typer-unittest.cc

Issue 1144183004: [strong] Refactor ObjectStrength into a replacement for strong boolean args (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 6 months 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <functional> 5 #include <functional>
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "test/cctest/types-fuzz.h" 10 #include "test/cctest/types-fuzz.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 219
220 //------------------------------------------------------------------------------ 220 //------------------------------------------------------------------------------
221 // Soundness 221 // Soundness
222 // For simplicity, we currently only test soundness on expression operators 222 // For simplicity, we currently only test soundness on expression operators
223 // that have a direct equivalent in C++. Also, testing is currently limited 223 // that have a direct equivalent in C++. Also, testing is currently limited
224 // to ranges as input types. 224 // to ranges as input types.
225 225
226 226
227 TEST_F(TyperTest, TypeJSAdd) { 227 TEST_F(TyperTest, TypeJSAdd) {
228 TestBinaryArithOp(javascript_.Add(LanguageMode::SLOPPY), std::plus<double>()); 228 TestBinaryArithOp(javascript_.Add(Strength::NORMAL), std::plus<double>());
229 TestBinaryArithOp(javascript_.Add(LanguageMode::STRONG), std::plus<double>()); 229 TestBinaryArithOp(javascript_.Add(Strength::STRONG), std::plus<double>());
230 } 230 }
231 231
232 232
233 TEST_F(TyperTest, TypeJSSubtract) { 233 TEST_F(TyperTest, TypeJSSubtract) {
234 TestBinaryArithOp(javascript_.Subtract(LanguageMode::SLOPPY), 234 TestBinaryArithOp(javascript_.Subtract(Strength::NORMAL),
235 std::minus<double>()); 235 std::minus<double>());
236 TestBinaryArithOp(javascript_.Subtract(LanguageMode::STRONG), 236 TestBinaryArithOp(javascript_.Subtract(Strength::STRONG),
237 std::minus<double>()); 237 std::minus<double>());
238 } 238 }
239 239
240 240
241 TEST_F(TyperTest, TypeJSMultiply) { 241 TEST_F(TyperTest, TypeJSMultiply) {
242 TestBinaryArithOp(javascript_.Multiply(LanguageMode::SLOPPY), 242 TestBinaryArithOp(javascript_.Multiply(Strength::NORMAL),
243 std::multiplies<double>()); 243 std::multiplies<double>());
244 TestBinaryArithOp(javascript_.Multiply(LanguageMode::STRONG), 244 TestBinaryArithOp(javascript_.Multiply(Strength::STRONG),
245 std::multiplies<double>()); 245 std::multiplies<double>());
246 } 246 }
247 247
248 248
249 TEST_F(TyperTest, TypeJSDivide) { 249 TEST_F(TyperTest, TypeJSDivide) {
250 TestBinaryArithOp(javascript_.Divide(LanguageMode::SLOPPY), 250 TestBinaryArithOp(javascript_.Divide(Strength::NORMAL),
251 std::divides<double>()); 251 std::divides<double>());
252 TestBinaryArithOp(javascript_.Divide(LanguageMode::STRONG), 252 TestBinaryArithOp(javascript_.Divide(Strength::STRONG),
253 std::divides<double>()); 253 std::divides<double>());
254 } 254 }
255 255
256 256
257 TEST_F(TyperTest, TypeJSModulus) { 257 TEST_F(TyperTest, TypeJSModulus) {
258 TestBinaryArithOp(javascript_.Modulus(LanguageMode::SLOPPY), modulo); 258 TestBinaryArithOp(javascript_.Modulus(Strength::NORMAL), modulo);
259 TestBinaryArithOp(javascript_.Modulus(LanguageMode::STRONG), modulo); 259 TestBinaryArithOp(javascript_.Modulus(Strength::STRONG), modulo);
260 } 260 }
261 261
262 262
263 TEST_F(TyperTest, TypeJSBitwiseOr) { 263 TEST_F(TyperTest, TypeJSBitwiseOr) {
264 TestBinaryBitOp(javascript_.BitwiseOr(LanguageMode::SLOPPY), bit_or); 264 TestBinaryBitOp(javascript_.BitwiseOr(Strength::NORMAL), bit_or);
265 TestBinaryBitOp(javascript_.BitwiseOr(LanguageMode::STRONG), bit_or); 265 TestBinaryBitOp(javascript_.BitwiseOr(Strength::STRONG), bit_or);
266 } 266 }
267 267
268 268
269 TEST_F(TyperTest, TypeJSBitwiseAnd) { 269 TEST_F(TyperTest, TypeJSBitwiseAnd) {
270 TestBinaryBitOp(javascript_.BitwiseAnd(LanguageMode::SLOPPY), bit_and); 270 TestBinaryBitOp(javascript_.BitwiseAnd(Strength::NORMAL), bit_and);
271 TestBinaryBitOp(javascript_.BitwiseAnd(LanguageMode::STRONG), bit_and); 271 TestBinaryBitOp(javascript_.BitwiseAnd(Strength::STRONG), bit_and);
272 } 272 }
273 273
274 274
275 TEST_F(TyperTest, TypeJSBitwiseXor) { 275 TEST_F(TyperTest, TypeJSBitwiseXor) {
276 TestBinaryBitOp(javascript_.BitwiseXor(LanguageMode::SLOPPY), bit_xor); 276 TestBinaryBitOp(javascript_.BitwiseXor(Strength::NORMAL), bit_xor);
277 TestBinaryBitOp(javascript_.BitwiseXor(LanguageMode::STRONG), bit_xor); 277 TestBinaryBitOp(javascript_.BitwiseXor(Strength::STRONG), bit_xor);
278 } 278 }
279 279
280 280
281 TEST_F(TyperTest, TypeJSShiftLeft) { 281 TEST_F(TyperTest, TypeJSShiftLeft) {
282 TestBinaryBitOp(javascript_.ShiftLeft(LanguageMode::SLOPPY), shift_left); 282 TestBinaryBitOp(javascript_.ShiftLeft(Strength::NORMAL), shift_left);
283 TestBinaryBitOp(javascript_.ShiftLeft(LanguageMode::STRONG), shift_left); 283 TestBinaryBitOp(javascript_.ShiftLeft(Strength::STRONG), shift_left);
284 } 284 }
285 285
286 286
287 TEST_F(TyperTest, TypeJSShiftRight) { 287 TEST_F(TyperTest, TypeJSShiftRight) {
288 TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::SLOPPY), shift_right); 288 TestBinaryBitOp(javascript_.ShiftRight(Strength::NORMAL), shift_right);
289 TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::STRONG), shift_right); 289 TestBinaryBitOp(javascript_.ShiftRight(Strength::STRONG), shift_right);
290 } 290 }
291 291
292 292
293 TEST_F(TyperTest, TypeJSLessThan) { 293 TEST_F(TyperTest, TypeJSLessThan) {
294 TestBinaryCompareOp(javascript_.LessThan(LanguageMode::SLOPPY), 294 TestBinaryCompareOp(javascript_.LessThan(Strength::NORMAL),
295 std::less<double>()); 295 std::less<double>());
296 TestBinaryCompareOp(javascript_.LessThan(LanguageMode::STRONG), 296 TestBinaryCompareOp(javascript_.LessThan(Strength::STRONG),
297 std::less<double>()); 297 std::less<double>());
298 } 298 }
299 299
300 300
301 TEST_F(TyperTest, TypeJSLessThanOrEqual) { 301 TEST_F(TyperTest, TypeJSLessThanOrEqual) {
302 TestBinaryCompareOp(javascript_.LessThanOrEqual(LanguageMode::SLOPPY), 302 TestBinaryCompareOp(javascript_.LessThanOrEqual(Strength::NORMAL),
303 std::less_equal<double>()); 303 std::less_equal<double>());
304 TestBinaryCompareOp(javascript_.LessThanOrEqual(LanguageMode::STRONG), 304 TestBinaryCompareOp(javascript_.LessThanOrEqual(Strength::STRONG),
305 std::less_equal<double>()); 305 std::less_equal<double>());
306 } 306 }
307 307
308 308
309 TEST_F(TyperTest, TypeJSGreaterThan) { 309 TEST_F(TyperTest, TypeJSGreaterThan) {
310 TestBinaryCompareOp(javascript_.GreaterThan(LanguageMode::SLOPPY), 310 TestBinaryCompareOp(javascript_.GreaterThan(Strength::NORMAL),
311 std::greater<double>()); 311 std::greater<double>());
312 TestBinaryCompareOp(javascript_.GreaterThan(LanguageMode::STRONG), 312 TestBinaryCompareOp(javascript_.GreaterThan(Strength::STRONG),
313 std::greater<double>()); 313 std::greater<double>());
314 } 314 }
315 315
316 316
317 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) { 317 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) {
318 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(LanguageMode::SLOPPY), 318 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(Strength::NORMAL),
319 std::greater_equal<double>()); 319 std::greater_equal<double>());
320 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(LanguageMode::STRONG), 320 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(Strength::STRONG),
321 std::greater_equal<double>()); 321 std::greater_equal<double>());
322 } 322 }
323 323
324 324
325 TEST_F(TyperTest, TypeJSEqual) { 325 TEST_F(TyperTest, TypeJSEqual) {
326 TestBinaryCompareOp(javascript_.Equal(), std::equal_to<double>()); 326 TestBinaryCompareOp(javascript_.Equal(), std::equal_to<double>());
327 } 327 }
328 328
329 329
330 TEST_F(TyperTest, TypeJSNotEqual) { 330 TEST_F(TyperTest, TypeJSNotEqual) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 376
377 #define TEST_FUNC(name) \ 377 #define TEST_FUNC(name) \
378 TEST_F(TyperTest, Monotonicity_##name) { \ 378 TEST_F(TyperTest, Monotonicity_##name) { \
379 TestBinaryMonotonicity(javascript_.name()); \ 379 TestBinaryMonotonicity(javascript_.name()); \
380 } 380 }
381 JSBINOP_LIST(TEST_FUNC) 381 JSBINOP_LIST(TEST_FUNC)
382 #undef TEST_FUNC 382 #undef TEST_FUNC
383 383
384 384
385 #define TEST_FUNC(name) \ 385 #define TEST_FUNC(name) \
386 TEST_F(TyperTest, Monotonicity_##name) { \ 386 TEST_F(TyperTest, Monotonicity_##name) { \
387 TestBinaryMonotonicity(javascript_.name(LanguageMode::SLOPPY)); \ 387 TestBinaryMonotonicity(javascript_.name(Strength::NORMAL)); \
388 TestBinaryMonotonicity(javascript_.name(LanguageMode::STRONG)); \ 388 TestBinaryMonotonicity(javascript_.name(Strength::STRONG)); \
389 } 389 }
390 JSBINOP_WITH_STRONG_LIST(TEST_FUNC) 390 JSBINOP_WITH_STRONG_LIST(TEST_FUNC)
391 #undef TEST_FUNC 391 #undef TEST_FUNC
392 392
393 393
394 //------------------------------------------------------------------------------ 394 //------------------------------------------------------------------------------
395 // Regression tests 395 // Regression tests
396 396
397 397
398 TEST_F(TyperTest, TypeRegressInt32Constant) { 398 TEST_F(TyperTest, TypeRegressInt32Constant) {
399 int values[] = {-5, 10}; 399 int values[] = {-5, 10};
400 for (auto i : values) { 400 for (auto i : values) {
401 Node* c = graph()->NewNode(common()->Int32Constant(i)); 401 Node* c = graph()->NewNode(common()->Int32Constant(i));
402 Type* type = NodeProperties::GetBounds(c).upper; 402 Type* type = NodeProperties::GetBounds(c).upper;
403 EXPECT_TRUE(type->Is(NewRange(i, i))); 403 EXPECT_TRUE(type->Is(NewRange(i, i)));
404 } 404 }
405 } 405 }
OLDNEW
« src/compiler/js-operator.h ('K') | « test/unittests/compiler/scheduler-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698