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 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
32 #include "compilation-cache.h" | 32 #include "compilation-cache.h" |
33 #include "compiler.h" | 33 #include "compiler.h" |
34 #include "data-flow.h" | 34 #include "data-flow.h" |
35 #include "debug.h" | 35 #include "debug.h" |
36 #include "fast-codegen.h" | |
37 #include "flow-graph.h" | 36 #include "flow-graph.h" |
38 #include "full-codegen.h" | 37 #include "full-codegen.h" |
39 #include "liveedit.h" | 38 #include "liveedit.h" |
40 #include "oprofile-agent.h" | 39 #include "oprofile-agent.h" |
41 #include "rewriter.h" | 40 #include "rewriter.h" |
42 #include "scopes.h" | 41 #include "scopes.h" |
43 #include "scopeinfo.h" | 42 #include "scopeinfo.h" |
44 | 43 |
45 namespace v8 { | 44 namespace v8 { |
46 namespace internal { | 45 namespace internal { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 112 } |
114 #endif | 113 #endif |
115 } | 114 } |
116 | 115 |
117 // Generate code and return it. Code generator selection is governed by | 116 // Generate code and return it. Code generator selection is governed by |
118 // which backends are enabled and whether the function is considered | 117 // which backends are enabled and whether the function is considered |
119 // run-once code or not: | 118 // run-once code or not: |
120 // | 119 // |
121 // --full-compiler enables the dedicated backend for code we expect to be | 120 // --full-compiler enables the dedicated backend for code we expect to be |
122 // run once | 121 // run once |
123 // --fast-compiler enables a speculative optimizing backend (for | |
124 // non-run-once code) | |
125 // | 122 // |
126 // The normal choice of backend can be overridden with the flags | 123 // The normal choice of backend can be overridden with the flags |
127 // --always-full-compiler and --always-fast-compiler, which are mutually | 124 // --always-full-compiler. |
128 // incompatible. | |
129 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); | |
130 | |
131 Handle<SharedFunctionInfo> shared = info->shared_info(); | 125 Handle<SharedFunctionInfo> shared = info->shared_info(); |
132 bool is_run_once = (shared.is_null()) | 126 bool is_run_once = (shared.is_null()) |
133 ? info->scope()->is_global_scope() | 127 ? info->scope()->is_global_scope() |
134 : (shared->is_toplevel() || shared->try_full_codegen()); | 128 : (shared->is_toplevel() || shared->try_full_codegen()); |
135 | 129 |
136 if (AlwaysFullCompiler()) { | 130 if (AlwaysFullCompiler()) { |
137 return FullCodeGenerator::MakeCode(info); | 131 return FullCodeGenerator::MakeCode(info); |
138 } else if (FLAG_full_compiler && is_run_once) { | 132 } else if (FLAG_full_compiler && is_run_once) { |
139 FullCodeGenSyntaxChecker checker; | 133 FullCodeGenSyntaxChecker checker; |
140 checker.Check(function); | 134 checker.Check(function); |
141 if (checker.has_supported_syntax()) { | 135 if (checker.has_supported_syntax()) { |
142 return FullCodeGenerator::MakeCode(info); | 136 return FullCodeGenerator::MakeCode(info); |
143 } | 137 } |
144 } else if (FLAG_always_fast_compiler || | |
145 (FLAG_fast_compiler && !is_run_once)) { | |
146 FastCodeGenSyntaxChecker checker; | |
147 checker.Check(info); | |
148 if (checker.has_supported_syntax()) { | |
149 return FastCodeGenerator::MakeCode(info); | |
150 } | |
151 } | 138 } |
152 | 139 |
153 return CodeGenerator::MakeCode(info); | 140 return CodeGenerator::MakeCode(info); |
154 } | 141 } |
155 | 142 |
156 | 143 |
157 #ifdef ENABLE_DEBUGGER_SUPPORT | 144 #ifdef ENABLE_DEBUGGER_SUPPORT |
158 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { | 145 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { |
159 Handle<Context> context = Handle<Context>::null(); | 146 Handle<Context> context = Handle<Context>::null(); |
160 Handle<Code> code = MakeCode(context, info); | 147 Handle<Code> code = MakeCode(context, info); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 graph->PrintAsText(literal->name()); | 508 graph->PrintAsText(literal->name()); |
522 } | 509 } |
523 #endif | 510 #endif |
524 } | 511 } |
525 | 512 |
526 // Generate code and return it. The way that the compilation mode | 513 // Generate code and return it. The way that the compilation mode |
527 // is controlled by the command-line flags is described in | 514 // is controlled by the command-line flags is described in |
528 // the static helper function MakeCode. | 515 // the static helper function MakeCode. |
529 CompilationInfo info(literal, script, false); | 516 CompilationInfo info(literal, script, false); |
530 | 517 |
531 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); | |
532 bool is_run_once = literal->try_full_codegen(); | 518 bool is_run_once = literal->try_full_codegen(); |
533 bool is_compiled = false; | 519 bool is_compiled = false; |
534 | 520 |
535 if (AlwaysFullCompiler()) { | 521 if (AlwaysFullCompiler()) { |
536 code = FullCodeGenerator::MakeCode(&info); | 522 code = FullCodeGenerator::MakeCode(&info); |
537 is_compiled = true; | 523 is_compiled = true; |
538 } else if (FLAG_full_compiler && is_run_once) { | 524 } else if (FLAG_full_compiler && is_run_once) { |
539 FullCodeGenSyntaxChecker checker; | 525 FullCodeGenSyntaxChecker checker; |
540 checker.Check(literal); | 526 checker.Check(literal); |
541 if (checker.has_supported_syntax()) { | 527 if (checker.has_supported_syntax()) { |
542 code = FullCodeGenerator::MakeCode(&info); | 528 code = FullCodeGenerator::MakeCode(&info); |
543 is_compiled = true; | 529 is_compiled = true; |
544 } | 530 } |
545 } else if (FLAG_always_fast_compiler || | |
546 (FLAG_fast_compiler && !is_run_once)) { | |
547 // Since we are not lazily compiling we do not have a receiver to | |
548 // specialize for. | |
549 FastCodeGenSyntaxChecker checker; | |
550 checker.Check(&info); | |
551 if (checker.has_supported_syntax()) { | |
552 code = FastCodeGenerator::MakeCode(&info); | |
553 is_compiled = true; | |
554 } | |
555 } | 531 } |
556 | 532 |
557 if (!is_compiled) { | 533 if (!is_compiled) { |
558 // We fall back to the classic V8 code generator. | 534 // We fall back to the classic V8 code generator. |
559 code = CodeGenerator::MakeCode(&info); | 535 code = CodeGenerator::MakeCode(&info); |
560 } | 536 } |
561 | 537 |
562 // Check for stack-overflow exception. | 538 // Check for stack-overflow exception. |
563 if (code.is_null()) { | 539 if (code.is_null()) { |
564 caller->SetStackOverflow(); | 540 caller->SetStackOverflow(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 621 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
646 *code, *func_name)); | 622 *code, *func_name)); |
647 OPROFILE(CreateNativeCodeRegion(*func_name, | 623 OPROFILE(CreateNativeCodeRegion(*func_name, |
648 code->instruction_start(), | 624 code->instruction_start(), |
649 code->instruction_size())); | 625 code->instruction_size())); |
650 } | 626 } |
651 } | 627 } |
652 } | 628 } |
653 | 629 |
654 } } // namespace v8::internal | 630 } } // namespace v8::internal |
OLD | NEW |