OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 3514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3525 __ Add(stub_entry, x0, Code::kHeaderSize - kHeapObjectTag); | 3525 __ Add(stub_entry, x0, Code::kHeaderSize - kHeapObjectTag); |
3526 // Restore caller-saved registers. | 3526 // Restore caller-saved registers. |
3527 __ Pop(lr, x0, x1); | 3527 __ Pop(lr, x0, x1); |
3528 } | 3528 } |
3529 | 3529 |
3530 // Tail-call to the new stub. | 3530 // Tail-call to the new stub. |
3531 __ Jump(stub_entry); | 3531 __ Jump(stub_entry); |
3532 } | 3532 } |
3533 | 3533 |
3534 | 3534 |
3535 void StringHelper::GenerateHashInit(MacroAssembler* masm, | |
3536 Register hash, | |
3537 Register character) { | |
3538 DCHECK(!AreAliased(hash, character)); | |
3539 | |
3540 // hash = character + (character << 10); | |
3541 __ LoadRoot(hash, Heap::kHashSeedRootIndex); | |
3542 // Untag smi seed and add the character. | |
3543 __ Add(hash, character, Operand::UntagSmi(hash)); | |
3544 | |
3545 // Compute hashes modulo 2^32 using a 32-bit W register. | |
3546 Register hash_w = hash.W(); | |
3547 | |
3548 // hash += hash << 10; | |
3549 __ Add(hash_w, hash_w, Operand(hash_w, LSL, 10)); | |
3550 // hash ^= hash >> 6; | |
3551 __ Eor(hash_w, hash_w, Operand(hash_w, LSR, 6)); | |
3552 } | |
3553 | |
3554 | |
3555 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, | |
3556 Register hash, | |
3557 Register character) { | |
3558 DCHECK(!AreAliased(hash, character)); | |
3559 | |
3560 // hash += character; | |
3561 __ Add(hash, hash, character); | |
3562 | |
3563 // Compute hashes modulo 2^32 using a 32-bit W register. | |
3564 Register hash_w = hash.W(); | |
3565 | |
3566 // hash += hash << 10; | |
3567 __ Add(hash_w, hash_w, Operand(hash_w, LSL, 10)); | |
3568 // hash ^= hash >> 6; | |
3569 __ Eor(hash_w, hash_w, Operand(hash_w, LSR, 6)); | |
3570 } | |
3571 | |
3572 | |
3573 void StringHelper::GenerateHashGetHash(MacroAssembler* masm, | |
3574 Register hash, | |
3575 Register scratch) { | |
3576 // Compute hashes modulo 2^32 using a 32-bit W register. | |
3577 Register hash_w = hash.W(); | |
3578 Register scratch_w = scratch.W(); | |
3579 DCHECK(!AreAliased(hash_w, scratch_w)); | |
3580 | |
3581 // hash += hash << 3; | |
3582 __ Add(hash_w, hash_w, Operand(hash_w, LSL, 3)); | |
3583 // hash ^= hash >> 11; | |
3584 __ Eor(hash_w, hash_w, Operand(hash_w, LSR, 11)); | |
3585 // hash += hash << 15; | |
3586 __ Add(hash_w, hash_w, Operand(hash_w, LSL, 15)); | |
3587 | |
3588 __ Ands(hash_w, hash_w, String::kHashBitMask); | |
3589 | |
3590 // if (hash == 0) hash = 27; | |
3591 __ Mov(scratch_w, StringHasher::kZeroHash); | |
3592 __ Csel(hash_w, scratch_w, hash_w, eq); | |
3593 } | |
3594 | |
3595 | |
3596 void SubStringStub::Generate(MacroAssembler* masm) { | 3535 void SubStringStub::Generate(MacroAssembler* masm) { |
3597 ASM_LOCATION("SubStringStub::Generate"); | 3536 ASM_LOCATION("SubStringStub::Generate"); |
3598 Label runtime; | 3537 Label runtime; |
3599 | 3538 |
3600 // Stack frame on entry. | 3539 // Stack frame on entry. |
3601 // lr: return address | 3540 // lr: return address |
3602 // jssp[0]: substring "to" offset | 3541 // jssp[0]: substring "to" offset |
3603 // jssp[8]: substring "from" offset | 3542 // jssp[8]: substring "from" offset |
3604 // jssp[16]: pointer to string object | 3543 // jssp[16]: pointer to string object |
3605 | 3544 |
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5114 MemOperand(fp, 6 * kPointerSize), | 5053 MemOperand(fp, 6 * kPointerSize), |
5115 NULL); | 5054 NULL); |
5116 } | 5055 } |
5117 | 5056 |
5118 | 5057 |
5119 #undef __ | 5058 #undef __ |
5120 | 5059 |
5121 } } // namespace v8::internal | 5060 } } // namespace v8::internal |
5122 | 5061 |
5123 #endif // V8_TARGET_ARCH_ARM64 | 5062 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |