| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 __ Bind(&size_tag_overflow); | 82 __ Bind(&size_tag_overflow); |
| 83 __ movl(EDI, Immediate(0)); | 83 __ movl(EDI, Immediate(0)); |
| 84 __ Bind(&done); | 84 __ Bind(&done); |
| 85 | 85 |
| 86 // Get the class index and insert it into the tags. | 86 // Get the class index and insert it into the tags. |
| 87 const Class& cls = Class::Handle(isolate->object_store()->array_class()); | 87 const Class& cls = Class::Handle(isolate->object_store()->array_class()); |
| 88 __ orl(EDI, Immediate(RawObject::ClassTag::encode(cls.index()))); | 88 __ orl(EDI, Immediate(RawObject::ClassTag::encode(cls.index()))); |
| 89 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags. | 89 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags. |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Store class value for array. | |
| 93 // EAX: new object start as a tagged pointer. | 92 // EAX: new object start as a tagged pointer. |
| 94 // EBX: new object end address. | 93 // EBX: new object end address. |
| 95 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); | |
| 96 __ movl(EDI, Address(EDI, Isolate::object_store_offset())); | |
| 97 __ movl(EDI, Address(EDI, ObjectStore::array_class_offset())); | |
| 98 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::class_offset()), EDI); | |
| 99 | |
| 100 // Store the type argument field. | 94 // Store the type argument field. |
| 101 __ movl(EDI, Address(ESP, kTypeArgumentsOffset)); // type argument. | 95 __ movl(EDI, Address(ESP, kTypeArgumentsOffset)); // type argument. |
| 102 __ StoreIntoObject(EAX, | 96 __ StoreIntoObject(EAX, |
| 103 FieldAddress(EAX, Array::type_arguments_offset()), | 97 FieldAddress(EAX, Array::type_arguments_offset()), |
| 104 EDI); | 98 EDI); |
| 105 | 99 |
| 106 // Set the length field. | 100 // Set the length field. |
| 107 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length. | 101 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length. |
| 108 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::length_offset()), EDI); | 102 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::length_offset()), EDI); |
| 109 | 103 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 __ cmpl(EDI, raw_null); | 191 __ cmpl(EDI, raw_null); |
| 198 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 192 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
| 199 | 193 |
| 200 __ movl(EBX, Address(ESP, + 3 * kWordSize)); // Array. | 194 __ movl(EBX, Address(ESP, + 3 * kWordSize)); // Array. |
| 201 __ movl(EBX, FieldAddress(EBX, type_args_field_offset)); | 195 __ movl(EBX, FieldAddress(EBX, type_args_field_offset)); |
| 202 // EBX: Type arguments of array. | 196 // EBX: Type arguments of array. |
| 203 __ cmpl(EBX, raw_null); | 197 __ cmpl(EBX, raw_null); |
| 204 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 198 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
| 205 // Check if it's Dynamic. | 199 // Check if it's Dynamic. |
| 206 // For now handle only TypeArguments and bail out if InstantiatedTypeArgs. | 200 // For now handle only TypeArguments and bail out if InstantiatedTypeArgs. |
| 207 __ movl(EAX, FieldAddress(EBX, Object::class_offset())); | 201 __ CompareClassOf(EBX, Class::Handle(Object::type_arguments_class()), EAX); |
| 208 __ CompareObject(EAX, Object::ZoneHandle(Object::type_arguments_class())); | |
| 209 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | 202 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
| 210 // Get type at index 0. | 203 // Get type at index 0. |
| 211 __ movl(EAX, FieldAddress(EBX, TypeArguments::type_at_offset(0))); | 204 __ movl(EAX, FieldAddress(EBX, TypeArguments::type_at_offset(0))); |
| 212 __ CompareObject(EAX, Type::ZoneHandle(Type::DynamicType())); | 205 __ CompareObject(EAX, Type::ZoneHandle(Type::DynamicType())); |
| 213 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 206 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
| 214 // Check for int and num. | 207 // Check for int and num. |
| 215 __ testl(EDI, Immediate(kSmiTagMask)); // Value is Smi? | 208 __ testl(EDI, Immediate(kSmiTagMask)); // Value is Smi? |
| 216 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi value. | 209 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi value. |
| 217 __ CompareObject(EAX, Type::ZoneHandle(Type::IntInterface())); | 210 __ CompareObject(EAX, Type::ZoneHandle(Type::IntInterface())); |
| 218 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 211 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 tags = RawObject::ClassTag::update(cls.index(), tags); | 290 tags = RawObject::ClassTag::update(cls.index(), tags); |
| 298 __ movl(FieldAddress(EAX, GrowableObjectArray::tags_offset()), | 291 __ movl(FieldAddress(EAX, GrowableObjectArray::tags_offset()), |
| 299 Immediate(tags)); | 292 Immediate(tags)); |
| 300 | 293 |
| 301 // Store backing array object in growable array object. | 294 // Store backing array object in growable array object. |
| 302 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument. | 295 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument. |
| 303 __ StoreIntoObject(EAX, | 296 __ StoreIntoObject(EAX, |
| 304 FieldAddress(EAX, GrowableObjectArray::data_offset()), | 297 FieldAddress(EAX, GrowableObjectArray::data_offset()), |
| 305 EBX); | 298 EBX); |
| 306 | 299 |
| 307 // Store class value for the growable array object. | |
| 308 // EAX: new growable array object start as a tagged pointer. | 300 // EAX: new growable array object start as a tagged pointer. |
| 309 __ movl(EBX, FieldAddress(CTX, Context::isolate_offset())); | |
| 310 __ movl(EBX, Address(EBX, Isolate::object_store_offset())); | |
| 311 __ movl(EBX, Address(EBX, ObjectStore::growable_object_array_class_offset())); | |
| 312 __ StoreIntoObject(EAX, | |
| 313 FieldAddress(EAX, GrowableObjectArray::class_offset()), | |
| 314 EBX); | |
| 315 | |
| 316 // Store the type argument field in the growable array object. | 301 // Store the type argument field in the growable array object. |
| 317 __ movl(EBX, Address(ESP, kTypeArgumentsOffset)); // type argument. | 302 __ movl(EBX, Address(ESP, kTypeArgumentsOffset)); // type argument. |
| 318 __ StoreIntoObject(EAX, | 303 __ StoreIntoObject(EAX, |
| 319 FieldAddress(EAX, | 304 FieldAddress(EAX, |
| 320 GrowableObjectArray::type_arguments_offset()), | 305 GrowableObjectArray::type_arguments_offset()), |
| 321 EBX); | 306 EBX); |
| 322 | 307 |
| 323 // Set the length field in the growable array object to 0. | 308 // Set the length field in the growable array object to 0. |
| 324 __ movl(FieldAddress(EAX, GrowableObjectArray::length_offset()), | 309 __ movl(FieldAddress(EAX, GrowableObjectArray::length_offset()), |
| 325 Immediate(0)); | 310 Immediate(0)); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 Label receiver_not_smi; | 728 Label receiver_not_smi; |
| 744 __ Bind(&check_for_mint); | 729 __ Bind(&check_for_mint); |
| 745 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Receiver. | 730 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Receiver. |
| 746 __ testl(EAX, Immediate(kSmiTagMask)); | 731 __ testl(EAX, Immediate(kSmiTagMask)); |
| 747 __ j(NOT_ZERO, &receiver_not_smi); | 732 __ j(NOT_ZERO, &receiver_not_smi); |
| 748 | 733 |
| 749 // Note that an instance of Mint never contains a value that can be | 734 // Note that an instance of Mint never contains a value that can be |
| 750 // represented by Smi. | 735 // represented by Smi. |
| 751 // Left is Smi, return false if right is Mint, otherwise fall through. | 736 // Left is Smi, return false if right is Mint, otherwise fall through. |
| 752 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. | 737 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. |
| 753 __ movl(EAX, FieldAddress(EAX, Object::class_offset())); | 738 __ CompareClassOf(EAX, Class::Handle(object_store->mint_class()), EAX); |
| 754 __ CompareObject(EAX, Class::ZoneHandle(object_store->mint_class())); | |
| 755 __ j(NOT_EQUAL, &fall_through); | 739 __ j(NOT_EQUAL, &fall_through); |
| 756 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. | 740 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. |
| 757 __ ret(); | 741 __ ret(); |
| 758 | 742 |
| 759 __ Bind(&receiver_not_smi); | 743 __ Bind(&receiver_not_smi); |
| 760 // EAX:: receiver. | 744 // EAX:: receiver. |
| 761 __ movl(EAX, FieldAddress(EAX, Object::class_offset())); | 745 __ CompareClassOf(EAX, Class::Handle(object_store->mint_class()), EAX); |
| 762 __ CompareObject(EAX, Class::ZoneHandle(object_store->mint_class())); | |
| 763 __ j(NOT_EQUAL, &fall_through); | 746 __ j(NOT_EQUAL, &fall_through); |
| 764 // Receiver is Mint, return false if right is Smi. | 747 // Receiver is Mint, return false if right is Smi. |
| 765 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. | 748 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Right argument. |
| 766 __ testl(EAX, Immediate(kSmiTagMask)); | 749 __ testl(EAX, Immediate(kSmiTagMask)); |
| 767 __ j(NOT_ZERO, &fall_through); | 750 __ j(NOT_ZERO, &fall_through); |
| 768 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. | 751 __ LoadObject(EAX, bool_false); // Smi == Mint -> false. |
| 769 __ ret(); | 752 __ ret(); |
| 770 // TODO(srdjan): Implement Mint == Mint comparison. | 753 // TODO(srdjan): Implement Mint == Mint comparison. |
| 771 | 754 |
| 772 __ Bind(&fall_through); | 755 __ Bind(&fall_through); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 804 |
| 822 // Check if the last argument is a double, jump to label 'is_smi' if smi | 805 // Check if the last argument is a double, jump to label 'is_smi' if smi |
| 823 // (easy to convert to double), otherwise jump to label 'not_double_smi', | 806 // (easy to convert to double), otherwise jump to label 'not_double_smi', |
| 824 // Returns the last argument in EAX. | 807 // Returns the last argument in EAX. |
| 825 static void TestLastArgumentIsDouble(Assembler* assembler, | 808 static void TestLastArgumentIsDouble(Assembler* assembler, |
| 826 Label* is_smi, | 809 Label* is_smi, |
| 827 Label* not_double_smi) { | 810 Label* not_double_smi) { |
| 828 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 811 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
| 829 __ testl(EAX, Immediate(kSmiTagMask)); | 812 __ testl(EAX, Immediate(kSmiTagMask)); |
| 830 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. | 813 __ j(ZERO, is_smi, Assembler::kNearJump); // Jump if Smi. |
| 831 __ LoadObject(EBX, Class::ZoneHandle( | 814 __ CompareClassOf(EAX, Class::Handle( |
| 832 Isolate::Current()->object_store()->double_class())); | 815 Isolate::Current()->object_store()->double_class()), EBX); |
| 833 __ cmpl(EBX, FieldAddress(EAX, Object::class_offset())); | |
| 834 __ j(NOT_EQUAL, not_double_smi, Assembler::kNearJump); | 816 __ j(NOT_EQUAL, not_double_smi, Assembler::kNearJump); |
| 835 // Fall through if double. | 817 // Fall through if double. |
| 836 } | 818 } |
| 837 | 819 |
| 838 | 820 |
| 839 // Both arguments on stack, arg0 (left) is a double, arg1 (right) is of unknown | 821 // Both arguments on stack, arg0 (left) is a double, arg1 (right) is of unknown |
| 840 // type. Return true or false object in the register EAX. Any NaN argument | 822 // type. Return true or false object in the register EAX. Any NaN argument |
| 841 // returns false. Any non-double arg1 causes control flow to fall through to the | 823 // returns false. Any non-double arg1 causes control flow to fall through to the |
| 842 // slow case (compiled method body). | 824 // slow case (compiled method body). |
| 843 static bool CompareDoubles(Assembler* assembler, Condition true_condition) { | 825 static bool CompareDoubles(Assembler* assembler, Condition true_condition) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 ObjectStore* object_store = Isolate::Current()->object_store(); | 1228 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1247 Label fall_through; | 1229 Label fall_through; |
| 1248 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. | 1230 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. |
| 1249 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. | 1231 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. |
| 1250 __ testl(EBX, Immediate(kSmiTagMask)); | 1232 __ testl(EBX, Immediate(kSmiTagMask)); |
| 1251 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. | 1233 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 1252 // Range check. | 1234 // Range check. |
| 1253 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); | 1235 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); |
| 1254 // Runtime throws exception. | 1236 // Runtime throws exception. |
| 1255 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 1237 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 1256 __ movl(EDI, FieldAddress(EAX, Instance::class_offset())); | 1238 __ CompareClassOf(EAX, |
| 1257 __ CompareObject(EDI, | 1239 Class::Handle(object_store->one_byte_string_class()), |
| 1258 Class::ZoneHandle(object_store->one_byte_string_class())); | 1240 EDI); |
| 1259 __ j(NOT_EQUAL, &fall_through); | 1241 __ j(NOT_EQUAL, &fall_through); |
| 1260 __ SmiUntag(EBX); | 1242 __ SmiUntag(EBX); |
| 1261 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); | 1243 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); |
| 1262 __ SmiTag(EAX); | 1244 __ SmiTag(EAX); |
| 1263 __ ret(); | 1245 __ ret(); |
| 1264 __ Bind(&fall_through); | 1246 __ Bind(&fall_through); |
| 1265 return false; | 1247 return false; |
| 1266 } | 1248 } |
| 1267 | 1249 |
| 1268 | 1250 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1293 __ Bind(&is_true); | 1275 __ Bind(&is_true); |
| 1294 __ LoadObject(EAX, bool_true); | 1276 __ LoadObject(EAX, bool_true); |
| 1295 __ ret(); | 1277 __ ret(); |
| 1296 return true; | 1278 return true; |
| 1297 } | 1279 } |
| 1298 | 1280 |
| 1299 #undef __ | 1281 #undef __ |
| 1300 } // namespace dart | 1282 } // namespace dart |
| 1301 | 1283 |
| 1302 #endif // defined TARGET_ARCH_IA32 | 1284 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |