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

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

Issue 2341523002: VM: Better handling of OOM errors in the background compiler (Closed)
Patch Set: lint Created 4 years, 3 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 | runtime/vm/exceptions.cc » ('j') | 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 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 if (FLAG_trace_compiler) { 1277 if (FLAG_trace_compiler) {
1278 THR_Print("Aborted background compilation: %s\n", 1278 THR_Print("Aborted background compilation: %s\n",
1279 function.ToFullyQualifiedCString()); 1279 function.ToFullyQualifiedCString());
1280 } 1280 }
1281 { 1281 {
1282 // If it was a bailout, then disable optimization. 1282 // If it was a bailout, then disable optimization.
1283 Error& error = Error::Handle(); 1283 Error& error = Error::Handle();
1284 // We got an error during compilation. 1284 // We got an error during compilation.
1285 error = thread->sticky_error(); 1285 error = thread->sticky_error();
1286 thread->clear_sticky_error(); 1286 thread->clear_sticky_error();
1287 if (error.IsLanguageError() && 1287 if ((error.IsLanguageError() &&
1288 LanguageError::Cast(error).kind() == Report::kBailout) { 1288 LanguageError::Cast(error).kind() == Report::kBailout) ||
1289 error.IsUnhandledException()) {
1289 if (FLAG_trace_compiler) { 1290 if (FLAG_trace_compiler) {
1290 THR_Print("--> disabling optimizations for '%s'\n", 1291 THR_Print("--> disabling optimizations for '%s'\n",
1291 function.ToFullyQualifiedCString()); 1292 function.ToFullyQualifiedCString());
1292 } 1293 }
1293 function.SetIsOptimizable(false); 1294 function.SetIsOptimizable(false);
1294 } 1295 }
1295 } 1296 }
1296 return Error::null(); 1297 return Error::null();
1297 } 1298 }
1298 // Optimizer bailed out. Disable optimizations and never try again. 1299 // Optimizer bailed out. Disable optimizations and never try again.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 error = thread->sticky_error(); 1354 error = thread->sticky_error();
1354 thread->clear_sticky_error(); 1355 thread->clear_sticky_error();
1355 if (error.raw() == Object::background_compilation_error().raw()) { 1356 if (error.raw() == Object::background_compilation_error().raw()) {
1356 // Exit compilation, retry it later. 1357 // Exit compilation, retry it later.
1357 if (FLAG_trace_bailout) { 1358 if (FLAG_trace_bailout) {
1358 THR_Print("Aborted background compilation: %s\n", 1359 THR_Print("Aborted background compilation: %s\n",
1359 function.ToFullyQualifiedCString()); 1360 function.ToFullyQualifiedCString());
1360 } 1361 }
1361 return Error::null(); 1362 return Error::null();
1362 } 1363 }
1363 // Unoptimized compilation or precompilation may encounter compile-time
1364 // errors, but regular optimized compilation should not.
1365 ASSERT(!optimized);
1366 // Do not attempt to optimize functions that can cause errors. 1364 // Do not attempt to optimize functions that can cause errors.
1367 function.set_is_optimizable(false); 1365 function.set_is_optimizable(false);
1368 return error.raw(); 1366 return error.raw();
1369 } 1367 }
1370 UNREACHABLE(); 1368 UNREACHABLE();
1371 return Error::null(); 1369 return Error::null();
1372 } 1370 }
1373 1371
1374 1372
1375 RawError* Compiler::CompileFunction(Thread* thread, 1373 RawError* Compiler::CompileFunction(Thread* thread,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 StackZone stack_zone(thread); 1853 StackZone stack_zone(thread);
1856 Zone* zone = stack_zone.GetZone(); 1854 Zone* zone = stack_zone.GetZone();
1857 HANDLESCOPE(thread); 1855 HANDLESCOPE(thread);
1858 Function& function = Function::Handle(zone); 1856 Function& function = Function::Handle(zone);
1859 { MonitorLocker ml(queue_monitor_); 1857 { MonitorLocker ml(queue_monitor_);
1860 function = function_queue()->PeekFunction(); 1858 function = function_queue()->PeekFunction();
1861 } 1859 }
1862 while (running_ && !function.IsNull() && !isolate_->IsTopLevelParsing()) { 1860 while (running_ && !function.IsNull() && !isolate_->IsTopLevelParsing()) {
1863 // Check that we have aggregated and cleared the stats. 1861 // Check that we have aggregated and cleared the stats.
1864 ASSERT(thread->compiler_stats()->IsCleared()); 1862 ASSERT(thread->compiler_stats()->IsCleared());
1865 const Error& error = Error::Handle(zone, 1863 Compiler::CompileOptimizedFunction(thread,
1866 Compiler::CompileOptimizedFunction(thread, 1864 function,
1867 function, 1865 Compiler::kNoOSRDeoptId);
1868 Compiler::kNoOSRDeoptId));
1869 // TODO(srdjan): We do not expect errors while compiling optimized
1870 // code, any errors should have been caught when compiling
1871 // unoptimized code. Any issues while optimizing are flagged by
1872 // making the result invalid.
1873 ASSERT(error.IsNull());
1874 #ifndef PRODUCT 1866 #ifndef PRODUCT
1875 Isolate* isolate = thread->isolate(); 1867 Isolate* isolate = thread->isolate();
1876 isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats()); 1868 isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats());
1877 thread->compiler_stats()->Clear(); 1869 thread->compiler_stats()->Clear();
1878 #endif // PRODUCT 1870 #endif // PRODUCT
1879 1871
1880 QueueElement* qelem = NULL; 1872 QueueElement* qelem = NULL;
1881 { MonitorLocker ml(queue_monitor_); 1873 { MonitorLocker ml(queue_monitor_);
1882 if (function_queue()->IsEmpty()) { 1874 if (function_queue()->IsEmpty()) {
1883 // We are shutting down, queue was cleared. 1875 // We are shutting down, queue was cleared.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2170
2179 2171
2180 bool BackgroundCompiler::IsDisabled() { 2172 bool BackgroundCompiler::IsDisabled() {
2181 UNREACHABLE(); 2173 UNREACHABLE();
2182 return true; 2174 return true;
2183 } 2175 }
2184 2176
2185 #endif // DART_PRECOMPILED_RUNTIME 2177 #endif // DART_PRECOMPILED_RUNTIME
2186 2178
2187 } // namespace dart 2179 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698