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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 863633002: Use signaling NaN for holes in fixed double arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Restore SSE2 Created 5 years, 11 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
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
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 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 } 1710 }
1711 } 1711 }
1712 1712
1713 1713
1714 void LCodeGen::DoConstantS(LConstantS* instr) { 1714 void LCodeGen::DoConstantS(LConstantS* instr) {
1715 __ Move(ToRegister(instr->result()), instr->value()); 1715 __ Move(ToRegister(instr->result()), instr->value());
1716 } 1716 }
1717 1717
1718 1718
1719 void LCodeGen::DoConstantD(LConstantD* instr) { 1719 void LCodeGen::DoConstantD(LConstantD* instr) {
1720 DCHECK(instr->result()->IsDoubleRegister()); 1720 __ Move(ToDoubleRegister(instr->result()), instr->bits());
1721 XMMRegister res = ToDoubleRegister(instr->result());
1722 double v = instr->value();
1723 uint64_t int_val = bit_cast<uint64_t, double>(v);
1724 // Use xor to produce +0.0 in a fast and compact way, but avoid to
1725 // do so if the constant is -0.0.
1726 if (int_val == 0) {
1727 __ xorps(res, res);
1728 } else {
1729 Register tmp = ToRegister(instr->temp());
1730 __ Set(tmp, int_val);
1731 __ movq(res, tmp);
1732 }
1733 } 1721 }
1734 1722
1735 1723
1736 void LCodeGen::DoConstantE(LConstantE* instr) { 1724 void LCodeGen::DoConstantE(LConstantE* instr) {
1737 __ LoadAddress(ToRegister(instr->result()), instr->value()); 1725 __ LoadAddress(ToRegister(instr->result()), instr->value());
1738 } 1726 }
1739 1727
1740 1728
1741 void LCodeGen::DoConstantT(LConstantT* instr) { 1729 void LCodeGen::DoConstantT(LConstantT* instr) {
1742 Handle<Object> object = instr->value(isolate()); 1730 Handle<Object> object = instr->value(isolate());
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3978 3966
3979 void LCodeGen::DoMathLog(LMathLog* instr) { 3967 void LCodeGen::DoMathLog(LMathLog* instr) {
3980 DCHECK(instr->value()->Equals(instr->result())); 3968 DCHECK(instr->value()->Equals(instr->result()));
3981 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3969 XMMRegister input_reg = ToDoubleRegister(instr->value());
3982 XMMRegister xmm_scratch = double_scratch0(); 3970 XMMRegister xmm_scratch = double_scratch0();
3983 Label positive, done, zero; 3971 Label positive, done, zero;
3984 __ xorps(xmm_scratch, xmm_scratch); 3972 __ xorps(xmm_scratch, xmm_scratch);
3985 __ ucomisd(input_reg, xmm_scratch); 3973 __ ucomisd(input_reg, xmm_scratch);
3986 __ j(above, &positive, Label::kNear); 3974 __ j(above, &positive, Label::kNear);
3987 __ j(not_carry, &zero, Label::kNear); 3975 __ j(not_carry, &zero, Label::kNear);
3988 ExternalReference nan = 3976 __ pcmpeqd(input_reg, input_reg);
3989 ExternalReference::address_of_canonical_non_hole_nan();
3990 Operand nan_operand = masm()->ExternalOperand(nan);
3991 __ movsd(input_reg, nan_operand);
3992 __ jmp(&done, Label::kNear); 3977 __ jmp(&done, Label::kNear);
3993 __ bind(&zero); 3978 __ bind(&zero);
3994 ExternalReference ninf = 3979 ExternalReference ninf =
3995 ExternalReference::address_of_negative_infinity(); 3980 ExternalReference::address_of_negative_infinity();
3996 Operand ninf_operand = masm()->ExternalOperand(ninf); 3981 Operand ninf_operand = masm()->ExternalOperand(ninf);
3997 __ movsd(input_reg, ninf_operand); 3982 __ movsd(input_reg, ninf_operand);
3998 __ jmp(&done, Label::kNear); 3983 __ jmp(&done, Label::kNear);
3999 __ bind(&positive); 3984 __ bind(&positive);
4000 __ fldln2(); 3985 __ fldln2();
4001 __ subp(rsp, Immediate(kDoubleSize)); 3986 __ subp(rsp, Immediate(kDoubleSize));
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
4405 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { 4390 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
4406 XMMRegister value = ToDoubleRegister(instr->value()); 4391 XMMRegister value = ToDoubleRegister(instr->value());
4407 LOperand* key = instr->key(); 4392 LOperand* key = instr->key();
4408 if (kPointerSize == kInt32Size && !key->IsConstantOperand() && 4393 if (kPointerSize == kInt32Size && !key->IsConstantOperand() &&
4409 instr->hydrogen()->IsDehoisted()) { 4394 instr->hydrogen()->IsDehoisted()) {
4410 // Sign extend key because it could be a 32 bit negative value 4395 // Sign extend key because it could be a 32 bit negative value
4411 // and the dehoisted address computation happens in 64 bits 4396 // and the dehoisted address computation happens in 64 bits
4412 __ movsxlq(ToRegister(key), ToRegister(key)); 4397 __ movsxlq(ToRegister(key), ToRegister(key));
4413 } 4398 }
4414 if (instr->NeedsCanonicalization()) { 4399 if (instr->NeedsCanonicalization()) {
4415 Label have_value; 4400 XMMRegister xmm_scratch = double_scratch0();
4416 4401 // Turn potential sNaN value into qNaN.
4417 __ ucomisd(value, value); 4402 __ xorps(xmm_scratch, xmm_scratch);
4418 __ j(parity_odd, &have_value, Label::kNear); // NaN. 4403 __ subsd(value, xmm_scratch);
4419
4420 __ Set(kScratchRegister,
4421 bit_cast<uint64_t>(
4422 FixedDoubleArray::canonical_not_the_hole_nan_as_double()));
4423 __ movq(value, kScratchRegister);
4424
4425 __ bind(&have_value);
4426 } 4404 }
4427 4405
4428 Operand double_store_operand = BuildFastArrayOperand( 4406 Operand double_store_operand = BuildFastArrayOperand(
4429 instr->elements(), 4407 instr->elements(),
4430 key, 4408 key,
4431 instr->hydrogen()->key()->representation(), 4409 instr->hydrogen()->key()->representation(),
4432 FAST_DOUBLE_ELEMENTS, 4410 FAST_DOUBLE_ELEMENTS,
4433 instr->base_offset()); 4411 instr->base_offset());
4434 4412
4435 __ movsd(double_store_operand, value); 4413 __ movsd(double_store_operand, value);
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 } 4931 }
4954 __ jmp(&done, Label::kNear); 4932 __ jmp(&done, Label::kNear);
4955 4933
4956 if (can_convert_undefined_to_nan) { 4934 if (can_convert_undefined_to_nan) {
4957 __ bind(&convert); 4935 __ bind(&convert);
4958 4936
4959 // Convert undefined (and hole) to NaN. Compute NaN as 0/0. 4937 // Convert undefined (and hole) to NaN. Compute NaN as 0/0.
4960 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); 4938 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
4961 DeoptimizeIf(not_equal, instr, "not a heap number/undefined"); 4939 DeoptimizeIf(not_equal, instr, "not a heap number/undefined");
4962 4940
4963 __ xorps(result_reg, result_reg); 4941 __ pcmpeqd(result_reg, result_reg);
4964 __ divsd(result_reg, result_reg);
4965 __ jmp(&done, Label::kNear); 4942 __ jmp(&done, Label::kNear);
4966 } 4943 }
4967 } else { 4944 } else {
4968 DCHECK(mode == NUMBER_CANDIDATE_IS_SMI); 4945 DCHECK(mode == NUMBER_CANDIDATE_IS_SMI);
4969 } 4946 }
4970 4947
4971 // Smi to XMM conversion 4948 // Smi to XMM conversion
4972 __ bind(&load_smi); 4949 __ bind(&load_smi);
4973 __ SmiToInteger32(kScratchRegister, input_reg); 4950 __ SmiToInteger32(kScratchRegister, input_reg);
4974 __ Cvtlsi2sd(result_reg, kScratchRegister); 4951 __ Cvtlsi2sd(result_reg, kScratchRegister);
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
5931 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5908 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5932 RecordSafepoint(Safepoint::kNoLazyDeopt); 5909 RecordSafepoint(Safepoint::kNoLazyDeopt);
5933 } 5910 }
5934 5911
5935 5912
5936 #undef __ 5913 #undef __
5937 5914
5938 } } // namespace v8::internal 5915 } } // namespace v8::internal
5939 5916
5940 #endif // V8_TARGET_ARCH_X64 5917 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698