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 explicit FullCodeGenerator(MacroAssembler* masm) | 80 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info) |
81 : masm_(masm), | 81 : masm_(masm), |
82 info_(NULL), | 82 info_(info), |
83 scope_(NULL), | 83 scope_(info->scope()), |
84 nesting_stack_(NULL), | 84 nesting_stack_(NULL), |
85 loop_depth_(0), | 85 loop_depth_(0), |
86 global_count_(0), | 86 global_count_(0), |
87 context_(NULL), | 87 context_(NULL), |
88 bailout_entries_(0), | 88 bailout_entries_(info->HasDeoptimizationSupport() |
| 89 ? info->function()->ast_node_count() : 0), |
89 stack_checks_(2), // There's always at least one. | 90 stack_checks_(2), // There's always at least one. |
90 type_feedback_cells_(0) { | 91 type_feedback_cells_(info->HasDeoptimizationSupport() |
91 } | 92 ? info->function()->ast_node_count() : 0) { } |
92 | 93 |
93 static bool MakeCode(CompilationInfo* info); | 94 static bool MakeCode(CompilationInfo* info); |
94 | 95 |
95 void Generate(CompilationInfo* info); | 96 void Generate(); |
96 void PopulateDeoptimizationData(Handle<Code> code); | 97 void PopulateDeoptimizationData(Handle<Code> code); |
97 void PopulateTypeFeedbackCells(Handle<Code> code); | 98 void PopulateTypeFeedbackCells(Handle<Code> code); |
98 | 99 |
99 Handle<FixedArray> handler_table() { return handler_table_; } | 100 Handle<FixedArray> handler_table() { return handler_table_; } |
100 | 101 |
101 class StateField : public BitField<State, 0, 8> { }; | 102 // Encode state and pc-offset as a BitField<type, start, size>. |
102 class PcField : public BitField<unsigned, 8, 32-8> { }; | 103 // Only use 30 bits because we encode the result as a smi. |
| 104 class StateField : public BitField<State, 0, 1> { }; |
| 105 class PcField : public BitField<unsigned, 1, 30-1> { }; |
103 | 106 |
104 static const char* State2String(State state) { | 107 static const char* State2String(State state) { |
105 switch (state) { | 108 switch (state) { |
106 case NO_REGISTERS: return "NO_REGISTERS"; | 109 case NO_REGISTERS: return "NO_REGISTERS"; |
107 case TOS_REG: return "TOS_REG"; | 110 case TOS_REG: return "TOS_REG"; |
108 } | 111 } |
109 UNREACHABLE(); | 112 UNREACHABLE(); |
110 return NULL; | 113 return NULL; |
111 } | 114 } |
112 | 115 |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 780 |
778 friend class NestedStatement; | 781 friend class NestedStatement; |
779 | 782 |
780 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 783 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
781 }; | 784 }; |
782 | 785 |
783 | 786 |
784 } } // namespace v8::internal | 787 } } // namespace v8::internal |
785 | 788 |
786 #endif // V8_FULL_CODEGEN_H_ | 789 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |