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

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

Issue 1089003002: Implement bigint shift intrinsics on IA32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
Cutch 2015/04/15 17:56:36 comment here about which registers can be modified
regis 2015/04/15 20:46:00 I have edited the existing comment on line 22 and
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/flow_graph_compiler.h" 12 #include "vm/flow_graph_compiler.h"
13 #include "vm/instructions.h" 13 #include "vm/instructions.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/regexp_assembler.h" 15 #include "vm/regexp_assembler.h"
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 __ Bind(&loop); 750 __ Bind(&loop);
751 __ movq(RAX, RDX); 751 __ movq(RAX, RDX);
752 __ movq(RDX, 752 __ movq(RDX,
753 FieldAddress(RDI, R8, TIMES_8, 753 FieldAddress(RDI, R8, TIMES_8,
754 TypedData::data_offset() - 2 * Bigint::kBytesPerDigit)); 754 TypedData::data_offset() - 2 * Bigint::kBytesPerDigit));
755 __ shldq(RAX, RDX, RCX); 755 __ shldq(RAX, RDX, RCX);
756 __ movq(Address(RBX, R8, TIMES_8, 0), RAX); 756 __ movq(Address(RBX, R8, TIMES_8, 0), RAX);
757 __ decq(R8); 757 __ decq(R8);
758 __ j(NOT_ZERO, &loop, Assembler::kNearJump); 758 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
759 __ Bind(&last); 759 __ Bind(&last);
760 __ xorq(RAX, RAX); // RAX = 0. 760 __ shldq(RDX, R8, RCX); // R8 == 0.
761 __ shldq(RDX, RAX, RCX);
762 __ movq(Address(RBX, 0), RDX); 761 __ movq(Address(RBX, 0), RDX);
763 // Returning Object::null() is not required, since this method is private. 762 // Returning Object::null() is not required, since this method is private.
764 __ ret(); 763 __ ret();
765 } 764 }
766 765
767 766
768 void Intrinsifier::Bigint_rsh(Assembler* assembler) { 767 void Intrinsifier::Bigint_rsh(Assembler* assembler) {
769 // static void _rsh(Uint32List x_digits, int x_used, int n, 768 // static void _rsh(Uint32List x_digits, int x_used, int n,
770 // Uint32List r_digits) 769 // Uint32List r_digits)
771 770
772 __ movq(RDI, Address(RSP, 4 * kWordSize)); // x_digits 771 __ movq(RDI, Address(RSP, 4 * kWordSize)); // x_digits
773 __ movq(R8, Address(RSP, 3 * kWordSize)); // x_used is Smi
774 __ subq(R8, Immediate(2)); // x_used > 0, Smi. R8 = x_used - 1, round up.
775 __ sarq(R8, Immediate(2));
776 __ movq(RCX, Address(RSP, 2 * kWordSize)); // n is Smi 772 __ movq(RCX, Address(RSP, 2 * kWordSize)); // n is Smi
777 __ SmiUntag(RCX); 773 __ SmiUntag(RCX);
778 __ movq(RBX, Address(RSP, 1 * kWordSize)); // r_digits 774 __ movq(RBX, Address(RSP, 1 * kWordSize)); // r_digits
779 __ movq(RSI, RCX); 775 __ movq(RDX, RCX);
780 __ sarq(RSI, Immediate(6)); // RSI = n ~/ (2*_DIGIT_BITS). 776 __ sarq(RDX, Immediate(6)); // RDX = n ~/ (2*_DIGIT_BITS).
777 __ movq(RSI, Address(RSP, 3 * kWordSize)); // x_used is Smi
778 __ subq(RSI, Immediate(2)); // x_used > 0, Smi. RSI = x_used - 1, round up.
779 __ sarq(RSI, Immediate(2));
781 __ leaq(RDI, FieldAddress(RDI, RSI, TIMES_8, TypedData::data_offset())); 780 __ leaq(RDI, FieldAddress(RDI, RSI, TIMES_8, TypedData::data_offset()));
782 __ movq(RDX, Address(RDI, 0)); 781 __ subq(RSI, RDX); // RSI + 1 = number of digit pairs to read.
783 __ subq(R8, RSI); // R8 + 1 = number of digit pairs to read. 782 __ leaq(RBX, FieldAddress(RBX, RSI, TIMES_8, TypedData::data_offset()));
783 __ negq(RSI);
784 __ movq(RDX, Address(RDI, RSI, TIMES_8, 0));
784 Label last; 785 Label last;
785 __ cmpq(R8, Immediate(0)); 786 __ cmpq(RSI, Immediate(0));
786 __ j(EQUAL, &last, Assembler::kNearJump); 787 __ j(EQUAL, &last, Assembler::kNearJump);
787 __ xorq(R9, R9); // R9 = 0.
788 Label loop; 788 Label loop;
789 __ Bind(&loop); 789 __ Bind(&loop);
790 __ movq(RAX, RDX); 790 __ movq(RAX, RDX);
791 __ movq(RDX, Address(RDI, R9, TIMES_8, 2 * Bigint::kBytesPerDigit)); 791 __ movq(RDX, Address(RDI, RSI, TIMES_8, 2 * Bigint::kBytesPerDigit));
792 __ shrdq(RAX, RDX, RCX); 792 __ shrdq(RAX, RDX, RCX);
793 __ movq(FieldAddress(RBX, R9, TIMES_8, TypedData::data_offset()), RAX); 793 __ movq(Address(RBX, RSI, TIMES_8, 0), RAX);
794 __ incq(R9); 794 __ incq(RSI);
795 __ cmpq(R9, R8); 795 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
796 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
797 __ Bind(&last); 796 __ Bind(&last);
798 __ xorq(RAX, RAX); // RAX = 0. 797 __ shrdq(RDX, RSI, RCX); // RSI == 0.
799 __ shrdq(RDX, RAX, RCX); 798 __ movq(Address(RBX, 0), RDX);
800 __ movq(FieldAddress(RBX, R8, TIMES_8, TypedData::data_offset()), RDX);
801 // Returning Object::null() is not required, since this method is private. 799 // Returning Object::null() is not required, since this method is private.
802 __ ret(); 800 __ ret();
803 } 801 }
804 802
805 803
806 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { 804 void Intrinsifier::Bigint_absAdd(Assembler* assembler) {
807 // static void _absAdd(Uint32List digits, int used, 805 // static void _absAdd(Uint32List digits, int used,
808 // Uint32List a_digits, int a_used, 806 // Uint32List a_digits, int a_used,
809 // Uint32List r_digits) 807 // Uint32List r_digits)
810 808
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 // Set return value to Isolate::current_tag_. 1986 // Set return value to Isolate::current_tag_.
1989 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1987 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1990 __ ret(); 1988 __ ret();
1991 } 1989 }
1992 1990
1993 #undef __ 1991 #undef __
1994 1992
1995 } // namespace dart 1993 } // namespace dart
1996 1994
1997 #endif // defined TARGET_ARCH_X64 1995 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intrinsifier_ia32.cc ('K') | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698