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

Unified Diff: src/ic/ic.cc

Issue 857783002: [turbofan] Make Factory::NewNumber() always return the minus_zero_value. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More tests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.cc ('k') | test/unittests/factory-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index 16dc6dc93c715a0f0c051cdb583e7b8028188c18..24689332ffb1a3279827e277919cc03d925efb8c 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -2499,6 +2499,19 @@ MaybeHandle<Object> BinaryOpIC::Transition(
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, Execution::Call(isolate(), function, left, 1, &right),
Object);
+ if (result->IsHeapNumber()) {
+ // If the result of this BinaryOpIC is used as left or right hand side of
+ // another binary operation, full-codegen.cc might have decided that its
+ // safe to reuse the double box returned by this BinaryOpIC, but the builtin
+ // above does not know or care about this fact and might return a canonical
+ // value (i.e. the global minus zero constant), which we would then
+ // overwrite in the surrounding binary operation. So to be safe, we need to
+ // take a copy of heap numbers here.
+ result = isolate()->factory()->NewHeapNumber(result->Number());
+ }
+ DCHECK(!result.is_identical_to(isolate()->factory()->nan_value()));
+ DCHECK(!result.is_identical_to(isolate()->factory()->infinity_value()));
+ DCHECK(!result.is_identical_to(isolate()->factory()->minus_zero_value()));
// Execution::Call can execute arbitrary JavaScript, hence potentially
// update the state of this very IC, so we must update the stored state.
« no previous file with comments | « src/factory.cc ('k') | test/unittests/factory-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698