Chromium Code Reviews| 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): calling into the runtime to allocate is not supported | |
| 308 // on ARM64 because the MachineCallTester uses CallAddress. | |
| 309 | |
| 310 TEST(RunChangeInt32ToTagged_smi) { | |
|
Michael Starzinger
2014/08/27 13:29:22
nit: s/_smi/Smi/
titzer
2014/08/27 13:51:09
Done.
| |
| 306 ChangesLoweringTester<Object*> t; | 311 ChangesLoweringTester<Object*> t; |
| 307 int32_t input; | 312 int32_t input; |
| 308 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), | 313 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), |
| 309 t.machine()->Load(kMachInt32), &input); | 314 t.machine()->Load(kMachInt32), &input); |
| 310 | 315 |
| 311 if (Pipeline::SupportedTarget()) { | 316 if (Pipeline::SupportedTarget()) { |
| 312 FOR_INT32_INPUTS(i) { | 317 FOR_INT32_INPUTS(i) { |
| 313 input = *i; | 318 input = *i; |
| 314 Object* result = t.CallWithPotentialGC<Object>(); | 319 if (!Smi::IsValid(input)) continue; |
| 315 t.CheckNumber(static_cast<double>(input), result); | 320 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); | 321 t.CheckNumber(static_cast<double>(input), result); |
| 325 } | 322 } |
| 326 } | 323 } |
| 327 } | 324 } |
| 328 | 325 |
| 329 | 326 |
| 330 TEST(RunChangeUint32ToTagged) { | 327 TEST(RunChangeUint32ToTagged_smi) { |
|
Michael Starzinger
2014/08/27 13:29:22
nit: s/_smi/Smi/
titzer
2014/08/27 13:51:09
Done.
| |
| 331 ChangesLoweringTester<Object*> t; | 328 ChangesLoweringTester<Object*> t; |
| 332 uint32_t input; | 329 uint32_t input; |
| 333 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), | 330 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), |
| 334 t.machine()->Load(kMachUint32), &input); | 331 t.machine()->Load(kMachUint32), &input); |
| 335 | 332 |
| 336 if (Pipeline::SupportedTarget()) { | 333 if (Pipeline::SupportedTarget()) { |
| 337 FOR_UINT32_INPUTS(i) { | 334 FOR_UINT32_INPUTS(i) { |
| 338 input = *i; | 335 input = *i; |
| 339 Object* result = t.CallWithPotentialGC<Object>(); | 336 if (!Smi::IsValid(input)) continue; |
| 337 Object* result = t.Call(); | |
| 340 double expected = static_cast<double>(input); | 338 double expected = static_cast<double>(input); |
| 341 t.CheckNumber(expected, result); | 339 t.CheckNumber(expected, result); |
| 342 } | 340 } |
| 343 } | 341 } |
| 342 } | |
| 343 | |
| 344 | |
| 345 TEST(RunChangeInt32ToTagged) { | |
| 346 ChangesLoweringTester<Object*> t; | |
| 347 int32_t input; | |
| 348 t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), | |
| 349 t.machine()->Load(kMachInt32), &input); | |
| 344 | 350 |
| 345 if (Pipeline::SupportedTarget()) { | 351 if (Pipeline::SupportedTarget()) { |
| 346 FOR_UINT32_INPUTS(i) { | 352 for (int m = 0; m < 3; m++) { // Try 3 GC modes. |
| 347 input = *i; | 353 FOR_INT32_INPUTS(i) { |
| 348 CcTest::heap()->DisableInlineAllocation(); | 354 if (m == 0) CcTest::heap()->EnableInlineAllocation(); |
| 349 Object* result = t.CallWithPotentialGC<Object>(); | 355 if (m == 1) CcTest::heap()->DisableInlineAllocation(); |
| 350 double expected = static_cast<double>(static_cast<uint32_t>(input)); | 356 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); |
| 351 t.CheckNumber(expected, result); | 357 |
| 358 input = *i; | |
| 359 Object* result = t.CallWithPotentialGC<Object>(); | |
| 360 t.CheckNumber(static_cast<double>(input), result); | |
| 361 } | |
| 352 } | 362 } |
| 353 } | 363 } |
| 354 } | 364 } |
| 365 | |
| 366 | |
| 367 TEST(RunChangeUint32ToTagged) { | |
| 368 ChangesLoweringTester<Object*> t; | |
| 369 uint32_t input; | |
| 370 t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), | |
| 371 t.machine()->Load(kMachUint32), &input); | |
| 372 | |
| 373 if (Pipeline::SupportedTarget()) { | |
| 374 for (int m = 0; m < 3; m++) { // Try 3 GC modes. | |
| 375 FOR_UINT32_INPUTS(i) { | |
| 376 if (m == 0) CcTest::heap()->EnableInlineAllocation(); | |
| 377 if (m == 1) CcTest::heap()->DisableInlineAllocation(); | |
| 378 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); | |
| 379 | |
| 380 input = *i; | |
| 381 Object* result = t.CallWithPotentialGC<Object>(); | |
| 382 double expected = static_cast<double>(input); | |
| 383 t.CheckNumber(expected, result); | |
| 384 } | |
| 385 } | |
| 386 } | |
| 387 } | |
| 355 | 388 |
| 356 | 389 |
| 357 TEST(RunChangeFloat64ToTagged) { | 390 TEST(RunChangeFloat64ToTagged) { |
| 358 ChangesLoweringTester<Object*> t; | 391 ChangesLoweringTester<Object*> t; |
| 359 double input; | 392 double input; |
| 360 t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), | 393 t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), |
| 361 t.machine()->Load(kMachFloat64), &input); | 394 t.machine()->Load(kMachFloat64), &input); |
| 362 | 395 |
| 363 { | 396 if (Pipeline::SupportedTarget()) { |
| 364 FOR_FLOAT64_INPUTS(i) { | 397 for (int m = 0; m < 3; m++) { // Try 3 GC modes. |
| 365 input = *i; | 398 FOR_FLOAT64_INPUTS(i) { |
| 366 Object* result = t.CallWithPotentialGC<Object>(); | 399 if (m == 0) CcTest::heap()->EnableInlineAllocation(); |
| 367 t.CheckNumber(input, result); | 400 if (m == 1) CcTest::heap()->DisableInlineAllocation(); |
| 368 } | 401 if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); |
| 369 } | |
| 370 | 402 |
| 371 { | 403 input = *i; |
| 372 FOR_FLOAT64_INPUTS(i) { | 404 Object* result = t.CallWithPotentialGC<Object>(); |
| 373 input = *i; | 405 t.CheckNumber(input, result); |
| 374 CcTest::heap()->DisableInlineAllocation(); | 406 } |
| 375 Object* result = t.CallWithPotentialGC<Object>(); | |
| 376 t.CheckNumber(input, result); | |
| 377 } | 407 } |
| 378 } | 408 } |
| 379 } | 409 } |
| 410 | |
| 411 #endif // !V8_TARGET_ARCH_ARM64 | |
| OLD | NEW |