| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // ----------------------------------------------------------------------------- | 70 // ----------------------------------------------------------------------------- |
| 71 // Full code generator. | 71 // Full code generator. |
| 72 | 72 |
| 73 class FullCodeGenerator: public AstVisitor { | 73 class FullCodeGenerator: public AstVisitor { |
| 74 public: | 74 public: |
| 75 enum State { | 75 enum State { |
| 76 NO_REGISTERS, | 76 NO_REGISTERS, |
| 77 TOS_REG | 77 TOS_REG |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info) | 80 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info, |
| 81 Zone* zone) |
| 81 : masm_(masm), | 82 : masm_(masm), |
| 82 info_(info), | 83 info_(info), |
| 83 scope_(info->scope()), | 84 scope_(info->scope()), |
| 84 nesting_stack_(NULL), | 85 nesting_stack_(NULL), |
| 85 loop_depth_(0), | 86 loop_depth_(0), |
| 86 globals_(NULL), | 87 globals_(NULL), |
| 87 context_(NULL), | 88 context_(NULL), |
| 88 bailout_entries_(info->HasDeoptimizationSupport() | 89 bailout_entries_(info->HasDeoptimizationSupport() |
| 89 ? info->function()->ast_node_count() : 0), | 90 ? info->function()->ast_node_count() : 0, zone), |
| 90 stack_checks_(2), // There's always at least one. | 91 stack_checks_(2, zone), // There's always at least one. |
| 91 type_feedback_cells_(info->HasDeoptimizationSupport() | 92 type_feedback_cells_(info->HasDeoptimizationSupport() |
| 92 ? info->function()->ast_node_count() : 0), | 93 ? info->function()->ast_node_count() : 0, zone), |
| 93 ic_total_count_(0) { } | 94 ic_total_count_(0), |
| 95 zone_(zone) { } |
| 94 | 96 |
| 95 static bool MakeCode(CompilationInfo* info); | 97 static bool MakeCode(CompilationInfo* info); |
| 96 | 98 |
| 97 // Encode state and pc-offset as a BitField<type, start, size>. | 99 // Encode state and pc-offset as a BitField<type, start, size>. |
| 98 // Only use 30 bits because we encode the result as a smi. | 100 // Only use 30 bits because we encode the result as a smi. |
| 99 class StateField : public BitField<State, 0, 1> { }; | 101 class StateField : public BitField<State, 0, 1> { }; |
| 100 class PcField : public BitField<unsigned, 1, 30-1> { }; | 102 class PcField : public BitField<unsigned, 1, 30-1> { }; |
| 101 | 103 |
| 102 static const char* State2String(State state) { | 104 static const char* State2String(State state) { |
| 103 switch (state) { | 105 switch (state) { |
| 104 case NO_REGISTERS: return "NO_REGISTERS"; | 106 case NO_REGISTERS: return "NO_REGISTERS"; |
| 105 case TOS_REG: return "TOS_REG"; | 107 case TOS_REG: return "TOS_REG"; |
| 106 } | 108 } |
| 107 UNREACHABLE(); | 109 UNREACHABLE(); |
| 108 return NULL; | 110 return NULL; |
| 109 } | 111 } |
| 110 | 112 |
| 113 Zone* zone() { return zone_; } |
| 114 |
| 111 private: | 115 private: |
| 112 class Breakable; | 116 class Breakable; |
| 113 class Iteration; | 117 class Iteration; |
| 114 | 118 |
| 115 class TestContext; | 119 class TestContext; |
| 116 | 120 |
| 117 class NestedStatement BASE_EMBEDDED { | 121 class NestedStatement BASE_EMBEDDED { |
| 118 public: | 122 public: |
| 119 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { | 123 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { |
| 120 // Link into codegen's nesting stack. | 124 // Link into codegen's nesting stack. |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 NestedStatement* nesting_stack_; | 783 NestedStatement* nesting_stack_; |
| 780 int loop_depth_; | 784 int loop_depth_; |
| 781 ZoneList<Handle<Object> >* globals_; | 785 ZoneList<Handle<Object> >* globals_; |
| 782 const ExpressionContext* context_; | 786 const ExpressionContext* context_; |
| 783 ZoneList<BailoutEntry> bailout_entries_; | 787 ZoneList<BailoutEntry> bailout_entries_; |
| 784 ZoneList<BailoutEntry> stack_checks_; | 788 ZoneList<BailoutEntry> stack_checks_; |
| 785 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 789 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
| 786 int ic_total_count_; | 790 int ic_total_count_; |
| 787 Handle<FixedArray> handler_table_; | 791 Handle<FixedArray> handler_table_; |
| 788 Handle<JSGlobalPropertyCell> profiling_counter_; | 792 Handle<JSGlobalPropertyCell> profiling_counter_; |
| 793 Zone* zone_; |
| 789 | 794 |
| 790 friend class NestedStatement; | 795 friend class NestedStatement; |
| 791 | 796 |
| 792 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 797 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 793 }; | 798 }; |
| 794 | 799 |
| 795 | 800 |
| 796 // A map from property names to getter/setter pairs allocated in the zone. | 801 // A map from property names to getter/setter pairs allocated in the zone. |
| 797 class AccessorTable: public TemplateHashMap<Literal, | 802 class AccessorTable: public TemplateHashMap<Literal, |
| 798 ObjectLiteral::Accessors, | 803 ObjectLiteral::Accessors, |
| 799 ZoneAllocationPolicy> { | 804 ZoneAllocationPolicy> { |
| 800 public: | 805 public: |
| 801 explicit AccessorTable(Zone* zone) : | 806 explicit AccessorTable(Zone* zone) : |
| 802 TemplateHashMap<Literal, ObjectLiteral::Accessors, | 807 TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| 803 ZoneAllocationPolicy>(Literal::Match), | 808 ZoneAllocationPolicy>(Literal::Match, |
| 809 ZoneAllocationPolicy(zone)), |
| 804 zone_(zone) { } | 810 zone_(zone) { } |
| 805 | 811 |
| 806 Iterator lookup(Literal* literal) { | 812 Iterator lookup(Literal* literal) { |
| 807 Iterator it = find(literal, true); | 813 Iterator it = find(literal, true, ZoneAllocationPolicy(zone_)); |
| 808 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); | 814 if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors(); |
| 809 return it; | 815 return it; |
| 810 } | 816 } |
| 811 | 817 |
| 812 private: | 818 private: |
| 813 Zone* zone_; | 819 Zone* zone_; |
| 814 }; | 820 }; |
| 815 | 821 |
| 816 | 822 |
| 817 } } // namespace v8::internal | 823 } } // namespace v8::internal |
| 818 | 824 |
| 819 #endif // V8_FULL_CODEGEN_H_ | 825 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |