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

Side by Side Diff: src/arm/builtins-arm.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 | « no previous file | src/arm64/builtins-arm64.cc » ('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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // tail call a stub 116 // tail call a stub
117 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); 117 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
118 ArrayConstructorStub stub(masm->isolate()); 118 ArrayConstructorStub stub(masm->isolate());
119 __ TailCallStub(&stub); 119 __ TailCallStub(&stub);
120 } 120 }
121 121
122 122
123 // static 123 // static
124 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { 124 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
125 // ----------- S t a t e ------------- 125 // ----------- S t a t e -------------
126 // -- r0 : number of arguments 126 // -- r0 : number of arguments
127 // -- r1 : function 127 // -- r1 : function
128 // -- cp : context 128 // -- cp : context
129 // -- lr : return address 129 // -- lr : return address
130 // -- sp[(argc - n) * 8] : arg[n] (zero-based) 130 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
131 // -- sp[(argc + 1) * 8] : receiver 131 // -- sp[argc * 4] : receiver
132 // ----------------------------------- 132 // -----------------------------------
133 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt; 133 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt;
134 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi; 134 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi;
135 Heap::RootListIndex const root_index = 135 Heap::RootListIndex const root_index =
136 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex 136 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
137 : Heap::kMinusInfinityValueRootIndex; 137 : Heap::kMinusInfinityValueRootIndex;
138 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; 138 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1;
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 r5 and the double value in d1. 141 // +Infinity), with the tagged value in r5 and the double value in d1.
142 __ LoadRoot(r5, root_index); 142 __ LoadRoot(r5, root_index);
143 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); 143 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset));
144 144
145 // Remember how many slots to drop (including the receiver).
146 __ add(r4, r0, Operand(1));
147
148 Label done_loop, loop; 145 Label done_loop, loop;
146 __ mov(r4, r0);
149 __ bind(&loop); 147 __ bind(&loop);
150 { 148 {
151 // Check if all parameters done. 149 // Check if all parameters done.
152 __ sub(r0, r0, Operand(1), SetCC); 150 __ sub(r4, r4, Operand(1), SetCC);
153 __ b(lt, &done_loop); 151 __ b(lt, &done_loop);
154 152
155 // Load the next parameter tagged value into r2. 153 // Load the next parameter tagged value into r2.
156 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); 154 __ ldr(r2, MemOperand(sp, r4, 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, convert_smi, convert_number, done_convert; 158 Label convert, convert_smi, convert_number, done_convert;
161 __ bind(&convert); 159 __ bind(&convert);
162 __ JumpIfSmi(r2, &convert_smi); 160 __ JumpIfSmi(r2, &convert_smi);
163 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); 161 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
164 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); 162 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number);
165 { 163 {
166 // Parameter is not a Number, use the ToNumber builtin to convert it. 164 // Parameter is not a Number, use the ToNumber builtin to convert it.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 __ b(&loop); 213 __ b(&loop);
216 214
217 // At least one side is NaN, which means that the result will be NaN too. 215 // At least one side is NaN, which means that the result will be NaN too.
218 __ bind(&compare_nan); 216 __ bind(&compare_nan);
219 __ LoadRoot(r5, Heap::kNanValueRootIndex); 217 __ LoadRoot(r5, Heap::kNanValueRootIndex);
220 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); 218 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset));
221 __ b(&loop); 219 __ b(&loop);
222 } 220 }
223 221
224 __ bind(&done_loop); 222 __ bind(&done_loop);
223 // Drop all slots, including the receiver.
224 __ add(r0, r0, Operand(1));
225 __ Drop(r0);
225 __ mov(r0, r5); 226 __ mov(r0, r5);
226 __ Drop(r4);
227 __ Ret(); 227 __ Ret();
228 } 228 }
229 229
230 // static 230 // static
231 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 231 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
232 // ----------- S t a t e ------------- 232 // ----------- S t a t e -------------
233 // -- r0 : number of arguments 233 // -- r0 : number of arguments
234 // -- r1 : constructor function 234 // -- r1 : constructor function
235 // -- lr : return address 235 // -- lr : return address
236 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 236 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
(...skipping 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 } 2878 }
2879 } 2879 }
2880 2880
2881 2881
2882 #undef __ 2882 #undef __
2883 2883
2884 } // namespace internal 2884 } // namespace internal
2885 } // namespace v8 2885 } // namespace v8
2886 2886
2887 #endif // V8_TARGET_ARCH_ARM 2887 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698