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 |
866 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 869 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
867 | 870 |
868 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); | 871 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); |
869 | 872 |
870 OptimizedCompileJob job(info); | 873 OptimizedCompileJob job(info); |
871 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || | 874 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || |
872 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || | 875 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || |
873 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { | 876 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { |
874 if (FLAG_trace_opt) { | 877 if (FLAG_trace_opt) { |
875 PrintF("[aborted optimizing "); | 878 PrintF("[aborted optimizing "); |
876 info->closure()->ShortPrint(); | 879 info->closure()->ShortPrint(); |
877 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); | 880 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); |
878 } | 881 } |
879 return false; | 882 return false; |
880 } | 883 } |
881 | 884 |
882 // Success! | 885 // Success! |
883 DCHECK(!info->isolate()->has_pending_exception()); | 886 DCHECK(!isolate->has_pending_exception()); |
884 InsertCodeIntoOptimizedCodeMap(info); | 887 InsertCodeIntoOptimizedCodeMap(info); |
885 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, | 888 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, |
886 info->shared_info()); | 889 info->shared_info()); |
887 return true; | 890 return true; |
888 } | 891 } |
889 | 892 |
890 | 893 |
891 static bool GetOptimizedCodeLater(CompilationInfo* info) { | 894 static bool GetOptimizedCodeLater(CompilationInfo* info) { |
892 Isolate* isolate = info->isolate(); | 895 Isolate* isolate = info->isolate(); |
| 896 CanonicalHandleScope canonical(isolate); |
| 897 |
893 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { | 898 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { |
894 if (FLAG_trace_concurrent_recompilation) { | 899 if (FLAG_trace_concurrent_recompilation) { |
895 PrintF(" ** Compilation queue full, will retry optimizing "); | 900 PrintF(" ** Compilation queue full, will retry optimizing "); |
896 info->closure()->ShortPrint(); | 901 info->closure()->ShortPrint(); |
897 PrintF(" later.\n"); | 902 PrintF(" later.\n"); |
898 } | 903 } |
899 return false; | 904 return false; |
900 } | 905 } |
901 | 906 |
902 CompilationHandleScope handle_scope(info); | 907 CompilationHandleScope handle_scope(info); |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 } | 1793 } |
1789 | 1794 |
1790 #if DEBUG | 1795 #if DEBUG |
1791 void CompilationInfo::PrintAstForTesting() { | 1796 void CompilationInfo::PrintAstForTesting() { |
1792 PrintF("--- Source from AST ---\n%s\n", | 1797 PrintF("--- Source from AST ---\n%s\n", |
1793 PrettyPrinter(isolate()).PrintProgram(literal())); | 1798 PrettyPrinter(isolate()).PrintProgram(literal())); |
1794 } | 1799 } |
1795 #endif | 1800 #endif |
1796 } // namespace internal | 1801 } // namespace internal |
1797 } // namespace v8 | 1802 } // namespace v8 |
OLD | NEW |