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

Side by Side Diff: src/compiler/typer.cc

Issue 2697063002: Fix typeof optimization for undetectable (Closed)
Patch Set: Add TypeOfIsFunction to EscapeStatusAnalysis Created 3 years, 10 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
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD) 284 SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD)
285 #undef DECLARE_METHOD 285 #undef DECLARE_METHOD
286 286
287 static Type* ObjectIsCallable(Type*, Typer*); 287 static Type* ObjectIsCallable(Type*, Typer*);
288 static Type* ObjectIsNonCallable(Type*, Typer*); 288 static Type* ObjectIsNonCallable(Type*, Typer*);
289 static Type* ObjectIsNumber(Type*, Typer*); 289 static Type* ObjectIsNumber(Type*, Typer*);
290 static Type* ObjectIsReceiver(Type*, Typer*); 290 static Type* ObjectIsReceiver(Type*, Typer*);
291 static Type* ObjectIsSmi(Type*, Typer*); 291 static Type* ObjectIsSmi(Type*, Typer*);
292 static Type* ObjectIsString(Type*, Typer*); 292 static Type* ObjectIsString(Type*, Typer*);
293 static Type* ObjectIsUndetectable(Type*, Typer*); 293 static Type* ObjectIsUndetectable(Type*, Typer*);
294 static Type* TypeOfIsFunction(Type*, Typer*);
294 295
295 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); 296 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*);
296 297
297 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); 298 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*);
298 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) 299 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD)
299 #undef DECLARE_METHOD 300 #undef DECLARE_METHOD
300 301
301 static Type* JSCallTyper(Type*, Typer*); 302 static Type* JSCallTyper(Type*, Typer*);
302 303
303 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); 304 static Type* ReferenceEqualTyper(Type*, Type*, Typer*);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 if (!type->Maybe(Type::String())) return t->singleton_false_; 540 if (!type->Maybe(Type::String())) return t->singleton_false_;
540 return Type::Boolean(); 541 return Type::Boolean();
541 } 542 }
542 543
543 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) { 544 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) {
544 if (type->Is(Type::Undetectable())) return t->singleton_true_; 545 if (type->Is(Type::Undetectable())) return t->singleton_true_;
545 if (!type->Maybe(Type::Undetectable())) return t->singleton_false_; 546 if (!type->Maybe(Type::Undetectable())) return t->singleton_false_;
546 return Type::Boolean(); 547 return Type::Boolean();
547 } 548 }
548 549
550 Type* Typer::Visitor::TypeOfIsFunction(Type* type, Typer* t) {
551 if (type->Is(Type::Function())) return t->singleton_true_;
552 if (!type->Maybe(Type::Function())) return t->singleton_false_;
553 return Type::Boolean();
554 }
549 555
550 // ----------------------------------------------------------------------------- 556 // -----------------------------------------------------------------------------
551 557
552 558
553 // Control operators. 559 // Control operators.
554 560
555 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); } 561 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); }
556 562
557 Type* Typer::Visitor::TypeIfException(Node* node) { 563 Type* Typer::Visitor::TypeIfException(Node* node) {
558 return Type::NonInternal(); 564 return Type::NonInternal();
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 } 1925 }
1920 1926
1921 Type* Typer::Visitor::TypeObjectIsString(Node* node) { 1927 Type* Typer::Visitor::TypeObjectIsString(Node* node) {
1922 return TypeUnaryOp(node, ObjectIsString); 1928 return TypeUnaryOp(node, ObjectIsString);
1923 } 1929 }
1924 1930
1925 Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) { 1931 Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
1926 return TypeUnaryOp(node, ObjectIsUndetectable); 1932 return TypeUnaryOp(node, ObjectIsUndetectable);
1927 } 1933 }
1928 1934
1935 Type* Typer::Visitor::TypeTypeOfIsFunction(Node* node) {
1936 return TypeUnaryOp(node, TypeOfIsFunction);
1937 }
1938
1929 Type* Typer::Visitor::TypeNewUnmappedArgumentsElements(Node* node) { 1939 Type* Typer::Visitor::TypeNewUnmappedArgumentsElements(Node* node) {
1930 return Type::OtherInternal(); 1940 return Type::OtherInternal();
1931 } 1941 }
1932 1942
1933 Type* Typer::Visitor::TypeNewRestParameterElements(Node* node) { 1943 Type* Typer::Visitor::TypeNewRestParameterElements(Node* node) {
1934 return Type::OtherInternal(); 1944 return Type::OtherInternal();
1935 } 1945 }
1936 1946
1937 Type* Typer::Visitor::TypeArrayBufferWasNeutered(Node* node) { 1947 Type* Typer::Visitor::TypeArrayBufferWasNeutered(Node* node) {
1938 return Type::Boolean(); 1948 return Type::Boolean();
1939 } 1949 }
1940 1950
1941 // Heap constants. 1951 // Heap constants.
1942 1952
1943 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { 1953 Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
1944 if (Type::IsInteger(*value)) { 1954 if (Type::IsInteger(*value)) {
1945 return Type::Range(value->Number(), value->Number(), zone()); 1955 return Type::Range(value->Number(), value->Number(), zone());
1946 } 1956 }
1947 return Type::NewConstant(value, zone()); 1957 return Type::NewConstant(value, zone());
1948 } 1958 }
1949 1959
1950 } // namespace compiler 1960 } // namespace compiler
1951 } // namespace internal 1961 } // namespace internal
1952 } // namespace v8 1962 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698