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

Unified Diff: src/x64/lithium-codegen-x64.cc

Issue 6369005: X64: Fix bug in DoBranch that miss detecting NaN as falsy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-x64
Patch Set: Copied changes from ia32 to lithium-x64.cc Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/x64/lithium-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 9938ff0fe0c09a5be482ad8d5e12962569e95ab5..dc988b1a652fa97bb2c97a2eb72888d0464518ec 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -977,25 +977,27 @@ void LCodeGen::DoBranch(LBranch* instr) {
Label* true_label = chunk_->GetAssemblyLabel(true_block);
Label* false_label = chunk_->GetAssemblyLabel(false_block);
- __ Cmp(reg, Factory::undefined_value());
+ __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
__ j(equal, false_label);
- __ Cmp(reg, Factory::true_value());
+ __ CompareRoot(reg, Heap::kTrueValueRootIndex);
__ j(equal, true_label);
- __ Cmp(reg, Factory::false_value());
+ __ CompareRoot(reg, Heap::kFalseValueRootIndex);
__ j(equal, false_label);
__ SmiCompare(reg, Smi::FromInt(0));
__ j(equal, false_label);
__ JumpIfSmi(reg, true_label);
- // Test for double values. Plus/minus zero are false. NaN is handled
- // in the stub.
+ // Test for double values. Plus/minus zero and NaN are false.
NearLabel call_stub;
- __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
- Factory::heap_number_map());
+ __ CompareRoot(FieldOperand(reg, HeapObject::kMapOffset),
+ Heap::kHeapNumberMapRootIndex);
__ j(not_equal, &call_stub);
- __ movq(kScratchRegister, FieldOperand(reg, HeapNumber::kValueOffset));
- __ shl(kScratchRegister, Immediate(1)); // Shift out the sign bit.
- __ j(zero, false_label); // Zero or negative zero.
+
+ // HeapNumber => false iff +0, -0, or NaN. These three cases set the
+ // zero flag when compared to zero using ucomisd.
+ __ xorpd(xmm0, xmm0);
+ __ ucomisd(xmm0, FieldOperand(reg, HeapNumber::kValueOffset));
+ __ j(zero, false_label);
__ jmp(true_label);
// The conversion stub doesn't cause garbage collections so it's
« no previous file with comments | « no previous file | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698