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/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 InterpreterActivationsFinder activations_finder(shared); | 880 InterpreterActivationsFinder activations_finder(shared); |
881 activations_finder.VisitThread(isolate, isolate->thread_local_top()); | 881 activations_finder.VisitThread(isolate, isolate->thread_local_top()); |
882 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); | 882 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); |
883 return activations_finder.has_activations_; | 883 return activations_finder.has_activations_; |
884 } | 884 } |
885 | 885 |
886 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { | 886 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { |
887 Isolate* isolate = function->GetIsolate(); | 887 Isolate* isolate = function->GetIsolate(); |
888 VMState<COMPILER> state(isolate); | 888 VMState<COMPILER> state(isolate); |
889 PostponeInterruptsScope postpone(isolate); | 889 PostponeInterruptsScope postpone(isolate); |
890 CompilationInfoWithZone info(function); | 890 Zone zone(isolate->allocator()); |
| 891 ParseInfo parse_info(&zone, function); |
| 892 CompilationInfo info(&parse_info, function); |
891 | 893 |
892 // Reset profiler ticks, function is no longer considered hot. | 894 // Reset profiler ticks, function is no longer considered hot. |
893 if (function->shared()->HasBytecodeArray()) { | 895 if (function->shared()->HasBytecodeArray()) { |
894 function->shared()->set_profiler_ticks(0); | 896 function->shared()->set_profiler_ticks(0); |
895 } | 897 } |
896 | 898 |
897 // Nothing left to do if the function already has baseline code. | 899 // Nothing left to do if the function already has baseline code. |
898 if (function->shared()->code()->kind() == Code::FUNCTION) { | 900 if (function->shared()->code()->kind() == Code::FUNCTION) { |
899 return Handle<Code>(function->shared()->code()); | 901 return Handle<Code>(function->shared()->code()); |
900 } | 902 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { | 993 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT).ToHandle(&code)) { |
992 DCHECK(function->shared()->is_compiled()); | 994 DCHECK(function->shared()->is_compiled()); |
993 return code; | 995 return code; |
994 } | 996 } |
995 } | 997 } |
996 | 998 |
997 if (function->shared()->is_compiled()) { | 999 if (function->shared()->is_compiled()) { |
998 return Handle<Code>(function->shared()->code()); | 1000 return Handle<Code>(function->shared()->code()); |
999 } | 1001 } |
1000 | 1002 |
1001 CompilationInfoWithZone info(function); | 1003 Zone zone(isolate->allocator()); |
| 1004 ParseInfo parse_info(&zone, function); |
| 1005 CompilationInfo info(&parse_info, function); |
1002 Handle<Code> result; | 1006 Handle<Code> result; |
1003 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); | 1007 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); |
1004 | 1008 |
1005 if (FLAG_always_opt) { | 1009 if (FLAG_always_opt) { |
1006 Handle<Code> opt_code; | 1010 Handle<Code> opt_code; |
1007 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) | 1011 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) |
1008 .ToHandle(&opt_code)) { | 1012 .ToHandle(&opt_code)) { |
1009 result = opt_code; | 1013 result = opt_code; |
1010 } | 1014 } |
1011 } | 1015 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1223 DCHECK(AllowCompilation::IsAllowed(isolate)); |
1220 | 1224 |
1221 // Start a compilation. | 1225 // Start a compilation. |
1222 Handle<Code> code; | 1226 Handle<Code> code; |
1223 if (!GetOptimizedCode(function, mode).ToHandle(&code)) { | 1227 if (!GetOptimizedCode(function, mode).ToHandle(&code)) { |
1224 // Optimization failed, get unoptimized code. | 1228 // Optimization failed, get unoptimized code. |
1225 DCHECK(!isolate->has_pending_exception()); | 1229 DCHECK(!isolate->has_pending_exception()); |
1226 if (function->shared()->is_compiled()) { | 1230 if (function->shared()->is_compiled()) { |
1227 code = handle(function->shared()->code(), isolate); | 1231 code = handle(function->shared()->code(), isolate); |
1228 } else { | 1232 } else { |
1229 CompilationInfoWithZone info(function); | 1233 Zone zone(isolate->allocator()); |
| 1234 ParseInfo parse_info(&zone, function); |
| 1235 CompilationInfo info(&parse_info, function); |
1230 if (!GetUnoptimizedCode(&info).ToHandle(&code)) { | 1236 if (!GetUnoptimizedCode(&info).ToHandle(&code)) { |
1231 return false; | 1237 return false; |
1232 } | 1238 } |
1233 } | 1239 } |
1234 } | 1240 } |
1235 | 1241 |
1236 // Install code on closure. | 1242 // Install code on closure. |
1237 function->ReplaceCode(*code); | 1243 function->ReplaceCode(*code); |
1238 | 1244 |
1239 // Check postconditions on success. | 1245 // Check postconditions on success. |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 MaybeHandle<Code> code; | 1813 MaybeHandle<Code> code; |
1808 if (cached.code != nullptr) code = handle(cached.code); | 1814 if (cached.code != nullptr) code = handle(cached.code); |
1809 Handle<Context> native_context(function->context()->native_context()); | 1815 Handle<Context> native_context(function->context()->native_context()); |
1810 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1816 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1811 literals, BailoutId::None()); | 1817 literals, BailoutId::None()); |
1812 } | 1818 } |
1813 } | 1819 } |
1814 | 1820 |
1815 } // namespace internal | 1821 } // namespace internal |
1816 } // namespace v8 | 1822 } // namespace v8 |
OLD | NEW |