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

Side by Side Diff: src/arm64/builtins-arm64.cc

Issue 2112883002: [builtins] Fix MathMaxMin on arm and arm64 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/arm/builtins-arm.cc ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); 117 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
118 __ Mov(x3, x1); 118 __ Mov(x3, x1);
119 ArrayConstructorStub stub(masm->isolate()); 119 ArrayConstructorStub stub(masm->isolate());
120 __ TailCallStub(&stub); 120 __ TailCallStub(&stub);
121 } 121 }
122 122
123 123
124 // static 124 // static
125 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { 125 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
126 // ----------- S t a t e ------------- 126 // ----------- S t a t e -------------
127 // -- x0 : number of arguments 127 // -- x0 : number of arguments
128 // -- x1 : function 128 // -- x1 : function
129 // -- cp : context 129 // -- cp : context
130 // -- lr : return address 130 // -- lr : return address
131 // -- sp[(argc - n) * 8] : arg[n] (zero-based) 131 // -- sp[(argc - n - 1) * 8] : arg[n] (zero-based)
132 // -- sp[(argc + 1) * 8] : receiver 132 // -- sp[argc * 8] : receiver
133 // ----------------------------------- 133 // -----------------------------------
134 ASM_LOCATION("Builtins::Generate_MathMaxMin"); 134 ASM_LOCATION("Builtins::Generate_MathMaxMin");
135 135
136 Heap::RootListIndex const root_index = 136 Heap::RootListIndex const root_index =
137 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex 137 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
138 : Heap::kMinusInfinityValueRootIndex; 138 : Heap::kMinusInfinityValueRootIndex;
139 139
140 // Load the accumulator with the default return value (either -Infinity or 140 // Load the accumulator with the default return value (either -Infinity or
141 // +Infinity), with the tagged value in x5 and the double value in d5. 141 // +Infinity), with the tagged value in x5 and the double value in d5.
142 __ LoadRoot(x5, root_index); 142 __ LoadRoot(x5, root_index);
143 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); 143 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset));
144 144
145 // Remember how many slots to drop (including the receiver).
146 __ Add(x4, x0, 1);
147
148 Label done_loop, loop; 145 Label done_loop, loop;
146 __ mov(x4, x0);
149 __ Bind(&loop); 147 __ Bind(&loop);
150 { 148 {
151 // Check if all parameters done. 149 // Check if all parameters done.
152 __ Subs(x0, x0, 1); 150 __ Subs(x4, x4, 1);
153 __ B(lt, &done_loop); 151 __ B(lt, &done_loop);
154 152
155 // Load the next parameter tagged value into x2. 153 // Load the next parameter tagged value into x2.
156 __ Peek(x2, Operand(x0, LSL, kPointerSizeLog2)); 154 __ Peek(x2, Operand(x4, LSL, kPointerSizeLog2));
157 155
158 // Load the double value of the parameter into d2, maybe converting the 156 // Load the double value of the parameter into d2, maybe converting the
159 // parameter to a number first using the ToNumber builtin if necessary. 157 // parameter to a number first using the ToNumber builtin if necessary.
160 Label convert_smi, convert_number, done_convert; 158 Label convert_smi, convert_number, done_convert;
161 __ JumpIfSmi(x2, &convert_smi); 159 __ JumpIfSmi(x2, &convert_smi);
162 __ JumpIfHeapNumber(x2, &convert_number); 160 __ JumpIfHeapNumber(x2, &convert_number);
163 { 161 {
164 // Parameter is not a Number, use the ToNumber builtin to convert it. 162 // Parameter is not a Number, use the ToNumber builtin to convert it.
165 FrameScope scope(masm, StackFrame::MANUAL); 163 FrameScope scope(masm, StackFrame::MANUAL);
166 __ Push(lr, fp); 164 __ Push(lr, fp);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 DCHECK(kind == MathMaxMinKind::kMax); 203 DCHECK(kind == MathMaxMinKind::kMax);
206 __ Fmax(d5, d5, d2); 204 __ Fmax(d5, d5, d2);
207 } 205 }
208 __ Fmov(x10, d5); 206 __ Fmov(x10, d5);
209 __ Cmp(x10, x11); 207 __ Cmp(x10, x11);
210 __ Csel(x5, x5, x2, eq); 208 __ Csel(x5, x5, x2, eq);
211 __ B(&loop); 209 __ B(&loop);
212 } 210 }
213 211
214 __ Bind(&done_loop); 212 __ Bind(&done_loop);
215 __ Drop(x4); 213 // Drop all slots, including the receiver.
214 __ Add(x0, x0, 1);
215 __ Drop(x0);
216 __ Mov(x0, x5); 216 __ Mov(x0, x5);
217 __ Ret(); 217 __ Ret();
218 } 218 }
219 219
220 // static 220 // static
221 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 221 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
222 // ----------- S t a t e ------------- 222 // ----------- S t a t e -------------
223 // -- x0 : number of arguments 223 // -- x0 : number of arguments
224 // -- x1 : constructor function 224 // -- x1 : constructor function
225 // -- lr : return address 225 // -- lr : return address
(...skipping 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 } 3001 }
3002 } 3002 }
3003 3003
3004 3004
3005 #undef __ 3005 #undef __
3006 3006
3007 } // namespace internal 3007 } // namespace internal
3008 } // namespace v8 3008 } // namespace v8
3009 3009
3010 #endif // V8_TARGET_ARCH_ARM 3010 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698