OLD | NEW |
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" | |
9 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
10 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
11 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
12 #include "src/compiler/graph-reducer.h" | 11 #include "src/compiler/graph-reducer.h" |
13 #include "src/compiler/js-operator.h" | 12 #include "src/compiler/js-operator.h" |
14 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
15 #include "src/compiler/node-properties.h" | 14 #include "src/compiler/node-properties.h" |
16 #include "src/compiler/simplified-operator.h" | 15 #include "src/compiler/simplified-operator.h" |
17 #include "src/objects-inl.h" | 16 #include "src/objects-inl.h" |
18 #include "src/zone-type-cache.h" | 17 #include "src/type-cache.h" |
19 | 18 |
20 namespace v8 { | 19 namespace v8 { |
21 namespace internal { | 20 namespace internal { |
22 namespace compiler { | 21 namespace compiler { |
23 | 22 |
24 namespace { | |
25 | |
26 base::LazyInstance<ZoneTypeCache>::type kCache = LAZY_INSTANCE_INITIALIZER; | |
27 | |
28 } // namespace | |
29 | |
30 | |
31 class Typer::Decorator final : public GraphDecorator { | 23 class Typer::Decorator final : public GraphDecorator { |
32 public: | 24 public: |
33 explicit Decorator(Typer* typer) : typer_(typer) {} | 25 explicit Decorator(Typer* typer) : typer_(typer) {} |
34 void Decorate(Node* node) final; | 26 void Decorate(Node* node) final; |
35 | 27 |
36 private: | 28 private: |
37 Typer* const typer_; | 29 Typer* const typer_; |
38 }; | 30 }; |
39 | 31 |
40 | 32 |
41 Typer::Typer(Isolate* isolate, Graph* graph, Flags flags, | 33 Typer::Typer(Isolate* isolate, Graph* graph, Flags flags, |
42 CompilationDependencies* dependencies, | 34 CompilationDependencies* dependencies, |
43 Type::FunctionType* function_type) | 35 Type::FunctionType* function_type) |
44 : isolate_(isolate), | 36 : isolate_(isolate), |
45 graph_(graph), | 37 graph_(graph), |
46 flags_(flags), | 38 flags_(flags), |
47 dependencies_(dependencies), | 39 dependencies_(dependencies), |
48 function_type_(function_type), | 40 function_type_(function_type), |
49 decorator_(nullptr), | 41 decorator_(nullptr), |
50 cache_(kCache.Get()) { | 42 cache_(TypeCache::Get()) { |
51 Zone* zone = this->zone(); | 43 Zone* zone = this->zone(); |
52 Factory* const factory = isolate->factory(); | 44 Factory* const factory = isolate->factory(); |
53 | 45 |
54 Type* infinity = Type::Constant(factory->infinity_value(), zone); | 46 Type* infinity = Type::Constant(factory->infinity_value(), zone); |
55 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); | 47 Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone); |
56 // TODO(neis): Unfortunately, the infinities created in other places might | 48 // TODO(neis): Unfortunately, the infinities created in other places might |
57 // be different ones (eg the result of NewNumber in TypeNumberConstant). | 49 // be different ones (eg the result of NewNumber in TypeNumberConstant). |
58 Type* truncating_to_zero = | 50 Type* truncating_to_zero = |
59 Type::Union(Type::Union(infinity, minus_infinity, zone), | 51 Type::Union(Type::Union(infinity, minus_infinity, zone), |
60 Type::MinusZeroOrNaN(), zone); | 52 Type::MinusZeroOrNaN(), zone); |
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 } | 2183 } |
2192 if (Type::IsInteger(*value)) { | 2184 if (Type::IsInteger(*value)) { |
2193 return Type::Range(value->Number(), value->Number(), zone()); | 2185 return Type::Range(value->Number(), value->Number(), zone()); |
2194 } | 2186 } |
2195 return Type::Constant(value, zone()); | 2187 return Type::Constant(value, zone()); |
2196 } | 2188 } |
2197 | 2189 |
2198 } // namespace compiler | 2190 } // namespace compiler |
2199 } // namespace internal | 2191 } // namespace internal |
2200 } // namespace v8 | 2192 } // namespace v8 |
OLD | NEW |