Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: runtime/vm/compiler.cc

Issue 2172063003: Retry background compilation if an assumption is invalidated (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } else { 1160 } else {
1161 // If the error isn't due to an out of range branch offset, we don't 1161 // If the error isn't due to an out of range branch offset, we don't
1162 // try again (done = true), and indicate that we did not finish 1162 // try again (done = true), and indicate that we did not finish
1163 // compiling (is_compiled = false). 1163 // compiling (is_compiled = false).
1164 if (FLAG_trace_bailout) { 1164 if (FLAG_trace_bailout) {
1165 THR_Print("%s\n", error.ToErrorCString()); 1165 THR_Print("%s\n", error.ToErrorCString());
1166 } 1166 }
1167 done = true; 1167 done = true;
1168 } 1168 }
1169 1169
1170 // Clear the error if it was not a real error, but just a bailout. 1170 // If is is not a background compilation, clear the error if it was not a
1171 if (error.IsLanguageError() && 1171 // real error, but just a bailout. If we're it a background compilation
1172 // this will be dealt with in the caller.
1173 if (!Compiler::IsBackgroundCompilation() && error.IsLanguageError() &&
1172 (LanguageError::Cast(error).kind() == Report::kBailout)) { 1174 (LanguageError::Cast(error).kind() == Report::kBailout)) {
1173 thread()->clear_sticky_error(); 1175 thread()->clear_sticky_error();
1174 } 1176 }
1175 is_compiled = false; 1177 is_compiled = false;
1176 } 1178 }
1177 // Reset global isolate state. 1179 // Reset global isolate state.
1178 thread()->set_deopt_id(prev_deopt_id); 1180 thread()->set_deopt_id(prev_deopt_id);
1179 } 1181 }
1180 return is_compiled; 1182 return is_compiled;
1181 } 1183 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 } 1272 }
1271 } else { 1273 } else {
1272 if (optimized) { 1274 if (optimized) {
1273 if (Compiler::IsBackgroundCompilation()) { 1275 if (Compiler::IsBackgroundCompilation()) {
1274 // Try again later, background compilation may abort because of 1276 // Try again later, background compilation may abort because of
1275 // state change during compilation. 1277 // state change during compilation.
1276 if (FLAG_trace_compiler) { 1278 if (FLAG_trace_compiler) {
1277 THR_Print("Aborted background compilation: %s\n", 1279 THR_Print("Aborted background compilation: %s\n",
1278 function.ToFullyQualifiedCString()); 1280 function.ToFullyQualifiedCString());
1279 } 1281 }
1282 {
1283 // If it was a bailout, then disable optimization.
1284 Error& error = Error::Handle();
1285 // We got an error during compilation.
1286 error = thread->sticky_error();
1287 thread->clear_sticky_error();
1288 if (error.IsLanguageError() &&
1289 LanguageError::Cast(error).kind() == Report::kBailout) {
1290 if (FLAG_trace_compiler) {
1291 THR_Print("--> disabling optimizations for '%s'\n",
1292 function.ToFullyQualifiedCString());
1293 }
1294 function.SetIsOptimizable(false);
1295 }
1296 }
1280 return Error::null(); 1297 return Error::null();
1281 } 1298 }
1282 // Optimizer bailed out. Disable optimizations and never try again. 1299 // Optimizer bailed out. Disable optimizations and never try again.
1283 if (trace_compiler) { 1300 if (trace_compiler) {
1284 THR_Print("--> disabling optimizations for '%s'\n", 1301 THR_Print("--> disabling optimizations for '%s'\n",
1285 function.ToFullyQualifiedCString()); 1302 function.ToFullyQualifiedCString());
1286 } else if (FLAG_trace_failed_optimization_attempts) { 1303 } else if (FLAG_trace_failed_optimization_attempts) {
1287 THR_Print("Cannot optimize: %s\n", 1304 THR_Print("Cannot optimize: %s\n",
1288 function.ToFullyQualifiedCString()); 1305 function.ToFullyQualifiedCString());
1289 } 1306 }
1290 function.SetIsOptimizable(false); 1307 function.SetIsOptimizable(false);
1291 return Error::null(); 1308 return Error::null();
1292 } else { 1309 } else {
1293 // Encountered error. 1310 // Encountered error.
1294 Error& error = Error::Handle(); 1311 Error& error = Error::Handle();
1295 // We got an error during compilation. 1312 // We got an error during compilation.
1296 error = thread->sticky_error(); 1313 error = thread->sticky_error();
1297 thread->clear_sticky_error(); 1314 thread->clear_sticky_error();
1315 // The non-optimizing compiler should not bail out.
1298 ASSERT(error.IsLanguageError() && 1316 ASSERT(error.IsLanguageError() &&
1299 LanguageError::Cast(error).kind() != Report::kBailout); 1317 LanguageError::Cast(error).kind() != Report::kBailout);
1300 return error.raw(); 1318 return error.raw();
1301 } 1319 }
1302 } 1320 }
1303 1321
1304 per_compile_timer.Stop(); 1322 per_compile_timer.Stop();
1305 1323
1306 if (trace_compiler && success) { 1324 if (trace_compiler && success) {
1307 THR_Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n", 1325 THR_Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n",
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 thread->compiler_stats()->Clear(); 1881 thread->compiler_stats()->Clear();
1864 #endif // PRODUCT 1882 #endif // PRODUCT
1865 1883
1866 QueueElement* qelem = NULL; 1884 QueueElement* qelem = NULL;
1867 { MonitorLocker ml(queue_monitor_); 1885 { MonitorLocker ml(queue_monitor_);
1868 if (function_queue()->IsEmpty()) { 1886 if (function_queue()->IsEmpty()) {
1869 // We are shutting down, queue was cleared. 1887 // We are shutting down, queue was cleared.
1870 function = Function::null(); 1888 function = Function::null();
1871 } else { 1889 } else {
1872 qelem = function_queue()->Remove(); 1890 qelem = function_queue()->Remove();
1873 if (FLAG_stress_test_background_compilation) { 1891 const Function& old = Function::Handle(qelem->Function());
1874 const Function& old = Function::Handle(qelem->Function()); 1892 if ((!old.HasOptimizedCode() && old.IsOptimizable()) ||
1893 FLAG_stress_test_background_compilation) {
1875 if (Compiler::CanOptimizeFunction(thread, old)) { 1894 if (Compiler::CanOptimizeFunction(thread, old)) {
1876 QueueElement* repeat_qelem = new QueueElement(old); 1895 QueueElement* repeat_qelem = new QueueElement(old);
1877 function_queue()->Add(repeat_qelem); 1896 function_queue()->Add(repeat_qelem);
1878 } 1897 }
1879 } 1898 }
1880 function = function_queue()->PeekFunction(); 1899 function = function_queue()->PeekFunction();
1881 } 1900 }
1882 } 1901 }
1883 if (qelem != NULL) { 1902 if (qelem != NULL) {
1884 delete qelem; 1903 delete qelem;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 2182
2164 2183
2165 bool BackgroundCompiler::IsDisabled() { 2184 bool BackgroundCompiler::IsDisabled() {
2166 UNREACHABLE(); 2185 UNREACHABLE();
2167 return true; 2186 return true;
2168 } 2187 }
2169 2188
2170 #endif // DART_PRECOMPILED_RUNTIME 2189 #endif // DART_PRECOMPILED_RUNTIME
2171 2190
2172 } // namespace dart 2191 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698