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

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

Issue 16888013: Revert "Initial implementation of on-stack replacement (OSR)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | 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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function"); 47 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function");
48 DEFINE_FLAG(bool, trace_failed_optimization_attempts, false, 48 DEFINE_FLAG(bool, trace_failed_optimization_attempts, false,
49 "Traces all failed optimization attempts"); 49 "Traces all failed optimization attempts");
50 DEFINE_FLAG(bool, trace_optimized_ic_calls, false, 50 DEFINE_FLAG(bool, trace_optimized_ic_calls, false,
51 "Trace IC calls in optimized code."); 51 "Trace IC calls in optimized code.");
52 DEFINE_FLAG(int, reoptimization_counter_threshold, 2000, 52 DEFINE_FLAG(int, reoptimization_counter_threshold, 2000,
53 "Counter threshold before a function gets reoptimized."); 53 "Counter threshold before a function gets reoptimized.");
54 DEFINE_FLAG(int, max_subtype_cache_entries, 100, 54 DEFINE_FLAG(int, max_subtype_cache_entries, 100,
55 "Maximum number of subtype cache entries (number of checks cached)."); 55 "Maximum number of subtype cache entries (number of checks cached).");
56 56
57 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
58 DEFINE_FLAG(bool, use_osr, true, "Use on-stack replacement.");
59 #else
60 DEFINE_FLAG(bool, use_osr, false, "Use on-stack replacement.");
61 #endif
62 DEFINE_FLAG(bool, trace_osr, false, "Trace attempts at on-stack replacement.");
63
64 57
65 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) { 58 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) {
66 ASSERT(arguments.ArgCount() == 59 ASSERT(arguments.ArgCount() ==
67 kTraceFunctionEntryRuntimeEntry.argument_count()); 60 kTraceFunctionEntryRuntimeEntry.argument_count());
68 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); 61 const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
69 const String& function_name = String::Handle(function.name()); 62 const String& function_name = String::Handle(function.name());
70 const String& class_name = 63 const String& class_name =
71 String::Handle(Class::Handle(function.Owner()).Name()); 64 String::Handle(Class::Handle(function.Owner()).Name());
72 OS::PrintErr("> Entering '%s.%s'\n", 65 OS::PrintErr("> Entering '%s.%s'\n",
73 class_name.ToCString(), function_name.ToCString()); 66 class_name.ToCString(), function_name.ToCString());
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 UNIMPLEMENTED(); 1258 UNIMPLEMENTED();
1266 } 1259 }
1267 } 1260 }
1268 } 1261 }
1269 if (interrupt_bits & Isolate::kVmStatusInterrupt) { 1262 if (interrupt_bits & Isolate::kVmStatusInterrupt) {
1270 Dart_IsolateInterruptCallback callback = isolate->VmStatsCallback(); 1263 Dart_IsolateInterruptCallback callback = isolate->VmStatsCallback();
1271 if (callback) { 1264 if (callback) {
1272 (*callback)(); 1265 (*callback)();
1273 } 1266 }
1274 } 1267 }
1275
1276 if (FLAG_use_osr && (interrupt_bits == 0)) {
1277 DartFrameIterator iterator;
1278 StackFrame* frame = iterator.NextFrame();
1279 const Function& function = Function::Handle(frame->LookupDartFunction());
1280 ASSERT(!function.IsNull());
1281 if (!function.is_optimizable()) return;
1282 intptr_t osr_id =
1283 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc());
1284 if (FLAG_trace_osr) {
1285 OS::Print("Attempting OSR for %s at id=%"Pd"\n",
1286 function.ToFullyQualifiedCString(),
1287 osr_id);
1288 }
1289
1290 const Error& error =
1291 Error::Handle(Compiler::CompileOptimizedFunction(function, osr_id));
1292 if (!error.IsNull()) Exceptions::PropagateError(error);
1293
1294 const Code& optimized_code = Code::Handle(function.CurrentCode());
1295 // The current code will not be optimized in the case that the compiler
1296 // bailed out (not an error) during OSR compilation.
1297 if (optimized_code.is_optimized()) {
1298 // The OSR code does not work for calling the function, so restore the
1299 // unoptimized code. Patch the stack frame to return into the OSR
1300 // code.
1301 intptr_t optimized_entry =
1302 Instructions::Handle(optimized_code.instructions()).EntryPoint();
1303 function.SetCode(Code::Handle(function.unoptimized_code()));
1304 frame->set_pc(optimized_entry);
1305 }
1306 }
1307 } 1268 }
1308 1269
1309 1270
1310 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) { 1271 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) {
1311 ASSERT(arguments.ArgCount() == 1272 ASSERT(arguments.ArgCount() ==
1312 kTraceICCallRuntimeEntry.argument_count()); 1273 kTraceICCallRuntimeEntry.argument_count());
1313 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0)); 1274 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0));
1314 const Function& function = Function::CheckedHandle(arguments.ArgAt(1)); 1275 const Function& function = Function::CheckedHandle(arguments.ArgAt(1));
1315 DartFrameIterator iterator; 1276 DartFrameIterator iterator;
1316 StackFrame* frame = iterator.NextFrame(); 1277 StackFrame* frame = iterator.NextFrame();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 return; 1321 return;
1361 } 1322 }
1362 if (function.is_optimizable()) { 1323 if (function.is_optimizable()) {
1363 const Error& error = 1324 const Error& error =
1364 Error::Handle(Compiler::CompileOptimizedFunction(function)); 1325 Error::Handle(Compiler::CompileOptimizedFunction(function));
1365 if (!error.IsNull()) { 1326 if (!error.IsNull()) {
1366 Exceptions::PropagateError(error); 1327 Exceptions::PropagateError(error);
1367 } 1328 }
1368 const Code& optimized_code = Code::Handle(function.CurrentCode()); 1329 const Code& optimized_code = Code::Handle(function.CurrentCode());
1369 ASSERT(!optimized_code.IsNull()); 1330 ASSERT(!optimized_code.IsNull());
1370 // Reset usage counter for reoptimization. 1331 // Set usage counter for reoptimization.
1371 function.set_usage_counter(0); 1332 function.set_usage_counter(
1333 function.usage_counter() - FLAG_reoptimization_counter_threshold);
1372 } else { 1334 } else {
1373 if (FLAG_trace_failed_optimization_attempts) { 1335 if (FLAG_trace_failed_optimization_attempts) {
1374 OS::PrintErr("Not Optimizable: %s\n", function.ToFullyQualifiedCString()); 1336 OS::PrintErr("Not Optimizable: %s\n", function.ToFullyQualifiedCString());
1375 } 1337 }
1376 // TODO(5442338): Abort as this should not happen. 1338 // TODO(5442338): Abort as this should not happen.
1377 function.set_usage_counter(kLowInvocationCount); 1339 function.set_usage_counter(kLowInvocationCount);
1378 } 1340 }
1379 arguments.SetReturn(Code::Handle(function.CurrentCode())); 1341 arguments.SetReturn(Code::Handle(function.CurrentCode()));
1380 } 1342 }
1381 1343
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 // Arg1: Value that is being stored. 1761 // Arg1: Value that is being stored.
1800 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1762 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1801 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1763 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1802 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1764 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1803 const Object& value = Object::Handle(arguments.ArgAt(1)); 1765 const Object& value = Object::Handle(arguments.ArgAt(1));
1804 1766
1805 field.UpdateCid(value.GetClassId()); 1767 field.UpdateCid(value.GetClassId());
1806 } 1768 }
1807 1769
1808 } // namespace dart 1770 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698