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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 ZoneList<BailoutEntry> stack_checks_; | 817 ZoneList<BailoutEntry> stack_checks_; |
821 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 818 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
822 int ic_total_count_; | 819 int ic_total_count_; |
823 Handle<FixedArray> handler_table_; | 820 Handle<FixedArray> handler_table_; |
824 Handle<JSGlobalPropertyCell> profiling_counter_; | 821 Handle<JSGlobalPropertyCell> profiling_counter_; |
825 bool generate_debug_code_; | 822 bool generate_debug_code_; |
826 Zone* zone_; | 823 Zone* zone_; |
827 | 824 |
828 friend class NestedStatement; | 825 friend class NestedStatement; |
829 | 826 |
830 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | |
831 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 827 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
832 }; | 828 }; |
833 | 829 |
834 | 830 |
835 // A map from property names to getter/setter pairs allocated in the zone. | 831 // A map from property names to getter/setter pairs allocated in the zone. |
836 class AccessorTable: public TemplateHashMap<Literal, | 832 class AccessorTable: public TemplateHashMap<Literal, |
837 ObjectLiteral::Accessors, | 833 ObjectLiteral::Accessors, |
838 ZoneAllocationPolicy> { | 834 ZoneAllocationPolicy> { |
839 public: | 835 public: |
840 explicit AccessorTable(Zone* zone) : | 836 explicit AccessorTable(Zone* zone) : |
841 TemplateHashMap<Literal, ObjectLiteral::Accessors, | 837 TemplateHashMap<Literal, ObjectLiteral::Accessors, |
842 ZoneAllocationPolicy>(Literal::Match, | 838 ZoneAllocationPolicy>(Literal::Match, |
843 ZoneAllocationPolicy(zone)), | 839 ZoneAllocationPolicy(zone)), |
844 zone_(zone) { } | 840 zone_(zone) { } |
845 | 841 |
846 Iterator lookup(Literal* literal) { | 842 Iterator lookup(Literal* literal) { |
847 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); | 843 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); |
848 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); | 844 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); |
849 return it; | 845 return it; |
850 } | 846 } |
851 | 847 |
852 private: | 848 private: |
853 Zone* zone_; | 849 Zone* zone_; |
854 }; | 850 }; |
855 | 851 |
856 | 852 |
857 } } // namespace v8::internal | 853 } } // namespace v8::internal |
858 | 854 |
859 #endif // V8_FULL_CODEGEN_H_ | 855 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |