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

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

Issue 2642743003: [turbofan] Also recognize 'type' === typeof x. (Closed)
Patch Set: Created 3 years, 11 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 | no next file » | 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 bd532b9d8b8757f021330c08cded31015ca81a83..01775ced41ddb4f8598fe8234b475652fe3f81e1 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -872,43 +872,50 @@ Reduction JSTypedLowering::ReduceJSTypeOf(Node* node) {
}
Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node, bool invert) {
+ Node* input;
+ Handle<String> type;
HeapObjectBinopMatcher m(node);
if (m.left().IsJSTypeOf() && m.right().HasValue() &&
m.right().Value()->IsString()) {
- Node* replacement;
- Node* input = m.left().InputAt(0);
- Handle<String> value = Handle<String>::cast(m.right().Value());
- if (String::Equals(value, factory()->boolean_string())) {
- replacement =
- 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(value, factory()->function_string())) {
- replacement = graph()->NewNode(simplified()->ObjectIsCallable(), input);
- } else if (String::Equals(value, factory()->number_string())) {
- replacement = graph()->NewNode(simplified()->ObjectIsNumber(), input);
- } else if (String::Equals(value, factory()->string_string())) {
- replacement = graph()->NewNode(simplified()->ObjectIsString(), input);
- } else if (String::Equals(value, factory()->undefined_string())) {
- replacement = graph()->NewNode(
- common()->Select(MachineRepresentation::kTagged),
- graph()->NewNode(simplified()->ReferenceEqual(), input,
- jsgraph()->NullConstant()),
- jsgraph()->FalseConstant(),
- graph()->NewNode(simplified()->ObjectIsUndetectable(), input));
- } else {
- return NoChange();
- }
- if (invert) {
- replacement = graph()->NewNode(simplified()->BooleanNot(), replacement);
- }
- ReplaceWithValue(node, replacement);
- return Replace(replacement);
+ 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();
}
- 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()->ObjectIsCallable(), input);
+ } else if (String::Equals(type, factory()->number_string())) {
+ value = graph()->NewNode(simplified()->ObjectIsNumber(), input);
+ } else if (String::Equals(type, factory()->string_string())) {
+ value = graph()->NewNode(simplified()->ObjectIsString(), 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();
+ }
+ if (invert) {
+ value = graph()->NewNode(simplified()->BooleanNot(), value);
+ }
+ ReplaceWithValue(node, value);
+ return Replace(value);
}
Reduction JSTypedLowering::ReduceJSEqual(Node* node, bool invert) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698