| OLD | NEW |
| 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/compiler/change-lowering.h" | 7 #include "src/compiler/change-lowering.h" |
| 8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
| 9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| 11 #include "src/compiler/node-properties-inl.h" | 11 #include "src/compiler/node-properties-inl.h" |
| 12 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
| 13 #include "src/compiler/simplified-node-factory.h" | 13 #include "src/compiler/simplified-node-factory.h" |
| 14 #include "src/compiler/typer.h" | 14 #include "src/compiler/typer.h" |
| 15 #include "src/compiler/verifier.h" | 15 #include "src/compiler/verifier.h" |
| 16 #include "src/execution.h" | 16 #include "src/execution.h" |
| 17 #include "src/globals.h" |
| 17 #include "src/parser.h" | 18 #include "src/parser.h" |
| 18 #include "src/rewriter.h" | 19 #include "src/rewriter.h" |
| 19 #include "src/scopes.h" | 20 #include "src/scopes.h" |
| 20 #include "test/cctest/cctest.h" | 21 #include "test/cctest/cctest.h" |
| 21 #include "test/cctest/compiler/codegen-tester.h" | 22 #include "test/cctest/compiler/codegen-tester.h" |
| 22 #include "test/cctest/compiler/graph-builder-tester.h" | 23 #include "test/cctest/compiler/graph-builder-tester.h" |
| 23 #include "test/cctest/compiler/value-helper.h" | 24 #include "test/cctest/compiler/value-helper.h" |
| 24 | 25 |
| 25 using namespace v8::internal; | 26 using namespace v8::internal; |
| 26 using namespace v8::internal::compiler; | 27 using namespace v8::internal::compiler; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 296 } |
| 296 | 297 |
| 297 if (Pipeline::SupportedTarget()) { | 298 if (Pipeline::SupportedTarget()) { |
| 298 Object* result = t.Call(0); | 299 Object* result = t.Call(0); |
| 299 Object* false_obj = t.heap()->false_value(); | 300 Object* false_obj = t.heap()->false_value(); |
| 300 CHECK_EQ(false_obj, result); | 301 CHECK_EQ(false_obj, result); |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 | 304 |
| 304 | 305 |
| 305 TEST(RunChangeInt32ToTagged) { | 306 #ifndef V8_TARGET_ARCH_ARM64 |
| 307 // TODO(titzer): disabled on ARM64 because calling into the runtime to |
| 308 // allocate uses the wrong stack pointer. |
| 309 // TODO(titzer): disabled on ARM |
| 310 |
| 311 TEST(RunChangeInt32ToTaggedSmi) { |
| 306 ChangesLoweringTester<Object*> t; | 312 ChangesLoweringTester<Object*> t; |
| 307 int32_t input; | 313 int32_t input; |
| 308 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), | 314 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), |
| 309 t.machine()->Load(kMachInt32), &input); | 315 t.machine()->Load(kMachInt32), &input); |
| 310 | 316 |
| 311 if (Pipeline::SupportedTarget()) { | 317 if (Pipeline::SupportedTarget()) { |
| 312 FOR_INT32_INPUTS(i) { | 318 FOR_INT32_INPUTS(i) { |
| 313 input = *i; | 319 input = *i; |
| 314 Object* result = t.CallWithPotentialGC<Object>(); | 320 if (!Smi::IsValid(input)) continue; |
| 315 t.CheckNumber(static_cast<double>(input), result); | 321 Object* result = t.Call(); |
| 316 } | |
| 317 } | |
| 318 | |
| 319 if (Pipeline::SupportedTarget()) { | |
| 320 FOR_INT32_INPUTS(i) { | |
| 321 input = *i; | |
| 322 CcTest::heap()->DisableInlineAllocation(); | |
| 323 Object* result = t.CallWithPotentialGC<Object>(); | |
| 324 t.CheckNumber(static_cast<double>(input), result); | 322 t.CheckNumber(static_cast<double>(input), result); |
| 325 } | 323 } |
| 326 } | 324 } |
| 327 } | 325 } |
| 328 | 326 |
| 329 | 327 |
| 330 TEST(RunChangeUint32ToTagged) { | 328 TEST(RunChangeUint32ToTaggedSmi) { |
| 331 ChangesLoweringTester<Object*> t; | 329 ChangesLoweringTester<Object*> t; |
| 332 uint32_t input; | 330 uint32_t input; |
| 333 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), | 331 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), |
| 334 t.machine()->Load(kMachUint32), &input); | 332 t.machine()->Load(kMachUint32), &input); |
| 335 | 333 |
| 336 if (Pipeline::SupportedTarget()) { | 334 if (Pipeline::SupportedTarget()) { |
| 337 FOR_UINT32_INPUTS(i) { | 335 FOR_UINT32_INPUTS(i) { |
| 338 input = *i; | 336 input = *i; |
| 339 Object* result = t.CallWithPotentialGC<Object>(); | 337 if (input > static_cast<uint32_t>(Smi::kMaxValue)) continue; |
| 338 Object* result = t.Call(); |
| 340 double expected = static_cast<double>(input); | 339 double expected = static_cast<double>(input); |
| 341 t.CheckNumber(expected, result); | 340 t.CheckNumber(expected, result); |
| 342 } | 341 } |
| 343 } | 342 } |
| 343 } |
| 344 |
| 345 |
| 346 TEST(RunChangeInt32ToTagged) { |
| 347 ChangesLoweringTester<Object*> t; |
| 348 int32_t input; |
| 349 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), |
| 350 t.machine()->Load(kMachInt32), &input); |
| 344 | 351 |
| 345 if (Pipeline::SupportedTarget()) { | 352 if (Pipeline::SupportedTarget()) { |
| 346 FOR_UINT32_INPUTS(i) { | 353 for (int m = 0; m < 3; m++) { // Try 3 GC modes. |
| 347 input = *i; | 354 FOR_INT32_INPUTS(i) { |
| 348 CcTest::heap()->DisableInlineAllocation(); | 355 if (m == 0) CcTest::heap()->EnableInlineAllocation(); |
| 349 Object* result = t.CallWithPotentialGC<Object>(); | 356 if (m == 1) CcTest::heap()->DisableInlineAllocation(); |
| 350 double expected = static_cast<double>(static_cast<uint32_t>(input)); | 357 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); |
| 351 t.CheckNumber(expected, result); | 358 |
| 359 input = *i; |
| 360 Object* result = t.CallWithPotentialGC<Object>(); |
| 361 t.CheckNumber(static_cast<double>(input), result); |
| 362 } |
| 352 } | 363 } |
| 353 } | 364 } |
| 354 } | 365 } |
| 366 |
| 367 |
| 368 TEST(RunChangeUint32ToTagged) { |
| 369 ChangesLoweringTester<Object*> t; |
| 370 uint32_t input; |
| 371 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), |
| 372 t.machine()->Load(kMachUint32), &input); |
| 373 |
| 374 if (Pipeline::SupportedTarget()) { |
| 375 for (int m = 0; m < 3; m++) { // Try 3 GC modes. |
| 376 FOR_UINT32_INPUTS(i) { |
| 377 if (m == 0) CcTest::heap()->EnableInlineAllocation(); |
| 378 if (m == 1) CcTest::heap()->DisableInlineAllocation(); |
| 379 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); |
| 380 |
| 381 input = *i; |
| 382 Object* result = t.CallWithPotentialGC<Object>(); |
| 383 double expected = static_cast<double>(input); |
| 384 t.CheckNumber(expected, result); |
| 385 } |
| 386 } |
| 387 } |
| 388 } |
| 355 | 389 |
| 356 | 390 |
| 357 TEST(RunChangeFloat64ToTagged) { | 391 TEST(RunChangeFloat64ToTagged) { |
| 358 ChangesLoweringTester<Object*> t; | 392 ChangesLoweringTester<Object*> t; |
| 359 double input; | 393 double input; |
| 360 t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), | 394 t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), |
| 361 t.machine()->Load(kMachFloat64), &input); | 395 t.machine()->Load(kMachFloat64), &input); |
| 362 | 396 |
| 363 { | 397 if (Pipeline::SupportedTarget()) { |
| 364 FOR_FLOAT64_INPUTS(i) { | 398 for (int m = 0; m < 3; m++) { // Try 3 GC modes. |
| 365 input = *i; | 399 FOR_FLOAT64_INPUTS(i) { |
| 366 Object* result = t.CallWithPotentialGC<Object>(); | 400 if (m == 0) CcTest::heap()->EnableInlineAllocation(); |
| 367 t.CheckNumber(input, result); | 401 if (m == 1) CcTest::heap()->DisableInlineAllocation(); |
| 368 } | 402 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); |
| 369 } | |
| 370 | 403 |
| 371 { | 404 input = *i; |
| 372 FOR_FLOAT64_INPUTS(i) { | 405 Object* result = t.CallWithPotentialGC<Object>(); |
| 373 input = *i; | 406 t.CheckNumber(input, result); |
| 374 CcTest::heap()->DisableInlineAllocation(); | 407 } |
| 375 Object* result = t.CallWithPotentialGC<Object>(); | |
| 376 t.CheckNumber(input, result); | |
| 377 } | 408 } |
| 378 } | 409 } |
| 379 } | 410 } |
| 411 |
| 412 #endif // !V8_TARGET_ARCH_ARM64 |
| OLD | NEW |