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

Side by Side Diff: src/ppc/code-stubs-ppc.cc

Issue 1826483002: PPC: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | src/ppc/macro-assembler-ppc.h » ('j') | 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 #if V8_TARGET_ARCH_PPC 5 #if V8_TARGET_ARCH_PPC
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 STRING_INDEX_IS_NUMBER, RECEIVER_IS_STRING); 2691 STRING_INDEX_IS_NUMBER, RECEIVER_IS_STRING);
2692 generator.GenerateFast(masm); 2692 generator.GenerateFast(masm);
2693 __ Drop(3); 2693 __ Drop(3);
2694 __ Ret(); 2694 __ Ret();
2695 generator.SkipSlow(masm, &runtime); 2695 generator.SkipSlow(masm, &runtime);
2696 } 2696 }
2697 2697
2698 2698
2699 void ToNumberStub::Generate(MacroAssembler* masm) { 2699 void ToNumberStub::Generate(MacroAssembler* masm) {
2700 // The ToNumber stub takes one argument in r3. 2700 // The ToNumber stub takes one argument in r3.
2701 Label not_smi; 2701 STATIC_ASSERT(kSmiTag == 0);
2702 __ JumpIfNotSmi(r3, &not_smi); 2702 __ TestIfSmi(r3, r0);
2703 __ blr(); 2703 __ Ret(eq, cr0);
2704 __ bind(&not_smi);
2705 2704
2706 __ CompareObjectType(r3, r4, r4, HEAP_NUMBER_TYPE); 2705 __ CompareObjectType(r3, r4, r4, HEAP_NUMBER_TYPE);
2707 // r3: receiver 2706 // r3: receiver
2708 // r4: receiver instance type 2707 // r4: receiver instance type
2709 __ Ret(eq); 2708 __ Ret(eq);
2710 2709
2711 Label not_string, slow_string; 2710 NonNumberToNumberStub stub(masm->isolate());
2712 __ cmpli(r4, Operand(FIRST_NONSTRING_TYPE)); 2711 __ TailCallStub(&stub);
2713 __ bge(&not_string); 2712 }
2714 // Check if string has a cached array index. 2713
2715 __ lwz(r5, FieldMemOperand(r3, String::kHashFieldOffset)); 2714 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2716 __ And(r0, r5, Operand(String::kContainsCachedArrayIndexMask), SetRC); 2715 // The NonNumberToNumber stub takes one argument in r3.
2717 __ bne(&slow_string, cr0); 2716 __ AssertNotNumber(r3);
2718 __ IndexFromHash(r5, r3); 2717
2719 __ blr(); 2718 __ CompareObjectType(r3, r4, r4, FIRST_NONSTRING_TYPE);
2720 __ bind(&slow_string); 2719 // r3: receiver
2721 __ push(r3); // Push argument. 2720 // r4: receiver instance type
2722 __ TailCallRuntime(Runtime::kStringToNumber); 2721 StringToNumberStub stub(masm->isolate());
2723 __ bind(&not_string); 2722 __ TailCallStub(&stub, lt);
2724 2723
2725 Label not_oddball; 2724 Label not_oddball;
2726 __ cmpi(r4, Operand(ODDBALL_TYPE)); 2725 __ cmpi(r4, Operand(ODDBALL_TYPE));
2727 __ bne(&not_oddball); 2726 __ bne(&not_oddball);
2728 __ LoadP(r3, FieldMemOperand(r3, Oddball::kToNumberOffset)); 2727 __ LoadP(r3, FieldMemOperand(r3, Oddball::kToNumberOffset));
2729 __ blr(); 2728 __ blr();
2730 __ bind(&not_oddball); 2729 __ bind(&not_oddball);
2731 2730
2732 __ push(r3); // Push argument. 2731 __ push(r3); // Push argument.
2733 __ TailCallRuntime(Runtime::kToNumber); 2732 __ TailCallRuntime(Runtime::kToNumber);
2734 } 2733 }
2735 2734
2735 void StringToNumberStub::Generate(MacroAssembler* masm) {
2736 // The StringToNumber stub takes one argument in r3.
2737 __ AssertString(r3);
2738
2739 // Check if string has a cached array index.
2740 Label runtime;
2741 __ lwz(r5, FieldMemOperand(r3, String::kHashFieldOffset));
2742 __ And(r0, r5, Operand(String::kContainsCachedArrayIndexMask), SetRC);
2743 __ bne(&runtime, cr0);
2744 __ IndexFromHash(r5, r3);
2745 __ blr();
2746
2747 __ bind(&runtime);
2748 __ push(r3); // Push argument.
2749 __ TailCallRuntime(Runtime::kStringToNumber);
2750 }
2736 2751
2737 void ToLengthStub::Generate(MacroAssembler* masm) { 2752 void ToLengthStub::Generate(MacroAssembler* masm) {
2738 // The ToLength stub takes one argument in r3. 2753 // The ToLength stub takes one argument in r3.
2739 Label not_smi; 2754 Label not_smi;
2740 __ JumpIfNotSmi(r3, &not_smi); 2755 __ JumpIfNotSmi(r3, &not_smi);
2741 STATIC_ASSERT(kSmiTag == 0); 2756 STATIC_ASSERT(kSmiTag == 0);
2742 __ cmpi(r3, Operand::Zero()); 2757 __ cmpi(r3, Operand::Zero());
2743 if (CpuFeatures::IsSupported(ISELECT)) { 2758 if (CpuFeatures::IsSupported(ISELECT)) {
2744 __ isel(lt, r3, r0, r3); 2759 __ isel(lt, r3, r0, r3);
2745 } else { 2760 } else {
(...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after
5789 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5804 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5790 kStackUnwindSpace, NULL, return_value_operand, NULL); 5805 kStackUnwindSpace, NULL, return_value_operand, NULL);
5791 } 5806 }
5792 5807
5793 5808
5794 #undef __ 5809 #undef __
5795 } // namespace internal 5810 } // namespace internal
5796 } // namespace v8 5811 } // namespace v8
5797 5812
5798 #endif // V8_TARGET_ARCH_PPC 5813 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | src/ppc/macro-assembler-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698