Commit 0554e36b authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Remove typeof optimization from typed lowering.

Now that Ignition has the dedicated TestTypeOf operator, there's not
really a point in doing the typeof with abstract/strict equal combining
in TurboFan anymore. In fact it's counter-productive to do so, as it
might try to cover typeof comparisons in cases where it's better to just
compute the typeof once, i.e.:

  let x = typeof a, y = typeof b;
  if (x === y) {
    if (x === 'string') {
      ...
    }
  }

Here we would combine the second comparison into an ObjectIsString, and
still compute the typeof a.

R=jarin@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2780953003
Cr-Commit-Position: refs/heads/master@{#44220}
parent ab4c9190
......@@ -842,63 +842,7 @@ Reduction JSTypedLowering::ReduceJSTypeOf(Node* node) {
return NoChange();
}
Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node) {
Node* input;
Handle<String> type;
HeapObjectBinopMatcher m(node);
if (m.left().IsJSTypeOf() && m.right().HasValue() &&
m.right().Value()->IsString()) {
input = m.left().InputAt(0);
type = Handle<String>::cast(m.right().Value());
} else if (m.right().IsJSTypeOf() && m.left().HasValue() &&
m.left().Value()->IsString()) {
input = m.right().InputAt(0);
type = Handle<String>::cast(m.left().Value());
} else {
return NoChange();
}
Node* value;
if (String::Equals(type, factory()->boolean_string())) {
value =
graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
graph()->NewNode(simplified()->ReferenceEqual(), input,
jsgraph()->TrueConstant()),
jsgraph()->TrueConstant(),
graph()->NewNode(simplified()->ReferenceEqual(), input,
jsgraph()->FalseConstant()));
} else if (String::Equals(type, factory()->function_string())) {
value = graph()->NewNode(simplified()->ObjectIsDetectableCallable(), input);
} else if (String::Equals(type, factory()->number_string())) {
value = graph()->NewNode(simplified()->ObjectIsNumber(), input);
} else if (String::Equals(type, factory()->object_string())) {
value = graph()->NewNode(
common()->Select(MachineRepresentation::kTagged),
graph()->NewNode(simplified()->ObjectIsNonCallable(), input),
jsgraph()->TrueConstant(),
graph()->NewNode(simplified()->ReferenceEqual(), input,
jsgraph()->NullConstant()));
} else if (String::Equals(type, factory()->string_string())) {
value = graph()->NewNode(simplified()->ObjectIsString(), input);
} else if (String::Equals(type, factory()->symbol_string())) {
value = graph()->NewNode(simplified()->ObjectIsSymbol(), input);
} else if (String::Equals(type, factory()->undefined_string())) {
value = graph()->NewNode(
common()->Select(MachineRepresentation::kTagged),
graph()->NewNode(simplified()->ReferenceEqual(), input,
jsgraph()->NullConstant()),
jsgraph()->FalseConstant(),
graph()->NewNode(simplified()->ObjectIsUndetectable(), input));
} else {
return NoChange();
}
ReplaceWithValue(node, value);
return Replace(value);
}
Reduction JSTypedLowering::ReduceJSEqual(Node* node) {
Reduction const reduction = ReduceJSEqualTypeOf(node);
if (reduction.Changed()) return reduction;
JSBinopReduction r(this, node);
if (r.BothInputsAre(Type::UniqueName())) {
......@@ -961,9 +905,6 @@ Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node) {
}
}
Reduction const reduction = ReduceJSEqualTypeOf(node);
if (reduction.Changed()) return reduction;
if (r.BothInputsAre(Type::Unique())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual());
}
......
......@@ -57,7 +57,6 @@ class V8_EXPORT_PRIVATE JSTypedLowering final
Reduction ReduceJSStoreContext(Node* node);
Reduction ReduceJSLoadModule(Node* node);
Reduction ReduceJSStoreModule(Node* node);
Reduction ReduceJSEqualTypeOf(Node* node);
Reduction ReduceJSEqual(Node* node);
Reduction ReduceJSStrictEqual(Node* node);
Reduction ReduceJSToBoolean(Node* node);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment