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

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

Issue 1307093006: Spliting out TyperCache into ZoneTypeCache to share with AsmTyper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/compiler/typer.h ('k') | src/zone-type-cache.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"
11 #include "src/compiler/graph-reducer.h" 11 #include "src/compiler/graph-reducer.h"
12 #include "src/compiler/js-operator.h" 12 #include "src/compiler/js-operator.h"
13 #include "src/compiler/node.h" 13 #include "src/compiler/node.h"
14 #include "src/compiler/node-properties.h" 14 #include "src/compiler/node-properties.h"
15 #include "src/compiler/simplified-operator.h" 15 #include "src/compiler/simplified-operator.h"
16 #include "src/zone-type-cache.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 namespace compiler { 20 namespace compiler {
20 21
21 class TyperCache final {
22 private:
23 // This has to be first for the initialization magic to work.
24 Zone zone_;
25
26 public:
27 TyperCache() = default;
28
29 Type* const kInt8 =
30 CreateNative(CreateRange<int8_t>(), Type::UntaggedSigned8());
31 Type* const kUint8 =
32 CreateNative(CreateRange<uint8_t>(), Type::UntaggedUnsigned8());
33 Type* const kUint8Clamped = kUint8;
34 Type* const kInt16 =
35 CreateNative(CreateRange<int16_t>(), Type::UntaggedSigned16());
36 Type* const kUint16 =
37 CreateNative(CreateRange<uint16_t>(), Type::UntaggedUnsigned16());
38 Type* const kInt32 = CreateNative(Type::Signed32(), Type::UntaggedSigned32());
39 Type* const kUint32 =
40 CreateNative(Type::Unsigned32(), Type::UntaggedUnsigned32());
41 Type* const kFloat32 = CreateNative(Type::Number(), Type::UntaggedFloat32());
42 Type* const kFloat64 = CreateNative(Type::Number(), Type::UntaggedFloat64());
43
44 Type* const kSingletonZero = CreateRange(0.0, 0.0);
45 Type* const kSingletonOne = CreateRange(1.0, 1.0);
46 Type* const kZeroOrOne = CreateRange(0.0, 1.0);
47 Type* const kZeroish =
48 Type::Union(kSingletonZero, Type::MinusZeroOrNaN(), zone());
49 Type* const kInteger = CreateRange(-V8_INFINITY, V8_INFINITY);
50 Type* const kWeakint = Type::Union(kInteger, Type::MinusZeroOrNaN(), zone());
51 Type* const kWeakintFunc1 = Type::Function(kWeakint, Type::Number(), zone());
52
53 Type* const kRandomFunc0 = Type::Function(Type::OrderedNumber(), zone());
54 Type* const kAnyFunc0 = Type::Function(Type::Any(), zone());
55 Type* const kAnyFunc1 = Type::Function(Type::Any(), Type::Any(), zone());
56 Type* const kAnyFunc2 =
57 Type::Function(Type::Any(), Type::Any(), Type::Any(), zone());
58 Type* const kAnyFunc3 = Type::Function(Type::Any(), Type::Any(), Type::Any(),
59 Type::Any(), zone());
60 Type* const kNumberFunc0 = Type::Function(Type::Number(), zone());
61 Type* const kNumberFunc1 =
62 Type::Function(Type::Number(), Type::Number(), zone());
63 Type* const kNumberFunc2 =
64 Type::Function(Type::Number(), Type::Number(), Type::Number(), zone());
65 Type* const kImulFunc = Type::Function(Type::Signed32(), Type::Integral32(),
66 Type::Integral32(), zone());
67 Type* const kClz32Func =
68 Type::Function(CreateRange(0, 32), Type::Number(), zone());
69
70 #define TYPED_ARRAY(TypeName, type_name, TYPE_NAME, ctype, size) \
71 Type* const k##TypeName##Array = CreateArray(k##TypeName);
72 TYPED_ARRAYS(TYPED_ARRAY)
73 #undef TYPED_ARRAY
74
75 private:
76 Type* CreateArray(Type* element) { return Type::Array(element, zone()); }
77
78 Type* CreateArrayFunction(Type* array) {
79 Type* arg1 = Type::Union(Type::Unsigned32(), Type::Object(), zone());
80 Type* arg2 = Type::Union(Type::Unsigned32(), Type::Undefined(), zone());
81 Type* arg3 = arg2;
82 return Type::Function(array, arg1, arg2, arg3, zone());
83 }
84
85 Type* CreateNative(Type* semantic, Type* representation) {
86 return Type::Intersect(semantic, representation, zone());
87 }
88
89 template <typename T>
90 Type* CreateRange() {
91 return CreateRange(std::numeric_limits<T>::min(),
92 std::numeric_limits<T>::max());
93 }
94
95 Type* CreateRange(double min, double max) {
96 return Type::Range(min, max, zone());
97 }
98
99 Zone* zone() { return &zone_; }
100 };
101
102
103 namespace { 22 namespace {
104 23
105 base::LazyInstance<TyperCache>::type kCache = LAZY_INSTANCE_INITIALIZER; 24 base::LazyInstance<ZoneTypeCache>::type kCache = LAZY_INSTANCE_INITIALIZER;
106 25
107 } // namespace 26 } // namespace
108 27
109 28
110 class Typer::Decorator final : public GraphDecorator { 29 class Typer::Decorator final : public GraphDecorator {
111 public: 30 public:
112 explicit Decorator(Typer* typer) : typer_(typer) {} 31 explicit Decorator(Typer* typer) : typer_(typer) {}
113 void Decorate(Node* node) final; 32 void Decorate(Node* node) final;
114 33
115 private: 34 private:
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2292 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2374 #undef TYPED_ARRAY_CASE 2293 #undef TYPED_ARRAY_CASE
2375 } 2294 }
2376 } 2295 }
2377 return Type::Constant(value, zone()); 2296 return Type::Constant(value, zone());
2378 } 2297 }
2379 2298
2380 } // namespace compiler 2299 } // namespace compiler
2381 } // namespace internal 2300 } // namespace internal
2382 } // namespace v8 2301 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/typer.h ('k') | src/zone-type-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698