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

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

Issue 648613006: Implement bigint absAdd, absSub, mulAdd, sqrAdd, estQuotientDigit intrinsics, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 __ ret(); 379 __ ret();
380 } 380 }
381 381
382 382
383 ASSEMBLER_TEST_RUN(SignedMultiply, test) { 383 ASSEMBLER_TEST_RUN(SignedMultiply, test) {
384 typedef int (*SignedMultiply)(); 384 typedef int (*SignedMultiply)();
385 EXPECT_EQ(8000, reinterpret_cast<SignedMultiply>(test->entry())()); 385 EXPECT_EQ(8000, reinterpret_cast<SignedMultiply>(test->entry())());
386 } 386 }
387 387
388 388
389 ASSEMBLER_TEST_GENERATE(UnsignedMultiply, assembler) {
390 __ movl(RAX, Immediate(-1));
391 __ movl(RCX, Immediate(16));
392 __ mull(RCX);
zra 2014/10/10 16:23:43 A comment about what is going on here might be goo
regis 2014/10/10 19:15:47 Done.
393 __ movq(RAX, RDX);
394 __ ret();
395 }
396
397
398 ASSEMBLER_TEST_RUN(UnsignedMultiply, test) {
399 typedef int (*UnsignedMultiply)();
400 EXPECT_EQ(15, reinterpret_cast<UnsignedMultiply>(test->entry())());
401 }
402
403
389 ASSEMBLER_TEST_GENERATE(SignedMultiply64, assembler) { 404 ASSEMBLER_TEST_GENERATE(SignedMultiply64, assembler) {
390 __ pushq(R15); // Callee saved. 405 __ pushq(R15); // Callee saved.
391 __ movq(RAX, Immediate(2)); 406 __ movq(RAX, Immediate(2));
392 __ movq(RCX, Immediate(4)); 407 __ movq(RCX, Immediate(4));
393 __ imulq(RAX, RCX); 408 __ imulq(RAX, RCX);
394 409
395 __ movq(R8, Immediate(2)); 410 __ movq(R8, Immediate(2));
396 __ movq(R9, Immediate(4)); 411 __ movq(R9, Immediate(4));
397 __ pushq(R9); 412 __ pushq(R9);
398 __ imulq(R8, Address(RSP, 0)); 413 __ imulq(R8, Address(RSP, 0));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 __ ret(); 516 __ ret();
502 } 517 }
503 518
504 519
505 ASSEMBLER_TEST_RUN(SignedDivide, test) { 520 ASSEMBLER_TEST_RUN(SignedDivide, test) {
506 typedef int32_t (*SignedDivide)(); 521 typedef int32_t (*SignedDivide)();
507 EXPECT_EQ(-87 / 42, reinterpret_cast<SignedDivide>(test->entry())()); 522 EXPECT_EQ(-87 / 42, reinterpret_cast<SignedDivide>(test->entry())());
508 } 523 }
509 524
510 525
526 ASSEMBLER_TEST_GENERATE(UnsignedDivide, assembler) {
527 __ movl(RAX, Immediate(0x0));
528 __ movl(RDX, Immediate(0xfffffffff0000000));
zra 2014/10/10 16:23:43 movq? Can you really give such a big immediate to
regis 2014/10/10 19:15:47 If you do not specify the high bits, the value is
529 __ movl(RCX, Immediate(-1));
530 __ divl(RCX);
zra 2014/10/10 16:23:43 A comment here too.
regis 2014/10/10 19:15:47 ditto
531 __ ret();
532 }
533
534
535 ASSEMBLER_TEST_RUN(UnsignedDivide, test) {
536 typedef uint32_t (*UnsignedDivide)();
537 EXPECT_EQ(0xF0000000, reinterpret_cast<UnsignedDivide>(test->entry())());
538 }
539
540
511 ASSEMBLER_TEST_GENERATE(SignedDivideLong, assembler) { 541 ASSEMBLER_TEST_GENERATE(SignedDivideLong, assembler) {
512 __ movq(RAX, Immediate(kLargeConstant)); 542 __ movq(RAX, Immediate(kLargeConstant));
513 __ movq(RDX, Immediate(123)); 543 __ movq(RDX, Immediate(123));
514 __ cqo(); // Clear RDX. 544 __ cqo(); // Clear RDX.
515 __ movq(RCX, Immediate(42)); 545 __ movq(RCX, Immediate(42));
516 __ idivq(RCX); 546 __ idivq(RCX);
517 __ ret(); 547 __ ret();
518 } 548 }
519 549
520 550
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 __ movl(RCX, Immediate(3)); 928 __ movl(RCX, Immediate(3));
899 __ shlq(RAX, Immediate(31)); 929 __ shlq(RAX, Immediate(31));
900 __ sarl(RAX, RCX); 930 __ sarl(RAX, RCX);
901 __ cmpl(RAX, Immediate(0xfffffffff0000000)); 931 __ cmpl(RAX, Immediate(0xfffffffff0000000));
902 __ j(EQUAL, &donetest13a); 932 __ j(EQUAL, &donetest13a);
903 // Be sure to skip this crashing code. 933 // Be sure to skip this crashing code.
904 __ movl(RAX, Immediate(0)); 934 __ movl(RAX, Immediate(0));
905 __ movl(Address(RAX, 0), RAX); 935 __ movl(Address(RAX, 0), RAX);
906 __ Bind(&donetest13a); 936 __ Bind(&donetest13a);
907 937
938 Label donetest15a;
939 __ movl(RDX, Immediate(0xffffffffff000000));
zra 2014/10/10 16:23:43 Same question in the sequence with l vs. q version
regis 2014/10/10 19:15:47 ditto
940 __ movl(RAX, Immediate(-1));
941 __ movl(RCX, Immediate(2));
942 __ shll(RDX, RCX);
943 __ shldl(RDX, RAX, Immediate(2));
zra 2014/10/10 16:23:43 A comment here.
regis 2014/10/10 19:15:47 Done.
944 __ cmpl(RDX, Immediate(0xfffffffff0000003));
945 __ j(EQUAL, &donetest15a);
946 __ int3();
947 __ Bind(&donetest15a);
948
908 __ movl(RAX, Immediate(0)); 949 __ movl(RAX, Immediate(0));
909 __ ret(); 950 __ ret();
910 } 951 }
911 952
912 953
913 ASSEMBLER_TEST_RUN(LogicalOps, test) { 954 ASSEMBLER_TEST_RUN(LogicalOps, test) {
914 typedef int (*LogicalOpsCode)(); 955 typedef int (*LogicalOpsCode)();
915 EXPECT_EQ(0, reinterpret_cast<LogicalOpsCode>(test->entry())()); 956 EXPECT_EQ(0, reinterpret_cast<LogicalOpsCode>(test->entry())());
916 } 957 }
917 958
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( 3067 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>(
3027 test->entry())(0x7fffffffffffffff, 2); 3068 test->entry())(0x7fffffffffffffff, 2);
3028 EXPECT_EQ(1, res); 3069 EXPECT_EQ(1, res);
3029 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); 3070 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1);
3030 EXPECT_EQ(0, res); 3071 EXPECT_EQ(0, res);
3031 } 3072 }
3032 3073
3033 } // namespace dart 3074 } // namespace dart
3034 3075
3035 #endif // defined TARGET_ARCH_X64 3076 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698