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

Side by Side Diff: src/crankshaft/ia32/lithium-codegen-ia32.cc

Issue 1841513003: [crankshaft] Address the deoptimization loops of Math.floor, Math.round and Math.ceil. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Register constraints in Crankshaft are fun Created 4 years, 8 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/crankshaft/hydrogen-instructions.cc ('k') | src/crankshaft/ia32/lithium-ia32.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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h" 7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h"
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 DeferredMathAbsTaggedHeapNumber* deferred = 3170 DeferredMathAbsTaggedHeapNumber* deferred =
3171 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr); 3171 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr);
3172 Register input_reg = ToRegister(instr->value()); 3172 Register input_reg = ToRegister(instr->value());
3173 // Smi check. 3173 // Smi check.
3174 __ JumpIfNotSmi(input_reg, deferred->entry()); 3174 __ JumpIfNotSmi(input_reg, deferred->entry());
3175 EmitIntegerMathAbs(instr); 3175 EmitIntegerMathAbs(instr);
3176 __ bind(deferred->exit()); 3176 __ bind(deferred->exit());
3177 } 3177 }
3178 } 3178 }
3179 3179
3180 void LCodeGen::DoMathFloorD(LMathFloorD* instr) {
3181 XMMRegister output_reg = ToDoubleRegister(instr->result());
3182 XMMRegister input_reg = ToDoubleRegister(instr->value());
3183 CpuFeatureScope scope(masm(), SSE4_1);
3184 __ roundsd(output_reg, input_reg, kRoundDown);
3185 }
3180 3186
3181 void LCodeGen::DoMathFloor(LMathFloor* instr) { 3187 void LCodeGen::DoMathFloorI(LMathFloorI* instr) {
3182 XMMRegister xmm_scratch = double_scratch0(); 3188 XMMRegister xmm_scratch = double_scratch0();
3183 Register output_reg = ToRegister(instr->result()); 3189 Register output_reg = ToRegister(instr->result());
3184 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3190 XMMRegister input_reg = ToDoubleRegister(instr->value());
3185 3191
3186 if (CpuFeatures::IsSupported(SSE4_1)) { 3192 if (CpuFeatures::IsSupported(SSE4_1)) {
3187 CpuFeatureScope scope(masm(), SSE4_1); 3193 CpuFeatureScope scope(masm(), SSE4_1);
3188 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3194 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3189 // Deoptimize on negative zero. 3195 // Deoptimize on negative zero.
3190 Label non_zero; 3196 Label non_zero;
3191 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. 3197 __ xorps(xmm_scratch, xmm_scratch); // Zero the register.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 __ Cvtsi2sd(xmm_scratch, output_reg); 3241 __ Cvtsi2sd(xmm_scratch, output_reg);
3236 __ ucomisd(input_reg, xmm_scratch); 3242 __ ucomisd(input_reg, xmm_scratch);
3237 __ j(equal, &done, Label::kNear); 3243 __ j(equal, &done, Label::kNear);
3238 __ sub(output_reg, Immediate(1)); 3244 __ sub(output_reg, Immediate(1));
3239 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow); 3245 DeoptimizeIf(overflow, instr, Deoptimizer::kOverflow);
3240 3246
3241 __ bind(&done); 3247 __ bind(&done);
3242 } 3248 }
3243 } 3249 }
3244 3250
3251 void LCodeGen::DoMathRoundD(LMathRoundD* instr) {
3252 XMMRegister xmm_scratch = double_scratch0();
3253 XMMRegister output_reg = ToDoubleRegister(instr->result());
3254 XMMRegister input_reg = ToDoubleRegister(instr->value());
3255 CpuFeatureScope scope(masm(), SSE4_1);
3256 Label done;
3257 __ roundsd(output_reg, input_reg, kRoundUp);
3258 __ Move(xmm_scratch, -0.5);
3259 __ addsd(xmm_scratch, output_reg);
3260 __ ucomisd(xmm_scratch, input_reg);
3261 __ j(below_equal, &done, Label::kNear);
3262 __ Move(xmm_scratch, 1.0);
3263 __ subsd(output_reg, xmm_scratch);
3264 __ bind(&done);
3265 }
3245 3266
3246 void LCodeGen::DoMathRound(LMathRound* instr) { 3267 void LCodeGen::DoMathRoundI(LMathRoundI* instr) {
3247 Register output_reg = ToRegister(instr->result()); 3268 Register output_reg = ToRegister(instr->result());
3248 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3269 XMMRegister input_reg = ToDoubleRegister(instr->value());
3249 XMMRegister xmm_scratch = double_scratch0(); 3270 XMMRegister xmm_scratch = double_scratch0();
3250 XMMRegister input_temp = ToDoubleRegister(instr->temp()); 3271 XMMRegister input_temp = ToDoubleRegister(instr->temp());
3251 ExternalReference one_half = ExternalReference::address_of_one_half(); 3272 ExternalReference one_half = ExternalReference::address_of_one_half();
3252 ExternalReference minus_one_half = 3273 ExternalReference minus_one_half =
3253 ExternalReference::address_of_minus_one_half(); 3274 ExternalReference::address_of_minus_one_half();
3254 3275
3255 Label done, round_to_zero, below_one_half, do_not_compensate; 3276 Label done, round_to_zero, below_one_half, do_not_compensate;
3256 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; 3277 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); 5287 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context);
5267 } 5288 }
5268 5289
5269 5290
5270 #undef __ 5291 #undef __
5271 5292
5272 } // namespace internal 5293 } // namespace internal
5273 } // namespace v8 5294 } // namespace v8
5274 5295
5275 #endif // V8_TARGET_ARCH_IA32 5296 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen-instructions.cc ('k') | src/crankshaft/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698