Chromium Code Reviews

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

Issue 1693833002: Remove strong mode support from binary operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mistake. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 "src/compiler/operator-properties.h" 10 #include "src/compiler/operator-properties.h"
(...skipping 222 matching lines...)
233 233
234 234
235 //------------------------------------------------------------------------------ 235 //------------------------------------------------------------------------------
236 // Soundness 236 // Soundness
237 // For simplicity, we currently only test soundness on expression operators 237 // For simplicity, we currently only test soundness on expression operators
238 // that have a direct equivalent in C++. Also, testing is currently limited 238 // that have a direct equivalent in C++. Also, testing is currently limited
239 // to ranges as input types. 239 // to ranges as input types.
240 240
241 241
242 TEST_F(TyperTest, TypeJSAdd) { 242 TEST_F(TyperTest, TypeJSAdd) {
243 TestBinaryArithOp(javascript_.Add(LanguageMode::SLOPPY, hints_), 243 TestBinaryArithOp(javascript_.Add(hints_), std::plus<double>());
244 std::plus<double>());
245 TestBinaryArithOp(javascript_.Add(LanguageMode::STRONG, hints_),
246 std::plus<double>());
247 } 244 }
248 245
249 246
250 TEST_F(TyperTest, TypeJSSubtract) { 247 TEST_F(TyperTest, TypeJSSubtract) {
251 TestBinaryArithOp(javascript_.Subtract(LanguageMode::SLOPPY, hints_), 248 TestBinaryArithOp(javascript_.Subtract(hints_), std::minus<double>());
252 std::minus<double>());
253 TestBinaryArithOp(javascript_.Subtract(LanguageMode::STRONG, hints_),
254 std::minus<double>());
255 } 249 }
256 250
257 251
258 TEST_F(TyperTest, TypeJSMultiply) { 252 TEST_F(TyperTest, TypeJSMultiply) {
259 TestBinaryArithOp(javascript_.Multiply(LanguageMode::SLOPPY, hints_), 253 TestBinaryArithOp(javascript_.Multiply(hints_), std::multiplies<double>());
260 std::multiplies<double>());
261 TestBinaryArithOp(javascript_.Multiply(LanguageMode::STRONG, hints_),
262 std::multiplies<double>());
263 } 254 }
264 255
265 256
266 TEST_F(TyperTest, TypeJSDivide) { 257 TEST_F(TyperTest, TypeJSDivide) {
267 TestBinaryArithOp(javascript_.Divide(LanguageMode::SLOPPY, hints_), 258 TestBinaryArithOp(javascript_.Divide(hints_), std::divides<double>());
268 std::divides<double>());
269 TestBinaryArithOp(javascript_.Divide(LanguageMode::STRONG, hints_),
270 std::divides<double>());
271 } 259 }
272 260
273 261
274 TEST_F(TyperTest, TypeJSModulus) { 262 TEST_F(TyperTest, TypeJSModulus) {
275 TestBinaryArithOp(javascript_.Modulus(LanguageMode::SLOPPY, hints_), modulo); 263 TestBinaryArithOp(javascript_.Modulus(hints_), modulo);
276 TestBinaryArithOp(javascript_.Modulus(LanguageMode::STRONG, hints_), modulo);
277 } 264 }
278 265
279 266
280 TEST_F(TyperTest, TypeJSBitwiseOr) { 267 TEST_F(TyperTest, TypeJSBitwiseOr) {
281 TestBinaryBitOp(javascript_.BitwiseOr(LanguageMode::SLOPPY, hints_), bit_or); 268 TestBinaryBitOp(javascript_.BitwiseOr(hints_), bit_or);
282 TestBinaryBitOp(javascript_.BitwiseOr(LanguageMode::STRONG, hints_), bit_or);
283 } 269 }
284 270
285 271
286 TEST_F(TyperTest, TypeJSBitwiseAnd) { 272 TEST_F(TyperTest, TypeJSBitwiseAnd) {
287 TestBinaryBitOp(javascript_.BitwiseAnd(LanguageMode::SLOPPY, hints_), 273 TestBinaryBitOp(javascript_.BitwiseAnd(hints_), bit_and);
288 bit_and);
289 TestBinaryBitOp(javascript_.BitwiseAnd(LanguageMode::STRONG, hints_),
290 bit_and);
291 } 274 }
292 275
293 276
294 TEST_F(TyperTest, TypeJSBitwiseXor) { 277 TEST_F(TyperTest, TypeJSBitwiseXor) {
295 TestBinaryBitOp(javascript_.BitwiseXor(LanguageMode::SLOPPY, hints_), 278 TestBinaryBitOp(javascript_.BitwiseXor(hints_), bit_xor);
296 bit_xor);
297 TestBinaryBitOp(javascript_.BitwiseXor(LanguageMode::STRONG, hints_),
298 bit_xor);
299 } 279 }
300 280
301 281
302 TEST_F(TyperTest, TypeJSShiftLeft) { 282 TEST_F(TyperTest, TypeJSShiftLeft) {
303 TestBinaryBitOp(javascript_.ShiftLeft(LanguageMode::SLOPPY, hints_), 283 TestBinaryBitOp(javascript_.ShiftLeft(hints_), shift_left);
304 shift_left);
305 TestBinaryBitOp(javascript_.ShiftLeft(LanguageMode::STRONG, hints_),
306 shift_left);
307 } 284 }
308 285
309 286
310 TEST_F(TyperTest, TypeJSShiftRight) { 287 TEST_F(TyperTest, TypeJSShiftRight) {
311 TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::SLOPPY, hints_), 288 TestBinaryBitOp(javascript_.ShiftRight(hints_), shift_right);
312 shift_right);
313 TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::STRONG, hints_),
314 shift_right);
315 } 289 }
316 290
317 291
318 TEST_F(TyperTest, TypeJSLessThan) { 292 TEST_F(TyperTest, TypeJSLessThan) {
319 TestBinaryCompareOp(javascript_.LessThan(LanguageMode::SLOPPY), 293 TestBinaryCompareOp(javascript_.LessThan(), std::less<double>());
320 std::less<double>());
321 TestBinaryCompareOp(javascript_.LessThan(LanguageMode::STRONG),
322 std::less<double>());
323 } 294 }
324 295
325 296
326 TEST_F(TyperTest, TypeJSLessThanOrEqual) { 297 TEST_F(TyperTest, TypeJSLessThanOrEqual) {
327 TestBinaryCompareOp(javascript_.LessThanOrEqual(LanguageMode::SLOPPY), 298 TestBinaryCompareOp(javascript_.LessThanOrEqual(), std::less_equal<double>());
328 std::less_equal<double>());
329 TestBinaryCompareOp(javascript_.LessThanOrEqual(LanguageMode::STRONG),
330 std::less_equal<double>());
331 } 299 }
332 300
333 301
334 TEST_F(TyperTest, TypeJSGreaterThan) { 302 TEST_F(TyperTest, TypeJSGreaterThan) {
335 TestBinaryCompareOp(javascript_.GreaterThan(LanguageMode::SLOPPY), 303 TestBinaryCompareOp(javascript_.GreaterThan(), std::greater<double>());
336 std::greater<double>());
337 TestBinaryCompareOp(javascript_.GreaterThan(LanguageMode::STRONG),
338 std::greater<double>());
339 } 304 }
340 305
341 306
342 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) { 307 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) {
343 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(LanguageMode::SLOPPY), 308 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(),
344 std::greater_equal<double>());
345 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(LanguageMode::STRONG),
346 std::greater_equal<double>()); 309 std::greater_equal<double>());
347 } 310 }
348 311
349 312
350 TEST_F(TyperTest, TypeJSEqual) { 313 TEST_F(TyperTest, TypeJSEqual) {
351 TestBinaryCompareOp(javascript_.Equal(), std::equal_to<double>()); 314 TestBinaryCompareOp(javascript_.Equal(), std::equal_to<double>());
352 } 315 }
353 316
354 317
355 TEST_F(TyperTest, TypeJSNotEqual) { 318 TEST_F(TyperTest, TypeJSNotEqual) {
(...skipping 18 matching lines...)
374 337
375 338
376 #define TEST_BINARY_MONOTONICITY(name) \ 339 #define TEST_BINARY_MONOTONICITY(name) \
377 TEST_F(TyperTest, Monotonicity_##name) { \ 340 TEST_F(TyperTest, Monotonicity_##name) { \
378 TestBinaryMonotonicity(javascript_.name()); \ 341 TestBinaryMonotonicity(javascript_.name()); \
379 } 342 }
380 TEST_BINARY_MONOTONICITY(Equal) 343 TEST_BINARY_MONOTONICITY(Equal)
381 TEST_BINARY_MONOTONICITY(NotEqual) 344 TEST_BINARY_MONOTONICITY(NotEqual)
382 TEST_BINARY_MONOTONICITY(StrictEqual) 345 TEST_BINARY_MONOTONICITY(StrictEqual)
383 TEST_BINARY_MONOTONICITY(StrictNotEqual) 346 TEST_BINARY_MONOTONICITY(StrictNotEqual)
384 #undef TEST_BINARY_MONOTONICITY
385
386
387 #define TEST_BINARY_MONOTONICITY(name) \
388 TEST_F(TyperTest, Monotonicity_##name) { \
389 TestBinaryMonotonicity(javascript_.name(LanguageMode::SLOPPY)); \
390 TestBinaryMonotonicity(javascript_.name(LanguageMode::STRONG)); \
391 }
392 TEST_BINARY_MONOTONICITY(LessThan) 347 TEST_BINARY_MONOTONICITY(LessThan)
393 TEST_BINARY_MONOTONICITY(GreaterThan) 348 TEST_BINARY_MONOTONICITY(GreaterThan)
394 TEST_BINARY_MONOTONICITY(LessThanOrEqual) 349 TEST_BINARY_MONOTONICITY(LessThanOrEqual)
395 TEST_BINARY_MONOTONICITY(GreaterThanOrEqual) 350 TEST_BINARY_MONOTONICITY(GreaterThanOrEqual)
396 #undef TEST_BINARY_MONOTONICITY 351 #undef TEST_BINARY_MONOTONICITY
397 352
398 353 #define TEST_BINARY_MONOTONICITY(name) \
399 #define TEST_BINARY_MONOTONICITY(name) \ 354 TEST_F(TyperTest, Monotonicity_##name) { \
400 TEST_F(TyperTest, Monotonicity_##name) { \ 355 TestBinaryMonotonicity(javascript_.name(BinaryOperationHints::Any())); \
401 TestBinaryMonotonicity( \
402 javascript_.name(LanguageMode::SLOPPY, BinaryOperationHints::Any())); \
403 TestBinaryMonotonicity( \
404 javascript_.name(LanguageMode::STRONG, BinaryOperationHints::Any())); \
405 } 356 }
406 TEST_BINARY_MONOTONICITY(BitwiseOr) 357 TEST_BINARY_MONOTONICITY(BitwiseOr)
407 TEST_BINARY_MONOTONICITY(BitwiseXor) 358 TEST_BINARY_MONOTONICITY(BitwiseXor)
408 TEST_BINARY_MONOTONICITY(BitwiseAnd) 359 TEST_BINARY_MONOTONICITY(BitwiseAnd)
409 TEST_BINARY_MONOTONICITY(ShiftLeft) 360 TEST_BINARY_MONOTONICITY(ShiftLeft)
410 TEST_BINARY_MONOTONICITY(ShiftRight) 361 TEST_BINARY_MONOTONICITY(ShiftRight)
411 TEST_BINARY_MONOTONICITY(ShiftRightLogical) 362 TEST_BINARY_MONOTONICITY(ShiftRightLogical)
412 TEST_BINARY_MONOTONICITY(Add) 363 TEST_BINARY_MONOTONICITY(Add)
413 TEST_BINARY_MONOTONICITY(Subtract) 364 TEST_BINARY_MONOTONICITY(Subtract)
414 TEST_BINARY_MONOTONICITY(Multiply) 365 TEST_BINARY_MONOTONICITY(Multiply)
(...skipping 11 matching lines...)
426 for (auto i : values) { 377 for (auto i : values) {
427 Node* c = graph()->NewNode(common()->Int32Constant(i)); 378 Node* c = graph()->NewNode(common()->Int32Constant(i));
428 Type* type = NodeProperties::GetType(c); 379 Type* type = NodeProperties::GetType(c);
429 EXPECT_TRUE(type->Is(NewRange(i, i))); 380 EXPECT_TRUE(type->Is(NewRange(i, i)));
430 } 381 }
431 } 382 }
432 383
433 } // namespace compiler 384 } // namespace compiler
434 } // namespace internal 385 } // namespace internal
435 } // namespace v8 386 } // namespace v8
OLDNEW

Powered by Google App Engine