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

Side by Side Diff: runtime/vm/intrinsifier_ia32.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_arm64.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | 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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
12 #if defined(TARGET_ARCH_IA32) 12 #if defined(TARGET_ARCH_IA32)
13 13
14 #include "vm/intrinsifier.h" 14 #include "vm/intrinsifier.h"
15 15
16 #include "vm/assembler.h" 16 #include "vm/assembler.h"
17 #include "vm/dart_entry.h" 17 #include "vm/dart_entry.h"
18 #include "vm/flow_graph_compiler.h" 18 #include "vm/flow_graph_compiler.h"
19 #include "vm/object.h" 19 #include "vm/object.h"
20 #include "vm/object_store.h" 20 #include "vm/object_store.h"
21 #include "vm/os.h" 21 #include "vm/os.h"
22 #include "vm/regexp_assembler.h" 22 #include "vm/regexp_assembler.h"
23 #include "vm/symbols.h" 23 #include "vm/symbols.h"
24 24
25 namespace dart { 25 namespace dart {
26 26
27 DECLARE_FLAG(bool, enable_type_checks); 27 DECLARE_FLAG(bool, enable_type_checks);
28 28
29 // When entering intrinsics code:
30 // ECX: IC Data
31 // EDX: Arguments descriptor
32 // TOS: Return address
33 // The ECX, EDX registers can be destroyed only if there is no slow-path, i.e.
34 // if the intrinsified method always executes a return.
35 // The EBP register should not be modified, because it is used by the profiler.
29 36
30 #define __ assembler-> 37 #define __ assembler->
31 38
32 39
33 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; } 40 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; }
34 41
35 42
36 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { 43 static intptr_t ComputeObjectArrayTypeArgumentsOffset() {
37 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 44 const Library& core_lib = Library::Handle(Library::CoreLibrary());
38 const Class& cls = Class::Handle( 45 const Class& cls = Class::Handle(
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 572
566 __ Bind(&overflow); 573 __ Bind(&overflow);
567 // Arguments are Smi but the shift produced an overflow to Mint. 574 // Arguments are Smi but the shift produced an overflow to Mint.
568 __ cmpl(EBX, Immediate(0)); 575 __ cmpl(EBX, Immediate(0));
569 // TODO(srdjan): Implement negative values, for now fall through. 576 // TODO(srdjan): Implement negative values, for now fall through.
570 __ j(LESS, &fall_through, Assembler::kNearJump); 577 __ j(LESS, &fall_through, Assembler::kNearJump);
571 __ SmiUntag(EBX); 578 __ SmiUntag(EBX);
572 __ movl(EAX, EBX); 579 __ movl(EAX, EBX);
573 __ shll(EBX, ECX); 580 __ shll(EBX, ECX);
574 __ xorl(EDI, EDI); 581 __ xorl(EDI, EDI);
575 __ shldl(EDI, EAX); 582 __ shldl(EDI, EAX, ECX);
576 // Result in EDI (high) and EBX (low). 583 // Result in EDI (high) and EBX (low).
577 const Class& mint_class = Class::Handle( 584 const Class& mint_class = Class::Handle(
578 Isolate::Current()->object_store()->mint_class()); 585 Isolate::Current()->object_store()->mint_class());
579 __ TryAllocate(mint_class, 586 __ TryAllocate(mint_class,
580 &fall_through, 587 &fall_through,
581 Assembler::kNearJump, 588 Assembler::kNearJump,
582 EAX, // Result register. 589 EAX, // Result register.
583 kNoRegister); 590 kNoRegister);
584 // EBX and EDI are not objects but integer values. 591 // EBX and EDI are not objects but integer values.
585 __ movl(FieldAddress(EAX, Mint::value_offset()), EBX); 592 __ movl(FieldAddress(EAX, Mint::value_offset()), EBX);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 // BSR does not write the destination register if source is zero. Put a 1 in 806 // BSR does not write the destination register if source is zero. Put a 1 in
800 // the Smi tag bit to ensure BSR writes to destination register. 807 // the Smi tag bit to ensure BSR writes to destination register.
801 __ orl(EAX, Immediate(kSmiTagMask)); 808 __ orl(EAX, Immediate(kSmiTagMask));
802 __ bsrl(EAX, EAX); 809 __ bsrl(EAX, EAX);
803 __ SmiTag(EAX); 810 __ SmiTag(EAX);
804 __ ret(); 811 __ ret();
805 } 812 }
806 813
807 814
808 void Intrinsifier::Bigint_lsh(Assembler* assembler) { 815 void Intrinsifier::Bigint_lsh(Assembler* assembler) {
809 // TODO(regis): Implement. 816 // static void _lsh(Uint32List x_digits, int x_used, int n,
817 // Uint32List r_digits)
818
819 __ movl(EDI, Address(ESP, 4 * kWordSize)); // x_digits
820 __ movl(ECX, Address(ESP, 2 * kWordSize)); // n is Smi
821 __ SmiUntag(ECX);
822 __ movl(EBX, Address(ESP, 1 * kWordSize)); // r_digits
823 __ movl(ESI, ECX);
824 __ sarl(ESI, Immediate(5)); // ESI = n ~/ _DIGIT_BITS.
825 __ leal(EBX, FieldAddress(EBX, ESI, TIMES_4, TypedData::data_offset()));
826 __ movl(ESI, Address(ESP, 3 * kWordSize)); // x_used > 0, Smi.
827 __ SmiUntag(ESI);
828 __ decl(ESI);
829 __ xorl(EAX, EAX); // EAX = 0.
830 __ movl(EDX, FieldAddress(EDI, ESI, TIMES_4, TypedData::data_offset()));
831 __ shldl(EAX, EDX, ECX);
832 __ movl(Address(EBX, ESI, TIMES_4, Bigint::kBytesPerDigit), EAX);
833 Label last;
834 __ cmpl(ESI, Immediate(0));
835 __ j(EQUAL, &last, Assembler::kNearJump);
836 Label loop;
837 __ Bind(&loop);
838 __ movl(EAX, EDX);
839 __ movl(EDX,
840 FieldAddress(EDI, ESI, TIMES_4,
841 TypedData::data_offset() - Bigint::kBytesPerDigit));
842 __ shldl(EAX, EDX, ECX);
843 __ movl(Address(EBX, ESI, TIMES_4, 0), EAX);
844 __ decl(ESI);
845 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
846 __ Bind(&last);
847 __ shldl(EDX, ESI, ECX); // ESI == 0.
848 __ movl(Address(EBX, 0), EDX);
849 // Returning Object::null() is not required, since this method is private.
850 __ ret();
810 } 851 }
811 852
812 853
813 void Intrinsifier::Bigint_rsh(Assembler* assembler) { 854 void Intrinsifier::Bigint_rsh(Assembler* assembler) {
814 // TODO(regis): Implement. 855 // static void _rsh(Uint32List x_digits, int x_used, int n,
856 // Uint32List r_digits)
857
858 __ movl(EDI, Address(ESP, 4 * kWordSize)); // x_digits
859 __ movl(ECX, Address(ESP, 2 * kWordSize)); // n is Smi
860 __ SmiUntag(ECX);
861 __ movl(EBX, Address(ESP, 1 * kWordSize)); // r_digits
862 __ movl(EDX, ECX);
863 __ sarl(EDX, Immediate(5)); // EDX = n ~/ _DIGIT_BITS.
864 __ movl(ESI, Address(ESP, 3 * kWordSize)); // x_used > 0, Smi.
865 __ SmiUntag(ESI);
866 __ decl(ESI);
867 // EDI = &x_digits[x_used - 1].
868 __ leal(EDI, FieldAddress(EDI, ESI, TIMES_4, TypedData::data_offset()));
869 __ subl(ESI, EDX);
870 // EBX = &r_digits[x_used - 1 - (n ~/ 32)].
871 __ leal(EBX, FieldAddress(EBX, ESI, TIMES_4, TypedData::data_offset()));
872 __ negl(ESI);
873 __ movl(EDX, Address(EDI, ESI, TIMES_4, 0));
874 Label last;
875 __ cmpl(ESI, Immediate(0));
876 __ j(EQUAL, &last, Assembler::kNearJump);
877 Label loop;
878 __ Bind(&loop);
879 __ movl(EAX, EDX);
880 __ movl(EDX, Address(EDI, ESI, TIMES_4, Bigint::kBytesPerDigit));
881 __ shrdl(EAX, EDX, ECX);
882 __ movl(Address(EBX, ESI, TIMES_4, 0), EAX);
883 __ incl(ESI);
884 __ j(NOT_ZERO, &loop, Assembler::kNearJump);
885 __ Bind(&last);
886 __ shrdl(EDX, ESI, ECX); // ESI == 0.
887 __ movl(Address(EBX, 0), EDX);
888 // Returning Object::null() is not required, since this method is private.
889 __ ret();
815 } 890 }
816 891
817 892
818 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { 893 void Intrinsifier::Bigint_absAdd(Assembler* assembler) {
819 // static void _absAdd(Uint32List digits, int used, 894 // static void _absAdd(Uint32List digits, int used,
820 // Uint32List a_digits, int a_used, 895 // Uint32List a_digits, int a_used,
821 // Uint32List r_digits) 896 // Uint32List r_digits)
822 897
823 __ movl(EDI, Address(ESP, 5 * kWordSize)); // digits 898 __ movl(EDI, Address(ESP, 5 * kWordSize)); // digits
824 __ movl(EAX, Address(ESP, 4 * kWordSize)); // used is Smi 899 __ movl(EAX, Address(ESP, 4 * kWordSize)); // used is Smi
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 Isolate::current_tag_offset()); 2088 Isolate::current_tag_offset());
2014 // Set return value to Isolate::current_tag_. 2089 // Set return value to Isolate::current_tag_.
2015 __ movl(EAX, current_tag_addr); 2090 __ movl(EAX, current_tag_addr);
2016 __ ret(); 2091 __ ret();
2017 } 2092 }
2018 2093
2019 #undef __ 2094 #undef __
2020 } // namespace dart 2095 } // namespace dart
2021 2096
2022 #endif // defined TARGET_ARCH_IA32 2097 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm64.cc ('k') | runtime/vm/intrinsifier_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698