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

Side by Side Diff: src/compiler/typer.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.cc ('k') | no next file » | 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/typer.h" 5 #include "src/compiler/typer.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/flags.h" 9 #include "src/base/flags.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 static Type* ObjectIsSmi(Type*, Typer*); 283 static Type* ObjectIsSmi(Type*, Typer*);
284 static Type* ObjectIsString(Type*, Typer*); 284 static Type* ObjectIsString(Type*, Typer*);
285 static Type* ObjectIsUndetectable(Type*, Typer*); 285 static Type* ObjectIsUndetectable(Type*, Typer*);
286 286
287 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); 287 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*);
288 288
289 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); 289 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*);
290 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) 290 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD)
291 #undef DECLARE_METHOD 291 #undef DECLARE_METHOD
292 292
293 static Type* JSTypeOfTyper(Type*, Typer*);
294 static Type* JSCallFunctionTyper(Type*, Typer*); 293 static Type* JSCallFunctionTyper(Type*, Typer*);
295 294
296 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); 295 static Type* ReferenceEqualTyper(Type*, Type*, Typer*);
297 static Type* StringFromCharCodeTyper(Type*, Typer*); 296 static Type* StringFromCharCodeTyper(Type*, Typer*);
298 static Type* StringFromCodePointTyper(Type*, Typer*); 297 static Type* StringFromCodePointTyper(Type*, Typer*);
299 298
300 Reduction UpdateType(Node* node, Type* current) { 299 Reduction UpdateType(Node* node, Type* current) {
301 if (NodeProperties::IsTyped(node)) { 300 if (NodeProperties::IsTyped(node)) {
302 // Widen the type of a previously typed node. 301 // Widen the type of a previously typed node.
303 Type* previous = NodeProperties::GetType(node); 302 Type* previous = NodeProperties::GetType(node);
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 } 1005 }
1007 1006
1008 Type* Typer::Visitor::JSModulusTyper(Type* lhs, Type* rhs, Typer* t) { 1007 Type* Typer::Visitor::JSModulusTyper(Type* lhs, Type* rhs, Typer* t) {
1009 return NumberModulus(ToNumber(lhs, t), ToNumber(rhs, t), t); 1008 return NumberModulus(ToNumber(lhs, t), ToNumber(rhs, t), t);
1010 } 1009 }
1011 1010
1012 1011
1013 // JS unary operators. 1012 // JS unary operators.
1014 1013
1015 1014
1016 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { 1015 Type* Typer::Visitor::TypeJSTypeOf(Node* node) {
1017 Factory* const f = t->isolate()->factory();
1018 if (type->Is(Type::Boolean())) {
1019 return Type::HeapConstant(f->boolean_string(), t->zone());
1020 } else if (type->Is(Type::Number())) {
1021 return Type::HeapConstant(f->number_string(), t->zone());
1022 } else if (type->Is(Type::String())) {
1023 return Type::HeapConstant(f->string_string(), t->zone());
1024 } else if (type->Is(Type::Symbol())) {
1025 return Type::HeapConstant(f->symbol_string(), t->zone());
1026 } else if (type->Is(Type::Union(Type::Undefined(), Type::OtherUndetectable(),
1027 t->zone()))) {
1028 return Type::HeapConstant(f->undefined_string(), t->zone());
1029 } else if (type->Is(Type::Null())) {
1030 return Type::HeapConstant(f->object_string(), t->zone());
1031 } else if (type->Is(Type::Function())) {
1032 return Type::HeapConstant(f->function_string(), t->zone());
1033 } else if (type->IsHeapConstant()) {
1034 return Type::HeapConstant(
1035 Object::TypeOf(t->isolate(), type->AsHeapConstant()->Value()),
1036 t->zone());
1037 } else if (type->IsOtherNumberConstant()) {
1038 return Type::HeapConstant(f->number_string(), t->zone());
1039 }
1040 return Type::InternalizedString(); 1016 return Type::InternalizedString();
1041 } 1017 }
1042 1018
1043 1019
1044 Type* Typer::Visitor::TypeJSTypeOf(Node* node) {
1045 return TypeUnaryOp(node, JSTypeOfTyper);
1046 }
1047
1048
1049 // JS conversion operators. 1020 // JS conversion operators.
1050 1021
1051 1022
1052 Type* Typer::Visitor::TypeJSToBoolean(Node* node) { 1023 Type* Typer::Visitor::TypeJSToBoolean(Node* node) {
1053 return TypeUnaryOp(node, ToBoolean); 1024 return TypeUnaryOp(node, ToBoolean);
1054 } 1025 }
1055 1026
1056 Type* Typer::Visitor::TypeJSToInteger(Node* node) { 1027 Type* Typer::Visitor::TypeJSToInteger(Node* node) {
1057 return TypeUnaryOp(node, ToInteger); 1028 return TypeUnaryOp(node, ToInteger);
1058 } 1029 }
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { 1721 Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
1751 if (Type::IsInteger(*value)) { 1722 if (Type::IsInteger(*value)) {
1752 return Type::Range(value->Number(), value->Number(), zone()); 1723 return Type::Range(value->Number(), value->Number(), zone());
1753 } 1724 }
1754 return Type::NewConstant(value, zone()); 1725 return Type::NewConstant(value, zone());
1755 } 1726 }
1756 1727
1757 } // namespace compiler 1728 } // namespace compiler
1758 } // namespace internal 1729 } // namespace internal
1759 } // namespace v8 1730 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698