OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Forward declarations. | 42 // Forward declarations. |
43 class JumpPatchSite; | 43 class JumpPatchSite; |
44 | 44 |
45 // AST node visitor which can tell whether a given statement will be breakable | 45 // AST node visitor which can tell whether a given statement will be breakable |
46 // when the code is compiled by the full compiler in the debugger. This means | 46 // when the code is compiled by the full compiler in the debugger. This means |
47 // that there will be an IC (load/store/call) in the code generated for the | 47 // that there will be an IC (load/store/call) in the code generated for the |
48 // debugger to piggybag on. | 48 // debugger to piggybag on. |
49 class BreakableStatementChecker: public AstVisitor { | 49 class BreakableStatementChecker: public AstVisitor { |
50 public: | 50 public: |
51 BreakableStatementChecker() : is_breakable_(false) { | 51 BreakableStatementChecker() : is_breakable_(false) {} |
52 InitializeAstVisitor(); | |
53 } | |
54 | 52 |
55 void Check(Statement* stmt); | 53 void Check(Statement* stmt); |
56 void Check(Expression* stmt); | 54 void Check(Expression* stmt); |
57 | 55 |
58 bool is_breakable() { return is_breakable_; } | 56 bool is_breakable() { return is_breakable_; } |
59 | 57 |
60 private: | 58 private: |
61 // AST node visit functions. | 59 // AST node visit functions. |
62 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 60 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
63 AST_NODE_LIST(DECLARE_VISIT) | 61 AST_NODE_LIST(DECLARE_VISIT) |
64 #undef DECLARE_VISIT | 62 #undef DECLARE_VISIT |
65 | 63 |
66 bool is_breakable_; | 64 bool is_breakable_; |
67 | 65 |
68 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | |
69 DISALLOW_COPY_AND_ASSIGN(BreakableStatementChecker); | 66 DISALLOW_COPY_AND_ASSIGN(BreakableStatementChecker); |
70 }; | 67 }; |
71 | 68 |
72 | 69 |
73 // ----------------------------------------------------------------------------- | 70 // ----------------------------------------------------------------------------- |
74 // Full code generator. | 71 // Full code generator. |
75 | 72 |
76 class FullCodeGenerator: public AstVisitor { | 73 class FullCodeGenerator: public AstVisitor { |
77 public: | 74 public: |
78 enum State { | 75 enum State { |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 ZoneList<BailoutEntry> stack_checks_; | 818 ZoneList<BailoutEntry> stack_checks_; |
822 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 819 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
823 int ic_total_count_; | 820 int ic_total_count_; |
824 Handle<FixedArray> handler_table_; | 821 Handle<FixedArray> handler_table_; |
825 Handle<JSGlobalPropertyCell> profiling_counter_; | 822 Handle<JSGlobalPropertyCell> profiling_counter_; |
826 bool generate_debug_code_; | 823 bool generate_debug_code_; |
827 Zone* zone_; | 824 Zone* zone_; |
828 | 825 |
829 friend class NestedStatement; | 826 friend class NestedStatement; |
830 | 827 |
831 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | |
832 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 828 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
833 }; | 829 }; |
834 | 830 |
835 | 831 |
836 // A map from property names to getter/setter pairs allocated in the zone. | 832 // A map from property names to getter/setter pairs allocated in the zone. |
837 class AccessorTable: public TemplateHashMap<Literal, | 833 class AccessorTable: public TemplateHashMap<Literal, |
838 ObjectLiteral::Accessors, | 834 ObjectLiteral::Accessors, |
839 ZoneAllocationPolicy> { | 835 ZoneAllocationPolicy> { |
840 public: | 836 public: |
841 explicit AccessorTable(Zone* zone) : | 837 explicit AccessorTable(Zone* zone) : |
842 TemplateHashMap<Literal, ObjectLiteral::Accessors, | 838 TemplateHashMap<Literal, ObjectLiteral::Accessors, |
843 ZoneAllocationPolicy>(Literal::Match, | 839 ZoneAllocationPolicy>(Literal::Match, |
844 ZoneAllocationPolicy(zone)), | 840 ZoneAllocationPolicy(zone)), |
845 zone_(zone) { } | 841 zone_(zone) { } |
846 | 842 |
847 Iterator lookup(Literal* literal) { | 843 Iterator lookup(Literal* literal) { |
848 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); | 844 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); |
849 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); | 845 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); |
850 return it; | 846 return it; |
851 } | 847 } |
852 | 848 |
853 private: | 849 private: |
854 Zone* zone_; | 850 Zone* zone_; |
855 }; | 851 }; |
856 | 852 |
857 | 853 |
858 } } // namespace v8::internal | 854 } } // namespace v8::internal |
859 | 855 |
860 #endif // V8_FULL_CODEGEN_H_ | 856 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |