| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 17 matching lines...) Expand all Loading... |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "compiler.h" | 30 #include "compiler.h" |
| 31 | 31 |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
| 34 #include "compilation-cache.h" | 34 #include "compilation-cache.h" |
| 35 #include "data-flow.h" | 35 #include "data-flow.h" |
| 36 #include "debug.h" | 36 #include "debug.h" |
| 37 #include "full-codegen.h" | 37 #include "full-codegen.h" |
| 38 #include "gdb-jit.h" |
| 38 #include "hydrogen.h" | 39 #include "hydrogen.h" |
| 39 #include "lithium-allocator.h" | 40 #include "lithium.h" |
| 40 #include "liveedit.h" | 41 #include "liveedit.h" |
| 41 #include "oprofile-agent.h" | 42 #include "oprofile-agent.h" |
| 42 #include "parser.h" | 43 #include "parser.h" |
| 43 #include "rewriter.h" | 44 #include "rewriter.h" |
| 44 #include "runtime-profiler.h" | 45 #include "runtime-profiler.h" |
| 45 #include "scopeinfo.h" | 46 #include "scopeinfo.h" |
| 46 #include "scopes.h" | 47 #include "scopes.h" |
| 47 #include "vm-state-inl.h" | 48 #include "vm-state-inl.h" |
| 48 | 49 |
| 49 namespace v8 { | 50 namespace v8 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 89 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
| 89 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 90 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
| 90 extension_(NULL), | 91 extension_(NULL), |
| 91 pre_parse_data_(NULL), | 92 pre_parse_data_(NULL), |
| 92 supports_deoptimization_(false), | 93 supports_deoptimization_(false), |
| 93 osr_ast_id_(AstNode::kNoNumber) { | 94 osr_ast_id_(AstNode::kNoNumber) { |
| 94 Initialize(BASE); | 95 Initialize(BASE); |
| 95 } | 96 } |
| 96 | 97 |
| 97 | 98 |
| 99 void CompilationInfo::DisableOptimization() { |
| 100 if (FLAG_optimize_closures) { |
| 101 // If we allow closures optimizations and it's an optimizable closure |
| 102 // mark it correspondingly. |
| 103 bool is_closure = closure_.is_null() && !scope_->HasTrivialOuterContext(); |
| 104 if (is_closure) { |
| 105 bool is_optimizable_closure = |
| 106 !scope_->outer_scope_calls_eval() && !scope_->inside_with(); |
| 107 if (is_optimizable_closure) { |
| 108 SetMode(BASE); |
| 109 return; |
| 110 } |
| 111 } |
| 112 } |
| 113 |
| 114 SetMode(NONOPT); |
| 115 } |
| 116 |
| 117 |
| 98 // Determine whether to use the full compiler for all code. If the flag | 118 // Determine whether to use the full compiler for all code. If the flag |
| 99 // --always-full-compiler is specified this is the case. For the virtual frame | 119 // --always-full-compiler is specified this is the case. For the virtual frame |
| 100 // based compiler the full compiler is also used if a debugger is connected, as | 120 // based compiler the full compiler is also used if a debugger is connected, as |
| 101 // the code from the full compiler supports mode precise break points. For the | 121 // the code from the full compiler supports mode precise break points. For the |
| 102 // crankshaft adaptive compiler debugging the optimized code is not possible at | 122 // crankshaft adaptive compiler debugging the optimized code is not possible at |
| 103 // all. However crankshaft support recompilation of functions, so in this case | 123 // all. However crankshaft support recompilation of functions, so in this case |
| 104 // the full compiler need not be be used if a debugger is attached, but only if | 124 // the full compiler need not be be used if a debugger is attached, but only if |
| 105 // break points has actually been set. | 125 // break points has actually been set. |
| 106 static bool AlwaysFullCompiler() { | 126 static bool AlwaysFullCompiler() { |
| 107 #ifdef ENABLE_DEBUGGER_SUPPORT | 127 #ifdef ENABLE_DEBUGGER_SUPPORT |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Fall back to using the full code generator if it's not possible | 205 // Fall back to using the full code generator if it's not possible |
| 186 // to use the Hydrogen-based optimizing compiler. We already have | 206 // to use the Hydrogen-based optimizing compiler. We already have |
| 187 // generated code for this from the shared function object. | 207 // generated code for this from the shared function object. |
| 188 if (AlwaysFullCompiler() || !FLAG_use_hydrogen) { | 208 if (AlwaysFullCompiler() || !FLAG_use_hydrogen) { |
| 189 info->SetCode(code); | 209 info->SetCode(code); |
| 190 return true; | 210 return true; |
| 191 } | 211 } |
| 192 | 212 |
| 193 // Limit the number of times we re-compile a functions with | 213 // Limit the number of times we re-compile a functions with |
| 194 // the optimizing compiler. | 214 // the optimizing compiler. |
| 195 const int kMaxOptCount = FLAG_deopt_every_n_times == 0 ? 10 : 1000; | 215 const int kMaxOptCount = |
| 216 FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000; |
| 196 if (info->shared_info()->opt_count() > kMaxOptCount) { | 217 if (info->shared_info()->opt_count() > kMaxOptCount) { |
| 197 AbortAndDisable(info); | 218 AbortAndDisable(info); |
| 198 // True indicates the compilation pipeline is still going, not | 219 // True indicates the compilation pipeline is still going, not |
| 199 // necessarily that we optimized the code. | 220 // necessarily that we optimized the code. |
| 200 return true; | 221 return true; |
| 201 } | 222 } |
| 202 | 223 |
| 203 // Due to an encoding limit on LUnallocated operands in the Lithium | 224 // Due to an encoding limit on LUnallocated operands in the Lithium |
| 204 // language, we cannot optimize functions with too many formal parameters | 225 // language, we cannot optimize functions with too many formal parameters |
| 205 // or perform on-stack replacement for function with too many | 226 // or perform on-stack replacement for function with too many |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 if (script->name()->IsString()) { | 421 if (script->name()->IsString()) { |
| 401 PROFILE(CodeCreateEvent( | 422 PROFILE(CodeCreateEvent( |
| 402 info->is_eval() | 423 info->is_eval() |
| 403 ? Logger::EVAL_TAG | 424 ? Logger::EVAL_TAG |
| 404 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 425 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 405 *info->code(), | 426 *info->code(), |
| 406 String::cast(script->name()))); | 427 String::cast(script->name()))); |
| 407 OPROFILE(CreateNativeCodeRegion(String::cast(script->name()), | 428 OPROFILE(CreateNativeCodeRegion(String::cast(script->name()), |
| 408 info->code()->instruction_start(), | 429 info->code()->instruction_start(), |
| 409 info->code()->instruction_size())); | 430 info->code()->instruction_size())); |
| 431 GDBJIT(AddCode(Handle<String>(String::cast(script->name())), |
| 432 script, |
| 433 info->code())); |
| 410 } else { | 434 } else { |
| 411 PROFILE(CodeCreateEvent( | 435 PROFILE(CodeCreateEvent( |
| 412 info->is_eval() | 436 info->is_eval() |
| 413 ? Logger::EVAL_TAG | 437 ? Logger::EVAL_TAG |
| 414 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 438 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 415 *info->code(), | 439 *info->code(), |
| 416 "")); | 440 "")); |
| 417 OPROFILE(CreateNativeCodeRegion(info->is_eval() ? "Eval" : "Script", | 441 OPROFILE(CreateNativeCodeRegion(info->is_eval() ? "Eval" : "Script", |
| 418 info->code()->instruction_start(), | 442 info->code()->instruction_start(), |
| 419 info->code()->instruction_size())); | 443 info->code()->instruction_size())); |
| 444 GDBJIT(AddCode(Handle<String>(), script, info->code())); |
| 420 } | 445 } |
| 421 | 446 |
| 422 // Allocate function. | 447 // Allocate function. |
| 423 Handle<SharedFunctionInfo> result = | 448 Handle<SharedFunctionInfo> result = |
| 424 FACTORY->NewSharedFunctionInfo( | 449 FACTORY->NewSharedFunctionInfo( |
| 425 lit->name(), | 450 lit->name(), |
| 426 lit->materialized_literal_count(), | 451 lit->materialized_literal_count(), |
| 427 info->code(), | 452 info->code(), |
| 428 SerializedScopeInfo::Create(info->scope())); | 453 SerializedScopeInfo::Create(info->scope())); |
| 429 | 454 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 code->instruction_size())); | 809 code->instruction_size())); |
| 785 } else { | 810 } else { |
| 786 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 811 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
| 787 *code, | 812 *code, |
| 788 *name)); | 813 *name)); |
| 789 OPROFILE(CreateNativeCodeRegion(*name, | 814 OPROFILE(CreateNativeCodeRegion(*name, |
| 790 code->instruction_start(), | 815 code->instruction_start(), |
| 791 code->instruction_size())); | 816 code->instruction_size())); |
| 792 } | 817 } |
| 793 } | 818 } |
| 819 |
| 820 GDBJIT(AddCode(name, |
| 821 Handle<Script>(info->script()), |
| 822 Handle<Code>(info->code()))); |
| 794 } | 823 } |
| 795 | 824 |
| 796 } } // namespace v8::internal | 825 } } // namespace v8::internal |
| OLD | NEW |