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

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

Issue 701473002: Make generic algorithm less generic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Jaro. Created 6 years, 1 month 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 | Annotate | Revision Log
« 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/js-operator.h" 7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 static Type* JSCallFunctionTyper(Type*, Typer*); 244 static Type* JSCallFunctionTyper(Type*, Typer*);
245 }; 245 };
246 246
247 247
248 class Typer::RunVisitor : public Typer::Visitor { 248 class Typer::RunVisitor : public Typer::Visitor {
249 public: 249 public:
250 explicit RunVisitor(Typer* typer) 250 explicit RunVisitor(Typer* typer)
251 : Visitor(typer), 251 : Visitor(typer),
252 redo(NodeSet::key_compare(), NodeSet::allocator_type(typer->zone())) {} 252 redo(NodeSet::key_compare(), NodeSet::allocator_type(typer->zone())) {}
253 253
254 GenericGraphVisit::Control Post(Node* node) { 254 void Post(Node* node) {
255 if (node->op()->ValueOutputCount() > 0) { 255 if (node->op()->ValueOutputCount() > 0) {
256 Bounds bounds = TypeNode(node); 256 Bounds bounds = TypeNode(node);
257 NodeProperties::SetBounds(node, bounds); 257 NodeProperties::SetBounds(node, bounds);
258 // Remember incompletely typed nodes for least fixpoint iteration. 258 // Remember incompletely typed nodes for least fixpoint iteration.
259 if (!NodeProperties::AllValueInputsAreTyped(node)) redo.insert(node); 259 if (!NodeProperties::AllValueInputsAreTyped(node)) redo.insert(node);
260 } 260 }
261 return GenericGraphVisit::CONTINUE;
262 } 261 }
263 262
264 NodeSet redo; 263 NodeSet redo;
265 }; 264 };
266 265
267 266
268 class Typer::NarrowVisitor : public Typer::Visitor {
269 public:
270 explicit NarrowVisitor(Typer* typer) : Visitor(typer) {}
271
272 GenericGraphVisit::Control Pre(Node* node) {
273 if (node->op()->ValueOutputCount() > 0) {
274 Bounds previous = NodeProperties::GetBounds(node);
275 Bounds current = TypeNode(node);
276 NodeProperties::SetBounds(node, Bounds::Both(current, previous, zone()));
277 DCHECK(current.Narrows(previous));
278 // Stop when nothing changed (but allow re-entry in case it does later).
279 return previous.Narrows(current) ? GenericGraphVisit::DEFER
280 : GenericGraphVisit::REENTER;
281 } else {
282 return GenericGraphVisit::SKIP;
283 }
284 }
285
286 GenericGraphVisit::Control Post(Node* node) {
287 return GenericGraphVisit::REENTER;
288 }
289 };
290
291
292 class Typer::WidenVisitor : public Typer::Visitor { 267 class Typer::WidenVisitor : public Typer::Visitor {
293 public: 268 public:
294 explicit WidenVisitor(Typer* typer) 269 explicit WidenVisitor(Typer* typer)
295 : Visitor(typer), 270 : Visitor(typer),
296 local_zone_(zone()->isolate()), 271 local_zone_(zone()->isolate()),
297 enabled_(graph()->NodeCount(), true, &local_zone_), 272 enabled_(graph()->NodeCount(), true, &local_zone_),
298 queue_(&local_zone_) {} 273 queue_(&local_zone_) {}
299 274
300 void Run(NodeSet* nodes) { 275 void Run(NodeSet* nodes) {
301 // Queue all the roots. 276 // Queue all the roots.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 329
355 void Typer::Run() { 330 void Typer::Run() {
356 RunVisitor typing(this); 331 RunVisitor typing(this);
357 graph_->VisitNodeInputsFromEnd(&typing); 332 graph_->VisitNodeInputsFromEnd(&typing);
358 // Find least fixpoint. 333 // Find least fixpoint.
359 WidenVisitor widen(this); 334 WidenVisitor widen(this);
360 widen.Run(&typing.redo); 335 widen.Run(&typing.redo);
361 } 336 }
362 337
363 338
364 void Typer::Narrow(Node* start) {
365 NarrowVisitor typing(this);
366 graph_->VisitNodeUsesFrom(start, &typing);
367 }
368
369
370 void Typer::Decorator::Decorate(Node* node) { 339 void Typer::Decorator::Decorate(Node* node) {
371 if (node->op()->ValueOutputCount() > 0) { 340 if (node->op()->ValueOutputCount() > 0) {
372 // Only eagerly type-decorate nodes with known input types. 341 // Only eagerly type-decorate nodes with known input types.
373 // Other cases will generally require a proper fixpoint iteration with Run. 342 // Other cases will generally require a proper fixpoint iteration with Run.
374 bool is_typed = NodeProperties::IsTyped(node); 343 bool is_typed = NodeProperties::IsTyped(node);
375 if (is_typed || NodeProperties::AllValueInputsAreTyped(node)) { 344 if (is_typed || NodeProperties::AllValueInputsAreTyped(node)) {
376 Visitor typing(typer_); 345 Visitor typing(typer_);
377 Bounds bounds = typing.TypeNode(node); 346 Bounds bounds = typing.TypeNode(node);
378 if (is_typed) { 347 if (is_typed) {
379 bounds = 348 bounds =
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 return typer_->float64_array_fun_; 1877 return typer_->float64_array_fun_;
1909 } 1878 }
1910 } 1879 }
1911 } 1880 }
1912 return Type::Constant(value, zone()); 1881 return Type::Constant(value, zone());
1913 } 1882 }
1914 1883
1915 } 1884 }
1916 } 1885 }
1917 } // namespace v8::internal::compiler 1886 } // namespace v8::internal::compiler
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