| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // | 97 // |
| 98 // --full-compiler enables the dedicated backend for code we expect to be | 98 // --full-compiler enables the dedicated backend for code we expect to be |
| 99 // run once | 99 // run once |
| 100 // | 100 // |
| 101 // The normal choice of backend can be overridden with the flags | 101 // The normal choice of backend can be overridden with the flags |
| 102 // --always-full-compiler. | 102 // --always-full-compiler. |
| 103 Handle<SharedFunctionInfo> shared = info->shared_info(); | 103 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 104 bool is_run_once = (shared.is_null()) | 104 bool is_run_once = (shared.is_null()) |
| 105 ? info->scope()->is_global_scope() | 105 ? info->scope()->is_global_scope() |
| 106 : (shared->is_toplevel() || shared->try_full_codegen()); | 106 : (shared->is_toplevel() || shared->try_full_codegen()); |
| 107 | 107 bool use_full = FLAG_full_compiler && !function->contains_loops(); |
| 108 if (AlwaysFullCompiler()) { | 108 if (AlwaysFullCompiler() || (use_full && is_run_once)) { |
| 109 return FullCodeGenerator::MakeCode(info); | 109 return FullCodeGenerator::MakeCode(info); |
| 110 } else if (FLAG_full_compiler && is_run_once) { | |
| 111 FullCodeGenSyntaxChecker checker; | |
| 112 checker.Check(function); | |
| 113 if (checker.has_supported_syntax()) { | |
| 114 return FullCodeGenerator::MakeCode(info); | |
| 115 } | |
| 116 } | 110 } |
| 117 | 111 |
| 118 AssignedVariablesAnalyzer ava(function); | 112 AssignedVariablesAnalyzer ava(function); |
| 119 if (!ava.Analyze()) return Handle<Code>::null(); | 113 if (!ava.Analyze()) return Handle<Code>::null(); |
| 120 return CodeGenerator::MakeCode(info); | 114 return CodeGenerator::MakeCode(info); |
| 121 } | 115 } |
| 122 | 116 |
| 123 | 117 |
| 124 #ifdef ENABLE_DEBUGGER_SUPPORT | 118 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 125 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { | 119 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (!Rewriter::Optimize(literal)) { | 463 if (!Rewriter::Optimize(literal)) { |
| 470 return Handle<SharedFunctionInfo>::null(); | 464 return Handle<SharedFunctionInfo>::null(); |
| 471 } | 465 } |
| 472 | 466 |
| 473 // Generate code and return it. The way that the compilation mode | 467 // Generate code and return it. The way that the compilation mode |
| 474 // is controlled by the command-line flags is described in | 468 // is controlled by the command-line flags is described in |
| 475 // the static helper function MakeCode. | 469 // the static helper function MakeCode. |
| 476 CompilationInfo info(literal, script, false); | 470 CompilationInfo info(literal, script, false); |
| 477 | 471 |
| 478 bool is_run_once = literal->try_full_codegen(); | 472 bool is_run_once = literal->try_full_codegen(); |
| 479 bool is_compiled = false; | 473 bool use_full = FLAG_full_compiler && !literal->contains_loops(); |
| 480 | 474 if (AlwaysFullCompiler() || (use_full && is_run_once)) { |
| 481 if (AlwaysFullCompiler()) { | |
| 482 code = FullCodeGenerator::MakeCode(&info); | 475 code = FullCodeGenerator::MakeCode(&info); |
| 483 is_compiled = true; | 476 } else { |
| 484 } else if (FLAG_full_compiler && is_run_once) { | |
| 485 FullCodeGenSyntaxChecker checker; | |
| 486 checker.Check(literal); | |
| 487 if (checker.has_supported_syntax()) { | |
| 488 code = FullCodeGenerator::MakeCode(&info); | |
| 489 is_compiled = true; | |
| 490 } | |
| 491 } | |
| 492 | |
| 493 if (!is_compiled) { | |
| 494 // We fall back to the classic V8 code generator. | 477 // We fall back to the classic V8 code generator. |
| 495 AssignedVariablesAnalyzer ava(literal); | 478 AssignedVariablesAnalyzer ava(literal); |
| 496 if (!ava.Analyze()) return Handle<SharedFunctionInfo>::null(); | 479 if (!ava.Analyze()) return Handle<SharedFunctionInfo>::null(); |
| 497 code = CodeGenerator::MakeCode(&info); | 480 code = CodeGenerator::MakeCode(&info); |
| 498 } | 481 } |
| 499 | 482 |
| 500 // Check for stack-overflow exception. | 483 // Check for stack-overflow exception. |
| 501 if (code.is_null()) { | 484 if (code.is_null()) { |
| 502 caller->SetStackOverflow(); | 485 caller->SetStackOverflow(); |
| 503 return Handle<SharedFunctionInfo>::null(); | 486 return Handle<SharedFunctionInfo>::null(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 566 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
| 584 *code, *func_name)); | 567 *code, *func_name)); |
| 585 OPROFILE(CreateNativeCodeRegion(*func_name, | 568 OPROFILE(CreateNativeCodeRegion(*func_name, |
| 586 code->instruction_start(), | 569 code->instruction_start(), |
| 587 code->instruction_size())); | 570 code->instruction_size())); |
| 588 } | 571 } |
| 589 } | 572 } |
| 590 } | 573 } |
| 591 | 574 |
| 592 } } // namespace v8::internal | 575 } } // namespace v8::internal |
| OLD | NEW |