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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 Deoptimizer::VisitAllOptimizedFunctions(isolate, activations_finder); | 885 Deoptimizer::VisitAllOptimizedFunctions(isolate, activations_finder); |
886 } | 886 } |
887 return activations_finder->has_activations(); | 887 return activations_finder->has_activations(); |
888 } | 888 } |
889 | 889 |
890 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { | 890 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { |
891 Isolate* isolate = function->GetIsolate(); | 891 Isolate* isolate = function->GetIsolate(); |
892 VMState<COMPILER> state(isolate); | 892 VMState<COMPILER> state(isolate); |
893 PostponeInterruptsScope postpone(isolate); | 893 PostponeInterruptsScope postpone(isolate); |
894 Zone zone(isolate->allocator()); | 894 Zone zone(isolate->allocator()); |
895 ParseInfo parse_info(&zone, handle(function->shared())); | 895 ParseInfo parse_info(&zone, function); |
896 CompilationInfo info(&parse_info, function); | 896 CompilationInfo info(&parse_info, function); |
897 | 897 |
898 // Reset profiler ticks, function is no longer considered hot. | 898 // Reset profiler ticks, function is no longer considered hot. |
899 if (function->shared()->HasBytecodeArray()) { | 899 if (function->shared()->HasBytecodeArray()) { |
900 function->shared()->set_profiler_ticks(0); | 900 function->shared()->set_profiler_ticks(0); |
901 } | 901 } |
902 | 902 |
903 // Nothing left to do if the function already has baseline code. | 903 // Nothing left to do if the function already has baseline code. |
904 if (function->shared()->code()->kind() == Code::FUNCTION) { | 904 if (function->shared()->code()->kind() == Code::FUNCTION) { |
905 return Handle<Code>(function->shared()->code()); | 905 return Handle<Code>(function->shared()->code()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 return Handle<Code>(function->shared()->code()); | 1006 return Handle<Code>(function->shared()->code()); |
1007 } | 1007 } |
1008 | 1008 |
1009 if (function->shared()->HasBytecodeArray()) { | 1009 if (function->shared()->HasBytecodeArray()) { |
1010 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); | 1010 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); |
1011 function->shared()->ReplaceCode(*entry); | 1011 function->shared()->ReplaceCode(*entry); |
1012 return entry; | 1012 return entry; |
1013 } | 1013 } |
1014 | 1014 |
1015 Zone zone(isolate->allocator()); | 1015 Zone zone(isolate->allocator()); |
1016 ParseInfo parse_info(&zone, handle(function->shared())); | 1016 ParseInfo parse_info(&zone, function); |
1017 CompilationInfo info(&parse_info, function); | 1017 CompilationInfo info(&parse_info, function); |
1018 Handle<Code> result; | 1018 Handle<Code> result; |
1019 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); | 1019 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); |
1020 | 1020 |
1021 if (FLAG_always_opt) { | 1021 if (FLAG_always_opt) { |
1022 Handle<Code> opt_code; | 1022 Handle<Code> opt_code; |
1023 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) | 1023 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) |
1024 .ToHandle(&opt_code)) { | 1024 .ToHandle(&opt_code)) { |
1025 result = opt_code; | 1025 result = opt_code; |
1026 } | 1026 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 if (!GetOptimizedCode(function, mode).ToHandle(&code)) { | 1236 if (!GetOptimizedCode(function, mode).ToHandle(&code)) { |
1237 // Optimization failed, get unoptimized code. | 1237 // Optimization failed, get unoptimized code. |
1238 DCHECK(!isolate->has_pending_exception()); | 1238 DCHECK(!isolate->has_pending_exception()); |
1239 if (function->shared()->is_compiled()) { | 1239 if (function->shared()->is_compiled()) { |
1240 code = handle(function->shared()->code(), isolate); | 1240 code = handle(function->shared()->code(), isolate); |
1241 } else if (function->shared()->HasBytecodeArray()) { | 1241 } else if (function->shared()->HasBytecodeArray()) { |
1242 code = isolate->builtins()->InterpreterEntryTrampoline(); | 1242 code = isolate->builtins()->InterpreterEntryTrampoline(); |
1243 function->shared()->ReplaceCode(*code); | 1243 function->shared()->ReplaceCode(*code); |
1244 } else { | 1244 } else { |
1245 Zone zone(isolate->allocator()); | 1245 Zone zone(isolate->allocator()); |
1246 ParseInfo parse_info(&zone, handle(function->shared())); | 1246 ParseInfo parse_info(&zone, function); |
1247 CompilationInfo info(&parse_info, function); | 1247 CompilationInfo info(&parse_info, function); |
1248 if (!GetUnoptimizedCode(&info).ToHandle(&code)) { | 1248 if (!GetUnoptimizedCode(&info).ToHandle(&code)) { |
1249 return false; | 1249 return false; |
1250 } | 1250 } |
1251 } | 1251 } |
1252 } | 1252 } |
1253 | 1253 |
1254 // Install code on closure. | 1254 // Install code on closure. |
1255 function->ReplaceCode(*code); | 1255 function->ReplaceCode(*code); |
1256 JSFunction::EnsureLiterals(function); | 1256 JSFunction::EnsureLiterals(function); |
1257 | 1257 |
1258 // Check postconditions on success. | 1258 // Check postconditions on success. |
1259 DCHECK(!isolate->has_pending_exception()); | 1259 DCHECK(!isolate->has_pending_exception()); |
1260 DCHECK(function->shared()->is_compiled()); | 1260 DCHECK(function->shared()->is_compiled()); |
1261 DCHECK(function->is_compiled()); | 1261 DCHECK(function->is_compiled()); |
1262 return true; | 1262 return true; |
1263 } | 1263 } |
1264 | 1264 |
1265 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { | 1265 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { |
1266 Isolate* isolate = function->GetIsolate(); | 1266 Isolate* isolate = function->GetIsolate(); |
1267 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1267 DCHECK(AllowCompilation::IsAllowed(isolate)); |
1268 | 1268 |
1269 // Start a compilation. | 1269 // Start a compilation. |
1270 Zone zone(isolate->allocator()); | 1270 Zone zone(isolate->allocator()); |
1271 ParseInfo parse_info(&zone, handle(function->shared())); | 1271 ParseInfo parse_info(&zone, function); |
1272 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1272 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
1273 if (IsEvalToplevel(handle(function->shared()))) { | 1273 if (IsEvalToplevel(handle(function->shared()))) { |
1274 parse_info.set_eval(); | 1274 parse_info.set_eval(); |
1275 parse_info.set_toplevel(); | 1275 parse_info.set_toplevel(); |
1276 parse_info.set_allow_lazy_parsing(false); | 1276 parse_info.set_allow_lazy_parsing(false); |
1277 parse_info.set_lazy(false); | 1277 parse_info.set_lazy(false); |
1278 } | 1278 } |
1279 info.MarkAsDebug(); | 1279 info.MarkAsDebug(); |
1280 if (GetUnoptimizedCode(&info).is_null()) { | 1280 if (GetUnoptimizedCode(&info).is_null()) { |
1281 isolate->clear_pending_exception(); | 1281 isolate->clear_pending_exception(); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 DCHECK(shared->is_compiled()); | 1888 DCHECK(shared->is_compiled()); |
1889 function->set_literals(cached.literals); | 1889 function->set_literals(cached.literals); |
1890 } else if (shared->is_compiled()) { | 1890 } else if (shared->is_compiled()) { |
1891 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1891 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1892 JSFunction::EnsureLiterals(function); | 1892 JSFunction::EnsureLiterals(function); |
1893 } | 1893 } |
1894 } | 1894 } |
1895 | 1895 |
1896 } // namespace internal | 1896 } // namespace internal |
1897 } // namespace v8 | 1897 } // namespace v8 |
OLD | NEW |