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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2084483002: [turbofan] Only consider inhabited types for constant folding in typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | test/mjsunit/compiler/regress-621423.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 09b9ffdf424c0f20d0caf42b7fef089d02ba95b0..f8c297ab615b775f73f494f0d5919375b4b595e4 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -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()) {
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-621423.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698