Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); | 25 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); |
| 26 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); | 26 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); |
| 27 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); | 27 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); |
| 28 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); | 28 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); |
| 29 DEFINE_FLAG(int, optimization_counter_threshold, 2000, | 29 DEFINE_FLAG(int, optimization_counter_threshold, 2000, |
| 30 "function's usage-counter value before it is optimized, -1 means never."); | 30 "function's usage-counter value before it is optimized, -1 means never."); |
| 31 DECLARE_FLAG(bool, enable_type_checks); | 31 DECLARE_FLAG(bool, enable_type_checks); |
| 32 DECLARE_FLAG(bool, trace_type_checks); | 32 DECLARE_FLAG(bool, trace_type_checks); |
| 33 DECLARE_FLAG(bool, report_usage_count); | 33 DECLARE_FLAG(bool, report_usage_count); |
| 34 DECLARE_FLAG(int, deoptimization_counter_threshold); | 34 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 35 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function"); | |
| 35 | 36 |
| 36 | 37 |
| 37 bool CodeGenerator::CanOptimize() { | 38 bool CodeGenerator::CanOptimize() { |
| 38 return | 39 return |
| 39 !FLAG_report_usage_count && | 40 !FLAG_report_usage_count && |
| 40 (FLAG_optimization_counter_threshold >= 0) && | 41 (FLAG_optimization_counter_threshold >= 0) && |
| 41 !Isolate::Current()->debugger()->IsActive(); | 42 !Isolate::Current()->debugger()->IsActive(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 | 45 |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1334 } | 1335 } |
| 1335 if (function.HasOptimizedCode()) { | 1336 if (function.HasOptimizedCode()) { |
| 1336 // The caller has been already optimized. | 1337 // The caller has been already optimized. |
| 1337 // TODO(srdjan): This is a significant slowdown, the caller is probably in | 1338 // TODO(srdjan): This is a significant slowdown, the caller is probably in |
| 1338 // a loop. Maybe test if the code has been optimized before calling. | 1339 // a loop. Maybe test if the code has been optimized before calling. |
| 1339 // If this happens from optimized code, then it means that the optimized | 1340 // If this happens from optimized code, then it means that the optimized |
| 1340 // code needs to be reoptimized. | 1341 // code needs to be reoptimized. |
| 1341 function.set_usage_counter(kLowInvocationCount); | 1342 function.set_usage_counter(kLowInvocationCount); |
| 1342 return; | 1343 return; |
| 1343 } | 1344 } |
| 1345 if ((FLAG_optimization_filter != NULL) && | |
| 1346 (strncmp(function.ToFullyQualifiedCString(), | |
| 1347 FLAG_optimization_filter, | |
| 1348 strlen(FLAG_optimization_filter)) != 0)) { | |
| 1349 function.set_usage_counter(kLowInvocationCount); | |
|
srdjan
2012/06/18 16:33:20
Why not doing this in the compiler and "Bailout" f
Vyacheslav Egorov (Google)
2012/06/18 17:51:16
I don't see any profit in bailing out so late in t
| |
| 1350 return; | |
| 1351 } | |
| 1344 if (function.is_optimizable()) { | 1352 if (function.is_optimizable()) { |
| 1345 ASSERT(!function.HasOptimizedCode()); | 1353 ASSERT(!function.HasOptimizedCode()); |
| 1346 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); | 1354 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); |
| 1347 // Compilation patches the entry of unoptimized code. | 1355 // Compilation patches the entry of unoptimized code. |
| 1348 const Error& error = | 1356 const Error& error = |
| 1349 Error::Handle(Compiler::CompileOptimizedFunction(function)); | 1357 Error::Handle(Compiler::CompileOptimizedFunction(function)); |
| 1350 if (!error.IsNull()) { | 1358 if (!error.IsNull()) { |
| 1351 Exceptions::PropagateError(error); | 1359 Exceptions::PropagateError(error); |
| 1352 } | 1360 } |
| 1353 const Code& optimized_code = Code::Handle(function.CurrentCode()); | 1361 const Code& optimized_code = Code::Handle(function.CurrentCode()); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1568 } | 1576 } |
| 1569 } | 1577 } |
| 1570 } | 1578 } |
| 1571 // The cache is null terminated, therefore the loop above should never | 1579 // The cache is null terminated, therefore the loop above should never |
| 1572 // terminate by itself. | 1580 // terminate by itself. |
| 1573 UNREACHABLE(); | 1581 UNREACHABLE(); |
| 1574 return Code::null(); | 1582 return Code::null(); |
| 1575 } | 1583 } |
| 1576 | 1584 |
| 1577 } // namespace dart | 1585 } // namespace dart |
| OLD | NEW |