Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: runtime/vm/intrinsifier_arm.cc

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Port remaining V8 regexp tests and fix exposed bugs. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 == kExternalOneByteStringCid ||
1608 cid == kTwoByteStringCid || 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 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 which string class we have been passed.
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 __ Stop("Unexpected class id");
1668
1669 GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid,
1670 &is_external_two_byte_string, &fallthrough);
1671 GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid,
1672 &is_external_one_byte_string, &fallthrough);
1673 GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid,
1674 &is_two_byte_string, &fallthrough);
1675 GenerateRegexpSpecializationFor(assembler, kOneByteStringCid,
1676 &is_one_byte_string, &fallthrough);
1677
1678 // R0 contains the appropriate specialized function.
1679
1680 __ Bind(&fallthrough);
1681
1682 // Registers have been set up for the lazy compile stub at this point.
1683 // It expects the function in R0, the argument descriptor in R5, and
1684 // IC-Data in R4. Irregexp generated functions do not use either the
1685 // arguments descriptor or IC-Data, and hence these are not set here.
1686
1687 // Tail-call the function.
1688 __ ldr(R1, FieldAddress(R0, Function::instructions_offset()));
1689 __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag);
1690 __ bx(R1);
1691 }
1692
1693
1602 // On stack: user tag (+0). 1694 // On stack: user tag (+0).
1603 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { 1695 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) {
1604 // R1: Isolate. 1696 // R1: Isolate.
1605 Isolate* isolate = Isolate::Current(); 1697 Isolate* isolate = Isolate::Current();
1606 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); 1698 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate));
1607 // R0: Current user tag. 1699 // R0: Current user tag.
1608 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1700 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1609 // R2: UserTag. 1701 // R2: UserTag.
1610 __ ldr(R2, Address(SP, + 0 * kWordSize)); 1702 __ ldr(R2, Address(SP, + 0 * kWordSize));
1611 // Set Isolate::current_tag_. 1703 // Set Isolate::current_tag_.
(...skipping 21 matching lines...) Expand all
1633 Isolate* isolate = Isolate::Current(); 1725 Isolate* isolate = Isolate::Current();
1634 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); 1726 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate));
1635 // Set return value to Isolate::current_tag_. 1727 // Set return value to Isolate::current_tag_.
1636 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1728 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1637 __ Ret(); 1729 __ Ret();
1638 } 1730 }
1639 1731
1640 } // namespace dart 1732 } // namespace dart
1641 1733
1642 #endif // defined TARGET_ARCH_ARM 1734 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698