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

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

Issue 1821283002: Fix background compilation: handle compilation abort during parsing. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: t Created 4 years, 9 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/object.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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 num_tokens_after - num_tokens_before); 1164 num_tokens_after - num_tokens_before);
1165 } 1165 }
1166 1166
1167 CompileParsedFunctionHelper helper(parsed_function, optimized, osr_id); 1167 CompileParsedFunctionHelper helper(parsed_function, optimized, osr_id);
1168 const bool success = helper.Compile(pipeline); 1168 const bool success = helper.Compile(pipeline);
1169 if (!success) { 1169 if (!success) {
1170 if (optimized) { 1170 if (optimized) {
1171 if (Compiler::IsBackgroundCompilation()) { 1171 if (Compiler::IsBackgroundCompilation()) {
1172 // Try again later, background compilation may abort because of 1172 // Try again later, background compilation may abort because of
1173 // state change during compilation. 1173 // state change during compilation.
1174 if (FLAG_trace_compiler) {
1175 THR_Print("Aborted background compilation: %s\n",
1176 function.ToFullyQualifiedCString());
1177 }
1174 return Error::null(); 1178 return Error::null();
1175 } 1179 }
1176 // Optimizer bailed out. Disable optimizations and never try again. 1180 // Optimizer bailed out. Disable optimizations and never try again.
1177 if (trace_compiler) { 1181 if (trace_compiler) {
1178 THR_Print("--> disabling optimizations for '%s'\n", 1182 THR_Print("--> disabling optimizations for '%s'\n",
1179 function.ToFullyQualifiedCString()); 1183 function.ToFullyQualifiedCString());
1180 } else if (FLAG_trace_failed_optimization_attempts) { 1184 } else if (FLAG_trace_failed_optimization_attempts) {
1181 THR_Print("Cannot optimize: %s\n", 1185 THR_Print("Cannot optimize: %s\n",
1182 function.ToFullyQualifiedCString()); 1186 function.ToFullyQualifiedCString());
1183 } 1187 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 THR_Print("*** BEGIN CODE\n"); 1222 THR_Print("*** BEGIN CODE\n");
1219 Disassembler::DisassembleCode(function, true); 1223 Disassembler::DisassembleCode(function, true);
1220 THR_Print("*** END CODE\n"); 1224 THR_Print("*** END CODE\n");
1221 } 1225 }
1222 DEBUG_ONLY(CheckInliningIntervals(function)); 1226 DEBUG_ONLY(CheckInliningIntervals(function));
1223 return Error::null(); 1227 return Error::null();
1224 } else { 1228 } else {
1225 Thread* const thread = Thread::Current(); 1229 Thread* const thread = Thread::Current();
1226 StackZone stack_zone(thread); 1230 StackZone stack_zone(thread);
1227 Error& error = Error::Handle(); 1231 Error& error = Error::Handle();
1228 // We got an error during compilation. 1232 // We got an error during compilation or it is a bailout from background
1233 // compilation (e.g., during parsing with EnsureIsFinalized).
1229 error = thread->sticky_error(); 1234 error = thread->sticky_error();
1230 thread->clear_sticky_error(); 1235 thread->clear_sticky_error();
1236 if (error.raw() == Object::background_compilation_error().raw()) {
1237 // Exit compilation, retry it later.
1238 if (FLAG_trace_bailout) {
1239 THR_Print("Aborted background compilation: %s\n",
1240 function.ToFullyQualifiedCString());
1241 }
1242 return Error::null();
1243 }
1231 // Unoptimized compilation or precompilation may encounter compile-time 1244 // Unoptimized compilation or precompilation may encounter compile-time
1232 // errors, but regular optimized compilation should not. 1245 // errors, but regular optimized compilation should not.
1233 ASSERT(!optimized); 1246 ASSERT(!optimized);
1234 // Do not attempt to optimize functions that can cause errors. 1247 // Do not attempt to optimize functions that can cause errors.
1235 function.set_is_optimizable(false); 1248 function.set_is_optimizable(false);
1236 return error.raw(); 1249 return error.raw();
1237 } 1250 }
1238 UNREACHABLE(); 1251 UNREACHABLE();
1239 return Error::null(); 1252 return Error::null();
1240 } 1253 }
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1896 }
1884 1897
1885 1898
1886 void BackgroundCompiler::EnsureInit(Thread* thread) { 1899 void BackgroundCompiler::EnsureInit(Thread* thread) {
1887 UNREACHABLE(); 1900 UNREACHABLE();
1888 } 1901 }
1889 1902
1890 #endif // DART_PRECOMPILED_RUNTIME 1903 #endif // DART_PRECOMPILED_RUNTIME
1891 1904
1892 } // namespace dart 1905 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698