OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 #ifdef DEBUG | 406 #ifdef DEBUG |
407 code->Print(); | 407 code->Print(); |
408 #endif | 408 #endif |
409 F1 f = FUNCTION_CAST<F1>(code->entry()); | 409 F1 f = FUNCTION_CAST<F1>(code->entry()); |
410 intptr_t res = | 410 intptr_t res = |
411 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); | 411 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
412 ::printf("f() = %" V8PRIdPTR "\n", res); | 412 ::printf("f() = %" V8PRIdPTR "\n", res); |
413 } | 413 } |
414 #endif | 414 #endif |
415 | 415 |
| 416 // Test msrkc and msgrkc |
| 417 TEST(10) { |
| 418 if (!CpuFeatures::IsSupported(MISC_INSTR_EXT2)) { |
| 419 return; |
| 420 } |
| 421 |
| 422 ::printf("MISC_INSTR_EXT2 is enabled.\n"); |
| 423 |
| 424 CcTest::InitializeVM(); |
| 425 Isolate* isolate = CcTest::i_isolate(); |
| 426 HandleScope scope(isolate); |
| 427 |
| 428 Assembler assm(isolate, NULL, 0); |
| 429 |
| 430 Label ok, failed; |
| 431 |
| 432 { // test 1: msrkc |
| 433 __ lgfi(r2, Operand(3)); |
| 434 __ lgfi(r3, Operand(4)); |
| 435 __ msrkc(r1, r2, r3); // 3 * 4 |
| 436 __ b(static_cast<Condition>(le | overflow), &failed); // test failed. |
| 437 __ chi(r1, Operand(12)); |
| 438 __ bne(&failed); // test failed. |
| 439 |
| 440 __ lgfi(r2, Operand(-3)); |
| 441 __ lgfi(r3, Operand(4)); |
| 442 __ msrkc(r1, r2, r3); // -3 * 4 |
| 443 __ b(static_cast<Condition>(ge | overflow), &failed); // test failed. |
| 444 __ chi(r1, Operand(-12)); |
| 445 __ bne(&failed); // test failed. |
| 446 |
| 447 __ iilf(r2, Operand(0x80000000)); |
| 448 __ lgfi(r3, Operand(-1)); |
| 449 __ msrkc(r1, r2, r3); // INT_MIN * -1 |
| 450 __ b(nooverflow, &failed); // test failed. |
| 451 __ cfi(r1, Operand(0x80000000)); |
| 452 __ bne(&failed); // test failed. |
| 453 } |
| 454 |
| 455 { // test 1: msgrkc |
| 456 __ lgfi(r2, Operand(3)); |
| 457 __ lgfi(r3, Operand(4)); |
| 458 __ msgrkc(r1, r2, r3); // 3 * 4 |
| 459 __ b(static_cast<Condition>(le | overflow), &failed); // test failed. |
| 460 __ chi(r1, Operand(12)); |
| 461 __ bne(&failed); // test failed. |
| 462 |
| 463 __ lgfi(r2, Operand(-3)); |
| 464 __ lgfi(r3, Operand(4)); |
| 465 __ msgrkc(r1, r2, r3); // -3 * 4 |
| 466 __ b(static_cast<Condition>(ge | overflow), &failed); // test failed. |
| 467 __ chi(r1, Operand(-12)); |
| 468 __ bne(&failed); // test failed. |
| 469 |
| 470 __ lgfi(r2, Operand::Zero()); |
| 471 __ iihf(r2, Operand(0x80000000)); |
| 472 __ lgfi(r3, Operand(-1)); |
| 473 __ msgrkc(r1, r2, r3); // INT_MIN * -1 |
| 474 __ b(nooverflow, &failed); // test failed. |
| 475 __ cgr(r1, r2); |
| 476 __ bne(&failed); // test failed. |
| 477 } |
| 478 |
| 479 __ bind(&ok); |
| 480 __ lgfi(r2, Operand::Zero()); |
| 481 __ b(r14); // test done. |
| 482 |
| 483 __ bind(&failed); |
| 484 __ lgfi(r2, Operand(1)); |
| 485 __ b(r14); |
| 486 |
| 487 CodeDesc desc; |
| 488 assm.GetCode(&desc); |
| 489 Handle<Code> code = isolate->factory()->NewCode( |
| 490 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 491 #ifdef DEBUG |
| 492 code->Print(); |
| 493 #endif |
| 494 F2 f = FUNCTION_CAST<F2>(code->entry()); |
| 495 intptr_t res = reinterpret_cast<intptr_t>( |
| 496 CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); |
| 497 ::printf("f() = %" V8PRIxPTR "\n", res); |
| 498 CHECK_EQ(0, static_cast<int>(res)); |
| 499 } |
| 500 |
416 #undef __ | 501 #undef __ |
OLD | NEW |