| 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 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 | 1419 |
| 1420 | 1420 |
| 1421 bool Intrinsifier::String_getLength(Assembler* assembler) { | 1421 bool Intrinsifier::String_getLength(Assembler* assembler) { |
| 1422 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // String object. | 1422 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // String object. |
| 1423 __ movq(RAX, FieldAddress(RAX, String::length_offset())); | 1423 __ movq(RAX, FieldAddress(RAX, String::length_offset())); |
| 1424 __ ret(); | 1424 __ ret(); |
| 1425 return true; | 1425 return true; |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 | 1428 |
| 1429 // TODO(srdjan): Implement for two and four byte strings as well. | |
| 1430 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { | 1429 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { |
| 1431 Label fall_through; | 1430 Label fall_through, try_two_byte_string; |
| 1432 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Index. | 1431 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Index. |
| 1433 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // String. | 1432 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // String. |
| 1434 __ testq(RCX, Immediate(kSmiTagMask)); | 1433 __ testq(RCX, Immediate(kSmiTagMask)); |
| 1435 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. | 1434 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 1436 // Range check. | 1435 // Range check. |
| 1437 __ cmpq(RCX, FieldAddress(RAX, String::length_offset())); | 1436 __ cmpq(RCX, FieldAddress(RAX, String::length_offset())); |
| 1438 // Runtime throws exception. | 1437 // Runtime throws exception. |
| 1439 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 1438 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 1440 __ CompareClassId(RAX, kOneByteStringCid); | 1439 __ CompareClassId(RAX, kOneByteStringCid); |
| 1441 __ j(NOT_EQUAL, &fall_through); | 1440 __ j(NOT_EQUAL, &try_two_byte_string, Assembler::kNearJump); |
| 1442 __ SmiUntag(RCX); | 1441 __ SmiUntag(RCX); |
| 1443 __ movzxb(RAX, FieldAddress(RAX, RCX, TIMES_1, OneByteString::data_offset())); | 1442 __ movzxb(RAX, FieldAddress(RAX, RCX, TIMES_1, OneByteString::data_offset())); |
| 1444 __ SmiTag(RAX); | 1443 __ SmiTag(RAX); |
| 1445 __ ret(); | 1444 __ ret(); |
| 1445 |
| 1446 __ Bind(&try_two_byte_string); |
| 1447 __ CompareClassId(RAX, kTwoByteStringCid); |
| 1448 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
| 1449 ASSERT(kSmiTagShift == 1); |
| 1450 __ movzxw(RAX, FieldAddress(RAX, RCX, TIMES_1, OneByteString::data_offset())); |
| 1451 __ SmiTag(RAX); |
| 1452 __ ret(); |
| 1453 |
| 1446 __ Bind(&fall_through); | 1454 __ Bind(&fall_through); |
| 1447 return false; | 1455 return false; |
| 1448 } | 1456 } |
| 1449 | 1457 |
| 1450 | 1458 |
| 1451 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { | 1459 bool Intrinsifier::String_getIsEmpty(Assembler* assembler) { |
| 1452 Label is_true; | 1460 Label is_true; |
| 1453 // Get length. | 1461 // Get length. |
| 1454 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // String object. | 1462 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // String object. |
| 1455 __ movq(RAX, FieldAddress(RAX, String::length_offset())); | 1463 __ movq(RAX, FieldAddress(RAX, String::length_offset())); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 __ Bind(&fall_through); | 1689 __ Bind(&fall_through); |
| 1682 return false; | 1690 return false; |
| 1683 } | 1691 } |
| 1684 | 1692 |
| 1685 | 1693 |
| 1686 #undef __ | 1694 #undef __ |
| 1687 | 1695 |
| 1688 } // namespace dart | 1696 } // namespace dart |
| 1689 | 1697 |
| 1690 #endif // defined TARGET_ARCH_X64 | 1698 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |