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

Side by Side Diff: src/compiler/ppc/code-generator-ppc.cc

Issue 2888533003: PPC: Work around unintended snan to qnan conversion (Closed)
Patch Set: Rephrase the comment to make more sense Created 3 years, 7 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/ppc/simulator-ppc.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 break; 2446 break;
2447 } 2447 }
2448 if (destination->IsStackSlot()) { 2448 if (destination->IsStackSlot()) {
2449 __ StoreP(dst, g.ToMemOperand(destination), r0); 2449 __ StoreP(dst, g.ToMemOperand(destination), r0);
2450 } 2450 }
2451 } else { 2451 } else {
2452 DoubleRegister dst = destination->IsFPRegister() 2452 DoubleRegister dst = destination->IsFPRegister()
2453 ? g.ToDoubleRegister(destination) 2453 ? g.ToDoubleRegister(destination)
2454 : kScratchDoubleReg; 2454 : kScratchDoubleReg;
2455 double value; 2455 double value;
2456 // bit_cast of snan is converted to qnan on ia32/x64
2457 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 2456 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
2458 intptr_t valueInt = (src.type() == Constant::kFloat32) 2457 // casting double precision snan to single precision
2459 ? src.ToFloat32AsInt() 2458 // converts it to qnan on ia32/x64
2460 : src.ToFloat64AsInt(); 2459 if (src.type() == Constant::kFloat32) {
2461 if (valueInt == ((src.type() == Constant::kFloat32) 2460 int32_t val = src.ToFloat32AsInt();
2462 ? 0x7fa00000 2461 if ((val & 0x7f800000) == 0x7f800000) {
2463 : 0x7fa0000000000000)) { 2462 int64_t dval = static_cast<int64_t>(val);
2464 value = bit_cast<double, int64_t>(0x7ff4000000000000L); 2463 dval = ((dval & 0xc0000000) << 32) | ((dval & 0x40000000) << 31) |
2464 ((dval & 0x40000000) << 30) | ((dval & 0x7fffffff) << 29);
2465 value = bit_cast<double, int64_t>(dval);
2466 } else {
2467 value = src.ToFloat32();
2468 }
2465 } else { 2469 } else {
2466 #endif 2470 int64_t val = src.ToFloat64AsInt();
2467 value = (src.type() == Constant::kFloat32) ? src.ToFloat32() 2471 if ((val & 0x7f80000000000000) == 0x7f80000000000000) {
2472 value = bit_cast<double, int64_t>(val);
2473 } else {
2474 value = src.ToFloat64();
2475 }
2476 }
2477 #else
2478 value = (src.type() == Constant::kFloat32) ? src.ToFloat32()
2468 : src.ToFloat64(); 2479 : src.ToFloat64();
2469 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
2470 }
2471 #endif 2480 #endif
2472 __ LoadDoubleLiteral(dst, value, kScratchReg); 2481 __ LoadDoubleLiteral(dst, value, kScratchReg);
2473 if (destination->IsFPStackSlot()) { 2482 if (destination->IsFPStackSlot()) {
2474 __ StoreDouble(dst, g.ToMemOperand(destination), r0); 2483 __ StoreDouble(dst, g.ToMemOperand(destination), r0);
2475 } 2484 }
2476 } 2485 }
2477 } else if (source->IsFPRegister()) { 2486 } else if (source->IsFPRegister()) {
2478 DoubleRegister src = g.ToDoubleRegister(source); 2487 DoubleRegister src = g.ToDoubleRegister(source);
2479 if (destination->IsFPRegister()) { 2488 if (destination->IsFPRegister()) {
2480 DoubleRegister dst = g.ToDoubleRegister(destination); 2489 DoubleRegister dst = g.ToDoubleRegister(destination);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 padding_size -= v8::internal::Assembler::kInstrSize; 2620 padding_size -= v8::internal::Assembler::kInstrSize;
2612 } 2621 }
2613 } 2622 }
2614 } 2623 }
2615 2624
2616 #undef __ 2625 #undef __
2617 2626
2618 } // namespace compiler 2627 } // namespace compiler
2619 } // namespace internal 2628 } // namespace internal
2620 } // namespace v8 2629 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/ppc/simulator-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698