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

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

Issue 1386503002: Initial design for background compilation (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address Comments Created 5 years, 2 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/compiler.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 13 matching lines...) Expand all
24 #include "vm/stack_frame.h" 24 #include "vm/stack_frame.h"
25 #include "vm/symbols.h" 25 #include "vm/symbols.h"
26 #include "vm/thread_registry.h" 26 #include "vm/thread_registry.h"
27 #include "vm/verifier.h" 27 #include "vm/verifier.h"
28 28
29 namespace dart { 29 namespace dart {
30 30
31 DEFINE_FLAG(bool, deoptimize_alot, false, 31 DEFINE_FLAG(bool, deoptimize_alot, false,
32 "Deoptimizes all live frames when we are about to return to Dart code from" 32 "Deoptimizes all live frames when we are about to return to Dart code from"
33 " native entries."); 33 " native entries.");
34 DEFINE_FLAG(bool, background_compilation, false,
35 "Run optimizing compilation in background");
34 DEFINE_FLAG(int, max_subtype_cache_entries, 100, 36 DEFINE_FLAG(int, max_subtype_cache_entries, 100,
35 "Maximum number of subtype cache entries (number of checks cached)."); 37 "Maximum number of subtype cache entries (number of checks cached).");
36 DEFINE_FLAG(int, optimization_counter_threshold, 30000, 38 DEFINE_FLAG(int, optimization_counter_threshold, 30000,
37 "Function's usage-counter value before it is optimized, -1 means never"); 39 "Function's usage-counter value before it is optimized, -1 means never");
38 DEFINE_FLAG(int, regexp_optimization_counter_threshold, 1000, 40 DEFINE_FLAG(int, regexp_optimization_counter_threshold, 1000,
39 "RegExp's usage-counter value before it is optimized, -1 means never"); 41 "RegExp's usage-counter value before it is optimized, -1 means never");
40 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function"); 42 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function");
41 DEFINE_FLAG(int, reoptimization_counter_threshold, 4000, 43 DEFINE_FLAG(int, reoptimization_counter_threshold, 4000,
42 "Counter threshold before a function gets reoptimized."); 44 "Counter threshold before a function gets reoptimized.");
43 DEFINE_FLAG(bool, stop_on_excessive_deoptimization, false, 45 DEFINE_FLAG(bool, stop_on_excessive_deoptimization, false,
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { 1444 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) {
1443 const Function& function = Function::CheckedHandle(zone, 1445 const Function& function = Function::CheckedHandle(zone,
1444 arguments.ArgAt(0)); 1446 arguments.ArgAt(0));
1445 ASSERT(!function.IsNull()); 1447 ASSERT(!function.IsNull());
1446 ASSERT(function.HasCode()); 1448 ASSERT(function.HasCode());
1447 1449
1448 if (CanOptimizeFunction(function, isolate)) { 1450 if (CanOptimizeFunction(function, isolate)) {
1449 // Reset usage counter for reoptimization before calling optimizer to 1451 // Reset usage counter for reoptimization before calling optimizer to
1450 // prevent recursive triggering of function optimization. 1452 // prevent recursive triggering of function optimization.
1451 function.set_usage_counter(0); 1453 function.set_usage_counter(0);
1454 if (FLAG_background_compilation) {
1455 BackgroundCompiler::EnsureInit(isolate);
1456 ASSERT(isolate->background_compiler() != NULL);
1457 isolate->background_compiler()->CompileOptimized(function);
1458 // Continue in the same code.
1459 arguments.SetReturn(Code::Handle(isolate, function.CurrentCode()));
1460 return;
1461 }
1452 if (FLAG_trace_compiler) { 1462 if (FLAG_trace_compiler) {
1453 if (function.HasOptimizedCode()) { 1463 if (function.HasOptimizedCode()) {
1454 THR_Print("ReCompiling function: '%s' \n", 1464 THR_Print("ReCompiling function: '%s' \n",
1455 function.ToFullyQualifiedCString()); 1465 function.ToFullyQualifiedCString());
1456 } 1466 }
1457 } 1467 }
1458 const Error& error = Error::Handle( 1468 const Error& error = Error::Handle(
1459 isolate, Compiler::CompileOptimizedFunction(thread, function)); 1469 isolate, Compiler::CompileOptimizedFunction(thread, function));
1460 if (!error.IsNull()) { 1470 if (!error.IsNull()) {
1461 Exceptions::PropagateError(error); 1471 Exceptions::PropagateError(error);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 const intptr_t elm_size = old_data.ElementSizeInBytes(); 1835 const intptr_t elm_size = old_data.ElementSizeInBytes();
1826 const TypedData& new_data = 1836 const TypedData& new_data =
1827 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 1837 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
1828 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 1838 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
1829 typed_data_cell.SetAt(0, new_data); 1839 typed_data_cell.SetAt(0, new_data);
1830 arguments.SetReturn(new_data); 1840 arguments.SetReturn(new_data);
1831 } 1841 }
1832 1842
1833 1843
1834 } // namespace dart 1844 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698