OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 pre_parse_data_ = pre_parse_data; | 113 pre_parse_data_ = pre_parse_data; |
114 } | 114 } |
115 void SetCallingContext(Handle<Context> context) { | 115 void SetCallingContext(Handle<Context> context) { |
116 ASSERT(is_eval()); | 116 ASSERT(is_eval()); |
117 calling_context_ = context; | 117 calling_context_ = context; |
118 } | 118 } |
119 void SetOsrAstId(int osr_ast_id) { | 119 void SetOsrAstId(int osr_ast_id) { |
120 ASSERT(IsOptimizing()); | 120 ASSERT(IsOptimizing()); |
121 osr_ast_id_ = osr_ast_id; | 121 osr_ast_id_ = osr_ast_id; |
122 } | 122 } |
123 void MarkCompilingForDebugging(Handle<Code> current_code) { | |
124 ASSERT(mode_ != OPTIMIZE); | |
125 ASSERT(current_code->kind() == Code::FUNCTION); | |
126 flags_ |= IsCompilingForDebugging::encode(true); | |
127 if (current_code->is_compiled_optimizable()) { | |
128 EnableDeoptimizationSupport(); | |
129 } else { | |
130 mode_ = CompilationInfo::NONOPT; | |
131 } | |
132 } | |
133 bool IsCompilingForDebugging() { | |
134 return IsCompilingForDebugging::decode(flags_); | |
135 } | |
136 | 123 |
137 bool has_global_object() const { | 124 bool has_global_object() const { |
138 return !closure().is_null() && (closure()->context()->global() != NULL); | 125 return !closure().is_null() && (closure()->context()->global() != NULL); |
139 } | 126 } |
140 | 127 |
141 GlobalObject* global_object() const { | 128 GlobalObject* global_object() const { |
142 return has_global_object() ? closure()->context()->global() : NULL; | 129 return has_global_object() ? closure()->context()->global() : NULL; |
143 } | 130 } |
144 | 131 |
145 // Accessors for the different compilation modes. | 132 // Accessors for the different compilation modes. |
146 bool IsOptimizing() const { return mode_ == OPTIMIZE; } | 133 bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
147 bool IsOptimizable() const { return mode_ == BASE; } | 134 bool IsOptimizable() const { return mode_ == BASE; } |
148 void SetOptimizing(int osr_ast_id) { | 135 void SetOptimizing(int osr_ast_id) { |
149 SetMode(OPTIMIZE); | 136 SetMode(OPTIMIZE); |
150 osr_ast_id_ = osr_ast_id; | 137 osr_ast_id_ = osr_ast_id; |
151 } | 138 } |
152 void DisableOptimization(); | 139 void DisableOptimization(); |
153 | 140 |
154 // Deoptimization support. | 141 // Deoptimization support. |
155 bool HasDeoptimizationSupport() const { | 142 bool HasDeoptimizationSupport() const { return supports_deoptimization_; } |
156 return SupportsDeoptimization::decode(flags_); | |
157 } | |
158 void EnableDeoptimizationSupport() { | 143 void EnableDeoptimizationSupport() { |
159 ASSERT(IsOptimizable()); | 144 ASSERT(IsOptimizable()); |
160 flags_ |= SupportsDeoptimization::encode(true); | 145 supports_deoptimization_ = true; |
161 } | 146 } |
162 | 147 |
163 // Determine whether or not we can adaptively optimize. | 148 // Determine whether or not we can adaptively optimize. |
164 bool AllowOptimize() { | 149 bool AllowOptimize() { |
165 return V8::UseCrankshaft() && !closure_.is_null(); | 150 return V8::UseCrankshaft() && !closure_.is_null(); |
166 } | 151 } |
167 | 152 |
168 // Disable all optimization attempts of this info for the rest of the | 153 // Disable all optimization attempts of this info for the rest of the |
169 // current compilation pipeline. | 154 // current compilation pipeline. |
170 void AbortOptimization(); | 155 void AbortOptimization(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 class IsEval: public BitField<bool, 1, 1> {}; | 196 class IsEval: public BitField<bool, 1, 1> {}; |
212 class IsGlobal: public BitField<bool, 2, 1> {}; | 197 class IsGlobal: public BitField<bool, 2, 1> {}; |
213 // Flags that can be set for lazy compilation. | 198 // Flags that can be set for lazy compilation. |
214 class IsInLoop: public BitField<bool, 3, 1> {}; | 199 class IsInLoop: public BitField<bool, 3, 1> {}; |
215 // Strict mode - used in eager compilation. | 200 // Strict mode - used in eager compilation. |
216 class IsStrictMode: public BitField<bool, 4, 1> {}; | 201 class IsStrictMode: public BitField<bool, 4, 1> {}; |
217 // Native syntax (%-stuff) allowed? | 202 // Native syntax (%-stuff) allowed? |
218 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; | 203 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; |
219 // Is this a function from our natives. | 204 // Is this a function from our natives. |
220 class IsNative: public BitField<bool, 6, 1> {}; | 205 class IsNative: public BitField<bool, 6, 1> {}; |
221 // Is this code being compiled with support for deoptimization.. | |
222 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | |
223 // If compiling for debugging produce just full code matching the | |
224 // initial mode setting. | |
225 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | |
226 | 206 |
227 | 207 |
228 unsigned flags_; | 208 unsigned flags_; |
229 | 209 |
230 // Fields filled in by the compilation pipeline. | 210 // Fields filled in by the compilation pipeline. |
231 // AST filled in by the parser. | 211 // AST filled in by the parser. |
232 FunctionLiteral* function_; | 212 FunctionLiteral* function_; |
233 // The scope of the function literal as a convenience. Set to indicate | 213 // The scope of the function literal as a convenience. Set to indicate |
234 // that scopes have been analyzed. | 214 // that scopes have been analyzed. |
235 Scope* scope_; | 215 Scope* scope_; |
236 // The compiled code. | 216 // The compiled code. |
237 Handle<Code> code_; | 217 Handle<Code> code_; |
238 | 218 |
239 // Possible initial inputs to the compilation process. | 219 // Possible initial inputs to the compilation process. |
240 Handle<JSFunction> closure_; | 220 Handle<JSFunction> closure_; |
241 Handle<SharedFunctionInfo> shared_info_; | 221 Handle<SharedFunctionInfo> shared_info_; |
242 Handle<Script> script_; | 222 Handle<Script> script_; |
243 | 223 |
244 // Fields possibly needed for eager compilation, NULL by default. | 224 // Fields possibly needed for eager compilation, NULL by default. |
245 v8::Extension* extension_; | 225 v8::Extension* extension_; |
246 ScriptDataImpl* pre_parse_data_; | 226 ScriptDataImpl* pre_parse_data_; |
247 | 227 |
248 // The context of the caller is needed for eval code, and will be a null | 228 // The context of the caller is needed for eval code, and will be a null |
249 // handle otherwise. | 229 // handle otherwise. |
250 Handle<Context> calling_context_; | 230 Handle<Context> calling_context_; |
251 | 231 |
252 // Compilation mode flag and whether deoptimization is allowed. | 232 // Compilation mode flag and whether deoptimization is allowed. |
253 Mode mode_; | 233 Mode mode_; |
| 234 bool supports_deoptimization_; |
254 int osr_ast_id_; | 235 int osr_ast_id_; |
255 | 236 |
256 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 237 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
257 }; | 238 }; |
258 | 239 |
259 | 240 |
260 // The V8 compiler | 241 // The V8 compiler |
261 // | 242 // |
262 // General strategy: Source code is translated into an anonymous function w/o | 243 // General strategy: Source code is translated into an anonymous function w/o |
263 // parameters which then can be executed. If the source code contains other | 244 // parameters which then can be executed. If the source code contains other |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 298 |
318 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 299 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
319 CompilationInfo* info, | 300 CompilationInfo* info, |
320 Handle<SharedFunctionInfo> shared); | 301 Handle<SharedFunctionInfo> shared); |
321 }; | 302 }; |
322 | 303 |
323 | 304 |
324 } } // namespace v8::internal | 305 } } // namespace v8::internal |
325 | 306 |
326 #endif // V8_COMPILER_H_ | 307 #endif // V8_COMPILER_H_ |
OLD | NEW |