Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_COMPILER_H_ |
| 29 | #define V8_COMPILER_H_ |
| 30 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 32 | #include "ast.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 33 | #include "zone.h" |
| 34 | |
| 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 38 | class ScriptDataImpl; |
| 39 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 40 | // CompilationInfo encapsulates some information known at compile time. It |
| 41 | // is constructed based on the resources available at compile-time. |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 42 | class CompilationInfo BASE_EMBEDDED { |
| 43 | public: |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 44 | explicit CompilationInfo(Handle<Script> script); |
| 45 | explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); |
| 46 | explicit CompilationInfo(Handle<JSFunction> closure); |
| 47 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 48 | Isolate* isolate() { |
| 49 | ASSERT(Isolate::Current() == isolate_); |
| 50 | return isolate_; |
| 51 | } |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 52 | bool is_lazy() const { return IsLazy::decode(flags_); } |
| 53 | bool is_eval() const { return IsEval::decode(flags_); } |
| 54 | bool is_global() const { return IsGlobal::decode(flags_); } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 55 | bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } |
| 56 | bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } |
| 57 | LanguageMode language_mode() const { |
| 58 | return LanguageModeField::decode(flags_); |
| 59 | } |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 60 | bool is_in_loop() const { return IsInLoop::decode(flags_); } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 61 | FunctionLiteral* function() const { return function_; } |
| 62 | Scope* scope() const { return scope_; } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 63 | Scope* global_scope() const { return global_scope_; } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 64 | Handle<Code> code() const { return code_; } |
| 65 | Handle<JSFunction> closure() const { return closure_; } |
| 66 | Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 67 | Handle<Script> script() const { return script_; } |
| 68 | v8::Extension* extension() const { return extension_; } |
| 69 | ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
| 70 | Handle<Context> calling_context() const { return calling_context_; } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 71 | int osr_ast_id() const { return osr_ast_id_; } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 72 | |
| 73 | void MarkAsEval() { |
| 74 | ASSERT(!is_lazy()); |
| 75 | flags_ |= IsEval::encode(true); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 76 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 77 | void MarkAsGlobal() { |
| 78 | ASSERT(!is_lazy()); |
| 79 | flags_ |= IsGlobal::encode(true); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 80 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 81 | void SetLanguageMode(LanguageMode language_mode) { |
| 82 | ASSERT(this->language_mode() == CLASSIC_MODE || |
| 83 | this->language_mode() == language_mode || |
| 84 | language_mode == EXTENDED_MODE); |
| 85 | flags_ = LanguageModeField::update(flags_, language_mode); |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 86 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 87 | void MarkAsInLoop() { |
| 88 | ASSERT(is_lazy()); |
| 89 | flags_ |= IsInLoop::encode(true); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 90 | } |
Ben Murdoch | 203a29f | 2011-10-20 14:36:23 +0100 | [diff] [blame] | 91 | void MarkAsNative() { |
| 92 | flags_ |= IsNative::encode(true); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 93 | } |
Ben Murdoch | 203a29f | 2011-10-20 14:36:23 +0100 | [diff] [blame] | 94 | bool is_native() const { |
| 95 | return IsNative::decode(flags_); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 96 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 97 | void SetFunction(FunctionLiteral* literal) { |
| 98 | ASSERT(function_ == NULL); |
| 99 | function_ = literal; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 100 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 101 | void SetScope(Scope* scope) { |
| 102 | ASSERT(scope_ == NULL); |
| 103 | scope_ = scope; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 104 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 105 | void SetGlobalScope(Scope* global_scope) { |
| 106 | ASSERT(global_scope_ == NULL); |
| 107 | global_scope_ = global_scope; |
| 108 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 109 | void SetCode(Handle<Code> code) { code_ = code; } |
| 110 | void SetExtension(v8::Extension* extension) { |
| 111 | ASSERT(!is_lazy()); |
| 112 | extension_ = extension; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 113 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 114 | void SetPreParseData(ScriptDataImpl* pre_parse_data) { |
| 115 | ASSERT(!is_lazy()); |
| 116 | pre_parse_data_ = pre_parse_data; |
| 117 | } |
| 118 | void SetCallingContext(Handle<Context> context) { |
| 119 | ASSERT(is_eval()); |
| 120 | calling_context_ = context; |
| 121 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 122 | void SetOsrAstId(int osr_ast_id) { |
| 123 | ASSERT(IsOptimizing()); |
| 124 | osr_ast_id_ = osr_ast_id; |
| 125 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 126 | void MarkCompilingForDebugging(Handle<Code> current_code) { |
| 127 | ASSERT(mode_ != OPTIMIZE); |
| 128 | ASSERT(current_code->kind() == Code::FUNCTION); |
| 129 | flags_ |= IsCompilingForDebugging::encode(true); |
| 130 | if (current_code->is_compiled_optimizable()) { |
| 131 | EnableDeoptimizationSupport(); |
| 132 | } else { |
| 133 | mode_ = CompilationInfo::NONOPT; |
| 134 | } |
| 135 | } |
| 136 | bool IsCompilingForDebugging() { |
| 137 | return IsCompilingForDebugging::decode(flags_); |
| 138 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 139 | |
| 140 | bool has_global_object() const { |
| 141 | return !closure().is_null() && (closure()->context()->global() != NULL); |
| 142 | } |
| 143 | |
| 144 | GlobalObject* global_object() const { |
| 145 | return has_global_object() ? closure()->context()->global() : NULL; |
| 146 | } |
| 147 | |
| 148 | // Accessors for the different compilation modes. |
| 149 | bool IsOptimizing() const { return mode_ == OPTIMIZE; } |
| 150 | bool IsOptimizable() const { return mode_ == BASE; } |
| 151 | void SetOptimizing(int osr_ast_id) { |
| 152 | SetMode(OPTIMIZE); |
| 153 | osr_ast_id_ = osr_ast_id; |
| 154 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 155 | void DisableOptimization(); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 156 | |
| 157 | // Deoptimization support. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 158 | bool HasDeoptimizationSupport() const { |
| 159 | return SupportsDeoptimization::decode(flags_); |
| 160 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 161 | void EnableDeoptimizationSupport() { |
| 162 | ASSERT(IsOptimizable()); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 163 | flags_ |= SupportsDeoptimization::encode(true); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 164 | } |
| 165 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 166 | // Determines whether or not to insert a self-optimization header. |
| 167 | bool ShouldSelfOptimize(); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 168 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 169 | // Disable all optimization attempts of this info for the rest of the |
| 170 | // current compilation pipeline. |
| 171 | void AbortOptimization(); |
| 172 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 173 | private: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 174 | Isolate* isolate_; |
| 175 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 176 | // Compilation mode. |
| 177 | // BASE is generated by the full codegen, optionally prepared for bailouts. |
| 178 | // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 179 | // NONOPT is generated by the full codegen and is not prepared for |
| 180 | // recompilation/bailouts. These functions are never recompiled. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 181 | enum Mode { |
| 182 | BASE, |
| 183 | OPTIMIZE, |
| 184 | NONOPT |
| 185 | }; |
| 186 | |
| 187 | CompilationInfo() : function_(NULL) {} |
| 188 | |
| 189 | void Initialize(Mode mode) { |
| 190 | mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 191 | ASSERT(!script_.is_null()); |
Ben Murdoch | 203a29f | 2011-10-20 14:36:23 +0100 | [diff] [blame] | 192 | if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 193 | MarkAsNative(); |
| 194 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 195 | if (!shared_info_.is_null()) { |
| 196 | ASSERT(language_mode() == CLASSIC_MODE); |
| 197 | SetLanguageMode(shared_info_->language_mode()); |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 198 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | void SetMode(Mode mode) { |
| 202 | ASSERT(V8::UseCrankshaft()); |
| 203 | mode_ = mode; |
| 204 | } |
| 205 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 206 | // Flags using template class BitField<type, start, length>. All are |
| 207 | // false by default. |
| 208 | // |
| 209 | // Compilation is either eager or lazy. |
| 210 | class IsLazy: public BitField<bool, 0, 1> {}; |
| 211 | // Flags that can be set for eager compilation. |
| 212 | class IsEval: public BitField<bool, 1, 1> {}; |
| 213 | class IsGlobal: public BitField<bool, 2, 1> {}; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 214 | // Flags that can be set for lazy compilation. |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 215 | class IsInLoop: public BitField<bool, 3, 1> {}; |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 216 | // Strict mode - used in eager compilation. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 217 | class LanguageModeField: public BitField<LanguageMode, 4, 2> {}; |
Ben Murdoch | 203a29f | 2011-10-20 14:36:23 +0100 | [diff] [blame] | 218 | // Is this a function from our natives. |
| 219 | class IsNative: public BitField<bool, 6, 1> {}; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 220 | // Is this code being compiled with support for deoptimization.. |
| 221 | class SupportsDeoptimization: public BitField<bool, 7, 1> {}; |
| 222 | // If compiling for debugging produce just full code matching the |
| 223 | // initial mode setting. |
| 224 | class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 225 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 226 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 227 | unsigned flags_; |
| 228 | |
| 229 | // Fields filled in by the compilation pipeline. |
| 230 | // AST filled in by the parser. |
| 231 | FunctionLiteral* function_; |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 232 | // The scope of the function literal as a convenience. Set to indicate |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 233 | // that scopes have been analyzed. |
| 234 | Scope* scope_; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 235 | // The global scope provided as a convenience. |
| 236 | Scope* global_scope_; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 237 | // The compiled code. |
| 238 | Handle<Code> code_; |
| 239 | |
| 240 | // Possible initial inputs to the compilation process. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 241 | Handle<JSFunction> closure_; |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 242 | Handle<SharedFunctionInfo> shared_info_; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 243 | Handle<Script> script_; |
| 244 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 245 | // Fields possibly needed for eager compilation, NULL by default. |
| 246 | v8::Extension* extension_; |
| 247 | ScriptDataImpl* pre_parse_data_; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 248 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 249 | // The context of the caller is needed for eval code, and will be a null |
| 250 | // handle otherwise. |
| 251 | Handle<Context> calling_context_; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 252 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 253 | // Compilation mode flag and whether deoptimization is allowed. |
| 254 | Mode mode_; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 255 | int osr_ast_id_; |
| 256 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 257 | DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 261 | // The V8 compiler |
| 262 | // |
| 263 | // 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 |
| 265 | // functions, they will be compiled and allocated as part of the compilation |
| 266 | // of the source code. |
| 267 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 268 | // Please note this interface returns shared function infos. This means you |
| 269 | // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a |
| 270 | // real function with a context. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 271 | |
| 272 | class Compiler : public AllStatic { |
| 273 | public: |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 274 | // Default maximum number of function optimization attempts before we |
| 275 | // give up. |
| 276 | static const int kDefaultMaxOptCount = 10; |
| 277 | |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 278 | static const int kMaxInliningLevels = 3; |
| 279 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 280 | // Call count before primitive functions trigger their own optimization. |
| 281 | static const int kCallsUntilPrimitiveOpt = 200; |
| 282 | |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 283 | // All routines return a SharedFunctionInfo. |
| 284 | // If an error occurs an exception is raised and the return handle |
| 285 | // contains NULL. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 286 | |
| 287 | // Compile a String source within a context. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 288 | static Handle<SharedFunctionInfo> Compile(Handle<String> source, |
| 289 | Handle<Object> script_name, |
| 290 | int line_offset, |
| 291 | int column_offset, |
| 292 | v8::Extension* extension, |
| 293 | ScriptDataImpl* pre_data, |
| 294 | Handle<Object> script_data, |
| 295 | NativesFlag is_natives_code); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 296 | |
| 297 | // Compile a String source within a context for Eval. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 298 | static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, |
| 299 | Handle<Context> context, |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 300 | bool is_global, |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 301 | LanguageMode language_mode, |
| 302 | int scope_position); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 303 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 304 | // Compile from function info (used for lazy compilation). Returns true on |
| 305 | // success and false if the compilation resulted in a stack overflow. |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 306 | static bool CompileLazy(CompilationInfo* info); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 307 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 308 | // Compile a shared function info object (the function is possibly lazily |
| 309 | // compiled). |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 310 | static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 311 | Handle<Script> script); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 312 | |
| 313 | // Set the function info for a newly compiled function. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 314 | static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 315 | FunctionLiteral* lit, |
| 316 | bool is_toplevel, |
| 317 | Handle<Script> script); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 318 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 319 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 320 | static bool MakeCodeForLiveEdit(CompilationInfo* info); |
| 321 | #endif |
| 322 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 323 | static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 324 | CompilationInfo* info, |
| 325 | Handle<SharedFunctionInfo> shared); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
| 328 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 329 | } } // namespace v8::internal |
| 330 | |
| 331 | #endif // V8_COMPILER_H_ |