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

Side by Side Diff: runtime/vm/intrinsifier_arm64.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 void Intrinsifier::OneByteString_equality(Assembler* assembler) { 1485 void Intrinsifier::OneByteString_equality(Assembler* assembler) {
1486 StringEquality(assembler, kOneByteStringCid); 1486 StringEquality(assembler, kOneByteStringCid);
1487 } 1487 }
1488 1488
1489 1489
1490 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { 1490 void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
1491 StringEquality(assembler, kTwoByteStringCid); 1491 StringEquality(assembler, kTwoByteStringCid);
1492 } 1492 }
1493 1493
1494 1494
1495 static void GenerateRegexpSpecializationFor(
1496 Assembler* assembler,
1497 intptr_t cid,
1498 Label* entry,
1499 Label* exit) {
1500 ASSERT(cid == kOneByteStringCid || cid == kExternalOneByteStringCid ||
1501 cid == kTwoByteStringCid || cid == kExternalTwoByteStringCid);
1502
1503 __ Bind(entry);
1504
1505 // The passed string is of class cid.
1506
1507 __ ldr(R0, FieldAddress(R2, JSRegExp::function_offset(cid)));
1508
1509 // Set the subject if it is currently unset.
1510
1511 __ LoadObject(R4, Object::null_object(), PP);
1512 __ ldr(R5, FieldAddress(R2, JSRegExp::subject_offset(cid)));
1513 __ cmp(R4, Operand(R5));
1514 __ b(exit, NE);
1515
1516 __ StoreIntoObject(R2,
1517 FieldAddress(R2, JSRegExp::subject_offset(cid)),
1518 R1,
1519 false);
1520
1521 __ b(exit);
1522 }
1523
1524
1525 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) {
1526 Label is_one_byte_string;
1527 Label is_two_byte_string;
1528 Label is_external_one_byte_string;
1529 Label is_external_two_byte_string;
1530 Label fallthrough;
1531
1532 static const intptr_t kRegExpParamOffset = + 2 * kWordSize;
1533 static const intptr_t kStringParamOffset = + 1 * kWordSize;
1534 // const Smi& start_index is located at (+ 0 * kWordSize).
1535
1536 // Register assignments are as follows:
1537 // R0: The appropriate specialized matcher function.
1538 // R2: The regexp object.
1539 // R4: Temp.
1540 // R5: Temp.
1541 // R1: Temp, Pointer to the function's code which we then tail-call.
1542
1543 __ ldr(R2, Address(SP, kRegExpParamOffset));
1544 __ ldr(R1, Address(SP, kStringParamOffset));
1545
1546 // Check which string class we have been passed.
1547
1548 __ CompareClassId(R1, kOneByteStringCid, R4);
1549 __ b(&is_one_byte_string, EQ);
1550
1551 __ CompareClassId(R1, kTwoByteStringCid, R4);
1552 __ b(&is_two_byte_string, EQ);
1553
1554 __ CompareClassId(R1, kExternalOneByteStringCid, R4);
1555 __ b(&is_external_one_byte_string, EQ);
1556
1557 __ CompareClassId(R1, kExternalTwoByteStringCid, R4);
1558 __ b(&is_external_two_byte_string, EQ);
1559
1560 __ Stop("Unexpected class id");
1561
1562 GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid,
1563 &is_external_two_byte_string, &fallthrough);
1564 GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid,
1565 &is_external_one_byte_string, &fallthrough);
1566 GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid,
1567 &is_two_byte_string, &fallthrough);
1568 GenerateRegexpSpecializationFor(assembler, kOneByteStringCid,
1569 &is_one_byte_string, &fallthrough);
1570
1571 // R0 contains the appropriate specialized function.
1572
1573 __ Bind(&fallthrough);
1574
1575 // Registers have been set up for the lazy compile stub at this point.
1576 // It expects the function in R0, the argument descriptor in R5, and
1577 // IC-Data in R4. Irregexp generated functions do not use either the
1578 // arguments descriptor or IC-Data, and hence these are not set here.
1579
1580 // Tail-call the function.
1581 __ ldr(R1, FieldAddress(R0, Function::instructions_offset()));
1582 __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP);
1583 __ br(R1);
1584 }
1585
1586
1495 // On stack: user tag (+0). 1587 // On stack: user tag (+0).
1496 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { 1588 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) {
1497 // R1: Isolate. 1589 // R1: Isolate.
1498 Isolate* isolate = Isolate::Current(); 1590 Isolate* isolate = Isolate::Current();
1499 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP); 1591 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP);
1500 // R0: Current user tag. 1592 // R0: Current user tag.
1501 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1593 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1502 // R2: UserTag. 1594 // R2: UserTag.
1503 __ ldr(R2, Address(SP, + 0 * kWordSize)); 1595 __ ldr(R2, Address(SP, + 0 * kWordSize));
1504 // Set Isolate::current_tag_. 1596 // Set Isolate::current_tag_.
(...skipping 22 matching lines...) Expand all
1527 Isolate* isolate = Isolate::Current(); 1619 Isolate* isolate = Isolate::Current();
1528 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP); 1620 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate), kNoPP);
1529 // Set return value to Isolate::current_tag_. 1621 // Set return value to Isolate::current_tag_.
1530 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); 1622 __ ldr(R0, Address(R1, Isolate::current_tag_offset()));
1531 __ ret(); 1623 __ ret();
1532 } 1624 }
1533 1625
1534 } // namespace dart 1626 } // namespace dart
1535 1627
1536 #endif // defined TARGET_ARCH_ARM64 1628 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698