| 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 26 matching lines...) Expand all Loading... |
| 37 #include "flow-graph.h" | 37 #include "flow-graph.h" |
| 38 #include "full-codegen.h" | 38 #include "full-codegen.h" |
| 39 #include "liveedit.h" | 39 #include "liveedit.h" |
| 40 #include "oprofile-agent.h" | 40 #include "oprofile-agent.h" |
| 41 #include "rewriter.h" | 41 #include "rewriter.h" |
| 42 #include "scopes.h" | 42 #include "scopes.h" |
| 43 | 43 |
| 44 namespace v8 { | 44 namespace v8 { |
| 45 namespace internal { | 45 namespace internal { |
| 46 | 46 |
| 47 // For normal operation the syntax checker is used to determine whether to |
| 48 // use the full compiler for top level code or not. However if the flag |
| 49 // --always-full-compiler is specified or debugging is active the full |
| 50 // compiler will be used for all code. |
| 51 static bool AlwaysFullCompiler() { |
| 52 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 53 return FLAG_always_full_compiler || Debugger::IsDebuggerActive(); |
| 54 #else |
| 55 return FLAG_always_full_compiler; |
| 56 #endif |
| 57 } |
| 58 |
| 47 | 59 |
| 48 static Handle<Code> MakeCode(Handle<Context> context, CompilationInfo* info) { | 60 static Handle<Code> MakeCode(Handle<Context> context, CompilationInfo* info) { |
| 49 FunctionLiteral* function = info->function(); | 61 FunctionLiteral* function = info->function(); |
| 50 ASSERT(function != NULL); | 62 ASSERT(function != NULL); |
| 51 // Rewrite the AST by introducing .result assignments where needed. | 63 // Rewrite the AST by introducing .result assignments where needed. |
| 52 if (!Rewriter::Process(function)) { | 64 if (!Rewriter::Process(function)) { |
| 53 // Signal a stack overflow by returning a null handle. The stack | 65 // Signal a stack overflow by returning a null handle. The stack |
| 54 // overflow exception will be thrown by the caller. | 66 // overflow exception will be thrown by the caller. |
| 55 return Handle<Code>::null(); | 67 return Handle<Code>::null(); |
| 56 } | 68 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // The normal choice of backend can be overridden with the flags | 125 // The normal choice of backend can be overridden with the flags |
| 114 // --always-full-compiler and --always-fast-compiler, which are mutually | 126 // --always-full-compiler and --always-fast-compiler, which are mutually |
| 115 // incompatible. | 127 // incompatible. |
| 116 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); | 128 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); |
| 117 | 129 |
| 118 Handle<SharedFunctionInfo> shared = info->shared_info(); | 130 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 119 bool is_run_once = (shared.is_null()) | 131 bool is_run_once = (shared.is_null()) |
| 120 ? info->scope()->is_global_scope() | 132 ? info->scope()->is_global_scope() |
| 121 : (shared->is_toplevel() || shared->try_full_codegen()); | 133 : (shared->is_toplevel() || shared->try_full_codegen()); |
| 122 | 134 |
| 123 bool force_full_compiler = false; | 135 if (AlwaysFullCompiler()) { |
| 124 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) | |
| 125 // On ia32 the full compiler can compile all code whereas the other platforms | |
| 126 // the constructs supported is checked by the associated syntax checker. When | |
| 127 // --always-full-compiler is used on ia32 the syntax checker is still in | |
| 128 // effect, but there is a special flag --force-full-compiler to ignore the | |
| 129 // syntax checker completely and use the full compiler for all code. Also | |
| 130 // when debugging on ia32 the full compiler will be used for all code. | |
| 131 force_full_compiler = | |
| 132 Debugger::IsDebuggerActive() || FLAG_force_full_compiler; | |
| 133 #endif | |
| 134 | |
| 135 if (force_full_compiler) { | |
| 136 return FullCodeGenerator::MakeCode(info); | 136 return FullCodeGenerator::MakeCode(info); |
| 137 } else if (FLAG_always_full_compiler || (FLAG_full_compiler && is_run_once)) { | 137 } else if (FLAG_full_compiler && is_run_once) { |
| 138 FullCodeGenSyntaxChecker checker; | 138 FullCodeGenSyntaxChecker checker; |
| 139 checker.Check(function); | 139 checker.Check(function); |
| 140 if (checker.has_supported_syntax()) { | 140 if (checker.has_supported_syntax()) { |
| 141 return FullCodeGenerator::MakeCode(info); | 141 return FullCodeGenerator::MakeCode(info); |
| 142 } | 142 } |
| 143 } else if (FLAG_always_fast_compiler || | 143 } else if (FLAG_always_fast_compiler || |
| 144 (FLAG_fast_compiler && !is_run_once)) { | 144 (FLAG_fast_compiler && !is_run_once)) { |
| 145 FastCodeGenSyntaxChecker checker; | 145 FastCodeGenSyntaxChecker checker; |
| 146 checker.Check(info); | 146 checker.Check(info); |
| 147 if (checker.has_supported_syntax()) { | 147 if (checker.has_supported_syntax()) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } | 514 } |
| 515 | 515 |
| 516 // Generate code and return it. The way that the compilation mode | 516 // Generate code and return it. The way that the compilation mode |
| 517 // is controlled by the command-line flags is described in | 517 // is controlled by the command-line flags is described in |
| 518 // the static helper function MakeCode. | 518 // the static helper function MakeCode. |
| 519 CompilationInfo info(literal, script, false); | 519 CompilationInfo info(literal, script, false); |
| 520 | 520 |
| 521 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); | 521 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); |
| 522 bool is_run_once = literal->try_full_codegen(); | 522 bool is_run_once = literal->try_full_codegen(); |
| 523 bool is_compiled = false; | 523 bool is_compiled = false; |
| 524 if (FLAG_always_full_compiler || (FLAG_full_compiler && is_run_once)) { | 524 |
| 525 if (AlwaysFullCompiler()) { |
| 526 code = FullCodeGenerator::MakeCode(&info); |
| 527 is_compiled = true; |
| 528 } else if (FLAG_full_compiler && is_run_once) { |
| 525 FullCodeGenSyntaxChecker checker; | 529 FullCodeGenSyntaxChecker checker; |
| 526 checker.Check(literal); | 530 checker.Check(literal); |
| 527 if (checker.has_supported_syntax()) { | 531 if (checker.has_supported_syntax()) { |
| 528 code = FullCodeGenerator::MakeCode(&info); | 532 code = FullCodeGenerator::MakeCode(&info); |
| 529 is_compiled = true; | 533 is_compiled = true; |
| 530 } | 534 } |
| 531 } else if (FLAG_always_fast_compiler || | 535 } else if (FLAG_always_fast_compiler || |
| 532 (FLAG_fast_compiler && !is_run_once)) { | 536 (FLAG_fast_compiler && !is_run_once)) { |
| 533 // Since we are not lazily compiling we do not have a receiver to | 537 // Since we are not lazily compiling we do not have a receiver to |
| 534 // specialize for. | 538 // specialize for. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 632 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
| 629 *code, *func_name)); | 633 *code, *func_name)); |
| 630 OPROFILE(CreateNativeCodeRegion(*func_name, | 634 OPROFILE(CreateNativeCodeRegion(*func_name, |
| 631 code->instruction_start(), | 635 code->instruction_start(), |
| 632 code->instruction_size())); | 636 code->instruction_size())); |
| 633 } | 637 } |
| 634 } | 638 } |
| 635 } | 639 } |
| 636 | 640 |
| 637 } } // namespace v8::internal | 641 } } // namespace v8::internal |
| OLD | NEW |