| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4535 // hash: hash of two character string (32-bit int) | 4535 // hash: hash of two character string (32-bit int) |
| 4536 // symbol_table: symbol table | 4536 // symbol_table: symbol table |
| 4537 // mask: capacity mask (32-bit int) | 4537 // mask: capacity mask (32-bit int) |
| 4538 // map: - | 4538 // map: - |
| 4539 // scratch: - | 4539 // scratch: - |
| 4540 | 4540 |
| 4541 // Perform a number of probes in the symbol table. | 4541 // Perform a number of probes in the symbol table. |
| 4542 static const int kProbes = 4; | 4542 static const int kProbes = 4; |
| 4543 Label found_in_symbol_table; | 4543 Label found_in_symbol_table; |
| 4544 Label next_probe[kProbes]; | 4544 Label next_probe[kProbes]; |
| 4545 Register candidate = scratch; // Scratch register contains candidate. |
| 4545 for (int i = 0; i < kProbes; i++) { | 4546 for (int i = 0; i < kProbes; i++) { |
| 4546 // Calculate entry in symbol table. | 4547 // Calculate entry in symbol table. |
| 4547 __ movl(scratch, hash); | 4548 __ movl(scratch, hash); |
| 4548 if (i > 0) { | 4549 if (i > 0) { |
| 4549 __ addl(scratch, Immediate(SymbolTable::GetProbeOffset(i))); | 4550 __ addl(scratch, Immediate(SymbolTable::GetProbeOffset(i))); |
| 4550 } | 4551 } |
| 4551 __ andl(scratch, mask); | 4552 __ andl(scratch, mask); |
| 4552 | 4553 |
| 4553 // Load the entry from the symbol table. | 4554 // Load the entry from the symbol table. |
| 4554 Register candidate = scratch; // Scratch register contains candidate. | |
| 4555 STATIC_ASSERT(SymbolTable::kEntrySize == 1); | 4555 STATIC_ASSERT(SymbolTable::kEntrySize == 1); |
| 4556 __ movq(candidate, | 4556 __ movq(candidate, |
| 4557 FieldOperand(symbol_table, | 4557 FieldOperand(symbol_table, |
| 4558 scratch, | 4558 scratch, |
| 4559 times_pointer_size, | 4559 times_pointer_size, |
| 4560 SymbolTable::kElementsStartOffset)); | 4560 SymbolTable::kElementsStartOffset)); |
| 4561 | 4561 |
| 4562 // If entry is undefined no string with this hash can be found. | 4562 // If entry is undefined no string with this hash can be found. |
| 4563 Label is_string; | 4563 Label is_string; |
| 4564 __ CmpObjectType(candidate, ODDBALL_TYPE, map); | 4564 __ CmpObjectType(candidate, ODDBALL_TYPE, map); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4590 __ andl(temp, Immediate(0x0000ffff)); | 4590 __ andl(temp, Immediate(0x0000ffff)); |
| 4591 __ cmpl(chars, temp); | 4591 __ cmpl(chars, temp); |
| 4592 __ j(equal, &found_in_symbol_table); | 4592 __ j(equal, &found_in_symbol_table); |
| 4593 __ bind(&next_probe[i]); | 4593 __ bind(&next_probe[i]); |
| 4594 } | 4594 } |
| 4595 | 4595 |
| 4596 // No matching 2 character string found by probing. | 4596 // No matching 2 character string found by probing. |
| 4597 __ jmp(not_found); | 4597 __ jmp(not_found); |
| 4598 | 4598 |
| 4599 // Scratch register contains result when we fall through to here. | 4599 // Scratch register contains result when we fall through to here. |
| 4600 Register result = scratch; | 4600 Register result = candidate; |
| 4601 __ bind(&found_in_symbol_table); | 4601 __ bind(&found_in_symbol_table); |
| 4602 if (!result.is(rax)) { | 4602 if (!result.is(rax)) { |
| 4603 __ movq(rax, result); | 4603 __ movq(rax, result); |
| 4604 } | 4604 } |
| 4605 } | 4605 } |
| 4606 | 4606 |
| 4607 | 4607 |
| 4608 void StringHelper::GenerateHashInit(MacroAssembler* masm, | 4608 void StringHelper::GenerateHashInit(MacroAssembler* masm, |
| 4609 Register hash, | 4609 Register hash, |
| 4610 Register character, | 4610 Register character, |
| 4611 Register scratch) { | 4611 Register scratch) { |
| 4612 // hash = character + (character << 10); | 4612 // hash = (seed + character) + ((seed + character) << 10); |
| 4613 __ movl(hash, character); | 4613 __ LoadRoot(scratch, Heap::kStringHashSeedRootIndex); |
| 4614 __ shll(hash, Immediate(10)); | 4614 __ SmiToInteger32(scratch, scratch); |
| 4615 __ addl(hash, character); | 4615 __ addl(scratch, character); |
| 4616 __ movl(hash, scratch); |
| 4617 __ shll(scratch, Immediate(10)); |
| 4618 __ addl(hash, scratch); |
| 4616 // hash ^= hash >> 6; | 4619 // hash ^= hash >> 6; |
| 4617 __ movl(scratch, hash); | 4620 __ movl(scratch, hash); |
| 4618 __ sarl(scratch, Immediate(6)); | 4621 __ shrl(scratch, Immediate(6)); |
| 4619 __ xorl(hash, scratch); | 4622 __ xorl(hash, scratch); |
| 4620 } | 4623 } |
| 4621 | 4624 |
| 4622 | 4625 |
| 4623 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, | 4626 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, |
| 4624 Register hash, | 4627 Register hash, |
| 4625 Register character, | 4628 Register character, |
| 4626 Register scratch) { | 4629 Register scratch) { |
| 4627 // hash += character; | 4630 // hash += character; |
| 4628 __ addl(hash, character); | 4631 __ addl(hash, character); |
| 4629 // hash += hash << 10; | 4632 // hash += hash << 10; |
| 4630 __ movl(scratch, hash); | 4633 __ movl(scratch, hash); |
| 4631 __ shll(scratch, Immediate(10)); | 4634 __ shll(scratch, Immediate(10)); |
| 4632 __ addl(hash, scratch); | 4635 __ addl(hash, scratch); |
| 4633 // hash ^= hash >> 6; | 4636 // hash ^= hash >> 6; |
| 4634 __ movl(scratch, hash); | 4637 __ movl(scratch, hash); |
| 4635 __ sarl(scratch, Immediate(6)); | 4638 __ shrl(scratch, Immediate(6)); |
| 4636 __ xorl(hash, scratch); | 4639 __ xorl(hash, scratch); |
| 4637 } | 4640 } |
| 4638 | 4641 |
| 4639 | 4642 |
| 4640 void StringHelper::GenerateHashGetHash(MacroAssembler* masm, | 4643 void StringHelper::GenerateHashGetHash(MacroAssembler* masm, |
| 4641 Register hash, | 4644 Register hash, |
| 4642 Register scratch) { | 4645 Register scratch) { |
| 4643 // hash += hash << 3; | 4646 // hash += hash << 3; |
| 4644 __ leal(hash, Operand(hash, hash, times_8, 0)); | 4647 __ leal(hash, Operand(hash, hash, times_8, 0)); |
| 4645 // hash ^= hash >> 11; | 4648 // hash ^= hash >> 11; |
| 4646 __ movl(scratch, hash); | 4649 __ movl(scratch, hash); |
| 4647 __ sarl(scratch, Immediate(11)); | 4650 __ shrl(scratch, Immediate(11)); |
| 4648 __ xorl(hash, scratch); | 4651 __ xorl(hash, scratch); |
| 4649 // hash += hash << 15; | 4652 // hash += hash << 15; |
| 4650 __ movl(scratch, hash); | 4653 __ movl(scratch, hash); |
| 4651 __ shll(scratch, Immediate(15)); | 4654 __ shll(scratch, Immediate(15)); |
| 4652 __ addl(hash, scratch); | 4655 __ addl(hash, scratch); |
| 4653 | 4656 |
| 4657 uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1; |
| 4658 __ andl(hash, Immediate(kHashShiftCutOffMask)); |
| 4659 |
| 4654 // if (hash == 0) hash = 27; | 4660 // if (hash == 0) hash = 27; |
| 4655 Label hash_not_zero; | 4661 Label hash_not_zero; |
| 4656 __ j(not_zero, &hash_not_zero); | 4662 __ j(not_zero, &hash_not_zero); |
| 4657 __ Set(hash, 27); | 4663 __ Set(hash, 27); |
| 4658 __ bind(&hash_not_zero); | 4664 __ bind(&hash_not_zero); |
| 4659 } | 4665 } |
| 4660 | 4666 |
| 4661 void SubStringStub::Generate(MacroAssembler* masm) { | 4667 void SubStringStub::Generate(MacroAssembler* masm) { |
| 4662 Label runtime; | 4668 Label runtime; |
| 4663 | 4669 |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5490 __ Drop(1); | 5496 __ Drop(1); |
| 5491 __ ret(2 * kPointerSize); | 5497 __ ret(2 * kPointerSize); |
| 5492 } | 5498 } |
| 5493 | 5499 |
| 5494 | 5500 |
| 5495 #undef __ | 5501 #undef __ |
| 5496 | 5502 |
| 5497 } } // namespace v8::internal | 5503 } } // namespace v8::internal |
| 5498 | 5504 |
| 5499 #endif // V8_TARGET_ARCH_X64 | 5505 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |