Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 class ScriptDataImpl; | 38 class ScriptDataImpl; |
| 39 | 39 |
| 40 // CompilationInfo encapsulates some information known at compile time. It | 40 // CompilationInfo encapsulates some information known at compile time. It |
| 41 // is constructed based on the resources available at compile-time. | 41 // is constructed based on the resources available at compile-time. |
| 42 class CompilationInfo BASE_EMBEDDED { | 42 class CompilationInfo BASE_EMBEDDED { |
| 43 public: | 43 public: |
| 44 explicit CompilationInfo(Handle<Script> script); | 44 CompilationInfo(Handle<Script> script, Zone* zone); |
| 45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); | 45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); |
| 46 explicit CompilationInfo(Handle<JSFunction> closure); | 46 CompilationInfo(Handle<JSFunction> closure, Zone* zone); |
| 47 | 47 |
| 48 Isolate* isolate() { | 48 Isolate* isolate() { |
| 49 ASSERT(Isolate::Current() == isolate_); | 49 ASSERT(Isolate::Current() == isolate_); |
| 50 return isolate_; | 50 return isolate_; |
| 51 } | 51 } |
| 52 Zone* zone() { | |
| 53 return zone_; | |
| 54 } | |
| 52 bool is_lazy() const { return IsLazy::decode(flags_); } | 55 bool is_lazy() const { return IsLazy::decode(flags_); } |
| 53 bool is_eval() const { return IsEval::decode(flags_); } | 56 bool is_eval() const { return IsEval::decode(flags_); } |
| 54 bool is_global() const { return IsGlobal::decode(flags_); } | 57 bool is_global() const { return IsGlobal::decode(flags_); } |
| 55 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } | 58 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } |
| 56 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } | 59 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } |
| 57 LanguageMode language_mode() const { | 60 LanguageMode language_mode() const { |
| 58 return LanguageModeField::decode(flags_); | 61 return LanguageModeField::decode(flags_); |
| 59 } | 62 } |
| 60 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 63 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
| 61 FunctionLiteral* function() const { return function_; } | 64 FunctionLiteral* function() const { return function_; } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 // BASE is generated by the full codegen, optionally prepared for bailouts. | 180 // BASE is generated by the full codegen, optionally prepared for bailouts. |
| 178 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 181 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
| 179 // NONOPT is generated by the full codegen and is not prepared for | 182 // NONOPT is generated by the full codegen and is not prepared for |
| 180 // recompilation/bailouts. These functions are never recompiled. | 183 // recompilation/bailouts. These functions are never recompiled. |
| 181 enum Mode { | 184 enum Mode { |
| 182 BASE, | 185 BASE, |
| 183 OPTIMIZE, | 186 OPTIMIZE, |
| 184 NONOPT | 187 NONOPT |
| 185 }; | 188 }; |
| 186 | 189 |
| 187 CompilationInfo() : function_(NULL) {} | |
| 188 | |
| 189 void Initialize(Mode mode) { | 190 void Initialize(Mode mode) { |
| 190 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 191 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 191 ASSERT(!script_.is_null()); | 192 ASSERT(!script_.is_null()); |
| 192 if (script_->type()->value() == Script::TYPE_NATIVE) { | 193 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 193 MarkAsNative(); | 194 MarkAsNative(); |
| 194 } | 195 } |
| 195 if (!shared_info_.is_null()) { | 196 if (!shared_info_.is_null()) { |
| 196 ASSERT(language_mode() == CLASSIC_MODE); | 197 ASSERT(language_mode() == CLASSIC_MODE); |
| 197 SetLanguageMode(shared_info_->language_mode()); | 198 SetLanguageMode(shared_info_->language_mode()); |
| 198 } | 199 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 ScriptDataImpl* pre_parse_data_; | 248 ScriptDataImpl* pre_parse_data_; |
| 248 | 249 |
| 249 // The context of the caller is needed for eval code, and will be a null | 250 // The context of the caller is needed for eval code, and will be a null |
| 250 // handle otherwise. | 251 // handle otherwise. |
| 251 Handle<Context> calling_context_; | 252 Handle<Context> calling_context_; |
| 252 | 253 |
| 253 // Compilation mode flag and whether deoptimization is allowed. | 254 // Compilation mode flag and whether deoptimization is allowed. |
| 254 Mode mode_; | 255 Mode mode_; |
| 255 int osr_ast_id_; | 256 int osr_ast_id_; |
| 256 | 257 |
| 258 // The zone the compilation pipeline working on this CompilationInfo | |
| 259 // allocates from. | |
|
danno
2012/06/14 14:22:19
Maybe: The zone from which the compilation pipelin
sanjoy
2012/06/15 09:24:31
Fixed.
| |
| 260 Zone* zone_; | |
| 261 | |
| 257 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 262 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 258 }; | 263 }; |
| 259 | 264 |
| 260 | 265 |
| 261 // The V8 compiler | 266 // The V8 compiler |
| 262 // | 267 // |
| 263 // General strategy: Source code is translated into an anonymous function w/o | 268 // General strategy: Source code is translated into an anonymous function w/o |
| 264 // parameters which then can be executed. If the source code contains other | 269 // parameters which then can be executed. If the source code contains other |
| 265 // functions, they will be compiled and allocated as part of the compilation | 270 // functions, they will be compiled and allocated as part of the compilation |
| 266 // of the source code. | 271 // of the source code. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 | 327 |
| 323 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 328 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 324 CompilationInfo* info, | 329 CompilationInfo* info, |
| 325 Handle<SharedFunctionInfo> shared); | 330 Handle<SharedFunctionInfo> shared); |
| 326 }; | 331 }; |
| 327 | 332 |
| 328 | 333 |
| 329 } } // namespace v8::internal | 334 } } // namespace v8::internal |
| 330 | 335 |
| 331 #endif // V8_COMPILER_H_ | 336 #endif // V8_COMPILER_H_ |
| OLD | NEW |