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_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 Loading... | |
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 == kExternalOneByteStringCid || | |
1520 cid == kTwoByteStringCid || 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, | |
Vyacheslav Egorov (Google)
2014/10/01 20:13:21
I really don't think there is any good reason to k
| |
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 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 which string class we have been passed. | |
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 __ Stop("Unexpected class id"); | |
1578 | |
1579 GenerateRegexpSpecializationFor(assembler, kExternalTwoByteStringCid, | |
1580 &is_external_two_byte_string, &fallthrough); | |
1581 GenerateRegexpSpecializationFor(assembler, kExternalOneByteStringCid, | |
1582 &is_external_one_byte_string, &fallthrough); | |
1583 GenerateRegexpSpecializationFor(assembler, kTwoByteStringCid, | |
1584 &is_two_byte_string, &fallthrough, | |
1585 Assembler::kNearJump); | |
1586 GenerateRegexpSpecializationFor(assembler, kOneByteStringCid, | |
1587 &is_one_byte_string, &fallthrough, | |
1588 Assembler::kNearJump); | |
1589 | |
1590 // RAX contains the appropriate specialized function. | |
1591 | |
1592 __ Bind(&fallthrough); | |
1593 | |
1594 // Registers have been set up for the lazy compile stub at this point. | |
1595 // It expects the function in RAX, the argument descriptor in R10, and | |
1596 // IC-Data in RCX. Irregexp generated functions do not use either the | |
1597 // arguments descriptor or IC-Data, and hence these are not set here. | |
1598 | |
1599 // Tail-call the function. | |
1600 __ movq(RDI, FieldAddress(RAX, Function::instructions_offset())); | |
1601 __ addq(RDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | |
1602 __ jmp(RDI); | |
1603 } | |
1604 | |
1605 | |
1513 // On stack: user tag (+1), return-address (+0). | 1606 // On stack: user tag (+1), return-address (+0). |
1514 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { | 1607 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
1515 // RBX: Isolate. | 1608 // RBX: Isolate. |
1516 Isolate* isolate = Isolate::Current(); | 1609 Isolate* isolate = Isolate::Current(); |
1517 const Immediate& isolate_address = | 1610 const Immediate& isolate_address = |
1518 Immediate(reinterpret_cast<int64_t>(isolate)); | 1611 Immediate(reinterpret_cast<int64_t>(isolate)); |
1519 __ movq(RBX, isolate_address); | 1612 __ movq(RBX, isolate_address); |
1520 // RAX: Current user tag. | 1613 // RAX: Current user tag. |
1521 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1614 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
1522 // R10: UserTag. | 1615 // R10: UserTag. |
(...skipping 30 matching lines...) Expand all Loading... | |
1553 // Set return value to Isolate::current_tag_. | 1646 // Set return value to Isolate::current_tag_. |
1554 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1647 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
1555 __ ret(); | 1648 __ ret(); |
1556 } | 1649 } |
1557 | 1650 |
1558 #undef __ | 1651 #undef __ |
1559 | 1652 |
1560 } // namespace dart | 1653 } // namespace dart |
1561 | 1654 |
1562 #endif // defined TARGET_ARCH_X64 | 1655 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |