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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 return false; | 1255 return false; |
1256 } | 1256 } |
1257 return true; | 1257 return true; |
1258 } | 1258 } |
1259 | 1259 |
1260 | 1260 |
1261 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { | 1261 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { |
1262 #if defined(USING_SIMULATOR) | 1262 #if defined(USING_SIMULATOR) |
1263 uword stack_pos = Simulator::Current()->get_register(SPREG); | 1263 uword stack_pos = Simulator::Current()->get_register(SPREG); |
1264 #else | 1264 #else |
1265 uword stack_pos = Isolate::GetCurrentStackPointer(); | 1265 uword stack_pos = Thread::GetCurrentStackPointer(); |
1266 #endif | 1266 #endif |
1267 // Always clear the stack overflow flags. They are meant for this | 1267 // Always clear the stack overflow flags. They are meant for this |
1268 // particular stack overflow runtime call and are not meant to | 1268 // particular stack overflow runtime call and are not meant to |
1269 // persist. | 1269 // persist. |
1270 uword stack_overflow_flags = isolate->GetAndClearStackOverflowFlags(); | 1270 uword stack_overflow_flags = thread->GetAndClearStackOverflowFlags(); |
1271 | 1271 |
1272 // If an interrupt happens at the same time as a stack overflow, we | 1272 // If an interrupt happens at the same time as a stack overflow, we |
1273 // process the stack overflow now and leave the interrupt for next | 1273 // process the stack overflow now and leave the interrupt for next |
1274 // time. | 1274 // time. |
1275 if (stack_pos < isolate->saved_stack_limit()) { | 1275 if (stack_pos < thread->saved_stack_limit()) { |
1276 // Use the preallocated stack overflow exception to avoid calling | 1276 // Use the preallocated stack overflow exception to avoid calling |
1277 // into dart code. | 1277 // into dart code. |
1278 const Instance& exception = | 1278 const Instance& exception = |
1279 Instance::Handle(isolate->object_store()->stack_overflow()); | 1279 Instance::Handle(isolate->object_store()->stack_overflow()); |
1280 Exceptions::Throw(thread, exception); | 1280 Exceptions::Throw(thread, exception); |
1281 UNREACHABLE(); | 1281 UNREACHABLE(); |
1282 } | 1282 } |
1283 | 1283 |
1284 // The following code is used to stress test deoptimization and | 1284 // The following code is used to stress test deoptimization and |
1285 // debugger stack tracing. | 1285 // debugger stack tracing. |
1286 bool do_deopt = false; | 1286 bool do_deopt = false; |
1287 bool do_stacktrace = false; | 1287 bool do_stacktrace = false; |
1288 if ((FLAG_deoptimize_every > 0) || (FLAG_stacktrace_every > 0)) { | 1288 if ((FLAG_deoptimize_every > 0) || (FLAG_stacktrace_every > 0)) { |
1289 // TODO(turnidge): To make --deoptimize_every and | 1289 // TODO(turnidge): To make --deoptimize_every and |
1290 // --stacktrace-every faster we could move this increment/test to | 1290 // --stacktrace-every faster we could move this increment/test to |
1291 // the generated code. | 1291 // the generated code. |
1292 int32_t count = isolate->IncrementAndGetStackOverflowCount(); | 1292 int32_t count = thread->IncrementAndGetStackOverflowCount(); |
1293 if (FLAG_deoptimize_every > 0 && | 1293 if (FLAG_deoptimize_every > 0 && |
1294 (count % FLAG_deoptimize_every) == 0) { | 1294 (count % FLAG_deoptimize_every) == 0) { |
1295 do_deopt = true; | 1295 do_deopt = true; |
1296 } | 1296 } |
1297 if (FLAG_stacktrace_every > 0 && | 1297 if (FLAG_stacktrace_every > 0 && |
1298 (count % FLAG_stacktrace_every) == 0) { | 1298 (count % FLAG_stacktrace_every) == 0) { |
1299 do_stacktrace = true; | 1299 do_stacktrace = true; |
1300 } | 1300 } |
1301 } | 1301 } |
1302 if ((FLAG_deoptimize_filter != NULL) || (FLAG_stacktrace_filter != NULL)) { | 1302 if ((FLAG_deoptimize_filter != NULL) || (FLAG_stacktrace_filter != NULL)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 // Variable locations and number are unknown when precompiling. | 1337 // Variable locations and number are unknown when precompiling. |
1338 const int num_vars = | 1338 const int num_vars = |
1339 FLAG_precompiled_runtime ? 0 : frame->NumLocalVariables(); | 1339 FLAG_precompiled_runtime ? 0 : frame->NumLocalVariables(); |
1340 TokenPosition unused = TokenPosition::kNoSource; | 1340 TokenPosition unused = TokenPosition::kNoSource; |
1341 for (intptr_t v = 0; v < num_vars; v++) { | 1341 for (intptr_t v = 0; v < num_vars; v++) { |
1342 frame->VariableAt(v, &var_name, &unused, &unused, &var_value); | 1342 frame->VariableAt(v, &var_name, &unused, &unused, &var_value); |
1343 } | 1343 } |
1344 } | 1344 } |
1345 } | 1345 } |
1346 | 1346 |
1347 const Error& error = Error::Handle(isolate->HandleInterrupts()); | 1347 const Error& error = Error::Handle(thread->HandleInterrupts()); |
1348 if (!error.IsNull()) { | 1348 if (!error.IsNull()) { |
1349 Exceptions::PropagateError(error); | 1349 Exceptions::PropagateError(error); |
1350 UNREACHABLE(); | 1350 UNREACHABLE(); |
1351 } | 1351 } |
1352 | 1352 |
1353 if ((stack_overflow_flags & Isolate::kOsrRequest) != 0) { | 1353 if ((stack_overflow_flags & Thread::kOsrRequest) != 0) { |
1354 ASSERT(FLAG_use_osr); | 1354 ASSERT(FLAG_use_osr); |
1355 DartFrameIterator iterator; | 1355 DartFrameIterator iterator; |
1356 StackFrame* frame = iterator.NextFrame(); | 1356 StackFrame* frame = iterator.NextFrame(); |
1357 ASSERT(frame != NULL); | 1357 ASSERT(frame != NULL); |
1358 const Code& code = Code::ZoneHandle(frame->LookupDartCode()); | 1358 const Code& code = Code::ZoneHandle(frame->LookupDartCode()); |
1359 ASSERT(!code.IsNull()); | 1359 ASSERT(!code.IsNull()); |
1360 const Function& function = Function::Handle(code.function()); | 1360 const Function& function = Function::Handle(code.function()); |
1361 ASSERT(!function.IsNull()); | 1361 ASSERT(!function.IsNull()); |
1362 // Since the code is referenced from the frame and the ZoneHandle, | 1362 // Since the code is referenced from the frame and the ZoneHandle, |
1363 // it cannot have been removed from the function. | 1363 // it cannot have been removed from the function. |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1874 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
1875 const TypedData& new_data = | 1875 const TypedData& new_data = |
1876 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1876 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
1877 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1877 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
1878 typed_data_cell.SetAt(0, new_data); | 1878 typed_data_cell.SetAt(0, new_data); |
1879 arguments.SetReturn(new_data); | 1879 arguments.SetReturn(new_data); |
1880 } | 1880 } |
1881 | 1881 |
1882 | 1882 |
1883 } // namespace dart | 1883 } // namespace dart |
OLD | NEW |