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

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

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues Created 5 years, 11 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/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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 #include "src/compiler/graph-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/graph-reducer.h" 7 #include "src/compiler/graph-reducer.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 27 matching lines...) Expand all
38 TYPED_ARRAYS(TYPED_ARRAY_CASE) 38 TYPED_ARRAYS(TYPED_ARRAY_CASE)
39 #undef TYPED_ARRAY_CASE 39 #undef TYPED_ARRAY_CASE
40 kNumLazyCachedTypes 40 kNumLazyCachedTypes
41 }; 41 };
42 42
43 43
44 // Constructs and caches types lazily. 44 // Constructs and caches types lazily.
45 // TODO(turbofan): these types could be globally cached or cached per isolate. 45 // TODO(turbofan): these types could be globally cached or cached per isolate.
46 class LazyTypeCache FINAL : public ZoneObject { 46 class LazyTypeCache FINAL : public ZoneObject {
47 public: 47 public:
48 explicit LazyTypeCache(Zone* zone) : zone_(zone) { 48 explicit LazyTypeCache(Isolate* isolate, Zone* zone)
49 : isolate_(isolate), zone_(zone) {
49 memset(cache_, 0, sizeof(cache_)); 50 memset(cache_, 0, sizeof(cache_));
50 } 51 }
51 52
52 inline Type* Get(LazyCachedType type) { 53 inline Type* Get(LazyCachedType type) {
53 int index = static_cast<int>(type); 54 int index = static_cast<int>(type);
54 DCHECK(index < kNumLazyCachedTypes); 55 DCHECK(index < kNumLazyCachedTypes);
55 if (cache_[index] == NULL) cache_[index] = Create(type); 56 if (cache_[index] == NULL) cache_[index] = Create(type);
56 return cache_[index]; 57 return cache_[index];
57 } 58 }
58 59
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return CreateRange(std::numeric_limits<T>::min(), 127 return CreateRange(std::numeric_limits<T>::min(),
127 std::numeric_limits<T>::max()); 128 std::numeric_limits<T>::max());
128 } 129 }
129 130
130 Type* CreateRange(double min, double max) const { 131 Type* CreateRange(double min, double max) const {
131 return Type::Range(factory()->NewNumber(min), factory()->NewNumber(max), 132 return Type::Range(factory()->NewNumber(min), factory()->NewNumber(max),
132 zone()); 133 zone());
133 } 134 }
134 135
135 Factory* factory() const { return isolate()->factory(); } 136 Factory* factory() const { return isolate()->factory(); }
136 Isolate* isolate() const { return zone()->isolate(); } 137 Isolate* isolate() const { return isolate_; }
137 Zone* zone() const { return zone_; } 138 Zone* zone() const { return zone_; }
138 139
139 Type* cache_[kNumLazyCachedTypes]; 140 Type* cache_[kNumLazyCachedTypes];
141 Isolate* isolate_;
140 Zone* zone_; 142 Zone* zone_;
141 }; 143 };
142 144
143 145
144 class Typer::Decorator FINAL : public GraphDecorator { 146 class Typer::Decorator FINAL : public GraphDecorator {
145 public: 147 public:
146 explicit Decorator(Typer* typer) : typer_(typer) {} 148 explicit Decorator(Typer* typer) : typer_(typer) {}
147 void Decorate(Node* node) FINAL; 149 void Decorate(Node* node) FINAL;
148 150
149 private: 151 private:
150 Typer* typer_; 152 Typer* typer_;
151 }; 153 };
152 154
153 155
154 Typer::Typer(Graph* graph, MaybeHandle<Context> context) 156 Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context)
155 : graph_(graph), 157 : isolate_(isolate),
158 graph_(graph),
156 context_(context), 159 context_(context),
157 decorator_(NULL), 160 decorator_(NULL),
158 cache_(new (graph->zone()) LazyTypeCache(graph->zone())), 161 cache_(new (graph->zone()) LazyTypeCache(isolate, graph->zone())),
159 weaken_min_limits_(graph->zone()), 162 weaken_min_limits_(graph->zone()),
160 weaken_max_limits_(graph->zone()) { 163 weaken_max_limits_(graph->zone()) {
161 Zone* zone = this->zone(); 164 Zone* zone = this->zone();
162 Factory* f = zone->isolate()->factory(); 165 Factory* f = isolate->factory();
163 166
164 Handle<Object> zero = f->NewNumber(0); 167 Handle<Object> zero = f->NewNumber(0);
165 Handle<Object> one = f->NewNumber(1); 168 Handle<Object> one = f->NewNumber(1);
166 Handle<Object> infinity = f->NewNumber(+V8_INFINITY); 169 Handle<Object> infinity = f->NewNumber(+V8_INFINITY);
167 Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY); 170 Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY);
168 171
169 Type* number = Type::Number(); 172 Type* number = Type::Number();
170 Type* signed32 = Type::Signed32(); 173 Type* signed32 = Type::Signed32();
171 Type* unsigned32 = Type::Unsigned32(); 174 Type* unsigned32 = Type::Unsigned32();
172 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone); 175 Type* nan_or_minuszero = Type::Union(Type::NaN(), Type::MinusZero(), zone);
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2117 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2115 #undef TYPED_ARRAY_CASE 2118 #undef TYPED_ARRAY_CASE
2116 } 2119 }
2117 } 2120 }
2118 return Type::Constant(value, zone()); 2121 return Type::Constant(value, zone());
2119 } 2122 }
2120 2123
2121 } // namespace compiler 2124 } // namespace compiler
2122 } // namespace internal 2125 } // namespace internal
2123 } // namespace v8 2126 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/typer.h ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698