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

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

Issue 1328193003: Construct Range rather than Constant when typing integers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo. Created 5 years, 3 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 | « no previous file | src/types.h » ('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/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 30 matching lines...) Expand all
41 : isolate_(isolate), 41 : isolate_(isolate),
42 graph_(graph), 42 graph_(graph),
43 function_type_(function_type), 43 function_type_(function_type),
44 decorator_(nullptr), 44 decorator_(nullptr),
45 cache_(kCache.Get()) { 45 cache_(kCache.Get()) {
46 Zone* zone = this->zone(); 46 Zone* zone = this->zone();
47 Factory* const factory = isolate->factory(); 47 Factory* const factory = isolate->factory();
48 48
49 Type* infinity = Type::Constant(factory->infinity_value(), zone); 49 Type* infinity = Type::Constant(factory->infinity_value(), zone);
50 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); 50 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone);
51 // TODO(neis): Unfortunately, the infinities created in other places might
52 // be different ones (eg the result of NewNumber in TypeNumberConstant).
51 Type* truncating_to_zero = 53 Type* truncating_to_zero =
52 Type::Union(Type::Union(infinity, minus_infinity, zone), 54 Type::Union(Type::Union(infinity, minus_infinity, zone),
53 Type::MinusZeroOrNaN(), zone); 55 Type::MinusZeroOrNaN(), zone);
54 56
55 singleton_false_ = Type::Constant(factory->false_value(), zone); 57 singleton_false_ = Type::Constant(factory->false_value(), zone);
56 singleton_true_ = Type::Constant(factory->true_value(), zone); 58 singleton_true_ = Type::Constant(factory->true_value(), zone);
57 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone); 59 signed32ish_ = Type::Union(Type::Signed32(), truncating_to_zero, zone);
58 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone); 60 unsigned32ish_ = Type::Union(Type::Unsigned32(), truncating_to_zero, zone);
59 falsish_ = Type::Union( 61 falsish_ = Type::Union(
60 Type::Undetectable(), 62 Type::Undetectable(),
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 530
529 Bounds Typer::Visitor::TypeFloat64Constant(Node* node) { 531 Bounds Typer::Visitor::TypeFloat64Constant(Node* node) {
530 return Bounds(Type::Intersect( 532 return Bounds(Type::Intersect(
531 Type::Of(OpParameter<double>(node), zone()), 533 Type::Of(OpParameter<double>(node), zone()),
532 Type::UntaggedFloat64(), zone())); 534 Type::UntaggedFloat64(), zone()));
533 } 535 }
534 536
535 537
536 Bounds Typer::Visitor::TypeNumberConstant(Node* node) { 538 Bounds Typer::Visitor::TypeNumberConstant(Node* node) {
537 Factory* f = isolate()->factory(); 539 Factory* f = isolate()->factory();
538 return Bounds(Type::Constant( 540 double number = OpParameter<double>(node);
539 f->NewNumber(OpParameter<double>(node)), zone())); 541 if (Type::IsInteger(number)) {
542 return Bounds(Type::Range(number, number, zone()));
543 }
544 return Bounds(Type::Constant(f->NewNumber(number), zone()));
540 } 545 }
541 546
542 547
543 Bounds Typer::Visitor::TypeHeapConstant(Node* node) { 548 Bounds Typer::Visitor::TypeHeapConstant(Node* node) {
544 return Bounds(TypeConstant(OpParameter<Handle<HeapObject>>(node))); 549 return Bounds(TypeConstant(OpParameter<Handle<HeapObject>>(node)));
545 } 550 }
546 551
547 552
548 Bounds Typer::Visitor::TypeExternalConstant(Node* node) { 553 Bounds Typer::Visitor::TypeExternalConstant(Node* node) {
549 return Bounds(Type::None(zone()), Type::Internal(zone())); 554 return Bounds(Type::None(zone()), Type::Internal(zone()));
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 } 2286 }
2282 } else if (value->IsJSTypedArray()) { 2287 } else if (value->IsJSTypedArray()) {
2283 switch (JSTypedArray::cast(*value)->type()) { 2288 switch (JSTypedArray::cast(*value)->type()) {
2284 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 2289 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
2285 case kExternal##Type##Array: \ 2290 case kExternal##Type##Array: \
2286 return typer_->cache_.k##Type##Array; 2291 return typer_->cache_.k##Type##Array;
2287 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2292 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2288 #undef TYPED_ARRAY_CASE 2293 #undef TYPED_ARRAY_CASE
2289 } 2294 }
2290 } 2295 }
2296 if (Type::IsInteger(*value)) {
2297 return Type::Range(value->Number(), value->Number(), zone());
2298 }
2291 return Type::Constant(value, zone()); 2299 return Type::Constant(value, zone());
2292 } 2300 }
2293 2301
2294 } // namespace compiler 2302 } // namespace compiler
2295 } // namespace internal 2303 } // namespace internal
2296 } // namespace v8 2304 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698