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 == 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 Loading... |
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 |
OLD | NEW |