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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 6
7 #include "src/builtins/builtins-utils.h" 7 #include "src/builtins/builtins-utils.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 default: 749 default:
750 return NoChange(); 750 return NoChange();
751 } 751 }
752 if (comparison->EffectInputCount() > 0) { 752 if (comparison->EffectInputCount() > 0) {
753 return r.ChangeToSpeculativeOperator(comparison, Type::Boolean()); 753 return r.ChangeToSpeculativeOperator(comparison, Type::Boolean());
754 } else { 754 } else {
755 return r.ChangeToPureOperator(comparison); 755 return r.ChangeToPureOperator(comparison);
756 } 756 }
757 } 757 }
758 758
759 Reduction JSTypedLowering::ReduceJSTypeOf(Node* node) {
760 Node* const input = node->InputAt(0);
761 Type* type = NodeProperties::GetType(input);
762 Factory* const f = factory();
763 if (type->Is(Type::Boolean())) {
764 return Replace(jsgraph()->Constant(f->boolean_string()));
765 } else if (type->Is(Type::Number())) {
766 return Replace(jsgraph()->Constant(f->number_string()));
767 } else if (type->Is(Type::String())) {
768 return Replace(jsgraph()->Constant(f->string_string()));
769 } else if (type->Is(Type::Symbol())) {
770 return Replace(jsgraph()->Constant(f->symbol_string()));
771 } else if (type->Is(Type::Union(Type::Undefined(), Type::OtherUndetectable(),
772 graph()->zone()))) {
773 return Replace(jsgraph()->Constant(f->undefined_string()));
774 } else if (type->Is(Type::Null())) {
775 return Replace(jsgraph()->Constant(f->object_string()));
776 } else if (type->Is(Type::Function())) {
777 return Replace(jsgraph()->Constant(f->function_string()));
778 } else if (type->IsHeapConstant()) {
779 return Replace(jsgraph()->Constant(
780 Object::TypeOf(isolate(), type->AsHeapConstant()->Value())));
781 } else if (type->IsOtherNumberConstant()) {
782 return Replace(jsgraph()->Constant(f->number_string()));
783 }
784
785 return NoChange();
786 }
787
759 Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node, bool invert) { 788 Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node, bool invert) {
760 HeapObjectBinopMatcher m(node); 789 HeapObjectBinopMatcher m(node);
761 if (m.left().IsJSTypeOf() && m.right().HasValue() && 790 if (m.left().IsJSTypeOf() && m.right().HasValue() &&
762 m.right().Value()->IsString()) { 791 m.right().Value()->IsString()) {
763 Node* replacement; 792 Node* replacement;
764 Node* input = m.left().InputAt(0); 793 Node* input = m.left().InputAt(0);
765 Handle<String> value = Handle<String>::cast(m.right().Value()); 794 Handle<String> value = Handle<String>::cast(m.right().Value());
766 if (String::Equals(value, factory()->boolean_string())) { 795 if (String::Equals(value, factory()->boolean_string())) {
767 replacement = 796 replacement =
768 graph()->NewNode(common()->Select(MachineRepresentation::kTagged), 797 graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 case IrOpcode::kJSToInteger: 2107 case IrOpcode::kJSToInteger:
2079 return ReduceJSToInteger(node); 2108 return ReduceJSToInteger(node);
2080 case IrOpcode::kJSToLength: 2109 case IrOpcode::kJSToLength:
2081 return ReduceJSToLength(node); 2110 return ReduceJSToLength(node);
2082 case IrOpcode::kJSToNumber: 2111 case IrOpcode::kJSToNumber:
2083 return ReduceJSToNumber(node); 2112 return ReduceJSToNumber(node);
2084 case IrOpcode::kJSToString: 2113 case IrOpcode::kJSToString:
2085 return ReduceJSToString(node); 2114 return ReduceJSToString(node);
2086 case IrOpcode::kJSToObject: 2115 case IrOpcode::kJSToObject:
2087 return ReduceJSToObject(node); 2116 return ReduceJSToObject(node);
2117 case IrOpcode::kJSTypeOf:
2118 return ReduceJSTypeOf(node);
2088 case IrOpcode::kJSLoadNamed: 2119 case IrOpcode::kJSLoadNamed:
2089 return ReduceJSLoadNamed(node); 2120 return ReduceJSLoadNamed(node);
2090 case IrOpcode::kJSLoadProperty: 2121 case IrOpcode::kJSLoadProperty:
2091 return ReduceJSLoadProperty(node); 2122 return ReduceJSLoadProperty(node);
2092 case IrOpcode::kJSStoreProperty: 2123 case IrOpcode::kJSStoreProperty:
2093 return ReduceJSStoreProperty(node); 2124 return ReduceJSStoreProperty(node);
2094 case IrOpcode::kJSInstanceOf: 2125 case IrOpcode::kJSInstanceOf:
2095 return ReduceJSInstanceOf(node); 2126 return ReduceJSInstanceOf(node);
2096 case IrOpcode::kJSLoadContext: 2127 case IrOpcode::kJSLoadContext:
2097 return ReduceJSLoadContext(node); 2128 return ReduceJSLoadContext(node);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 } 2172 }
2142 2173
2143 2174
2144 CompilationDependencies* JSTypedLowering::dependencies() const { 2175 CompilationDependencies* JSTypedLowering::dependencies() const {
2145 return dependencies_; 2176 return dependencies_;
2146 } 2177 }
2147 2178
2148 } // namespace compiler 2179 } // namespace compiler
2149 } // namespace internal 2180 } // namespace internal
2150 } // namespace v8 2181 } // namespace v8
OLDNEW
« 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