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

Side by Side Diff: src/data-flow.h

Issue 1113009: Merge 4205:4215 from bleeding_edge to partial_snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.cc ('k') | src/data-flow.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 Node* entry_; 479 Node* entry_;
480 Node* exit_; 480 Node* exit_;
481 }; 481 };
482 482
483 483
484 // Construct a flow graph from a function literal. Build pre- and postorder 484 // Construct a flow graph from a function literal. Build pre- and postorder
485 // traversal orders as a byproduct. 485 // traversal orders as a byproduct.
486 class FlowGraphBuilder: public AstVisitor { 486 class FlowGraphBuilder: public AstVisitor {
487 public: 487 public:
488 FlowGraphBuilder() 488 explicit FlowGraphBuilder(int variable_count)
489 : graph_(FlowGraph::Empty()), 489 : graph_(FlowGraph::Empty()),
490 global_exit_(NULL), 490 global_exit_(NULL),
491 preorder_(4), 491 preorder_(4),
492 postorder_(4), 492 postorder_(4),
493 definitions_(4) {} 493 variable_count_(variable_count),
494 body_definitions_(4) {
495 }
494 496
495 void Build(FunctionLiteral* lit); 497 void Build(FunctionLiteral* lit);
496 498
497 FlowGraph* graph() { return &graph_; } 499 FlowGraph* graph() { return &graph_; }
498 ZoneList<Node*>* postorder() { return &postorder_; } 500 ZoneList<Node*>* postorder() { return &postorder_; }
499 ZoneList<Expression*>* definitions() { return &definitions_; } 501 ZoneList<Expression*>* body_definitions() { return &body_definitions_; }
500 502
501 private: 503 private:
502 ExitNode* global_exit() { return global_exit_; } 504 ExitNode* global_exit() { return global_exit_; }
503 505
504 // Helpers to allow tranforming the ast during flow graph construction. 506 // Helpers to allow tranforming the ast during flow graph construction.
505 void VisitStatements(ZoneList<Statement*>* stmts); 507 void VisitStatements(ZoneList<Statement*>* stmts);
506 Statement* ProcessStatement(Statement* stmt); 508 Statement* ProcessStatement(Statement* stmt);
507 509
508 // AST node visit functions. 510 // AST node visit functions.
509 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 511 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
510 AST_NODE_LIST(DECLARE_VISIT) 512 AST_NODE_LIST(DECLARE_VISIT)
511 #undef DECLARE_VISIT 513 #undef DECLARE_VISIT
512 514
513 FlowGraph graph_; 515 FlowGraph graph_;
514 ExitNode* global_exit_; 516 ExitNode* global_exit_;
515 ZoneList<Node*> preorder_; 517 ZoneList<Node*> preorder_;
516 ZoneList<Node*> postorder_; 518 ZoneList<Node*> postorder_;
517 519
518 // The flow graph builder collects a list of definitions (assignments and 520 // The flow graph builder collects a list of explicit definitions
519 // count operations) to stack-allocated variables to use for reaching 521 // (assignments and count operations) to stack-allocated variables to use
520 // definitions analysis. AST node numbers in the AST are used to refer 522 // for reaching definitions analysis. It does not count the implicit
521 // into this list. 523 // definition at function entry. AST node numbers in the AST are used to
522 ZoneList<Expression*> definitions_; 524 // refer into this list.
525 int variable_count_;
526 ZoneList<Expression*> body_definitions_;
523 527
524 DISALLOW_COPY_AND_ASSIGN(FlowGraphBuilder); 528 DISALLOW_COPY_AND_ASSIGN(FlowGraphBuilder);
525 }; 529 };
526 530
527 531
528 // This class is used to number all expressions in the AST according to 532 // This class is used to number all expressions in the AST according to
529 // their evaluation order (post-order left-to-right traversal). 533 // their evaluation order (post-order left-to-right traversal).
530 class AstLabeler: public AstVisitor { 534 class AstLabeler: public AstVisitor {
531 public: 535 public:
532 AstLabeler() : next_number_(0) {} 536 AstLabeler() : next_number_(0) {}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 // Accumulator for assigned variables set. 589 // Accumulator for assigned variables set.
586 BitVector av_; 590 BitVector av_;
587 591
588 DISALLOW_COPY_AND_ASSIGN(AssignedVariablesAnalyzer); 592 DISALLOW_COPY_AND_ASSIGN(AssignedVariablesAnalyzer);
589 }; 593 };
590 594
591 595
592 class ReachingDefinitions BASE_EMBEDDED { 596 class ReachingDefinitions BASE_EMBEDDED {
593 public: 597 public:
594 ReachingDefinitions(ZoneList<Node*>* postorder, 598 ReachingDefinitions(ZoneList<Node*>* postorder,
595 ZoneList<Expression*>* definitions, 599 ZoneList<Expression*>* body_definitions,
596 int variable_count) 600 int variable_count)
597 : postorder_(postorder), 601 : postorder_(postorder),
598 definitions_(definitions), 602 body_definitions_(body_definitions),
599 variables_(variable_count) { 603 variable_count_(variable_count) {
600 int definition_count = definitions->length();
601 for (int i = 0; i < variable_count; i++) {
602 variables_.Add(new BitVector(definition_count));
603 }
604 } 604 }
605 605
606 static int IndexFor(Variable* var, int variable_count); 606 static int IndexFor(Variable* var, int variable_count);
607 607
608 void Compute(); 608 void Compute();
609 609
610 private: 610 private:
611 // A (postorder) list of flow-graph nodes in the body. 611 // A (postorder) list of flow-graph nodes in the body.
612 ZoneList<Node*>* postorder_; 612 ZoneList<Node*>* postorder_;
613 613
614 // A list of all the definitions in the body. 614 // A list of all the definitions in the body.
615 ZoneList<Expression*>* definitions_; 615 ZoneList<Expression*>* body_definitions_;
616 616
617 // For each variable, the set of all its definitions. 617 int variable_count_;
618 List<BitVector*> variables_;
619 618
620 DISALLOW_COPY_AND_ASSIGN(ReachingDefinitions); 619 DISALLOW_COPY_AND_ASSIGN(ReachingDefinitions);
621 }; 620 };
622 621
623 622
624 } } // namespace v8::internal 623 } } // namespace v8::internal
625 624
626 625
627 #endif // V8_DATAFLOW_H_ 626 #endif // V8_DATAFLOW_H_
OLDNEW
« no previous file with comments | « src/cpu-profiler.cc ('k') | src/data-flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698