OLD | NEW |
---|---|
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. |
srdjan
2015/04/15 05:05:37
Please also add comment that EBP may not be touche
Cutch
2015/04/15 17:56:36
Also on intrinsifer_x64 RBP may not be touched.
regis
2015/04/15 20:46:00
Done.
regis
2015/04/15 20:46:00
Done.
| |
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" |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 | 565 |
566 __ Bind(&overflow); | 566 __ Bind(&overflow); |
567 // Arguments are Smi but the shift produced an overflow to Mint. | 567 // Arguments are Smi but the shift produced an overflow to Mint. |
568 __ cmpl(EBX, Immediate(0)); | 568 __ cmpl(EBX, Immediate(0)); |
569 // TODO(srdjan): Implement negative values, for now fall through. | 569 // TODO(srdjan): Implement negative values, for now fall through. |
570 __ j(LESS, &fall_through, Assembler::kNearJump); | 570 __ j(LESS, &fall_through, Assembler::kNearJump); |
571 __ SmiUntag(EBX); | 571 __ SmiUntag(EBX); |
572 __ movl(EAX, EBX); | 572 __ movl(EAX, EBX); |
573 __ shll(EBX, ECX); | 573 __ shll(EBX, ECX); |
574 __ xorl(EDI, EDI); | 574 __ xorl(EDI, EDI); |
575 __ shldl(EDI, EAX); | 575 __ shldl(EDI, EAX, ECX); |
576 // Result in EDI (high) and EBX (low). | 576 // Result in EDI (high) and EBX (low). |
577 const Class& mint_class = Class::Handle( | 577 const Class& mint_class = Class::Handle( |
578 Isolate::Current()->object_store()->mint_class()); | 578 Isolate::Current()->object_store()->mint_class()); |
579 __ TryAllocate(mint_class, | 579 __ TryAllocate(mint_class, |
580 &fall_through, | 580 &fall_through, |
581 Assembler::kNearJump, | 581 Assembler::kNearJump, |
582 EAX, // Result register. | 582 EAX, // Result register. |
583 kNoRegister); | 583 kNoRegister); |
584 // EBX and EDI are not objects but integer values. | 584 // EBX and EDI are not objects but integer values. |
585 __ movl(FieldAddress(EAX, Mint::value_offset()), EBX); | 585 __ movl(FieldAddress(EAX, Mint::value_offset()), EBX); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 // BSR does not write the destination register if source is zero. Put a 1 in | 799 // 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. | 800 // the Smi tag bit to ensure BSR writes to destination register. |
801 __ orl(EAX, Immediate(kSmiTagMask)); | 801 __ orl(EAX, Immediate(kSmiTagMask)); |
802 __ bsrl(EAX, EAX); | 802 __ bsrl(EAX, EAX); |
803 __ SmiTag(EAX); | 803 __ SmiTag(EAX); |
804 __ ret(); | 804 __ ret(); |
805 } | 805 } |
806 | 806 |
807 | 807 |
808 void Intrinsifier::Bigint_lsh(Assembler* assembler) { | 808 void Intrinsifier::Bigint_lsh(Assembler* assembler) { |
809 // TODO(regis): Implement. | 809 // static void _lsh(Uint32List x_digits, int x_used, int n, |
810 // Uint32List r_digits) | |
811 | |
812 __ movl(EDI, Address(ESP, 4 * kWordSize)); // x_digits | |
813 __ movl(ECX, Address(ESP, 2 * kWordSize)); // n is Smi | |
814 __ SmiUntag(ECX); | |
815 __ movl(EBX, Address(ESP, 1 * kWordSize)); // r_digits | |
816 __ movl(ESI, ECX); | |
817 __ sarl(ESI, Immediate(5)); // ESI = n ~/ _DIGIT_BITS. | |
818 __ leal(EBX, FieldAddress(EBX, ESI, TIMES_4, TypedData::data_offset())); | |
819 __ movl(ESI, Address(ESP, 3 * kWordSize)); // x_used > 0, Smi. | |
820 __ SmiUntag(ESI); | |
821 __ decl(ESI); | |
822 __ xorl(EAX, EAX); // EAX = 0. | |
823 __ movl(EDX, FieldAddress(EDI, ESI, TIMES_4, TypedData::data_offset())); | |
824 __ shldl(EAX, EDX, ECX); | |
825 __ movl(Address(EBX, ESI, TIMES_4, Bigint::kBytesPerDigit), EAX); | |
826 Label last; | |
827 __ cmpl(ESI, Immediate(0)); | |
828 __ j(EQUAL, &last, Assembler::kNearJump); | |
829 Label loop; | |
830 __ Bind(&loop); | |
831 __ movl(EAX, EDX); | |
832 __ movl(EDX, | |
833 FieldAddress(EDI, ESI, TIMES_4, | |
834 TypedData::data_offset() - Bigint::kBytesPerDigit)); | |
835 __ shldl(EAX, EDX, ECX); | |
836 __ movl(Address(EBX, ESI, TIMES_4, 0), EAX); | |
837 __ decl(ESI); | |
838 __ j(NOT_ZERO, &loop, Assembler::kNearJump); | |
839 __ Bind(&last); | |
840 __ shldl(EDX, ESI, ECX); // ESI == 0. | |
841 __ movl(Address(EBX, 0), EDX); | |
842 // Returning Object::null() is not required, since this method is private. | |
843 __ ret(); | |
810 } | 844 } |
811 | 845 |
812 | 846 |
813 void Intrinsifier::Bigint_rsh(Assembler* assembler) { | 847 void Intrinsifier::Bigint_rsh(Assembler* assembler) { |
814 // TODO(regis): Implement. | 848 // static void _rsh(Uint32List x_digits, int x_used, int n, |
849 // Uint32List r_digits) | |
850 | |
851 __ movl(EDI, Address(ESP, 4 * kWordSize)); // x_digits | |
852 __ movl(ECX, Address(ESP, 2 * kWordSize)); // n is Smi | |
853 __ SmiUntag(ECX); | |
854 __ movl(EBX, Address(ESP, 1 * kWordSize)); // r_digits | |
855 __ movl(EDX, ECX); | |
856 __ sarl(EDX, Immediate(5)); // EDX = n ~/ _DIGIT_BITS. | |
857 __ movl(ESI, Address(ESP, 3 * kWordSize)); // x_used > 0, Smi. | |
858 __ SmiUntag(ESI); | |
859 __ decl(ESI); | |
860 // EDI = &x_digits[x_used - 1]. | |
861 __ leal(EDI, FieldAddress(EDI, ESI, TIMES_4, TypedData::data_offset())); | |
862 __ subl(ESI, EDX); | |
863 // EBX = &r_digits[x_used - 1 - (n ~/ 32)]. | |
864 __ leal(EBX, FieldAddress(EBX, ESI, TIMES_4, TypedData::data_offset())); | |
865 __ negl(ESI); | |
866 __ movl(EDX, Address(EDI, ESI, TIMES_4, 0)); | |
867 Label last; | |
868 __ cmpl(ESI, Immediate(0)); | |
869 __ j(EQUAL, &last, Assembler::kNearJump); | |
870 Label loop; | |
871 __ Bind(&loop); | |
872 __ movl(EAX, EDX); | |
873 __ movl(EDX, Address(EDI, ESI, TIMES_4, Bigint::kBytesPerDigit)); | |
874 __ shrdl(EAX, EDX, ECX); | |
875 __ movl(Address(EBX, ESI, TIMES_4, 0), EAX); | |
876 __ incl(ESI); | |
877 __ j(NOT_ZERO, &loop, Assembler::kNearJump); | |
878 __ Bind(&last); | |
879 __ shrdl(EDX, ESI, ECX); // ESI == 0. | |
880 __ movl(Address(EBX, 0), EDX); | |
881 // Returning Object::null() is not required, since this method is private. | |
882 __ ret(); | |
815 } | 883 } |
816 | 884 |
817 | 885 |
818 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { | 886 void Intrinsifier::Bigint_absAdd(Assembler* assembler) { |
819 // static void _absAdd(Uint32List digits, int used, | 887 // static void _absAdd(Uint32List digits, int used, |
820 // Uint32List a_digits, int a_used, | 888 // Uint32List a_digits, int a_used, |
821 // Uint32List r_digits) | 889 // Uint32List r_digits) |
822 | 890 |
823 __ movl(EDI, Address(ESP, 5 * kWordSize)); // digits | 891 __ movl(EDI, Address(ESP, 5 * kWordSize)); // digits |
824 __ movl(EAX, Address(ESP, 4 * kWordSize)); // used is Smi | 892 __ movl(EAX, Address(ESP, 4 * kWordSize)); // used is Smi |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 Isolate::current_tag_offset()); | 2081 Isolate::current_tag_offset()); |
2014 // Set return value to Isolate::current_tag_. | 2082 // Set return value to Isolate::current_tag_. |
2015 __ movl(EAX, current_tag_addr); | 2083 __ movl(EAX, current_tag_addr); |
2016 __ ret(); | 2084 __ ret(); |
2017 } | 2085 } |
2018 | 2086 |
2019 #undef __ | 2087 #undef __ |
2020 } // namespace dart | 2088 } // namespace dart |
2021 | 2089 |
2022 #endif // defined TARGET_ARCH_IA32 | 2090 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |