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

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
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
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"
16 #include "vm/symbols.h" 16 #include "vm/symbols.h"
17 17
18 namespace dart { 18 namespace dart {
19 19
20 DECLARE_FLAG(bool, enable_type_checks); 20 DECLARE_FLAG(bool, enable_type_checks);
21 21
22 // When entering intrinsics code: 22 // When entering intrinsics code:
23 // RBX: IC Data 23 // RBX: IC Data
24 // R10: Arguments descriptor 24 // R10: Arguments descriptor
25 // TOS: Return address 25 // TOS: Return address
26 // The RBX, R10 registers can be destroyed only if there is no slow-path (i.e., 26 // The RBX, R10 registers can be destroyed only if there is no slow-path, i.e.
27 // the methods returns true). 27 // if the intrinsified method always executes a return.
28 // The RBP register should not be modified, because it is used by the profiler.
28 29
29 #define __ assembler-> 30 #define __ assembler->
30 31
31 32
32 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; } 33 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; }
33 34
34 35
35 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { 36 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) {
36 if (Isolate::Current()->TypeChecksEnabled()) { 37 if (Isolate::Current()->TypeChecksEnabled()) {
37 return; 38 return;
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 __ Bind(&loop); 751 __ Bind(&loop);
751 __ movq(RAX, RDX); 752 __ movq(RAX, RDX);
752 __ movq(RDX, 753 __ movq(RDX,
753 FieldAddress(RDI, R8, TIMES_8, 754 FieldAddress(RDI, R8, TIMES_8,
754 TypedData::data_offset() - 2 * Bigint::kBytesPerDigit)); 755 TypedData::data_offset() - 2 * Bigint::kBytesPerDigit));
755 __ shldq(RAX, RDX, RCX); 756 __ shldq(RAX, RDX, RCX);
756 __ movq(Address(RBX, R8, TIMES_8, 0), RAX); 757 __ movq(Address(RBX, R8, TIMES_8, 0), RAX);
757 __ decq(R8); 758 __ decq(R8);
758 __ j(NOT_ZERO, &loop, Assembler::kNearJump); 759 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
759 __ Bind(&last); 760 __ Bind(&last);
760 __ xorq(RAX, RAX); // RAX = 0. 761 __ shldq(RDX, R8, RCX); // R8 == 0.
761 __ shldq(RDX, RAX, RCX);
762 __ movq(Address(RBX, 0), RDX); 762 __ movq(Address(RBX, 0), RDX);
763 // Returning Object::null() is not required, since this method is private. 763 // Returning Object::null() is not required, since this method is private.
764 __ ret(); 764 __ ret();
765 } 765 }
766 766
767 767
768 void Intrinsifier::Bigint_rsh(Assembler* assembler) { 768 void Intrinsifier::Bigint_rsh(Assembler* assembler) {
769 // static void _rsh(Uint32List x_digits, int x_used, int n, 769 // static void _rsh(Uint32List x_digits, int x_used, int n,
770 // Uint32List r_digits) 770 // Uint32List r_digits)
771 771
772 __ movq(RDI, Address(RSP, 4 * kWordSize)); // x_digits 772 __ 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 773 __ movq(RCX, Address(RSP, 2 * kWordSize)); // n is Smi
777 __ SmiUntag(RCX); 774 __ SmiUntag(RCX);
778 __ movq(RBX, Address(RSP, 1 * kWordSize)); // r_digits 775 __ movq(RBX, Address(RSP, 1 * kWordSize)); // r_digits
779 __ movq(RSI, RCX); 776 __ movq(RDX, RCX);
780 __ sarq(RSI, Immediate(6)); // RSI = n ~/ (2*_DIGIT_BITS). 777 __ sarq(RDX, Immediate(6)); // RDX = n ~/ (2*_DIGIT_BITS).
778 __ movq(RSI, Address(RSP, 3 * kWordSize)); // x_used is Smi
779 __ subq(RSI, Immediate(2)); // x_used > 0, Smi. RSI = x_used - 1, round up.
780 __ sarq(RSI, Immediate(2));
781 __ leaq(RDI, FieldAddress(RDI, RSI, TIMES_8, TypedData::data_offset())); 781 __ leaq(RDI, FieldAddress(RDI, RSI, TIMES_8, TypedData::data_offset()));
782 __ movq(RDX, Address(RDI, 0)); 782 __ subq(RSI, RDX); // RSI + 1 = number of digit pairs to read.
783 __ subq(R8, RSI); // R8 + 1 = number of digit pairs to read. 783 __ leaq(RBX, FieldAddress(RBX, RSI, TIMES_8, TypedData::data_offset()));
784 __ negq(RSI);
785 __ movq(RDX, Address(RDI, RSI, TIMES_8, 0));
784 Label last; 786 Label last;
785 __ cmpq(R8, Immediate(0)); 787 __ cmpq(RSI, Immediate(0));
786 __ j(EQUAL, &last, Assembler::kNearJump); 788 __ j(EQUAL, &last, Assembler::kNearJump);
787 __ xorq(R9, R9); // R9 = 0.
788 Label loop; 789 Label loop;
789 __ Bind(&loop); 790 __ Bind(&loop);
790 __ movq(RAX, RDX); 791 __ movq(RAX, RDX);
791 __ movq(RDX, Address(RDI, R9, TIMES_8, 2 * Bigint::kBytesPerDigit)); 792 __ movq(RDX, Address(RDI, RSI, TIMES_8, 2 * Bigint::kBytesPerDigit));
792 __ shrdq(RAX, RDX, RCX); 793 __ shrdq(RAX, RDX, RCX);
793 __ movq(FieldAddress(RBX, R9, TIMES_8, TypedData::data_offset()), RAX); 794 __ movq(Address(RBX, RSI, TIMES_8, 0), RAX);
794 __ incq(R9); 795 __ incq(RSI);
795 __ cmpq(R9, R8); 796 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
796 __ j(NOT_EQUAL, &loop, Assembler::kNearJump);
797 __ Bind(&last); 797 __ Bind(&last);
798 __ xorq(RAX, RAX); // RAX = 0. 798 __ shrdq(RDX, RSI, RCX); // RSI == 0.
799 __ shrdq(RDX, RAX, RCX); 799 __ 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. 800 // Returning Object::null() is not required, since this method is private.
802 __ ret(); 801 __ ret();
803 } 802 }
804 803
805 804
806 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { 805 void Intrinsifier::Bigint_absAdd(Assembler* assembler) {
807 // static void _absAdd(Uint32List digits, int used, 806 // static void _absAdd(Uint32List digits, int used,
808 // Uint32List a_digits, int a_used, 807 // Uint32List a_digits, int a_used,
809 // Uint32List r_digits) 808 // Uint32List r_digits)
810 809
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 // Set return value to Isolate::current_tag_. 1987 // Set return value to Isolate::current_tag_.
1989 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1988 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1990 __ ret(); 1989 __ ret();
1991 } 1990 }
1992 1991
1993 #undef __ 1992 #undef __
1994 1993
1995 } // namespace dart 1994 } // namespace dart
1996 1995
1997 #endif // defined TARGET_ARCH_X64 1996 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698