OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 __ mov_b(Operand(dest, 0), scratch); | 2563 __ mov_b(Operand(dest, 0), scratch); |
2564 __ inc(src); | 2564 __ inc(src); |
2565 __ inc(dest); | 2565 __ inc(dest); |
2566 __ dec(count); | 2566 __ dec(count); |
2567 __ j(not_zero, &loop); | 2567 __ j(not_zero, &loop); |
2568 | 2568 |
2569 __ bind(&done); | 2569 __ bind(&done); |
2570 } | 2570 } |
2571 | 2571 |
2572 | 2572 |
2573 void StringHelper::GenerateHashInit(MacroAssembler* masm, | |
2574 Register hash, | |
2575 Register character, | |
2576 Register scratch) { | |
2577 // hash = (seed + character) + ((seed + character) << 10); | |
2578 if (masm->serializer_enabled()) { | |
2579 __ LoadRoot(scratch, Heap::kHashSeedRootIndex); | |
2580 __ SmiUntag(scratch); | |
2581 __ add(scratch, character); | |
2582 __ mov(hash, scratch); | |
2583 __ shl(scratch, 10); | |
2584 __ add(hash, scratch); | |
2585 } else { | |
2586 int32_t seed = masm->isolate()->heap()->HashSeed(); | |
2587 __ lea(scratch, Operand(character, seed)); | |
2588 __ shl(scratch, 10); | |
2589 __ lea(hash, Operand(scratch, character, times_1, seed)); | |
2590 } | |
2591 // hash ^= hash >> 6; | |
2592 __ mov(scratch, hash); | |
2593 __ shr(scratch, 6); | |
2594 __ xor_(hash, scratch); | |
2595 } | |
2596 | |
2597 | |
2598 void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm, | |
2599 Register hash, | |
2600 Register character, | |
2601 Register scratch) { | |
2602 // hash += character; | |
2603 __ add(hash, character); | |
2604 // hash += hash << 10; | |
2605 __ mov(scratch, hash); | |
2606 __ shl(scratch, 10); | |
2607 __ add(hash, scratch); | |
2608 // hash ^= hash >> 6; | |
2609 __ mov(scratch, hash); | |
2610 __ shr(scratch, 6); | |
2611 __ xor_(hash, scratch); | |
2612 } | |
2613 | |
2614 | |
2615 void StringHelper::GenerateHashGetHash(MacroAssembler* masm, | |
2616 Register hash, | |
2617 Register scratch) { | |
2618 // hash += hash << 3; | |
2619 __ mov(scratch, hash); | |
2620 __ shl(scratch, 3); | |
2621 __ add(hash, scratch); | |
2622 // hash ^= hash >> 11; | |
2623 __ mov(scratch, hash); | |
2624 __ shr(scratch, 11); | |
2625 __ xor_(hash, scratch); | |
2626 // hash += hash << 15; | |
2627 __ mov(scratch, hash); | |
2628 __ shl(scratch, 15); | |
2629 __ add(hash, scratch); | |
2630 | |
2631 __ and_(hash, String::kHashBitMask); | |
2632 | |
2633 // if (hash == 0) hash = 27; | |
2634 Label hash_not_zero; | |
2635 __ j(not_zero, &hash_not_zero, Label::kNear); | |
2636 __ mov(hash, Immediate(StringHasher::kZeroHash)); | |
2637 __ bind(&hash_not_zero); | |
2638 } | |
2639 | |
2640 | |
2641 void SubStringStub::Generate(MacroAssembler* masm) { | 2573 void SubStringStub::Generate(MacroAssembler* masm) { |
2642 Label runtime; | 2574 Label runtime; |
2643 | 2575 |
2644 // Stack frame on entry. | 2576 // Stack frame on entry. |
2645 // esp[0]: return address | 2577 // esp[0]: return address |
2646 // esp[4]: to | 2578 // esp[4]: to |
2647 // esp[8]: from | 2579 // esp[8]: from |
2648 // esp[12]: string | 2580 // esp[12]: string |
2649 | 2581 |
2650 // Make sure first argument is a string. | 2582 // Make sure first argument is a string. |
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4391 Operand(ebp, 7 * kPointerSize), | 4323 Operand(ebp, 7 * kPointerSize), |
4392 NULL); | 4324 NULL); |
4393 } | 4325 } |
4394 | 4326 |
4395 | 4327 |
4396 #undef __ | 4328 #undef __ |
4397 | 4329 |
4398 } } // namespace v8::internal | 4330 } } // namespace v8::internal |
4399 | 4331 |
4400 #endif // V8_TARGET_ARCH_X87 | 4332 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |