| 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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
| 6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
| 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
| 8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
| 9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
| 10 | 10 |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 __ cmpl(EAX, Immediate(Smi::RawValue(0))); | 1464 __ cmpl(EAX, Immediate(Smi::RawValue(0))); |
| 1465 __ j(EQUAL, &is_true, Assembler::kNearJump); | 1465 __ j(EQUAL, &is_true, Assembler::kNearJump); |
| 1466 __ LoadObject(EAX, Bool::False()); | 1466 __ LoadObject(EAX, Bool::False()); |
| 1467 __ ret(); | 1467 __ ret(); |
| 1468 __ Bind(&is_true); | 1468 __ Bind(&is_true); |
| 1469 __ LoadObject(EAX, Bool::True()); | 1469 __ LoadObject(EAX, Bool::True()); |
| 1470 __ ret(); | 1470 __ ret(); |
| 1471 return true; | 1471 return true; |
| 1472 } | 1472 } |
| 1473 | 1473 |
| 1474 |
| 1475 bool Intrinsifier::OneByteString_getHashCode(Assembler* assembler) { |
| 1476 Label compute_hash; |
| 1477 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // OneByteString object. |
| 1478 __ movl(EAX, FieldAddress(EBX, String::hash_offset())); |
| 1479 __ cmpl(EAX, Immediate(0)); |
| 1480 __ j(EQUAL, &compute_hash, Assembler::kNearJump); |
| 1481 __ ret(); |
| 1482 |
| 1483 __ Bind(&compute_hash); |
| 1484 // Hash not yet computed, use algorithm of class StringHasher. |
| 1485 __ movl(ECX, FieldAddress(EBX, String::length_offset())); |
| 1486 __ SmiUntag(ECX); |
| 1487 __ xorl(EAX, EAX); |
| 1488 __ xorl(EDI, EDI); |
| 1489 // EBX: Instance of OneByteString. |
| 1490 // ECX: String length, untagged integer. |
| 1491 // EDI: Loop counter, untagged integer. |
| 1492 // EAX: Hash code, untagged integer. |
| 1493 Label loop, done, set_hash_code; |
| 1494 __ Bind(&loop); |
| 1495 __ cmpl(EDI, ECX); |
| 1496 __ j(EQUAL, &done, Assembler::kNearJump); |
| 1497 // Add to hash code: |
| 1498 // hash_ += ch; |
| 1499 // hash_ += hash_ << 10; |
| 1500 // hash_ ^= hash_ >> 6; |
| 1501 // Get one characters (ch). |
| 1502 __ movzxb(EDX, FieldAddress(EBX, EDI, TIMES_1, OneByteString::data_offset())); |
| 1503 // EDX: ch and temporary. |
| 1504 __ addl(EAX, EDX); |
| 1505 __ movl(EDX, EAX); |
| 1506 __ shll(EDX, Immediate(10)); |
| 1507 __ addl(EAX, EDX); |
| 1508 __ movl(EDX, EAX); |
| 1509 __ shrl(EDX, Immediate(6)); |
| 1510 __ xorl(EAX, EDX); |
| 1511 |
| 1512 __ incl(EDI); |
| 1513 __ jmp(&loop, Assembler::kNearJump); |
| 1514 |
| 1515 __ Bind(&done); |
| 1516 // Finalize: |
| 1517 // hash_ += hash_ << 3; |
| 1518 // hash_ ^= hash_ >> 11; |
| 1519 // hash_ += hash_ << 15; |
| 1520 __ movl(EDX, EAX); |
| 1521 __ shll(EDX, Immediate(3)); |
| 1522 __ addl(EAX, EDX); |
| 1523 __ movl(EDX, EAX); |
| 1524 __ shrl(EDX, Immediate(11)); |
| 1525 __ xorl(EAX, EDX); |
| 1526 __ movl(EDX, EAX); |
| 1527 __ shll(EDX, Immediate(15)); |
| 1528 __ addl(EAX, EDX); |
| 1529 // hash_ = hash_ & ((static_cast<intptr_t>(1) << bits) - 1); |
| 1530 __ andl(EAX, |
| 1531 Immediate(((static_cast<intptr_t>(1) << String::kHashBits) - 1))); |
| 1532 |
| 1533 // return hash_ == 0 ? 1 : hash_; |
| 1534 __ cmpl(EAX, Immediate(0)); |
| 1535 __ j(NOT_EQUAL, &set_hash_code, Assembler::kNearJump); |
| 1536 __ incl(EAX); |
| 1537 __ Bind(&set_hash_code); |
| 1538 __ SmiTag(EAX); |
| 1539 __ movl(FieldAddress(EBX, String::hash_offset()), EAX); |
| 1540 __ ret(); |
| 1541 return true; |
| 1542 } |
| 1543 |
| 1474 #undef __ | 1544 #undef __ |
| 1475 } // namespace dart | 1545 } // namespace dart |
| 1476 | 1546 |
| 1477 #endif // defined TARGET_ARCH_IA32 | 1547 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |