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. |
10 | 10 |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 | 1080 |
1081 // Argument is Smi (receiver). | 1081 // Argument is Smi (receiver). |
1082 void Intrinsifier::Smi_bitNegate(Assembler* assembler) { | 1082 void Intrinsifier::Smi_bitNegate(Assembler* assembler) { |
1083 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Index. | 1083 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Index. |
1084 __ notl(EAX); | 1084 __ notl(EAX); |
1085 __ andl(EAX, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. | 1085 __ andl(EAX, Immediate(~kSmiTagMask)); // Remove inverted smi-tag. |
1086 __ ret(); | 1086 __ ret(); |
1087 } | 1087 } |
1088 | 1088 |
1089 | 1089 |
1090 void Intrinsifier::Smi_bitLength(Assembler* assembler) { | |
srdjan
2013/09/06 15:35:34
How does optimized code compare, is intrinsified m
sra1
2013/09/06 22:11:57
It appears to be worthwhile.
The release build is
| |
1091 ASSERT(kSmiTagShift == 1); | |
1092 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Index. | |
1093 // XOR with sign bit to complement bits if value is negative. | |
1094 __ movl(ECX, EAX); | |
1095 __ sarl(ECX, Immediate(31)); // All 0 or all 1. | |
1096 __ xorl(EAX, ECX); | |
1097 // BSR does not write the destination register if source is zero. Put a 1 in | |
1098 // the Smi tag bit to ensure BSR writes to destination register. | |
1099 __ orl(EAX, Immediate(kSmiTagMask)); | |
1100 __ bsrl(EAX, EAX); | |
1101 __ SmiTag(EAX); | |
1102 __ ret(); | |
1103 } | |
1104 | |
1105 | |
1090 // Check if the last argument is a double, jump to label 'is_smi' if smi | 1106 // Check if the last argument is a double, jump to label 'is_smi' if smi |
1091 // (easy to convert to double), otherwise jump to label 'not_double_smi', | 1107 // (easy to convert to double), otherwise jump to label 'not_double_smi', |
1092 // Returns the last argument in EAX. | 1108 // Returns the last argument in EAX. |
1093 static void TestLastArgumentIsDouble(Assembler* assembler, | 1109 static void TestLastArgumentIsDouble(Assembler* assembler, |
1094 Label* is_smi, | 1110 Label* is_smi, |
1095 Label* not_double_smi) { | 1111 Label* not_double_smi) { |
1096 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 1112 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
1097 __ testl(EAX, Immediate(kSmiTagMask)); | 1113 __ testl(EAX, Immediate(kSmiTagMask)); |
1098 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. | 1114 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. |
1099 __ CompareClassId(EAX, kDoubleCid, EBX); | 1115 __ CompareClassId(EAX, kDoubleCid, EBX); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 __ Bind(&ok); | 1733 __ Bind(&ok); |
1718 __ ret(); | 1734 __ ret(); |
1719 | 1735 |
1720 __ Bind(&fall_through); | 1736 __ Bind(&fall_through); |
1721 } | 1737 } |
1722 | 1738 |
1723 #undef __ | 1739 #undef __ |
1724 } // namespace dart | 1740 } // namespace dart |
1725 | 1741 |
1726 #endif // defined TARGET_ARCH_IA32 | 1742 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |