| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 const char* to = new char[10]; | 2560 const char* to = new char[10]; |
| 2561 typedef void (*TestRepMovsBytes)(const char* from, const char* to, int count); | 2561 typedef void (*TestRepMovsBytes)(const char* from, const char* to, int count); |
| 2562 reinterpret_cast<TestRepMovsBytes>(test->entry())(from, to, 10); | 2562 reinterpret_cast<TestRepMovsBytes>(test->entry())(from, to, 10); |
| 2563 EXPECT_EQ(to[0], '0'); | 2563 EXPECT_EQ(to[0], '0'); |
| 2564 for (int i = 0; i < 10; i++) { | 2564 for (int i = 0; i < 10; i++) { |
| 2565 EXPECT_EQ(from[i], to[i]); | 2565 EXPECT_EQ(from[i], to[i]); |
| 2566 } | 2566 } |
| 2567 delete [] to; | 2567 delete [] to; |
| 2568 } | 2568 } |
| 2569 | 2569 |
| 2570 |
| 2571 ASSEMBLER_TEST_GENERATE(ConditionalMovesCompare, assembler) { |
| 2572 // RDI: Arg0. |
| 2573 // RSI: Arg1. |
| 2574 __ movq(RDX, Immediate(1)); // Greater equal. |
| 2575 __ movq(RCX, Immediate(-1)); // Less |
| 2576 __ cmpq(RDI, RSI); |
| 2577 __ cmovlessq(RAX, RCX); |
| 2578 __ cmovgeq(RAX, RDX); |
| 2579 __ ret(); |
| 2580 } |
| 2581 |
| 2582 |
| 2583 ASSEMBLER_TEST_RUN(ConditionalMovesCompare, test) { |
| 2584 typedef int (*ConditionalMovesCompareCode)(int i, int i); |
| 2585 int res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(10, 5); |
| 2586 EXPECT_EQ(1, res); // Greater equal. |
| 2587 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); |
| 2588 EXPECT_EQ(1, res); // Greater equal. |
| 2589 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); |
| 2590 EXPECT_EQ(-1, res); // Less. |
| 2591 } |
| 2592 |
| 2570 } // namespace dart | 2593 } // namespace dart |
| 2571 | 2594 |
| 2572 #endif // defined TARGET_ARCH_X64 | 2595 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |