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

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

Issue 1743433002: Revert of [compiler] Drop the CompareNilIC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/compiler/simplified-operator.cc ('k') | src/compiler/verifier.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/typer.h" 5 #include "src/compiler/typer.h"
6 6
7 #include "src/base/flags.h" 7 #include "src/base/flags.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 Type::MinusZeroOrNaN(), zone); 50 Type::MinusZeroOrNaN(), zone);
51 DCHECK(!truncating_to_zero->Maybe(Type::Integral32())); 51 DCHECK(!truncating_to_zero->Maybe(Type::Integral32()));
52 52
53 singleton_false_ = Type::Constant(factory->false_value(), zone); 53 singleton_false_ = Type::Constant(factory->false_value(), zone);
54 singleton_true_ = Type::Constant(factory->true_value(), zone); 54 singleton_true_ = Type::Constant(factory->true_value(), zone);
55 singleton_the_hole_ = Type::Constant(factory->the_hole_value(), zone); 55 singleton_the_hole_ = Type::Constant(factory->the_hole_value(), zone);
56 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); 56 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone);
57 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); 57 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone);
58 falsish_ = Type::Union( 58 falsish_ = Type::Union(
59 Type::Undetectable(), 59 Type::Undetectable(),
60 Type::Union(Type::Union(singleton_false_, cache_.kZeroish, zone), 60 Type::Union(
61 singleton_the_hole_, zone), 61 Type::Union(Type::Union(singleton_false_, cache_.kZeroish, zone),
62 Type::NullOrUndefined(), zone),
63 singleton_the_hole_, zone),
62 zone); 64 zone);
63 truish_ = Type::Union( 65 truish_ = Type::Union(
64 singleton_true_, 66 singleton_true_,
65 Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone); 67 Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone), zone);
66 68
67 decorator_ = new (zone) Decorator(this); 69 decorator_ = new (zone) Decorator(this);
68 graph_->AddDecorator(decorator_); 70 graph_->AddDecorator(decorator_);
69 } 71 }
70 72
71 73
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 static Type* ToName(Type*, Typer*); 237 static Type* ToName(Type*, Typer*);
236 static Type* ToNumber(Type*, Typer*); 238 static Type* ToNumber(Type*, Typer*);
237 static Type* ToObject(Type*, Typer*); 239 static Type* ToObject(Type*, Typer*);
238 static Type* ToString(Type*, Typer*); 240 static Type* ToString(Type*, Typer*);
239 static Type* NumberToInt32(Type*, Typer*); 241 static Type* NumberToInt32(Type*, Typer*);
240 static Type* NumberToUint32(Type*, Typer*); 242 static Type* NumberToUint32(Type*, Typer*);
241 243
242 static Type* ObjectIsNumber(Type*, Typer*); 244 static Type* ObjectIsNumber(Type*, Typer*);
243 static Type* ObjectIsReceiver(Type*, Typer*); 245 static Type* ObjectIsReceiver(Type*, Typer*);
244 static Type* ObjectIsSmi(Type*, Typer*); 246 static Type* ObjectIsSmi(Type*, Typer*);
245 static Type* ObjectIsUndetectable(Type*, Typer*);
246 247
247 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); 248 static Type* JSAddRanger(RangeType*, RangeType*, Typer*);
248 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); 249 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*);
249 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*); 250 static Type* JSDivideRanger(RangeType*, RangeType*, Typer*);
250 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*); 251 static Type* JSModulusRanger(RangeType*, RangeType*, Typer*);
251 252
252 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); 253 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*);
253 254
254 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); 255 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*);
255 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) 256 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 462 }
462 return Type::Number(); 463 return Type::Number();
463 } 464 }
464 465
465 466
466 // static 467 // static
467 Type* Typer::Visitor::ToObject(Type* type, Typer* t) { 468 Type* Typer::Visitor::ToObject(Type* type, Typer* t) {
468 // ES6 section 7.1.13 ToObject ( argument ) 469 // ES6 section 7.1.13 ToObject ( argument )
469 if (type->Is(Type::Receiver())) return type; 470 if (type->Is(Type::Receiver())) return type;
470 if (type->Is(Type::Primitive())) return Type::OtherObject(); 471 if (type->Is(Type::Primitive())) return Type::OtherObject();
471 if (!type->Maybe(Type::OtherUndetectable())) { 472 if (!type->Maybe(Type::Undetectable())) return Type::DetectableReceiver();
472 return Type::DetectableReceiver();
473 }
474 return Type::Receiver(); 473 return Type::Receiver();
475 } 474 }
476 475
477 476
478 // static 477 // static
479 Type* Typer::Visitor::ToString(Type* type, Typer* t) { 478 Type* Typer::Visitor::ToString(Type* type, Typer* t) {
480 // ES6 section 7.1.12 ToString ( argument ) 479 // ES6 section 7.1.12 ToString ( argument )
481 type = ToPrimitive(type, t); 480 type = ToPrimitive(type, t);
482 if (type->Is(Type::String())) return type; 481 if (type->Is(Type::String())) return type;
483 return Type::String(); 482 return Type::String();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return Type::Boolean(); 525 return Type::Boolean();
527 } 526 }
528 527
529 528
530 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) { 529 Type* Typer::Visitor::ObjectIsSmi(Type* type, Typer* t) {
531 if (type->Is(Type::TaggedSigned())) return t->singleton_true_; 530 if (type->Is(Type::TaggedSigned())) return t->singleton_true_;
532 if (type->Is(Type::TaggedPointer())) return t->singleton_false_; 531 if (type->Is(Type::TaggedPointer())) return t->singleton_false_;
533 return Type::Boolean(); 532 return Type::Boolean();
534 } 533 }
535 534
536
537 Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) {
538 if (type->Is(Type::Undetectable())) return t->singleton_true_;
539 if (!type->Maybe(Type::Undetectable())) return t->singleton_false_;
540 return Type::Boolean();
541 }
542
543 535
544 // ----------------------------------------------------------------------------- 536 // -----------------------------------------------------------------------------
545 537
546 538
547 // Control operators. 539 // Control operators.
548 540
549 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); } 541 Type* Typer::Visitor::TypeStart(Node* node) { return Type::Internal(); }
550 542
551 Type* Typer::Visitor::TypeIfException(Node* node) { return Type::Any(); } 543 Type* Typer::Visitor::TypeIfException(Node* node) { return Type::Any(); }
552 544
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) { 1164 Type* Typer::Visitor::JSTypeOfTyper(Type* type, Typer* t) {
1173 Factory* const f = t->isolate()->factory(); 1165 Factory* const f = t->isolate()->factory();
1174 if (type->Is(Type::Boolean())) { 1166 if (type->Is(Type::Boolean())) {
1175 return Type::Constant(f->boolean_string(), t->zone()); 1167 return Type::Constant(f->boolean_string(), t->zone());
1176 } else if (type->Is(Type::Number())) { 1168 } else if (type->Is(Type::Number())) {
1177 return Type::Constant(f->number_string(), t->zone()); 1169 return Type::Constant(f->number_string(), t->zone());
1178 } else if (type->Is(Type::String())) { 1170 } else if (type->Is(Type::String())) {
1179 return Type::Constant(f->string_string(), t->zone()); 1171 return Type::Constant(f->string_string(), t->zone());
1180 } else if (type->Is(Type::Symbol())) { 1172 } else if (type->Is(Type::Symbol())) {
1181 return Type::Constant(f->symbol_string(), t->zone()); 1173 return Type::Constant(f->symbol_string(), t->zone());
1182 } else if (type->Is(Type::Union(Type::Undefined(), Type::OtherUndetectable(), 1174 } else if (type->Is(Type::Union(Type::Undefined(), Type::Undetectable(),
1183 t->zone()))) { 1175 t->zone()))) {
1184 return Type::Constant(f->undefined_string(), t->zone()); 1176 return Type::Constant(f->undefined_string(), t->zone());
1185 } else if (type->Is(Type::Null())) { 1177 } else if (type->Is(Type::Null())) {
1186 return Type::Constant(f->object_string(), t->zone()); 1178 return Type::Constant(f->object_string(), t->zone());
1187 } else if (type->Is(Type::Function())) { 1179 } else if (type->Is(Type::Function())) {
1188 return Type::Constant(f->function_string(), t->zone()); 1180 return Type::Constant(f->function_string(), t->zone());
1189 } else if (type->IsConstant()) { 1181 } else if (type->IsConstant()) {
1190 return Type::Constant( 1182 return Type::Constant(
1191 Object::TypeOf(t->isolate(), type->AsConstant()->Value()), t->zone()); 1183 Object::TypeOf(t->isolate(), type->AsConstant()->Value()), t->zone());
1192 } 1184 }
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) { 1918 Type* Typer::Visitor::TypeObjectIsReceiver(Node* node) {
1927 return TypeUnaryOp(node, ObjectIsReceiver); 1919 return TypeUnaryOp(node, ObjectIsReceiver);
1928 } 1920 }
1929 1921
1930 1922
1931 Type* Typer::Visitor::TypeObjectIsSmi(Node* node) { 1923 Type* Typer::Visitor::TypeObjectIsSmi(Node* node) {
1932 return TypeUnaryOp(node, ObjectIsSmi); 1924 return TypeUnaryOp(node, ObjectIsSmi);
1933 } 1925 }
1934 1926
1935 1927
1936 Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
1937 return TypeUnaryOp(node, ObjectIsUndetectable);
1938 }
1939
1940
1941 // Machine operators. 1928 // Machine operators.
1942 1929
1943 Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); } 1930 Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); }
1944 1931
1945 Type* Typer::Visitor::TypeStackSlot(Node* node) { return Type::Any(); } 1932 Type* Typer::Visitor::TypeStackSlot(Node* node) { return Type::Any(); }
1946 1933
1947 Type* Typer::Visitor::TypeStore(Node* node) { 1934 Type* Typer::Visitor::TypeStore(Node* node) {
1948 UNREACHABLE(); 1935 UNREACHABLE();
1949 return nullptr; 1936 return nullptr;
1950 } 1937 }
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 } 2443 }
2457 if (Type::IsInteger(*value)) { 2444 if (Type::IsInteger(*value)) {
2458 return Type::Range(value->Number(), value->Number(), zone()); 2445 return Type::Range(value->Number(), value->Number(), zone());
2459 } 2446 }
2460 return Type::Constant(value, zone()); 2447 return Type::Constant(value, zone());
2461 } 2448 }
2462 2449
2463 } // namespace compiler 2450 } // namespace compiler
2464 } // namespace internal 2451 } // namespace internal
2465 } // namespace v8 2452 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698