From f292c4f78e3f793daa6a04bd9357a3c1fc491f67 Mon Sep 17 00:00:00 2001 From: "neis@chromium.org" Date: Mon, 29 Sep 2014 13:15:41 +0000 Subject: [PATCH] Take output type into account in JSTypedLowering reduction. R=rossberg@chromium.org BUG= Review URL: https://codereview.chromium.org/607033002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24287 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler/js-typed-lowering.cc | 9 +++++++++ src/compiler/opcodes.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 39104bb..e6610a7 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -630,6 +630,15 @@ static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { Reduction JSTypedLowering::Reduce(Node* node) { + // Check if the output type is a singleton. In that case we already know the + // result value and can simply replace the node unless there are effects. + if (node->bounds().upper->IsConstant() && + !IrOpcode::IsLeafOpcode(node->opcode()) && + !OperatorProperties::HasEffectOutput(node->op())) { + return ReplaceEagerly(node, jsgraph()->Constant( + node->bounds().upper->AsConstant()->Value())); + // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? + } switch (node->opcode()) { case IrOpcode::kJSEqual: return ReduceJSEqual(node, false); diff --git a/src/compiler/opcodes.h b/src/compiler/opcodes.h index e210abd..80d772d 100644 --- a/src/compiler/opcodes.h +++ b/src/compiler/opcodes.h @@ -289,6 +289,18 @@ class IrOpcode { } } + static bool IsLeafOpcode(Value val) { + switch (val) { +#define RETURN_NAME(x) \ + case k##x: \ + return true; + LEAF_OP_LIST(RETURN_NAME) +#undef RETURN_NAME + default: + return false; + } + } + static bool IsCommonOpcode(Value val) { switch (val) { #define RETURN_NAME(x) \ -- 2.7.4