| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 return false; | 425 return false; |
| 426 } | 426 } |
| 427 __ movl(EAX, Address(ESP, + 2 * kWordSize)); | 427 __ movl(EAX, Address(ESP, + 2 * kWordSize)); |
| 428 __ movl(EBX, Address(ESP, + 1 * kWordSize)); | 428 __ movl(EBX, Address(ESP, + 1 * kWordSize)); |
| 429 __ movl(FieldAddress(EAX, GrowableObjectArray::data_offset()), EBX); | 429 __ movl(FieldAddress(EAX, GrowableObjectArray::data_offset()), EBX); |
| 430 __ ret(); | 430 __ ret(); |
| 431 return true; | 431 return true; |
| 432 } | 432 } |
| 433 | 433 |
| 434 | 434 |
| 435 // Handles only class InternalByteArray. |
| 436 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) { |
| 437 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 438 Label fall_through; |
| 439 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
| 440 __ movl(EBX, FieldAddress(EAX, Object::class_offset())); |
| 441 __ CompareObject(EBX, |
| 442 Class::ZoneHandle(object_store->internal_byte_array_class())); |
| 443 __ j(NOT_EQUAL, &fall_through); |
| 444 __ movl(EAX, FieldAddress(EAX, InternalByteArray::length_offset())); |
| 445 __ ret(); |
| 446 __ Bind(&fall_through); |
| 447 return false; |
| 448 } |
| 449 |
| 450 |
| 451 // Handles only class InternalByteArray. |
| 452 bool Intrinsifier::ByteArrayBase_getIndexed(Assembler* assembler) { |
| 453 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 454 Label fall_through; |
| 455 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. |
| 456 __ movl(EBX, FieldAddress(EAX, Object::class_offset())); |
| 457 __ CompareObject(EBX, |
| 458 Class::ZoneHandle(object_store->internal_byte_array_class())); |
| 459 __ j(NOT_EQUAL, &fall_through); |
| 460 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. |
| 461 __ testl(EBX, Immediate(kSmiTagMask)); |
| 462 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 463 // Range check. |
| 464 __ cmpl(EBX, FieldAddress(EAX, InternalByteArray::length_offset())); |
| 465 // Runtime throws exception. |
| 466 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 467 __ SmiUntag(EBX); |
| 468 __ movzxb(EAX, |
| 469 FieldAddress(EAX, EBX, TIMES_1, InternalByteArray::data_offset())); |
| 470 // The values stored in the byte array are regular, untagged values, |
| 471 // therefore they need to be tagged. |
| 472 __ SmiTag(EAX); |
| 473 __ ret(); |
| 474 __ Bind(&fall_through); |
| 475 return false; |
| 476 } |
| 477 |
| 478 |
| 435 // Tests if two top most arguments are smis, jumps to label not_smi if not. | 479 // Tests if two top most arguments are smis, jumps to label not_smi if not. |
| 436 // Topmost argument is in EAX. | 480 // Topmost argument is in EAX. |
| 437 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { | 481 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { |
| 438 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 482 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
| 439 __ movl(EBX, Address(ESP, + 2 * kWordSize)); | 483 __ movl(EBX, Address(ESP, + 2 * kWordSize)); |
| 440 __ orl(EBX, EAX); | 484 __ orl(EBX, EAX); |
| 441 __ testl(EBX, Immediate(kSmiTagMask)); | 485 __ testl(EBX, Immediate(kSmiTagMask)); |
| 442 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); | 486 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); |
| 443 } | 487 } |
| 444 | 488 |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 __ Bind(&is_true); | 1337 __ Bind(&is_true); |
| 1294 __ LoadObject(EAX, bool_true); | 1338 __ LoadObject(EAX, bool_true); |
| 1295 __ ret(); | 1339 __ ret(); |
| 1296 return true; | 1340 return true; |
| 1297 } | 1341 } |
| 1298 | 1342 |
| 1299 #undef __ | 1343 #undef __ |
| 1300 } // namespace dart | 1344 } // namespace dart |
| 1301 | 1345 |
| 1302 #endif // defined TARGET_ARCH_IA32 | 1346 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |