Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 1 | // Copyright 2011 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 | #include "v8.h" |
| 29 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 30 | #include "compiler.h" |
| 31 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 32 | #include "bootstrapper.h" |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 33 | #include "codegen.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | #include "compilation-cache.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 35 | #include "debug.h" |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 36 | #include "full-codegen.h" |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 37 | #include "gdb-jit.h" |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 38 | #include "hydrogen.h" |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 39 | #include "lithium.h" |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 40 | #include "liveedit.h" |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 41 | #include "parser.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 42 | #include "rewriter.h" |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 43 | #include "runtime-profiler.h" |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 44 | #include "scanner-character-streams.h" |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 45 | #include "scopeinfo.h" |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 46 | #include "scopes.h" |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 47 | #include "vm-state-inl.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 48 | |
| 49 | namespace v8 { |
| 50 | namespace internal { |
| 51 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 52 | |
| 53 | CompilationInfo::CompilationInfo(Handle<Script> script) |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 54 | : isolate_(script->GetIsolate()), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 55 | flags_(0), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 56 | function_(NULL), |
| 57 | scope_(NULL), |
| 58 | script_(script), |
| 59 | extension_(NULL), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 60 | pre_parse_data_(NULL), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 61 | supports_deoptimization_(false), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 62 | osr_ast_id_(AstNode::kNoNumber) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 63 | Initialize(NONOPT); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | |
| 67 | CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 68 | : isolate_(shared_info->GetIsolate()), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 69 | flags_(IsLazy::encode(true)), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 70 | function_(NULL), |
| 71 | scope_(NULL), |
| 72 | shared_info_(shared_info), |
| 73 | script_(Handle<Script>(Script::cast(shared_info->script()))), |
| 74 | extension_(NULL), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 75 | pre_parse_data_(NULL), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 76 | supports_deoptimization_(false), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 77 | osr_ast_id_(AstNode::kNoNumber) { |
| 78 | Initialize(BASE); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | |
| 82 | CompilationInfo::CompilationInfo(Handle<JSFunction> closure) |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 83 | : isolate_(closure->GetIsolate()), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 84 | flags_(IsLazy::encode(true)), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 85 | function_(NULL), |
| 86 | scope_(NULL), |
| 87 | closure_(closure), |
| 88 | shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
| 89 | script_(Handle<Script>(Script::cast(shared_info_->script()))), |
| 90 | extension_(NULL), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 91 | pre_parse_data_(NULL), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 92 | supports_deoptimization_(false), |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 93 | osr_ast_id_(AstNode::kNoNumber) { |
| 94 | Initialize(BASE); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 98 | // Disable optimization for the rest of the compilation pipeline. |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 99 | void CompilationInfo::DisableOptimization() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 100 | bool is_optimizable_closure = |
| 101 | FLAG_optimize_closures && |
| 102 | closure_.is_null() && |
| 103 | !scope_->HasTrivialOuterContext() && |
| 104 | !scope_->outer_scope_calls_non_strict_eval() && |
| 105 | !scope_->inside_with(); |
| 106 | SetMode(is_optimizable_closure ? BASE : NONOPT); |
| 107 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 108 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 109 | |
| 110 | void CompilationInfo::AbortOptimization() { |
| 111 | Handle<Code> code(shared_info()->code()); |
| 112 | SetCode(code); |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 116 | // Determine whether to use the full compiler for all code. If the flag |
| 117 | // --always-full-compiler is specified this is the case. For the virtual frame |
| 118 | // based compiler the full compiler is also used if a debugger is connected, as |
| 119 | // the code from the full compiler supports mode precise break points. For the |
| 120 | // crankshaft adaptive compiler debugging the optimized code is not possible at |
| 121 | // all. However crankshaft support recompilation of functions, so in this case |
| 122 | // the full compiler need not be be used if a debugger is attached, but only if |
| 123 | // break points has actually been set. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 124 | static bool is_debugging_active() { |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 125 | #ifdef ENABLE_DEBUGGER_SUPPORT |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 126 | Isolate* isolate = Isolate::Current(); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 127 | return V8::UseCrankshaft() ? |
| 128 | isolate->debug()->has_break_points() : |
| 129 | isolate->debugger()->IsDebuggerActive(); |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 130 | #else |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 131 | return false; |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 132 | #endif |
| 133 | } |
| 134 | |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 135 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 136 | static bool AlwaysFullCompiler() { |
| 137 | return FLAG_always_full_compiler || is_debugging_active(); |
| 138 | } |
| 139 | |
| 140 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 141 | static void FinishOptimization(Handle<JSFunction> function, int64_t start) { |
| 142 | int opt_count = function->shared()->opt_count(); |
| 143 | function->shared()->set_opt_count(opt_count + 1); |
| 144 | double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
| 145 | if (FLAG_trace_opt) { |
| 146 | PrintF("[optimizing: "); |
| 147 | function->PrintName(); |
| 148 | PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function)); |
| 149 | PrintF(" - took %0.3f ms]\n", ms); |
| 150 | } |
| 151 | if (FLAG_trace_opt_stats) { |
| 152 | static double compilation_time = 0.0; |
| 153 | static int compiled_functions = 0; |
| 154 | static int code_size = 0; |
| 155 | |
| 156 | compilation_time += ms; |
| 157 | compiled_functions++; |
| 158 | code_size += function->shared()->SourceSize(); |
| 159 | PrintF("Compiled: %d functions with %d byte source size in %fms.\n", |
| 160 | compiled_functions, |
| 161 | code_size, |
| 162 | compilation_time); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 167 | static bool MakeCrankshaftCode(CompilationInfo* info) { |
| 168 | // Test if we can optimize this function when asked to. We can only |
| 169 | // do this after the scopes are computed. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 170 | if (!info->AllowOptimize()) info->DisableOptimization(); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 171 | |
| 172 | // In case we are not optimizing simply return the code from |
| 173 | // the full code generator. |
| 174 | if (!info->IsOptimizing()) { |
| 175 | return FullCodeGenerator::MakeCode(info); |
| 176 | } |
| 177 | |
| 178 | // We should never arrive here if there is not code object on the |
| 179 | // shared function object. |
| 180 | Handle<Code> code(info->shared_info()->code()); |
| 181 | ASSERT(code->kind() == Code::FUNCTION); |
| 182 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 183 | // We should never arrive here if optimization has been disabled on the |
| 184 | // shared function info. |
| 185 | ASSERT(!info->shared_info()->optimization_disabled()); |
| 186 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 187 | // Fall back to using the full code generator if it's not possible |
| 188 | // to use the Hydrogen-based optimizing compiler. We already have |
| 189 | // generated code for this from the shared function object. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 190 | if (AlwaysFullCompiler() || !FLAG_use_hydrogen) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 191 | info->SetCode(code); |
| 192 | return true; |
| 193 | } |
| 194 | |
| 195 | // Limit the number of times we re-compile a functions with |
| 196 | // the optimizing compiler. |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 197 | const int kMaxOptCount = |
| 198 | FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 199 | if (info->shared_info()->opt_count() > kMaxOptCount) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 200 | info->AbortOptimization(); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 201 | Handle<JSFunction> closure = info->closure(); |
| 202 | info->shared_info()->DisableOptimization(*closure); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 203 | // True indicates the compilation pipeline is still going, not |
| 204 | // necessarily that we optimized the code. |
| 205 | return true; |
| 206 | } |
| 207 | |
| 208 | // Due to an encoding limit on LUnallocated operands in the Lithium |
| 209 | // language, we cannot optimize functions with too many formal parameters |
| 210 | // or perform on-stack replacement for function with too many |
| 211 | // stack-allocated local variables. |
| 212 | // |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 213 | // The encoding is as a signed value, with parameters and receiver using |
| 214 | // the negative indices and locals the non-negative ones. |
Ben Murdoch | 7d3e7fc | 2011-07-12 16:37:06 +0100 | [diff] [blame] | 215 | const int parameter_limit = -LUnallocated::kMinFixedIndex; |
| 216 | const int locals_limit = LUnallocated::kMaxFixedIndex; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 217 | Scope* scope = info->scope(); |
Ben Murdoch | 7d3e7fc | 2011-07-12 16:37:06 +0100 | [diff] [blame] | 218 | if ((scope->num_parameters() + 1) > parameter_limit || |
| 219 | (info->osr_ast_id() != AstNode::kNoNumber && |
| 220 | scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit)) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 221 | info->AbortOptimization(); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 222 | Handle<JSFunction> closure = info->closure(); |
| 223 | info->shared_info()->DisableOptimization(*closure); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 224 | // True indicates the compilation pipeline is still going, not |
| 225 | // necessarily that we optimized the code. |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | // Take --hydrogen-filter into account. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 230 | Vector<const char> filter = CStrVector(FLAG_hydrogen_filter); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 231 | Handle<String> name = info->function()->debug_name(); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 232 | bool match = filter.is_empty() || name->IsEqualTo(filter); |
| 233 | if (!match) { |
| 234 | info->SetCode(code); |
| 235 | return true; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | // Recompile the unoptimized version of the code if the current version |
| 239 | // doesn't have deoptimization support. Alternatively, we may decide to |
| 240 | // run the full code generator to get a baseline for the compile-time |
| 241 | // performance of the hydrogen-based compiler. |
| 242 | int64_t start = OS::Ticks(); |
| 243 | bool should_recompile = !info->shared_info()->has_deoptimization_support(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 244 | if (should_recompile || FLAG_hydrogen_stats) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 245 | HPhase phase(HPhase::kFullCodeGen); |
| 246 | CompilationInfo unoptimized(info->shared_info()); |
| 247 | // Note that we use the same AST that we will use for generating the |
| 248 | // optimized code. |
| 249 | unoptimized.SetFunction(info->function()); |
| 250 | unoptimized.SetScope(info->scope()); |
| 251 | if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
| 252 | bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); |
| 253 | if (should_recompile) { |
| 254 | if (!succeeded) return false; |
| 255 | Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 256 | shared->EnableDeoptimizationSupport(*unoptimized.code()); |
| 257 | // The existing unoptimized code was replaced with the new one. |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 258 | Compiler::RecordFunctionCompilation( |
| 259 | Logger::LAZY_COMPILE_TAG, &unoptimized, shared); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
| 263 | // Check that the unoptimized, shared code is ready for |
| 264 | // optimizations. When using the always_opt flag we disregard the |
| 265 | // optimizable marker in the code object and optimize anyway. This |
| 266 | // is safe as long as the unoptimized code has deoptimization |
| 267 | // support. |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 268 | ASSERT(FLAG_always_opt || code->optimizable()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 269 | ASSERT(info->shared_info()->has_deoptimization_support()); |
| 270 | |
| 271 | if (FLAG_trace_hydrogen) { |
| 272 | PrintF("-----------------------------------------------------------\n"); |
| 273 | PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
| 274 | HTracer::Instance()->TraceCompilation(info->function()); |
| 275 | } |
| 276 | |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 277 | Handle<Context> global_context(info->closure()->context()->global_context()); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 278 | TypeFeedbackOracle oracle(code, global_context); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 279 | HGraphBuilder builder(info, &oracle); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 280 | HPhase phase(HPhase::kTotal); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 281 | HGraph* graph = builder.CreateGraph(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 282 | if (info->isolate()->has_pending_exception()) { |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 283 | info->SetCode(Handle<Code>::null()); |
| 284 | return false; |
| 285 | } |
| 286 | |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 287 | if (graph != NULL && FLAG_build_lithium) { |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 288 | Handle<Code> optimized_code = graph->Compile(info); |
| 289 | if (!optimized_code.is_null()) { |
| 290 | info->SetCode(optimized_code); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 291 | FinishOptimization(info->closure(), start); |
| 292 | return true; |
| 293 | } |
| 294 | } |
| 295 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 296 | // Keep using the shared code. |
| 297 | info->AbortOptimization(); |
| 298 | if (!builder.inline_bailout()) { |
| 299 | // Mark the shared code as unoptimizable unless it was an inlined |
| 300 | // function that bailed out. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 301 | Handle<JSFunction> closure = info->closure(); |
| 302 | info->shared_info()->DisableOptimization(*closure); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 303 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 304 | // True indicates the compilation pipeline is still going, not necessarily |
| 305 | // that we optimized the code. |
| 306 | return true; |
| 307 | } |
| 308 | |
| 309 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 310 | static bool GenerateCode(CompilationInfo* info) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 311 | return V8::UseCrankshaft() ? |
| 312 | MakeCrankshaftCode(info) : |
| 313 | FullCodeGenerator::MakeCode(info); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 317 | static bool MakeCode(CompilationInfo* info) { |
| 318 | // Precondition: code has been parsed. Postcondition: the code field in |
| 319 | // the compilation info is set if compilation succeeded. |
| 320 | ASSERT(info->function() != NULL); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 321 | return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 325 | #ifdef ENABLE_DEBUGGER_SUPPORT |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 326 | bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) { |
| 327 | // Precondition: code has been parsed. Postcondition: the code field in |
| 328 | // the compilation info is set if compilation succeeded. |
| 329 | bool succeeded = MakeCode(info); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 330 | if (!info->shared_info().is_null()) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 331 | Handle<SerializedScopeInfo> scope_info = |
| 332 | SerializedScopeInfo::Create(info->scope()); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 333 | info->shared_info()->set_scope_info(*scope_info); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 334 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 335 | return succeeded; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 336 | } |
| 337 | #endif |
| 338 | |
| 339 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 340 | static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 341 | Isolate* isolate = info->isolate(); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 342 | ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 343 | PostponeInterruptsScope postpone(isolate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 344 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 345 | ASSERT(!isolate->global_context().is_null()); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 346 | Handle<Script> script = info->script(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 347 | script->set_context_data((*isolate->global_context())->data()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 348 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 349 | #ifdef ENABLE_DEBUGGER_SUPPORT |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 350 | if (info->is_eval()) { |
| 351 | Script::CompilationType compilation_type = Script::COMPILATION_TYPE_EVAL; |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 352 | script->set_compilation_type(Smi::FromInt(compilation_type)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 353 | // For eval scripts add information on the function from which eval was |
| 354 | // called. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 355 | if (info->is_eval()) { |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 356 | StackTraceFrameIterator it(isolate); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 357 | if (!it.done()) { |
| 358 | script->set_eval_from_shared( |
| 359 | JSFunction::cast(it.frame()->function())->shared()); |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 360 | Code* code = it.frame()->LookupCode(); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 361 | int offset = static_cast<int>( |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 362 | it.frame()->pc() - code->instruction_start()); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 363 | script->set_eval_from_instructions_offset(Smi::FromInt(offset)); |
| 364 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | |
| 368 | // Notify debugger |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 369 | isolate->debugger()->OnBeforeCompile(script); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 370 | #endif |
| 371 | |
| 372 | // Only allow non-global compiles for eval. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 373 | ASSERT(info->is_eval() || info->is_global()); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 374 | |
| 375 | if (!ParserApi::Parse(info)) return Handle<SharedFunctionInfo>::null(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 376 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 377 | // Measure how long it takes to do the compilation; only take the |
| 378 | // rest of the function into account to avoid overlap with the |
| 379 | // parsing statistics. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 380 | HistogramTimer* rate = info->is_eval() |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 381 | ? info->isolate()->counters()->compile_eval() |
| 382 | : info->isolate()->counters()->compile(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 383 | HistogramTimerScope timer(rate); |
| 384 | |
| 385 | // Compile the code. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 386 | FunctionLiteral* lit = info->function(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 387 | LiveEditFunctionTracker live_edit_tracker(isolate, lit); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 388 | if (!MakeCode(info)) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 389 | isolate->StackOverflow(); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 390 | return Handle<SharedFunctionInfo>::null(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 393 | // Allocate function. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 394 | ASSERT(!info->code().is_null()); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 395 | Handle<SharedFunctionInfo> result = |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 396 | isolate->factory()->NewSharedFunctionInfo( |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 397 | lit->name(), |
| 398 | lit->materialized_literal_count(), |
| 399 | info->code(), |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 400 | SerializedScopeInfo::Create(info->scope())); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 401 | |
| 402 | ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
| 403 | Compiler::SetFunctionInfo(result, lit, true, script); |
| 404 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 405 | if (script->name()->IsString()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 406 | PROFILE(isolate, CodeCreateEvent( |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 407 | info->is_eval() |
| 408 | ? Logger::EVAL_TAG |
| 409 | : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 410 | *info->code(), |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 411 | *result, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 412 | String::cast(script->name()))); |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 413 | GDBJIT(AddCode(Handle<String>(String::cast(script->name())), |
| 414 | script, |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 415 | info->code(), |
| 416 | info)); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 417 | } else { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 418 | PROFILE(isolate, CodeCreateEvent( |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 419 | info->is_eval() |
| 420 | ? Logger::EVAL_TAG |
| 421 | : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 422 | *info->code(), |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 423 | *result, |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 424 | isolate->heap()->empty_string())); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 425 | GDBJIT(AddCode(Handle<String>(), script, info->code(), info)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 426 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 427 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 428 | // Hint to the runtime system used when allocating space for initial |
| 429 | // property space by setting the expected number of properties for |
| 430 | // the instances of the function. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 431 | SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 432 | |
| 433 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 434 | // Notify debugger |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 435 | isolate->debugger()->OnAfterCompile( |
| 436 | script, Debugger::NO_AFTER_COMPILE_FLAGS); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 437 | #endif |
| 438 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 439 | live_edit_tracker.RecordFunctionInfo(result, lit); |
| 440 | |
| 441 | return result; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 445 | Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, |
| 446 | Handle<Object> script_name, |
| 447 | int line_offset, |
| 448 | int column_offset, |
| 449 | v8::Extension* extension, |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 450 | ScriptDataImpl* input_pre_data, |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 451 | Handle<Object> script_data, |
| 452 | NativesFlag natives) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 453 | Isolate* isolate = source->GetIsolate(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 454 | int source_length = source->length(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 455 | isolate->counters()->total_load_size()->Increment(source_length); |
| 456 | isolate->counters()->total_compile_size()->Increment(source_length); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 457 | |
| 458 | // The VM is in the COMPILER state until exiting this function. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 459 | VMState state(isolate, COMPILER); |
| 460 | |
| 461 | CompilationCache* compilation_cache = isolate->compilation_cache(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 462 | |
| 463 | // Do a lookup in the compilation cache but not for extensions. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 464 | Handle<SharedFunctionInfo> result; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 465 | if (extension == NULL) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 466 | result = compilation_cache->LookupScript(source, |
| 467 | script_name, |
| 468 | line_offset, |
| 469 | column_offset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | if (result.is_null()) { |
Steve Block | 5915150 | 2010-09-22 15:07:15 +0100 | [diff] [blame] | 473 | // No cache entry found. Do pre-parsing, if it makes sense, and compile |
| 474 | // the script. |
| 475 | // Building preparse data that is only used immediately after is only a |
| 476 | // saving if we might skip building the AST for lazily compiled functions. |
| 477 | // I.e., preparse data isn't relevant when the lazy flag is off, and |
| 478 | // for small sources, odds are that there aren't many functions |
| 479 | // that would be compiled lazily anyway, so we skip the preparse step |
| 480 | // in that case too. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 481 | ScriptDataImpl* pre_data = input_pre_data; |
| 482 | bool harmony_block_scoping = natives != NATIVES_CODE && |
| 483 | FLAG_harmony_block_scoping; |
| 484 | if (pre_data == NULL |
| 485 | && source_length >= FLAG_min_preparse_length) { |
| 486 | if (source->IsExternalTwoByteString()) { |
| 487 | ExternalTwoByteStringUC16CharacterStream stream( |
| 488 | Handle<ExternalTwoByteString>::cast(source), 0, source->length()); |
| 489 | pre_data = ParserApi::PartialPreParse(&stream, |
| 490 | extension, |
| 491 | harmony_block_scoping); |
| 492 | } else { |
| 493 | GenericStringUC16CharacterStream stream(source, 0, source->length()); |
| 494 | pre_data = ParserApi::PartialPreParse(&stream, |
| 495 | extension, |
| 496 | harmony_block_scoping); |
| 497 | } |
| 498 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 499 | |
| 500 | // Create a script object describing the script to be compiled. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 501 | Handle<Script> script = FACTORY->NewScript(source); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 502 | if (natives == NATIVES_CODE) { |
| 503 | script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 504 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 505 | if (!script_name.is_null()) { |
| 506 | script->set_name(*script_name); |
| 507 | script->set_line_offset(Smi::FromInt(line_offset)); |
| 508 | script->set_column_offset(Smi::FromInt(column_offset)); |
| 509 | } |
| 510 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 511 | script->set_data(script_data.is_null() ? HEAP->undefined_value() |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 512 | : *script_data); |
| 513 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 514 | // Compile the function and add it to the cache. |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 515 | CompilationInfo info(script); |
| 516 | info.MarkAsGlobal(); |
| 517 | info.SetExtension(extension); |
| 518 | info.SetPreParseData(pre_data); |
| 519 | result = MakeFunctionInfo(&info); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 520 | if (extension == NULL && !result.is_null()) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 521 | compilation_cache->PutScript(source, result); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 522 | } |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 523 | |
| 524 | // Get rid of the pre-parsing data (if necessary). |
| 525 | if (input_pre_data == NULL && pre_data != NULL) { |
| 526 | delete pre_data; |
| 527 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 530 | if (result.is_null()) isolate->ReportPendingMessages(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 531 | return result; |
| 532 | } |
| 533 | |
| 534 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 535 | Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, |
| 536 | Handle<Context> context, |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 537 | bool is_global, |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 538 | StrictModeFlag strict_mode) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 539 | Isolate* isolate = source->GetIsolate(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 540 | int source_length = source->length(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 541 | isolate->counters()->total_eval_size()->Increment(source_length); |
| 542 | isolate->counters()->total_compile_size()->Increment(source_length); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 543 | |
| 544 | // The VM is in the COMPILER state until exiting this function. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 545 | VMState state(isolate, COMPILER); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 546 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 547 | // Do a lookup in the compilation cache; if the entry is not there, invoke |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 548 | // the compiler and add the result to the cache. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 549 | Handle<SharedFunctionInfo> result; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 550 | CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 551 | result = compilation_cache->LookupEval(source, |
| 552 | context, |
| 553 | is_global, |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 554 | strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 555 | |
| 556 | if (result.is_null()) { |
| 557 | // Create a script object describing the script to be compiled. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 558 | Handle<Script> script = isolate->factory()->NewScript(source); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 559 | CompilationInfo info(script); |
| 560 | info.MarkAsEval(); |
| 561 | if (is_global) info.MarkAsGlobal(); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 562 | if (strict_mode == kStrictMode) info.MarkAsStrictMode(); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 563 | info.SetCallingContext(context); |
| 564 | result = MakeFunctionInfo(&info); |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 565 | if (!result.is_null()) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 566 | CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 567 | // If caller is strict mode, the result must be strict as well, |
| 568 | // but not the other way around. Consider: |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 569 | // eval("'use strict'; ..."); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 570 | ASSERT(strict_mode == kNonStrictMode || result->strict_mode()); |
| 571 | compilation_cache->PutEval(source, context, is_global, result); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 572 | } |
| 573 | } |
| 574 | |
| 575 | return result; |
| 576 | } |
| 577 | |
| 578 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 579 | bool Compiler::CompileLazy(CompilationInfo* info) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 580 | Isolate* isolate = info->isolate(); |
| 581 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 582 | ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 583 | |
| 584 | // The VM is in the COMPILER state until exiting this function. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 585 | VMState state(isolate, COMPILER); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 586 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 587 | PostponeInterruptsScope postpone(isolate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 588 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 589 | Handle<SharedFunctionInfo> shared = info->shared_info(); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 590 | int compiled_size = shared->end_position() - shared->start_position(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 591 | isolate->counters()->total_compile_size()->Increment(compiled_size); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 592 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 593 | // Generate the AST for the lazily compiled function. |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 594 | if (ParserApi::Parse(info)) { |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 595 | // Measure how long it takes to do the lazy compilation; only take the |
| 596 | // rest of the function into account to avoid overlap with the lazy |
| 597 | // parsing statistics. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 598 | HistogramTimerScope timer(isolate->counters()->compile_lazy()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 599 | |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 600 | // After parsing we know function's strict mode. Remember it. |
| 601 | if (info->function()->strict_mode()) { |
| 602 | shared->set_strict_mode(true); |
| 603 | info->MarkAsStrictMode(); |
| 604 | } |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 605 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 606 | // Compile the code. |
| 607 | if (!MakeCode(info)) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 608 | if (!isolate->has_pending_exception()) { |
| 609 | isolate->StackOverflow(); |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 610 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 611 | } else { |
| 612 | ASSERT(!info->code().is_null()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 613 | Handle<Code> code = info->code(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 614 | // Set optimizable to false if this is disallowed by the shared |
| 615 | // function info, e.g., we might have flushed the code and must |
| 616 | // reset this bit when lazy compiling the code again. |
| 617 | if (shared->optimization_disabled()) code->set_optimizable(false); |
| 618 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 619 | Handle<JSFunction> function = info->closure(); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 620 | RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 621 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 622 | if (info->IsOptimizing()) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 623 | ASSERT(shared->scope_info() != SerializedScopeInfo::Empty()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 624 | function->ReplaceCode(*code); |
| 625 | } else { |
| 626 | // Update the shared function info with the compiled code and the |
| 627 | // scope info. Please note, that the order of the shared function |
| 628 | // info initialization is important since set_scope_info might |
| 629 | // trigger a GC, causing the ASSERT below to be invalid if the code |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 630 | // was flushed. By settting the code object last we avoid this. |
| 631 | Handle<SerializedScopeInfo> scope_info = |
| 632 | SerializedScopeInfo::Create(info->scope()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 633 | shared->set_scope_info(*scope_info); |
| 634 | shared->set_code(*code); |
| 635 | if (!function.is_null()) { |
| 636 | function->ReplaceCode(*code); |
| 637 | ASSERT(!function->IsOptimized()); |
| 638 | } |
| 639 | |
| 640 | // Set the expected number of properties for instances. |
| 641 | FunctionLiteral* lit = info->function(); |
| 642 | int expected = lit->expected_property_count(); |
| 643 | SetExpectedNofPropertiesFromEstimate(shared, expected); |
| 644 | |
| 645 | // Set the optimization hints after performing lazy compilation, as |
| 646 | // these are not set when the function is set up as a lazily |
| 647 | // compiled function. |
| 648 | shared->SetThisPropertyAssignmentsInfo( |
| 649 | lit->has_only_simple_this_property_assignments(), |
| 650 | *lit->this_property_assignments()); |
| 651 | |
| 652 | // Check the function has compiled code. |
| 653 | ASSERT(shared->is_compiled()); |
| 654 | shared->set_code_age(0); |
| 655 | |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 656 | if (info->AllowOptimize() && !shared->optimization_disabled()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 657 | // If we're asked to always optimize, we compile the optimized |
| 658 | // version of the function right away - unless the debugger is |
| 659 | // active as it makes no sense to compile optimized code then. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 660 | if (FLAG_always_opt && |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 661 | !Isolate::Current()->DebuggerHasBreakPoints()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 662 | CompilationInfo optimized(function); |
| 663 | optimized.SetOptimizing(AstNode::kNoNumber); |
| 664 | return CompileLazy(&optimized); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 665 | } |
| 666 | } |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 667 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 668 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 669 | return true; |
| 670 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 673 | ASSERT(info->code().is_null()); |
| 674 | return false; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 678 | Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 679 | Handle<Script> script) { |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 680 | // Precondition: code has been parsed and scopes have been analyzed. |
| 681 | CompilationInfo info(script); |
| 682 | info.SetFunction(literal); |
| 683 | info.SetScope(literal->scope()); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 684 | if (literal->scope()->is_strict_mode()) info.MarkAsStrictMode(); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 685 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 686 | LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 687 | // Determine if the function can be lazily compiled. This is necessary to |
| 688 | // allow some of our builtin JS files to be lazily compiled. These |
| 689 | // builtins cannot be handled lazily by the parser, since we have to know |
| 690 | // if a function uses the special natives syntax, which is something the |
| 691 | // parser records. |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 692 | bool allow_lazy = literal->AllowsLazyCompilation() && |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 693 | !LiveEditFunctionTracker::IsActive(info.isolate()); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 694 | |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 695 | Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty()); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 696 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 697 | // Generate code |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 698 | if (FLAG_lazy && allow_lazy) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 699 | Handle<Code> code = info.isolate()->builtins()->LazyCompile(); |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 700 | info.SetCode(code); |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 701 | } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) || |
| 702 | (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 703 | ASSERT(!info.code().is_null()); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 704 | scope_info = SerializedScopeInfo::Create(info.scope()); |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 705 | } else { |
| 706 | return Handle<SharedFunctionInfo>::null(); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 707 | } |
| 708 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 709 | // Create a shared function info object. |
| 710 | Handle<SharedFunctionInfo> result = |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 711 | FACTORY->NewSharedFunctionInfo(literal->name(), |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 712 | literal->materialized_literal_count(), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 713 | info.code(), |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 714 | scope_info); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 715 | SetFunctionInfo(result, literal, false, script); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 716 | RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 717 | result->set_allows_lazy_compilation(allow_lazy); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 718 | |
| 719 | // Set the expected number of properties for instances and return |
| 720 | // the resulting function. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 721 | SetExpectedNofPropertiesFromEstimate(result, |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 722 | literal->expected_property_count()); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 723 | live_edit_tracker.RecordFunctionInfo(result, literal); |
| 724 | return result; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | |
| 728 | // Sets the function info on a function. |
| 729 | // The start_position points to the first '(' character after the function name |
| 730 | // in the full script source. When counting characters in the script source the |
| 731 | // the first character is number 0 (not 1). |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 732 | void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 733 | FunctionLiteral* lit, |
| 734 | bool is_toplevel, |
| 735 | Handle<Script> script) { |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 736 | function_info->set_length(lit->num_parameters()); |
| 737 | function_info->set_formal_parameter_count(lit->num_parameters()); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 738 | function_info->set_script(*script); |
| 739 | function_info->set_function_token_position(lit->function_token_position()); |
| 740 | function_info->set_start_position(lit->start_position()); |
| 741 | function_info->set_end_position(lit->end_position()); |
| 742 | function_info->set_is_expression(lit->is_expression()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 743 | function_info->set_is_anonymous(lit->is_anonymous()); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 744 | function_info->set_is_toplevel(is_toplevel); |
| 745 | function_info->set_inferred_name(*lit->inferred_name()); |
| 746 | function_info->SetThisPropertyAssignmentsInfo( |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 747 | lit->has_only_simple_this_property_assignments(), |
| 748 | *lit->this_property_assignments()); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 749 | function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame^] | 750 | function_info->set_strict_mode(lit->strict_mode()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 751 | function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
| 752 | function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 756 | void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 757 | CompilationInfo* info, |
| 758 | Handle<SharedFunctionInfo> shared) { |
| 759 | // SharedFunctionInfo is passed separately, because if CompilationInfo |
| 760 | // was created using Script object, it will not have it. |
| 761 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 762 | // Log the code generation. If source information is available include |
| 763 | // script name and line number. Check explicitly whether logging is |
| 764 | // enabled as finding the line number is not free. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 765 | if (info->isolate()->logger()->is_logging() || |
| 766 | CpuProfiler::is_profiling(info->isolate())) { |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 767 | Handle<Script> script = info->script(); |
| 768 | Handle<Code> code = info->code(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 769 | if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) |
| 770 | return; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 771 | if (script->name()->IsString()) { |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 772 | int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 773 | USE(line_num); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 774 | PROFILE(info->isolate(), |
| 775 | CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 776 | *code, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 777 | *shared, |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 778 | String::cast(script->name()), |
| 779 | line_num)); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 780 | } else { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 781 | PROFILE(info->isolate(), |
| 782 | CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 783 | *code, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 784 | *shared, |
| 785 | shared->DebugName())); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 786 | } |
| 787 | } |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 788 | |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 789 | GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 790 | Handle<Script>(info->script()), |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 791 | Handle<Code>(info->code()), |
| 792 | info)); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 793 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 794 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 795 | } } // namespace v8::internal |