Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: runtime/vm/assembler_x64_test.cc

Issue 867383002: Implement bitLength intrinsic on x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 613
614 614
615 ASSEMBLER_TEST_RUN(UnsignedDivideLong, test) { 615 ASSEMBLER_TEST_RUN(UnsignedDivideLong, test) {
616 typedef uint64_t (*UnsignedDivideLong)(); 616 typedef uint64_t (*UnsignedDivideLong)();
617 EXPECT_EQ(0xf000000000000000, 617 EXPECT_EQ(0xf000000000000000,
618 reinterpret_cast<UnsignedDivideLong>(test->entry())()); 618 reinterpret_cast<UnsignedDivideLong>(test->entry())());
619 } 619 }
620 620
621 621
622 ASSEMBLER_TEST_GENERATE(Negate, assembler) { 622 ASSEMBLER_TEST_GENERATE(Negate, assembler) {
623 __ movl(RCX, Immediate(42)); 623 __ movq(RCX, Immediate(42));
Cutch 2015/01/23 22:10:00 Good catch.
624 __ negl(RCX); 624 __ negq(RCX);
625 __ movl(RAX, RCX); 625 __ movq(RAX, RCX);
626 __ ret(); 626 __ ret();
627 } 627 }
628 628
629 629
630 ASSEMBLER_TEST_RUN(Negate, test) { 630 ASSEMBLER_TEST_RUN(Negate, test) {
631 typedef int (*Negate)(); 631 typedef int (*Negate)();
632 EXPECT_EQ(-42, reinterpret_cast<Negate>(test->entry())()); 632 EXPECT_EQ(-42, reinterpret_cast<Negate>(test->entry())());
633 } 633 }
634 634
635 635
636 ASSEMBLER_TEST_GENERATE(BitScanReverse, assembler) {
637 __ pushq(CallingConventions::kArg1Reg);
638 __ movq(RCX, Address(RSP, 0));
639 __ movq(RAX, Immediate(666)); // Marker for conditional write.
640 __ bsrq(RAX, RCX);
641 __ popq(RCX);
642 __ ret();
643 }
644
645
646 ASSEMBLER_TEST_RUN(BitScanReverse, test) {
647 typedef int (*Bsr)(int input);
648 Bsr call = reinterpret_cast<Bsr>(test->entry());
649 EXPECT_EQ(666, call(0));
650 EXPECT_EQ(0, call(1));
651 EXPECT_EQ(1, call(2));
652 EXPECT_EQ(1, call(3));
653 EXPECT_EQ(2, call(4));
654 EXPECT_EQ(5, call(42));
655 EXPECT_EQ(31, call(-1));
656 }
657
658
636 ASSEMBLER_TEST_GENERATE(MoveExtend, assembler) { 659 ASSEMBLER_TEST_GENERATE(MoveExtend, assembler) {
637 __ movq(RDX, Immediate(0xffff)); 660 __ movq(RDX, Immediate(0xffff));
638 __ movzxb(RAX, RDX); // RAX = 0xff 661 __ movzxb(RAX, RDX); // RAX = 0xff
639 __ movsxw(R8, RDX); // R8 = -1 662 __ movsxw(R8, RDX); // R8 = -1
640 __ movzxw(RCX, RDX); // RCX = 0xffff 663 __ movzxw(RCX, RDX); // RCX = 0xffff
641 __ addq(R8, RCX); 664 __ addq(R8, RCX);
642 __ addq(RAX, R8); 665 __ addq(RAX, R8);
643 __ ret(); 666 __ ret();
644 } 667 }
645 668
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); 3573 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64)));
3551 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); 3574 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64)));
3552 3575
3553 EXPECT_EQ(0, range_of(Bool::True().raw())); 3576 EXPECT_EQ(0, range_of(Bool::True().raw()));
3554 } 3577 }
3555 3578
3556 3579
3557 } // namespace dart 3580 } // namespace dart
3558 3581
3559 #endif // defined TARGET_ARCH_X64 3582 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698