| OLD | NEW |
| 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 Instance::Handle(isolate->object_store()->stack_overflow()); | 1235 Instance::Handle(isolate->object_store()->stack_overflow()); |
| 1236 Exceptions::Throw(thread, exception); | 1236 Exceptions::Throw(thread, exception); |
| 1237 UNREACHABLE(); | 1237 UNREACHABLE(); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 // The following code is used to stress test deoptimization and | 1240 // The following code is used to stress test deoptimization and |
| 1241 // debugger stack tracing. | 1241 // debugger stack tracing. |
| 1242 bool do_deopt = false; | 1242 bool do_deopt = false; |
| 1243 bool do_stacktrace = false; | 1243 bool do_stacktrace = false; |
| 1244 bool do_reload = false; | 1244 bool do_reload = false; |
| 1245 const intptr_t isolate_reload_every = |
| 1246 isolate->reload_every_n_stack_overflow_checks(); |
| 1245 if ((FLAG_deoptimize_every > 0) || | 1247 if ((FLAG_deoptimize_every > 0) || |
| 1246 (FLAG_stacktrace_every > 0) || | 1248 (FLAG_stacktrace_every > 0) || |
| 1247 (FLAG_reload_every > 0)) { | 1249 (isolate_reload_every > 0)) { |
| 1248 // TODO(turnidge): To make --deoptimize_every and | 1250 // TODO(turnidge): To make --deoptimize_every and |
| 1249 // --stacktrace-every faster we could move this increment/test to | 1251 // --stacktrace-every faster we could move this increment/test to |
| 1250 // the generated code. | 1252 // the generated code. |
| 1251 int32_t count = thread->IncrementAndGetStackOverflowCount(); | 1253 int32_t count = thread->IncrementAndGetStackOverflowCount(); |
| 1252 if (FLAG_deoptimize_every > 0 && | 1254 if (FLAG_deoptimize_every > 0 && |
| 1253 (count % FLAG_deoptimize_every) == 0) { | 1255 (count % FLAG_deoptimize_every) == 0) { |
| 1254 do_deopt = true; | 1256 do_deopt = true; |
| 1255 } | 1257 } |
| 1256 if (FLAG_stacktrace_every > 0 && | 1258 if (FLAG_stacktrace_every > 0 && |
| 1257 (count % FLAG_stacktrace_every) == 0) { | 1259 (count % FLAG_stacktrace_every) == 0) { |
| 1258 do_stacktrace = true; | 1260 do_stacktrace = true; |
| 1259 } | 1261 } |
| 1260 if ((FLAG_reload_every > 0) && | 1262 if ((isolate_reload_every > 0) && |
| 1261 (count % FLAG_reload_every) == 0) { | 1263 (count % isolate_reload_every) == 0) { |
| 1262 do_reload = isolate->CanReload(); | 1264 do_reload = isolate->CanReload(); |
| 1263 } | 1265 } |
| 1264 } | 1266 } |
| 1265 if ((FLAG_deoptimize_filter != NULL) || | 1267 if ((FLAG_deoptimize_filter != NULL) || |
| 1266 (FLAG_stacktrace_filter != NULL) || | 1268 (FLAG_stacktrace_filter != NULL) || |
| 1267 FLAG_reload_every_optimized) { | 1269 FLAG_reload_every_optimized) { |
| 1268 DartFrameIterator iterator; | 1270 DartFrameIterator iterator; |
| 1269 StackFrame* frame = iterator.NextFrame(); | 1271 StackFrame* frame = iterator.NextFrame(); |
| 1270 ASSERT(frame != NULL); | 1272 ASSERT(frame != NULL); |
| 1271 const Code& code = Code::Handle(frame->LookupDartCode()); | 1273 const Code& code = Code::Handle(frame->LookupDartCode()); |
| 1272 ASSERT(!code.IsNull()); | 1274 ASSERT(!code.IsNull()); |
| 1273 const Function& function = Function::Handle(code.function()); | 1275 const Function& function = Function::Handle(code.function()); |
| 1274 ASSERT(!function.IsNull()); | 1276 ASSERT(!function.IsNull()); |
| 1275 const char* function_name = function.ToFullyQualifiedCString(); | 1277 const char* function_name = function.ToFullyQualifiedCString(); |
| 1276 ASSERT(function_name != NULL); | 1278 ASSERT(function_name != NULL); |
| 1277 if (!code.is_optimized() && FLAG_reload_every_optimized) { | 1279 if (!code.is_optimized() && FLAG_reload_every_optimized) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1290 OS::PrintErr("*** Computing stacktrace (%s)\n", | 1292 OS::PrintErr("*** Computing stacktrace (%s)\n", |
| 1291 function.ToFullyQualifiedCString()); | 1293 function.ToFullyQualifiedCString()); |
| 1292 do_stacktrace = true; | 1294 do_stacktrace = true; |
| 1293 } | 1295 } |
| 1294 } | 1296 } |
| 1295 if (do_deopt) { | 1297 if (do_deopt) { |
| 1296 // TODO(turnidge): Consider using DeoptimizeAt instead. | 1298 // TODO(turnidge): Consider using DeoptimizeAt instead. |
| 1297 DeoptimizeFunctionsOnStack(); | 1299 DeoptimizeFunctionsOnStack(); |
| 1298 } | 1300 } |
| 1299 if (do_reload) { | 1301 if (do_reload) { |
| 1300 if (FLAG_reload_every_back_off) { | 1302 // Maybe adjust the rate of future reloads. |
| 1301 FLAG_reload_every *= 2; | 1303 isolate->MaybeIncreaseReloadEveryNStackOverflowChecks(); |
| 1302 } | 1304 // Issue a reload. |
| 1303 NOT_IN_PRODUCT(isolate->ReloadSources();) | 1305 NOT_IN_PRODUCT(isolate->ReloadSources();) |
| 1304 } | 1306 } |
| 1305 if (FLAG_support_debugger && do_stacktrace) { | 1307 if (FLAG_support_debugger && do_stacktrace) { |
| 1306 String& var_name = String::Handle(); | 1308 String& var_name = String::Handle(); |
| 1307 Instance& var_value = Instance::Handle(); | 1309 Instance& var_value = Instance::Handle(); |
| 1308 // Collecting the stack trace and accessing local variables | 1310 // Collecting the stack trace and accessing local variables |
| 1309 // of frames may trigger parsing of functions to compute | 1311 // of frames may trigger parsing of functions to compute |
| 1310 // variable descriptors of functions. Parsing may trigger | 1312 // variable descriptors of functions. Parsing may trigger |
| 1311 // code execution, e.g. to compute compile-time constants. Thus, | 1313 // code execution, e.g. to compute compile-time constants. Thus, |
| 1312 // disable FLAG_stacktrace_every during trace collection to prevent | 1314 // disable FLAG_stacktrace_every during trace collection to prevent |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1892 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
| 1891 const TypedData& new_data = | 1893 const TypedData& new_data = |
| 1892 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1894 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
| 1893 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1895 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
| 1894 typed_data_cell.SetAt(0, new_data); | 1896 typed_data_cell.SetAt(0, new_data); |
| 1895 arguments.SetReturn(new_data); | 1897 arguments.SetReturn(new_data); |
| 1896 } | 1898 } |
| 1897 | 1899 |
| 1898 | 1900 |
| 1899 } // namespace dart | 1901 } // namespace dart |
| OLD | NEW |