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