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

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

Issue 2411703002: [turbofan] Optimize typeof operator without storing strings in Type (Closed)
Patch Set: Created 4 years, 2 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 | « src/compiler/js-typed-lowering.h ('k') | src/compiler/typer.cc » ('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 c7a1f43426815e944e66b7aa956d98fa3884217f..5dfc97285c7195d9c523a18185230624c98ff355 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -756,6 +756,35 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
}
}
+Reduction JSTypedLowering::ReduceJSTypeOf(Node* node) {
+ Node* const input = node->InputAt(0);
+ Type* type = NodeProperties::GetType(input);
+ Factory* const f = factory();
+ if (type->Is(Type::Boolean())) {
+ return Replace(jsgraph()->Constant(f->boolean_string()));
+ } else if (type->Is(Type::Number())) {
+ return Replace(jsgraph()->Constant(f->number_string()));
+ } else if (type->Is(Type::String())) {
+ return Replace(jsgraph()->Constant(f->string_string()));
+ } else if (type->Is(Type::Symbol())) {
+ return Replace(jsgraph()->Constant(f->symbol_string()));
+ } else if (type->Is(Type::Union(Type::Undefined(), Type::OtherUndetectable(),
+ graph()->zone()))) {
+ return Replace(jsgraph()->Constant(f->undefined_string()));
+ } else if (type->Is(Type::Null())) {
+ return Replace(jsgraph()->Constant(f->object_string()));
+ } else if (type->Is(Type::Function())) {
+ return Replace(jsgraph()->Constant(f->function_string()));
+ } else if (type->IsHeapConstant()) {
+ return Replace(jsgraph()->Constant(
+ Object::TypeOf(isolate(), type->AsHeapConstant()->Value())));
+ } else if (type->IsOtherNumberConstant()) {
+ return Replace(jsgraph()->Constant(f->number_string()));
+ }
+
+ return NoChange();
+}
+
Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node, bool invert) {
HeapObjectBinopMatcher m(node);
if (m.left().IsJSTypeOf() && m.right().HasValue() &&
@@ -2085,6 +2114,8 @@ Reduction JSTypedLowering::Reduce(Node* node) {
return ReduceJSToString(node);
case IrOpcode::kJSToObject:
return ReduceJSToObject(node);
+ case IrOpcode::kJSTypeOf:
+ return ReduceJSTypeOf(node);
case IrOpcode::kJSLoadNamed:
return ReduceJSLoadNamed(node);
case IrOpcode::kJSLoadProperty:
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698