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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 TIMES_1, | 557 TIMES_1, |
558 Uint16Array::data_offset())); | 558 Uint16Array::data_offset())); |
559 __ SmiTag(EAX); | 559 __ SmiTag(EAX); |
560 __ ret(); | 560 __ ret(); |
561 __ Bind(&fall_through); | 561 __ Bind(&fall_through); |
562 return false; | 562 return false; |
563 } | 563 } |
564 | 564 |
565 | 565 |
566 bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) { | 566 bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) { |
| 567 Label fall_through; |
| 568 TestByteArrayIndex(assembler, &fall_through); |
| 569 // After TestByteArrayIndex: |
| 570 // * EAX has the base address of the byte array. |
| 571 // * EBX has the index into the array. |
| 572 // EBX contains the SMI index which is shifted left by 1. |
| 573 // This shift means we only multiply the index by 2 not 4 (sizeof Int32). |
| 574 __ movl(EAX, FieldAddress(EAX, |
| 575 EBX, |
| 576 TIMES_2, |
| 577 Int32Array::data_offset())); |
| 578 // Verify that the signed value in EAX can fit inside a Smi. |
| 579 __ cmpl(EAX, Immediate(0xC0000000)); |
| 580 __ j(NEGATIVE, &fall_through, Assembler::kNearJump); // Won't fit Smi. |
| 581 __ SmiTag(EAX); |
| 582 __ ret(); |
| 583 __ Bind(&fall_through); |
567 return false; | 584 return false; |
568 } | 585 } |
569 | 586 |
570 | 587 |
571 bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) { | 588 bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) { |
| 589 Label fall_through; |
| 590 TestByteArrayIndex(assembler, &fall_through); |
| 591 // After TestByteArrayIndex: |
| 592 // * EAX has the base address of the byte array. |
| 593 // * EBX has the index into the array. |
| 594 // EBX contains the SMI index which is shifted left by 1. |
| 595 // This shift means we only multiply the index by 2 not 4 (sizeof Uint32). |
| 596 __ movl(EAX, FieldAddress(EAX, |
| 597 EBX, |
| 598 TIMES_2, |
| 599 Uint32Array::data_offset())); |
| 600 // Verify that the unsigned value in EAX can be stored in a Smi. |
| 601 __ testl(EAX, Immediate(0xC0000000)); |
| 602 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Won't fit Smi. |
| 603 __ SmiTag(EAX); |
| 604 __ ret(); |
| 605 __ Bind(&fall_through); |
572 return false; | 606 return false; |
573 } | 607 } |
574 | 608 |
| 609 |
| 610 bool Intrinsifier::Int64Array_getIndexed(Assembler* assembler) { |
| 611 return false; |
| 612 } |
| 613 |
| 614 |
| 615 bool Intrinsifier::Uint64Array_getIndexed(Assembler* assembler) { |
| 616 return false; |
| 617 } |
| 618 |
575 | 619 |
576 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) { | 620 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) { |
577 Label fall_through; | 621 Label fall_through; |
578 TestByteArrayIndex(assembler, &fall_through); | 622 TestByteArrayIndex(assembler, &fall_through); |
579 // After TestByteArrayIndex: | 623 // After TestByteArrayIndex: |
580 // * EAX has the base address of the byte array. | 624 // * EAX has the base address of the byte array. |
581 // * EBX has the index into the array. | 625 // * EBX has the index into the array. |
582 // EBX contains the SMI index which is shifted left by 1. | 626 // EBX contains the SMI index which is shifted left by 1. |
583 // This shift means we only multiply the index by 2 not 4 (sizeof float). | 627 // This shift means we only multiply the index by 2 not 4 (sizeof float). |
584 // Load single precision float into XMM7. | 628 // Load single precision float into XMM7. |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 __ Bind(&is_true); | 1590 __ Bind(&is_true); |
1547 __ LoadObject(EAX, bool_true); | 1591 __ LoadObject(EAX, bool_true); |
1548 __ ret(); | 1592 __ ret(); |
1549 return true; | 1593 return true; |
1550 } | 1594 } |
1551 | 1595 |
1552 #undef __ | 1596 #undef __ |
1553 } // namespace dart | 1597 } // namespace dart |
1554 | 1598 |
1555 #endif // defined TARGET_ARCH_IA32 | 1599 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |