| 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 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 | 1503 |
| 1504 | 1504 |
| 1505 bool Intrinsifier::String_getLength(Assembler* assembler) { | 1505 bool Intrinsifier::String_getLength(Assembler* assembler) { |
| 1506 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. | 1506 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. |
| 1507 __ movl(EAX, FieldAddress(EAX, String::length_offset())); | 1507 __ movl(EAX, FieldAddress(EAX, String::length_offset())); |
| 1508 __ ret(); | 1508 __ ret(); |
| 1509 return true; | 1509 return true; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 | 1512 |
| 1513 // TODO(srdjan): Implement for two and four byte strings as well. | |
| 1514 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { | 1513 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { |
| 1515 Label fall_through; | 1514 Label fall_through, try_two_byte_string; |
| 1516 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. | 1515 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. |
| 1517 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. | 1516 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // String. |
| 1518 __ testl(EBX, Immediate(kSmiTagMask)); | 1517 __ testl(EBX, Immediate(kSmiTagMask)); |
| 1519 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. | 1518 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 1520 // Range check. | 1519 // Range check. |
| 1521 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); | 1520 __ cmpl(EBX, FieldAddress(EAX, String::length_offset())); |
| 1522 // Runtime throws exception. | 1521 // Runtime throws exception. |
| 1523 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 1522 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 1524 __ CompareClassId(EAX, kOneByteStringCid, EDI); | 1523 __ CompareClassId(EAX, kOneByteStringCid, EDI); |
| 1525 __ j(NOT_EQUAL, &fall_through); | 1524 __ j(NOT_EQUAL, &try_two_byte_string, Assembler::kNearJump); |
| 1526 __ SmiUntag(EBX); | 1525 __ SmiUntag(EBX); |
| 1527 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); | 1526 __ movzxb(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); |
| 1528 __ SmiTag(EAX); | 1527 __ SmiTag(EAX); |
| 1529 __ ret(); | 1528 __ ret(); |
| 1529 |
| 1530 __ Bind(&try_two_byte_string); |
| 1531 __ CompareClassId(EAX, kTwoByteStringCid, EDI); |
| 1532 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
| 1533 ASSERT(kSmiTagShift == 1); |
| 1534 __ movzxw(EAX, FieldAddress(EAX, EBX, TIMES_1, OneByteString::data_offset())); |
| 1535 __ SmiTag(EAX); |
| 1536 __ ret(); |
| 1537 |
| 1530 __ Bind(&fall_through); | 1538 __ Bind(&fall_through); |
| 1531 return false; | 1539 return false; |
| 1532 } | 1540 } |
| 1533 | 1541 |
| 1534 | 1542 |
| 1535 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { | 1543 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { |
| 1536 Label is_true; | 1544 Label is_true; |
| 1537 // Get length. | 1545 // Get length. |
| 1538 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. | 1546 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. |
| 1539 __ movl(EAX, FieldAddress(EAX, String::length_offset())); | 1547 __ movl(EAX, FieldAddress(EAX, String::length_offset())); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 __ ret(); | 1769 __ ret(); |
| 1762 | 1770 |
| 1763 __ Bind(&fall_through); | 1771 __ Bind(&fall_through); |
| 1764 return false; | 1772 return false; |
| 1765 } | 1773 } |
| 1766 | 1774 |
| 1767 #undef __ | 1775 #undef __ |
| 1768 } // namespace dart | 1776 } // namespace dart |
| 1769 | 1777 |
| 1770 #endif // defined TARGET_ARCH_IA32 | 1778 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |