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 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 void Intrinsifier::OneByteString_equality(Assembler* assembler) { | 1592 void Intrinsifier::OneByteString_equality(Assembler* assembler) { |
1593 StringEquality(assembler, kOneByteStringCid); | 1593 StringEquality(assembler, kOneByteStringCid); |
1594 } | 1594 } |
1595 | 1595 |
1596 | 1596 |
1597 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { | 1597 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
1598 StringEquality(assembler, kTwoByteStringCid); | 1598 StringEquality(assembler, kTwoByteStringCid); |
1599 } | 1599 } |
1600 | 1600 |
1601 | 1601 |
| 1602 static void GenerateRegexpSpecializationFor( |
| 1603 Assembler* assembler, |
| 1604 intptr_t cid, |
| 1605 Label* entry, |
| 1606 Label* exit) { |
| 1607 ASSERT(cid == kOneByteStringCid || cid == kTwoByteStringCid || |
| 1608 cid == kExternalOneByteStringCid || cid == kExternalTwoByteStringCid); |
| 1609 |
| 1610 __ Bind(entry); |
| 1611 |
| 1612 // The passed string is of class cid. |
| 1613 |
| 1614 __ ldr(R0, FieldAddress(R2, JSRegExp::function_offset(cid))); |
| 1615 |
| 1616 // Set the subject if it is currently unset. |
| 1617 |
| 1618 __ LoadObject(R4, Object::null_object()); |
| 1619 __ ldr(R5, FieldAddress(R2, JSRegExp::subject_offset(cid))); |
| 1620 __ cmp(R4, Operand(R5)); |
| 1621 __ b(exit, NE); |
| 1622 |
| 1623 __ StoreIntoObject(R2, |
| 1624 FieldAddress(R2, JSRegExp::subject_offset(cid)), |
| 1625 R1, |
| 1626 false); |
| 1627 |
| 1628 __ b(exit); |
| 1629 } |
| 1630 |
| 1631 |
| 1632 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) { |
| 1633 Label is_one_byte_string; |
| 1634 Label is_two_byte_string; |
| 1635 Label is_external_one_byte_string; |
| 1636 Label is_external_two_byte_string; |
| 1637 Label fallthrough; |
| 1638 |
| 1639 static const intptr_t kRegExpParamOffset = + 2 * kWordSize; |
| 1640 static const intptr_t kStringParamOffset = + 1 * kWordSize; |
| 1641 // const Smi& start_index is located at (+ 0 * kWordSize). |
| 1642 |
| 1643 // Register assignments are as follows: |
| 1644 // R0: The appropriate (one- or two-byte specialized) matcher function. |
| 1645 // R2: The regexp object. |
| 1646 // R4: Temp. |
| 1647 // R5: Temp. |
| 1648 // R1: Temp, Pointer to the function's code which we then tail-call. |
| 1649 |
| 1650 __ ldr(R2, Address(SP, kRegExpParamOffset)); |
| 1651 __ ldr(R1, Address(SP, kStringParamOffset)); |
| 1652 |
| 1653 // Check if the string is a one byte string. |
| 1654 |
| 1655 __ CompareClassId(R1, kOneByteStringCid, R4); |
| 1656 __ b(&is_one_byte_string, EQ); |
| 1657 |
| 1658 __ CompareClassId(R1, kTwoByteStringCid, R4); |
| 1659 __ b(&is_two_byte_string, EQ); |
| 1660 |
| 1661 __ CompareClassId(R1, kExternalOneByteStringCid, R4); |
| 1662 __ b(&is_external_one_byte_string, EQ); |
| 1663 |
| 1664 __ CompareClassId(R1, kExternalTwoByteStringCid, R4); |
| 1665 __ b(&is_external_two_byte_string, EQ); |
| 1666 |
| 1667 GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid, |
| 1668 &is_external_two_byte_string, &fallthrough); |
| 1669 GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid, |
| 1670 &is_external_one_byte_string, &fallthrough); |
| 1671 GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid, |
| 1672 &is_two_byte_string, &fallthrough); |
| 1673 GenerateRegexpSpecializationFor(assembler, kOneByteStringCid, |
| 1674 &is_one_byte_string, &fallthrough); |
| 1675 |
| 1676 // R0 contains the appropriate (one- or two-byte string) function. |
| 1677 |
| 1678 __ Bind(&fallthrough); |
| 1679 |
| 1680 // Registers have been set up for the lazy compile stub at this point. |
| 1681 // It expects the function in R0 while; R5 and R4 are unused. |
| 1682 |
| 1683 // Tail-call the function. |
| 1684 __ ldr(R1, FieldAddress(R0, Function::instructions_offset())); |
| 1685 __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag); |
| 1686 __ bx(R1); |
| 1687 } |
| 1688 |
| 1689 |
1602 // On stack: user tag (+0). | 1690 // On stack: user tag (+0). |
1603 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { | 1691 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
1604 // R1: Isolate. | 1692 // R1: Isolate. |
1605 Isolate* isolate = Isolate::Current(); | 1693 Isolate* isolate = Isolate::Current(); |
1606 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); | 1694 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); |
1607 // R0: Current user tag. | 1695 // R0: Current user tag. |
1608 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); | 1696 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); |
1609 // R2: UserTag. | 1697 // R2: UserTag. |
1610 __ ldr(R2, Address(SP, + 0 * kWordSize)); | 1698 __ ldr(R2, Address(SP, + 0 * kWordSize)); |
1611 // Set Isolate::current_tag_. | 1699 // Set Isolate::current_tag_. |
(...skipping 21 matching lines...) Expand all Loading... |
1633 Isolate* isolate = Isolate::Current(); | 1721 Isolate* isolate = Isolate::Current(); |
1634 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); | 1722 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); |
1635 // Set return value to Isolate::current_tag_. | 1723 // Set return value to Isolate::current_tag_. |
1636 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); | 1724 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); |
1637 __ Ret(); | 1725 __ Ret(); |
1638 } | 1726 } |
1639 | 1727 |
1640 } // namespace dart | 1728 } // namespace dart |
1641 | 1729 |
1642 #endif // defined TARGET_ARCH_ARM | 1730 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |