OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 __ cmpl(EDI, raw_null); | 194 __ cmpl(EDI, raw_null); |
195 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 195 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
196 | 196 |
197 __ movl(EBX, Address(ESP, + 3 * kWordSize)); // Array. | 197 __ movl(EBX, Address(ESP, + 3 * kWordSize)); // Array. |
198 __ movl(EBX, FieldAddress(EBX, type_args_field_offset)); | 198 __ movl(EBX, FieldAddress(EBX, type_args_field_offset)); |
199 // EBX: Type arguments of array. | 199 // EBX: Type arguments of array. |
200 __ cmpl(EBX, raw_null); | 200 __ cmpl(EBX, raw_null); |
201 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 201 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
202 // Check if it's Dynamic. | 202 // Check if it's Dynamic. |
203 // For now handle only TypeArguments and bail out if InstantiatedTypeArgs. | 203 // For now handle only TypeArguments and bail out if InstantiatedTypeArgs. |
204 __ CompareClassId(EBX, kTypeArguments, EAX); | 204 __ CompareClassId(EBX, kTypeArgumentsCid, EAX); |
205 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | 205 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
206 // Get type at index 0. | 206 // Get type at index 0. |
207 __ movl(EAX, FieldAddress(EBX, TypeArguments::type_at_offset(0))); | 207 __ movl(EAX, FieldAddress(EBX, TypeArguments::type_at_offset(0))); |
208 __ CompareObject(EAX, Type::ZoneHandle(Type::DynamicType())); | 208 __ CompareObject(EAX, Type::ZoneHandle(Type::DynamicType())); |
209 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 209 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
210 // Check for int and num. | 210 // Check for int and num. |
211 __ testl(EDI, Immediate(kSmiTagMask)); // Value is Smi? | 211 __ testl(EDI, Immediate(kSmiTagMask)); // Value is Smi? |
212 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi value. | 212 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi value. |
213 __ CompareObject(EAX, Type::ZoneHandle(Type::IntInterface())); | 213 __ CompareObject(EAX, Type::ZoneHandle(Type::IntInterface())); |
214 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 214 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 Label receiver_not_smi; | 832 Label receiver_not_smi; |
833 __ Bind(&check_for_mint); | 833 __ Bind(&check_for_mint); |
834 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Receiver. | 834 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Receiver. |
835 __ testl(EAX, Immediate(kSmiTagMask)); | 835 __ testl(EAX, Immediate(kSmiTagMask)); |
836 __ j(NOT_ZERO, &receiver_not_smi); | 836 __ j(NOT_ZERO, &receiver_not_smi); |
837 | 837 |
838 // Left (receiver) is Smi, return false if right is not Double. | 838 // Left (receiver) is Smi, return false if right is not Double. |
839 // Note that an instance of Mint or Bigint never contains a value that can be | 839 // Note that an instance of Mint or Bigint never contains a value that can be |
840 // represented by Smi. | 840 // represented by Smi. |
841 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. | 841 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. |
842 __ CompareClassId(EAX, kDouble, EDI); | 842 __ CompareClassId(EAX, kDoubleCid, EDI); |
843 __ j(EQUAL, &fall_through); | 843 __ j(EQUAL, &fall_through); |
844 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. | 844 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. |
845 __ ret(); | 845 __ ret(); |
846 | 846 |
847 __ Bind(&receiver_not_smi); | 847 __ Bind(&receiver_not_smi); |
848 // EAX:: receiver. | 848 // EAX:: receiver. |
849 __ CompareClassId(EAX, kMint, EDI); | 849 __ CompareClassId(EAX, kMintCid, EDI); |
850 __ j(NOT_EQUAL, &fall_through); | 850 __ j(NOT_EQUAL, &fall_through); |
851 // Receiver is Mint, return false if right is Smi. | 851 // Receiver is Mint, return false if right is Smi. |
852 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. | 852 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. |
853 __ testl(EAX, Immediate(kSmiTagMask)); | 853 __ testl(EAX, Immediate(kSmiTagMask)); |
854 __ j(NOT_ZERO, &fall_through); | 854 __ j(NOT_ZERO, &fall_through); |
855 __ LoadObject(EAX, bool_false); | 855 __ LoadObject(EAX, bool_false); |
856 __ ret(); | 856 __ ret(); |
857 // TODO(srdjan): Implement Mint == Mint comparison. | 857 // TODO(srdjan): Implement Mint == Mint comparison. |
858 | 858 |
859 __ Bind(&fall_through); | 859 __ Bind(&fall_through); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 905 |
906 // Check if the last argument is a double, jump to label 'is_smi' if smi | 906 // Check if the last argument is a double, jump to label 'is_smi' if smi |
907 // (easy to convert to double), otherwise jump to label 'not_double_smi', | 907 // (easy to convert to double), otherwise jump to label 'not_double_smi', |
908 // Returns the last argument in EAX. | 908 // Returns the last argument in EAX. |
909 static void TestLastArgumentIsDouble(Assembler* assembler, | 909 static void TestLastArgumentIsDouble(Assembler* assembler, |
910 Label* is_smi, | 910 Label* is_smi, |
911 Label* not_double_smi) { | 911 Label* not_double_smi) { |
912 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 912 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
913 __ testl(EAX, Immediate(kSmiTagMask)); | 913 __ testl(EAX, Immediate(kSmiTagMask)); |
914 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. | 914 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. |
915 __ CompareClassId(EAX, kDouble, EBX); | 915 __ CompareClassId(EAX, kDoubleCid, EBX); |
916 __ j(NOT_EQUAL, not_double_smi, Assembler::kNearJump); | 916 __ j(NOT_EQUAL, not_double_smi, Assembler::kNearJump); |
917 // Fall through if double. | 917 // Fall through if double. |
918 } | 918 } |
919 | 919 |
920 | 920 |
921 // Both arguments on stack, arg0 (left) is a double, arg1 (right) is of unknown | 921 // Both arguments on stack, arg0 (left) is a double, arg1 (right) is of unknown |
922 // type. Return true or false object in the register EAX. Any NaN argument | 922 // type. Return true or false object in the register EAX. Any NaN argument |
923 // returns false. Any non-double arg1 causes control flow to fall through to the | 923 // returns false. Any non-double arg1 causes control flow to fall through to the |
924 // slow case (compiled method body). | 924 // slow case (compiled method body). |
925 static bool CompareDoubles(Assembler* assembler, Condition true_condition) { | 925 static bool CompareDoubles(Assembler* assembler, Condition true_condition) { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 bool Intrinsifier::String_charCodeAt(Assembler* assembler) { | 1319 bool Intrinsifier::String_charCodeAt(Assembler* assembler) { |
1320 Label fall_through; | 1320 Label fall_through; |
1321 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. | 1321 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. |
1322 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. | 1322 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. |
1323 __ testl(EBX, Immediate(kSmiTagMask)); | 1323 __ testl(EBX, Immediate(kSmiTagMask)); |
1324 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. | 1324 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
1325 // Range check. | 1325 // Range check. |
1326 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); | 1326 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); |
1327 // Runtime throws exception. | 1327 // Runtime throws exception. |
1328 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 1328 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
1329 __ CompareClassId(EAX, kOneByteString, EDI); | 1329 __ CompareClassId(EAX, kOneByteStringCid, EDI); |
1330 __ j(NOT_EQUAL, &fall_through); | 1330 __ j(NOT_EQUAL, &fall_through); |
1331 __ SmiUntag(EBX); | 1331 __ SmiUntag(EBX); |
1332 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); | 1332 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); |
1333 __ SmiTag(EAX); | 1333 __ SmiTag(EAX); |
1334 __ ret(); | 1334 __ ret(); |
1335 __ Bind(&fall_through); | 1335 __ Bind(&fall_through); |
1336 return false; | 1336 return false; |
1337 } | 1337 } |
1338 | 1338 |
1339 | 1339 |
(...skipping 24 matching lines...) Expand all Loading... |
1364 __ Bind(&is_true); | 1364 __ Bind(&is_true); |
1365 __ LoadObject(EAX, bool_true); | 1365 __ LoadObject(EAX, bool_true); |
1366 __ ret(); | 1366 __ ret(); |
1367 return true; | 1367 return true; |
1368 } | 1368 } |
1369 | 1369 |
1370 #undef __ | 1370 #undef __ |
1371 } // namespace dart | 1371 } // namespace dart |
1372 | 1372 |
1373 #endif // defined TARGET_ARCH_IA32 | 1373 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |