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

Side by Side Diff: runtime/vm/intrinsifier_x64.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: Updated to current version Created 6 years, 3 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 void Intrinsifier::OneByteString_equality(Assembler* assembler) { 1503 void Intrinsifier::OneByteString_equality(Assembler* assembler) {
1504 StringEquality(assembler, kOneByteStringCid); 1504 StringEquality(assembler, kOneByteStringCid);
1505 } 1505 }
1506 1506
1507 1507
1508 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { 1508 void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
1509 StringEquality(assembler, kTwoByteStringCid); 1509 StringEquality(assembler, kTwoByteStringCid);
1510 } 1510 }
1511 1511
1512 1512
1513 static void GenerateRegexpSpecializationFor(
1514 Assembler* assembler,
1515 intptr_t cid,
1516 Label* entry,
1517 Label* exit,
1518 bool jump_kind = Assembler::kFarJump) {
1519 ASSERT(cid == kOneByteStringCid || cid == kTwoByteStringCid ||
1520 cid == kExternalOneByteStringCid || cid == kExternalTwoByteStringCid);
1521
1522 __ Bind(entry);
1523
1524 // The passed string is of class cid.
1525
1526 __ movq(RAX, FieldAddress(RBX, JSRegExp::function_offset(cid)));
1527
1528 // Set the subject if it is currently unset.
1529
1530 __ LoadObject(RCX, Object::null_object(), PP);
1531 __ cmpq(RCX, FieldAddress(RBX, JSRegExp::subject_offset(cid)));
1532 __ j(NOT_EQUAL, exit, jump_kind);
1533
1534 __ StoreIntoObject(RBX,
1535 FieldAddress(RBX, JSRegExp::subject_offset(cid)),
1536 RDI,
1537 false);
1538
1539 __ jmp(exit, jump_kind);
1540 }
1541
1542
1543 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) {
1544 Label is_one_byte_string;
1545 Label is_two_byte_string;
1546 Label is_external_one_byte_string;
1547 Label is_external_two_byte_string;
1548 Label fallthrough;
1549
1550 static const intptr_t kRegExpParamOffset = + 3 * kWordSize;
1551 static const intptr_t kStringParamOffset = + 2 * kWordSize;
1552 // const Smi& start_index is located at (+ 1 * kWordSize).
1553
1554 // Register assignments are as follows:
1555 // RAX: The appropriate (one- or two-byte specialized) matcher function.
1556 // RBX: The regexp object.
1557 // RCX: Temp.
1558 // RDI: Temp, Pointer to the function's code which we then tail-call.
1559
1560 __ movq(RBX, Address(RSP, kRegExpParamOffset));
1561 __ movq(RDI, Address(RSP, kStringParamOffset));
1562
1563 // Check if the string is a one byte string.
1564
1565 __ CompareClassId(RDI, kOneByteStringCid);
1566 __ j(EQUAL, &is_one_byte_string);
1567
1568 __ CompareClassId(RDI, kTwoByteStringCid);
1569 __ j(EQUAL, &is_two_byte_string);
1570
1571 __ CompareClassId(RDI, kExternalOneByteStringCid);
1572 __ j(EQUAL, &is_external_one_byte_string);
1573
1574 __ CompareClassId(RDI, kExternalTwoByteStringCid);
1575 __ j(EQUAL, &is_external_two_byte_string);
1576
1577 GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid,
1578 &is_external_two_byte_string, &fallthrough);
1579 GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid,
1580 &is_external_one_byte_string, &fallthrough);
1581 GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid,
1582 &is_two_byte_string, &fallthrough,
1583 Assembler::kNearJump);
1584 GenerateRegexpSpecializationFor(assembler, kOneByteStringCid,
1585 &is_one_byte_string, &fallthrough,
1586 Assembler::kNearJump);
1587
1588 // RAX contains the appropriate (one- or two-byte string) function.
1589
1590 __ Bind(&fallthrough);
1591
1592 // Registers have been set up for the lazy compile stub at this point.
1593 // It expects the function in RAX while; R10 and RCX are unused.
1594
1595 // Tail-call the function.
1596 __ movq(RDI, FieldAddress(RAX, Function::instructions_offset()));
1597 __ addq(RDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1598 __ jmp(RDI);
1599 }
1600
1601
1513 // On stack: user tag (+1), return-address (+0). 1602 // On stack: user tag (+1), return-address (+0).
1514 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { 1603 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) {
1515 // RBX: Isolate. 1604 // RBX: Isolate.
1516 Isolate* isolate = Isolate::Current(); 1605 Isolate* isolate = Isolate::Current();
1517 const Immediate& isolate_address = 1606 const Immediate& isolate_address =
1518 Immediate(reinterpret_cast<int64_t>(isolate)); 1607 Immediate(reinterpret_cast<int64_t>(isolate));
1519 __ movq(RBX, isolate_address); 1608 __ movq(RBX, isolate_address);
1520 // RAX: Current user tag. 1609 // RAX: Current user tag.
1521 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1610 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1522 // R10: UserTag. 1611 // R10: UserTag.
(...skipping 30 matching lines...) Expand all
1553 // Set return value to Isolate::current_tag_. 1642 // Set return value to Isolate::current_tag_.
1554 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1643 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1555 __ ret(); 1644 __ ret();
1556 } 1645 }
1557 1646
1558 #undef __ 1647 #undef __
1559 1648
1560 } // namespace dart 1649 } // namespace dart
1561 1650
1562 #endif // defined TARGET_ARCH_X64 1651 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698