OLD | NEW |
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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 543 |
544 // Traversal number for labelling AST nodes. | 544 // Traversal number for labelling AST nodes. |
545 int next_number_; | 545 int next_number_; |
546 | 546 |
547 CompilationInfo* info_; | 547 CompilationInfo* info_; |
548 | 548 |
549 DISALLOW_COPY_AND_ASSIGN(AstLabeler); | 549 DISALLOW_COPY_AND_ASSIGN(AstLabeler); |
550 }; | 550 }; |
551 | 551 |
552 | 552 |
553 class VarUseMap : public HashMap { | |
554 public: | |
555 VarUseMap() : HashMap(VarMatch) {} | |
556 | |
557 ZoneList<Expression*>* Lookup(Variable* var); | |
558 | |
559 private: | |
560 static bool VarMatch(void* key1, void* key2) { return key1 == key2; } | |
561 }; | |
562 | |
563 | |
564 class DefinitionInfo : public ZoneObject { | |
565 public: | |
566 explicit DefinitionInfo() : last_use_(NULL) {} | |
567 | |
568 Expression* last_use() { return last_use_; } | |
569 void set_last_use(Expression* expr) { last_use_ = expr; } | |
570 | |
571 private: | |
572 Expression* last_use_; | |
573 Register location_; | |
574 }; | |
575 | |
576 | |
577 class LivenessAnalyzer : public AstVisitor { | |
578 public: | |
579 LivenessAnalyzer() {} | |
580 | |
581 void Analyze(FunctionLiteral* fun); | |
582 | |
583 private: | |
584 void VisitStatements(ZoneList<Statement*>* stmts); | |
585 | |
586 void RecordUse(Variable* var, Expression* expr); | |
587 void RecordDef(Variable* var, Expression* expr); | |
588 | |
589 | |
590 // AST node visit functions. | |
591 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | |
592 AST_NODE_LIST(DECLARE_VISIT) | |
593 #undef DECLARE_VISIT | |
594 | |
595 // Map for tracking the live variables. | |
596 VarUseMap live_vars_; | |
597 | |
598 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); | |
599 }; | |
600 | |
601 | |
602 // Computes the set of assigned variables and annotates variables proxies | 553 // Computes the set of assigned variables and annotates variables proxies |
603 // that are trivial sub-expressions and for-loops where the loop variable | 554 // that are trivial sub-expressions and for-loops where the loop variable |
604 // is guaranteed to be a smi. | 555 // is guaranteed to be a smi. |
605 class AssignedVariablesAnalyzer : public AstVisitor { | 556 class AssignedVariablesAnalyzer : public AstVisitor { |
606 public: | 557 public: |
607 explicit AssignedVariablesAnalyzer(FunctionLiteral* fun); | 558 explicit AssignedVariablesAnalyzer(FunctionLiteral* fun); |
608 | 559 |
609 void Analyze(); | 560 void Analyze(); |
610 | 561 |
611 private: | 562 private: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 List<BitVector*> variables_; | 615 List<BitVector*> variables_; |
665 | 616 |
666 DISALLOW_COPY_AND_ASSIGN(ReachingDefinitions); | 617 DISALLOW_COPY_AND_ASSIGN(ReachingDefinitions); |
667 }; | 618 }; |
668 | 619 |
669 | 620 |
670 } } // namespace v8::internal | 621 } } // namespace v8::internal |
671 | 622 |
672 | 623 |
673 #endif // V8_DATAFLOW_H_ | 624 #endif // V8_DATAFLOW_H_ |
OLD | NEW |