[turbofan] Only consider inhabited types for constant folding in typed lowering.
BUG=chromium:621423 Review-Url: https://codereview.chromium.org/2084483002 Cr-Commit-Position: refs/heads/master@{#37092}
This commit is contained in:
parent
093df3fafc
commit
50d6837ada
@ -1849,30 +1849,33 @@ Reduction JSTypedLowering::Reduce(Node* node) {
|
||||
if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) &&
|
||||
node->op()->HasProperty(Operator::kEliminatable)) {
|
||||
Type* upper = NodeProperties::GetType(node);
|
||||
if (upper->IsConstant()) {
|
||||
Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::MinusZero())) {
|
||||
Node* replacement = jsgraph()->Constant(factory()->minus_zero_value());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::NaN())) {
|
||||
Node* replacement = jsgraph()->NaNConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::Null())) {
|
||||
Node* replacement = jsgraph()->NullConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::PlainNumber()) && upper->Min() == upper->Max()) {
|
||||
Node* replacement = jsgraph()->Constant(upper->Min());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::Undefined())) {
|
||||
Node* replacement = jsgraph()->UndefinedConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
if (upper->IsInhabited()) {
|
||||
if (upper->IsConstant()) {
|
||||
Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::MinusZero())) {
|
||||
Node* replacement = jsgraph()->Constant(factory()->minus_zero_value());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::NaN())) {
|
||||
Node* replacement = jsgraph()->NaNConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::Null())) {
|
||||
Node* replacement = jsgraph()->NullConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::PlainNumber()) &&
|
||||
upper->Min() == upper->Max()) {
|
||||
Node* replacement = jsgraph()->Constant(upper->Min());
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
} else if (upper->Is(Type::Undefined())) {
|
||||
Node* replacement = jsgraph()->UndefinedConstant();
|
||||
ReplaceWithValue(node, replacement);
|
||||
return Changed(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (node->opcode()) {
|
||||
|
21
test/mjsunit/compiler/regress-621423.js
Normal file
21
test/mjsunit/compiler/regress-621423.js
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
var a = [0, ""];
|
||||
a[0] = 0;
|
||||
|
||||
function g(array) {
|
||||
array[1] = undefined;
|
||||
}
|
||||
|
||||
function f() {
|
||||
g(function() {});
|
||||
g(a);
|
||||
}
|
||||
|
||||
f();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f();
|
Loading…
Reference in New Issue
Block a user