From 3071a64f5fb8a8b387016178268cccfafd801ee0 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Wed, 3 Sep 2014 11:35:19 +0000 Subject: [PATCH] Fix typed lowering of JSToBoolean on number inputs. R=titzer@chromium.org TEST=cctest/test-js-typed-lowering/JSToBoolean_replacement Review URL: https://codereview.chromium.org/533103002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23642 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler/js-typed-lowering.cc | 5 +---- test/cctest/compiler/test-js-typed-lowering.cc | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 6fad5ab..772ab0e 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -491,10 +491,7 @@ Reduction JSTypedLowering::ReduceJSToBooleanInput(Node* input) { Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input, jsgraph()->ZeroConstant()); Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp); - ReplaceEagerly(input, inv); - // TODO(titzer): Ugly. ReplaceEagerly smashes all uses. Smash it back here. - cmp->ReplaceInput(0, input); - return Changed(inv); + return ReplaceWith(inv); } // TODO(turbofan): js-typed-lowering of ToBoolean(string) return NoChange(); diff --git a/test/cctest/compiler/test-js-typed-lowering.cc b/test/cctest/compiler/test-js-typed-lowering.cc index 0bee87a..9d0d720 100644 --- a/test/cctest/compiler/test-js-typed-lowering.cc +++ b/test/cctest/compiler/test-js-typed-lowering.cc @@ -506,7 +506,8 @@ TEST(JSToBoolean) { TEST(JSToBoolean_replacement) { JSTypedLoweringTester R; - Type* types[] = {Type::Null(), Type::Undefined(), Type::Boolean(), + Type* types[] = {Type::Null(), Type::Undefined(), + Type::Boolean(), Type::Number(), Type::DetectableObject(), Type::Undetectable()}; for (size_t i = 0; i < arraysize(types); i++) { @@ -521,6 +522,8 @@ TEST(JSToBoolean_replacement) { if (types[i]->Is(Type::Boolean())) { CHECK_EQ(n, r); + } else if (types[i]->Is(Type::Number())) { + CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); } else { CHECK_EQ(IrOpcode::kHeapConstant, r->opcode()); } -- 2.7.4