Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: src/ppc/macro-assembler-ppc.cc

Issue 1339143002: PPC: [builtins] Simplify String constructor code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ppc/macro-assembler-ppc.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 <assert.h> // For assert 5 #include <assert.h> // For assert
6 #include <limits.h> // For LONG_MIN, LONG_MAX. 6 #include <limits.h> // For LONG_MIN, LONG_MAX.
7 7
8 #if V8_TARGET_ARCH_PPC 8 #if V8_TARGET_ARCH_PPC
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 Register heap_number_map, 2619 Register heap_number_map,
2620 Register scratch, 2620 Register scratch,
2621 Label* on_not_heap_number) { 2621 Label* on_not_heap_number) {
2622 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); 2622 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
2623 AssertIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 2623 AssertIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
2624 cmp(scratch, heap_number_map); 2624 cmp(scratch, heap_number_map);
2625 bne(on_not_heap_number); 2625 bne(on_not_heap_number);
2626 } 2626 }
2627 2627
2628 2628
2629 void MacroAssembler::LookupNumberStringCache(Register object, Register result,
2630 Register scratch1,
2631 Register scratch2,
2632 Register scratch3,
2633 Label* not_found) {
2634 // Use of registers. Register result is used as a temporary.
2635 Register number_string_cache = result;
2636 Register mask = scratch3;
2637
2638 // Load the number string cache.
2639 LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
2640
2641 // Make the hash mask from the length of the number string cache. It
2642 // contains two elements (number and string) for each cache entry.
2643 LoadP(mask, FieldMemOperand(number_string_cache, FixedArray::kLengthOffset));
2644 // Divide length by two (length is a smi).
2645 ShiftRightArithImm(mask, mask, kSmiTagSize + kSmiShiftSize + 1);
2646 subi(mask, mask, Operand(1)); // Make mask.
2647
2648 // Calculate the entry in the number string cache. The hash value in the
2649 // number string cache for smis is just the smi value, and the hash for
2650 // doubles is the xor of the upper and lower words. See
2651 // Heap::GetNumberStringCache.
2652 Label is_smi;
2653 Label load_result_from_cache;
2654 JumpIfSmi(object, &is_smi);
2655 CheckMap(object, scratch1, Heap::kHeapNumberMapRootIndex, not_found,
2656 DONT_DO_SMI_CHECK);
2657
2658 STATIC_ASSERT(8 == kDoubleSize);
2659 lwz(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset));
2660 lwz(scratch2, FieldMemOperand(object, HeapNumber::kMantissaOffset));
2661 xor_(scratch1, scratch1, scratch2);
2662 and_(scratch1, scratch1, mask);
2663
2664 // Calculate address of entry in string cache: each entry consists
2665 // of two pointer sized fields.
2666 ShiftLeftImm(scratch1, scratch1, Operand(kPointerSizeLog2 + 1));
2667 add(scratch1, number_string_cache, scratch1);
2668
2669 Register probe = mask;
2670 LoadP(probe, FieldMemOperand(scratch1, FixedArray::kHeaderSize));
2671 JumpIfSmi(probe, not_found);
2672 lfd(d0, FieldMemOperand(object, HeapNumber::kValueOffset));
2673 lfd(d1, FieldMemOperand(probe, HeapNumber::kValueOffset));
2674 fcmpu(d0, d1);
2675 bne(not_found); // The cache did not contain this value.
2676 b(&load_result_from_cache);
2677
2678 bind(&is_smi);
2679 Register scratch = scratch1;
2680 SmiUntag(scratch, object);
2681 and_(scratch, mask, scratch);
2682 // Calculate address of entry in string cache: each entry consists
2683 // of two pointer sized fields.
2684 ShiftLeftImm(scratch, scratch, Operand(kPointerSizeLog2 + 1));
2685 add(scratch, number_string_cache, scratch);
2686
2687 // Check if the entry is the smi we are looking for.
2688 LoadP(probe, FieldMemOperand(scratch, FixedArray::kHeaderSize));
2689 cmp(object, probe);
2690 bne(not_found);
2691
2692 // Get the result from the cache.
2693 bind(&load_result_from_cache);
2694 LoadP(result,
2695 FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize));
2696 IncrementCounter(isolate()->counters()->number_to_string_native(), 1,
2697 scratch1, scratch2);
2698 }
2699
2700
2701 void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings( 2629 void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings(
2702 Register first, Register second, Register scratch1, Register scratch2, 2630 Register first, Register second, Register scratch1, Register scratch2,
2703 Label* failure) { 2631 Label* failure) {
2704 // Test that both first and second are sequential one-byte strings. 2632 // Test that both first and second are sequential one-byte strings.
2705 // Assume that they are non-smis. 2633 // Assume that they are non-smis.
2706 LoadP(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); 2634 LoadP(scratch1, FieldMemOperand(first, HeapObject::kMapOffset));
2707 LoadP(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); 2635 LoadP(scratch2, FieldMemOperand(second, HeapObject::kMapOffset));
2708 lbz(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); 2636 lbz(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
2709 lbz(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); 2637 lbz(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset));
2710 2638
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
4426 } 4354 }
4427 if (mag.shift > 0) srawi(result, result, mag.shift); 4355 if (mag.shift > 0) srawi(result, result, mag.shift);
4428 ExtractBit(r0, dividend, 31); 4356 ExtractBit(r0, dividend, 31);
4429 add(result, result, r0); 4357 add(result, result, r0);
4430 } 4358 }
4431 4359
4432 } // namespace internal 4360 } // namespace internal
4433 } // namespace v8 4361 } // namespace v8
4434 4362
4435 #endif // V8_TARGET_ARCH_PPC 4363 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/macro-assembler-ppc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698