| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 } | 856 } |
| 857 | 857 |
| 858 | 858 |
| 859 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 859 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
| 860 if (!Parser::ParseStatic(info)) return false; | 860 if (!Parser::ParseStatic(info)) return false; |
| 861 return Compiler::Analyze(info); | 861 return Compiler::Analyze(info); |
| 862 } | 862 } |
| 863 | 863 |
| 864 | 864 |
| 865 static bool GetOptimizedCodeNow(CompilationInfo* info) { | 865 static bool GetOptimizedCodeNow(CompilationInfo* info) { |
| 866 Isolate* isolate = info->isolate(); | |
| 867 CanonicalHandleScope canonical(isolate); | |
| 868 | |
| 869 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 866 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
| 870 | 867 |
| 871 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); | 868 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 872 | 869 |
| 873 OptimizedCompileJob job(info); | 870 OptimizedCompileJob job(info); |
| 874 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || | 871 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || |
| 875 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || | 872 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || |
| 876 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { | 873 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { |
| 877 if (FLAG_trace_opt) { | 874 if (FLAG_trace_opt) { |
| 878 PrintF("[aborted optimizing "); | 875 PrintF("[aborted optimizing "); |
| 879 info->closure()->ShortPrint(); | 876 info->closure()->ShortPrint(); |
| 880 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 877 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
| 881 } | 878 } |
| 882 return false; | 879 return false; |
| 883 } | 880 } |
| 884 | 881 |
| 885 // Success! | 882 // Success! |
| 886 DCHECK(!isolate->has_pending_exception()); | 883 DCHECK(!info->isolate()->has_pending_exception()); |
| 887 InsertCodeIntoOptimizedCodeMap(info); | 884 InsertCodeIntoOptimizedCodeMap(info); |
| 888 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, | 885 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, |
| 889 info->shared_info()); | 886 info->shared_info()); |
| 890 return true; | 887 return true; |
| 891 } | 888 } |
| 892 | 889 |
| 893 | 890 |
| 894 static bool GetOptimizedCodeLater(CompilationInfo* info) { | 891 static bool GetOptimizedCodeLater(CompilationInfo* info) { |
| 895 Isolate* isolate = info->isolate(); | 892 Isolate* isolate = info->isolate(); |
| 896 CanonicalHandleScope canonical(isolate); | |
| 897 | |
| 898 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 893 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { |
| 899 if (FLAG_trace_concurrent_recompilation) { | 894 if (FLAG_trace_concurrent_recompilation) { |
| 900 PrintF(" ** Compilation queue full, will retry optimizing "); | 895 PrintF(" ** Compilation queue full, will retry optimizing "); |
| 901 info->closure()->ShortPrint(); | 896 info->closure()->ShortPrint(); |
| 902 PrintF(" later.\n"); | 897 PrintF(" later.\n"); |
| 903 } | 898 } |
| 904 return false; | 899 return false; |
| 905 } | 900 } |
| 906 | 901 |
| 907 CompilationHandleScope handle_scope(info); | 902 CompilationHandleScope handle_scope(info); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 } | 1788 } |
| 1794 | 1789 |
| 1795 #if DEBUG | 1790 #if DEBUG |
| 1796 void CompilationInfo::PrintAstForTesting() { | 1791 void CompilationInfo::PrintAstForTesting() { |
| 1797 PrintF("--- Source from AST ---\n%s\n", | 1792 PrintF("--- Source from AST ---\n%s\n", |
| 1798 PrettyPrinter(isolate()).PrintProgram(literal())); | 1793 PrettyPrinter(isolate()).PrintProgram(literal())); |
| 1799 } | 1794 } |
| 1800 #endif | 1795 #endif |
| 1801 } // namespace internal | 1796 } // namespace internal |
| 1802 } // namespace v8 | 1797 } // namespace v8 |
| OLD | NEW |