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

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

Issue 1818923002: [stubs] Split ToNumberStub into reusable subparts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE 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 | « src/mips/macro-assembler-mips.cc ('k') | src/mips64/macro-assembler-mips64.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 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 #if V8_TARGET_ARCH_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 2794
2795 void ToNumberStub::Generate(MacroAssembler* masm) { 2795 void ToNumberStub::Generate(MacroAssembler* masm) {
2796 // The ToNumber stub takes one argument in a0. 2796 // The ToNumber stub takes one argument in a0.
2797 Label not_smi; 2797 Label not_smi;
2798 __ JumpIfNotSmi(a0, &not_smi); 2798 __ JumpIfNotSmi(a0, &not_smi);
2799 __ Ret(USE_DELAY_SLOT); 2799 __ Ret(USE_DELAY_SLOT);
2800 __ mov(v0, a0); 2800 __ mov(v0, a0);
2801 __ bind(&not_smi); 2801 __ bind(&not_smi);
2802 2802
2803 Label not_heap_number; 2803 Label not_heap_number;
2804 __ ld(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); 2804 __ GetObjectType(a0, a1, a1);
2805 __ lbu(a1, FieldMemOperand(a1, Map::kInstanceTypeOffset)); 2805 // a0: receiver
2806 // a0: object 2806 // a1: receiver instance type
2807 // a1: instance type.
2808 __ Branch(&not_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); 2807 __ Branch(&not_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE));
2809 __ Ret(USE_DELAY_SLOT); 2808 __ Ret(USE_DELAY_SLOT);
2810 __ mov(v0, a0); 2809 __ mov(v0, a0);
2811 __ bind(&not_heap_number); 2810 __ bind(&not_heap_number);
2812 2811
2813 Label not_string, slow_string; 2812 NonNumberToNumberStub stub(masm->isolate());
2813 __ TailCallStub(&stub);
2814 }
2815
2816 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2817 // The NonNumberToNumber stub takes on argument in a0.
2818 __ AssertNotNumber(a0);
2819
2820 Label not_string;
2821 __ GetObjectType(a0, a1, a1);
2822 // a0: receiver
2823 // a1: receiver instance type
2814 __ Branch(&not_string, hs, a1, Operand(FIRST_NONSTRING_TYPE)); 2824 __ Branch(&not_string, hs, a1, Operand(FIRST_NONSTRING_TYPE));
2815 // Check if string has a cached array index. 2825 StringToNumberStub stub(masm->isolate());
2816 __ lwu(a2, FieldMemOperand(a0, String::kHashFieldOffset)); 2826 __ TailCallStub(&stub);
2817 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask));
2818 __ Branch(&slow_string, ne, at, Operand(zero_reg));
2819 __ IndexFromHash(a2, a0);
2820 __ Ret(USE_DELAY_SLOT);
2821 __ mov(v0, a0);
2822 __ bind(&slow_string);
2823 __ push(a0); // Push argument.
2824 __ TailCallRuntime(Runtime::kStringToNumber);
2825 __ bind(&not_string); 2827 __ bind(&not_string);
2826 2828
2827 Label not_oddball; 2829 Label not_oddball;
2828 __ Branch(&not_oddball, ne, a1, Operand(ODDBALL_TYPE)); 2830 __ Branch(&not_oddball, ne, a1, Operand(ODDBALL_TYPE));
2829 __ Ret(USE_DELAY_SLOT); 2831 __ Ret(USE_DELAY_SLOT);
2830 __ ld(v0, FieldMemOperand(a0, Oddball::kToNumberOffset)); 2832 __ ld(v0, FieldMemOperand(a0, Oddball::kToNumberOffset)); // In delay slot.
2831 __ bind(&not_oddball); 2833 __ bind(&not_oddball);
2832 2834
2833 __ push(a0); // Push argument. 2835 __ Push(a0); // Push argument.
2834 __ TailCallRuntime(Runtime::kToNumber); 2836 __ TailCallRuntime(Runtime::kToNumber);
2835 } 2837 }
2836 2838
2839 void StringToNumberStub::Generate(MacroAssembler* masm) {
2840 // The StringToNumber stub takes on argument in a0.
2841 __ AssertString(a0);
2842
2843 // Check if string has a cached array index.
2844 Label runtime;
2845 __ lwu(a2, FieldMemOperand(a0, String::kHashFieldOffset));
2846 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask));
2847 __ Branch(&runtime, ne, at, Operand(zero_reg));
2848 __ IndexFromHash(a2, v0);
2849 __ Ret(USE_DELAY_SLOT);
2850 __ mov(v0, a0); // In delay slot.
2851
2852 __ bind(&runtime);
2853 __ Push(a0); // Push argument.
2854 __ TailCallRuntime(Runtime::kStringToNumber);
2855 }
2837 2856
2838 void ToLengthStub::Generate(MacroAssembler* masm) { 2857 void ToLengthStub::Generate(MacroAssembler* masm) {
2839 // The ToLength stub takes on argument in a0. 2858 // The ToLength stub takes on argument in a0.
2840 Label not_smi, positive_smi; 2859 Label not_smi, positive_smi;
2841 __ JumpIfNotSmi(a0, &not_smi); 2860 __ JumpIfNotSmi(a0, &not_smi);
2842 STATIC_ASSERT(kSmiTag == 0); 2861 STATIC_ASSERT(kSmiTag == 0);
2843 __ Branch(&positive_smi, ge, a0, Operand(zero_reg)); 2862 __ Branch(&positive_smi, ge, a0, Operand(zero_reg));
2844 __ mov(a0, zero_reg); 2863 __ mov(a0, zero_reg);
2845 __ bind(&positive_smi); 2864 __ bind(&positive_smi);
2846 __ Ret(USE_DELAY_SLOT); 2865 __ Ret(USE_DELAY_SLOT);
(...skipping 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after
5772 return_value_operand, NULL); 5791 return_value_operand, NULL);
5773 } 5792 }
5774 5793
5775 5794
5776 #undef __ 5795 #undef __
5777 5796
5778 } // namespace internal 5797 } // namespace internal
5779 } // namespace v8 5798 } // namespace v8
5780 5799
5781 #endif // V8_TARGET_ARCH_MIPS64 5800 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | src/mips64/macro-assembler-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698