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

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

Issue 1344993002: Refactor isolate interrupts to use OOB messages instead of interrupt bits. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 706
707 707
708 // Gets called from debug stub when code reaches a breakpoint 708 // Gets called from debug stub when code reaches a breakpoint
709 // set on a runtime stub call. 709 // set on a runtime stub call.
710 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { 710 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) {
711 DartFrameIterator iterator; 711 DartFrameIterator iterator;
712 StackFrame* caller_frame = iterator.NextFrame(); 712 StackFrame* caller_frame = iterator.NextFrame();
713 ASSERT(caller_frame != NULL); 713 ASSERT(caller_frame != NULL);
714 uword orig_stub = 714 uword orig_stub =
715 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc()); 715 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc());
716 isolate->debugger()->SignalBpReached(); 716 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached());
717 if (!error.IsNull()) {
718 Exceptions::PropagateError(error);
719 UNREACHABLE();
720 }
717 ASSERT((orig_stub & kSmiTagMask) == kSmiTag); 721 ASSERT((orig_stub & kSmiTagMask) == kSmiTag);
718 arguments.SetReturn(Smi::Handle(reinterpret_cast<RawSmi*>(orig_stub))); 722 arguments.SetReturn(Smi::Handle(reinterpret_cast<RawSmi*>(orig_stub)));
719 } 723 }
720 724
721 725
722 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { 726 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) {
723 isolate->debugger()->DebuggerStepCallback(); 727 const Error& error =
728 Error::Handle(isolate->debugger()->DebuggerStepCallback());
729 if (!error.IsNull()) {
730 Exceptions::PropagateError(error);
731 UNREACHABLE();
732 }
724 } 733 }
725 734
726 735
727 // An instance call of the form o.f(...) could not be resolved. Check if 736 // An instance call of the form o.f(...) could not be resolved. Check if
728 // there is a getter with the same name. If so, invoke it. If the value is 737 // there is a getter with the same name. If so, invoke it. If the value is
729 // a closure, invoke it with the given arguments. If the value is a 738 // a closure, invoke it with the given arguments. If the value is a
730 // non-closure, attempt to invoke "call" on it. 739 // non-closure, attempt to invoke "call" on it.
731 static bool ResolveCallThroughGetter(const Instance& receiver, 740 static bool ResolveCallThroughGetter(const Instance& receiver,
732 const Class& receiver_class, 741 const Class& receiver_class,
733 const String& target_name, 742 const String& target_name,
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 // Variable locations and number are unknown when 'always_optimize'. 1354 // Variable locations and number are unknown when 'always_optimize'.
1346 const int num_vars = 1355 const int num_vars =
1347 Compiler::always_optimize() ? 0 : frame->NumLocalVariables(); 1356 Compiler::always_optimize() ? 0 : frame->NumLocalVariables();
1348 intptr_t unused; 1357 intptr_t unused;
1349 for (intptr_t v = 0; v < num_vars; v++) { 1358 for (intptr_t v = 0; v < num_vars; v++) {
1350 frame->VariableAt(v, &var_name, &unused, &unused, &var_value); 1359 frame->VariableAt(v, &var_name, &unused, &unused, &var_value);
1351 } 1360 }
1352 } 1361 }
1353 } 1362 }
1354 1363
1355 uword interrupt_bits = isolate->GetAndClearInterrupts(); 1364 const Error& error = Error::Handle(isolate->HandleInterrupts());
1356 if ((interrupt_bits & Isolate::kVMInterrupt) != 0) { 1365 if (!error.IsNull()) {
1357 isolate->thread_registry()->CheckSafepoint(); 1366 Exceptions::PropagateError(error);
1358 if (isolate->store_buffer()->Overflowed()) { 1367 UNREACHABLE();
1359 if (FLAG_verbose_gc) {
1360 OS::PrintErr("Scavenge scheduled by store buffer overflow.\n");
1361 }
1362 isolate->heap()->CollectGarbage(Heap::kNew);
1363 }
1364 }
1365 if ((interrupt_bits & Isolate::kMessageInterrupt) != 0) {
1366 bool ok = isolate->message_handler()->HandleOOBMessages();
1367 if (!ok) {
1368 // False result from HandleOOBMessages signals that the isolate should
1369 // be terminating.
1370 const String& msg = String::Handle(String::New("isolate terminated"));
1371 const UnwindError& error = UnwindError::Handle(UnwindError::New(msg));
1372 Exceptions::PropagateError(error);
1373 UNREACHABLE();
1374 }
1375 }
1376 if ((interrupt_bits & Isolate::kApiInterrupt) != 0) {
1377 // Signal isolate interrupt event.
1378 Debugger::SignalIsolateInterrupted();
1379
1380 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback();
1381 if (callback != NULL) {
1382 if ((*callback)()) {
1383 return;
1384 } else {
1385 // TODO(turnidge): Unwind the stack.
1386 UNIMPLEMENTED();
1387 }
1388 }
1389 } 1368 }
1390 1369
1391 if ((stack_overflow_flags & Isolate::kOsrRequest) != 0) { 1370 if ((stack_overflow_flags & Isolate::kOsrRequest) != 0) {
1392 ASSERT(FLAG_use_osr); 1371 ASSERT(FLAG_use_osr);
1393 DartFrameIterator iterator; 1372 DartFrameIterator iterator;
1394 StackFrame* frame = iterator.NextFrame(); 1373 StackFrame* frame = iterator.NextFrame();
1395 ASSERT(frame != NULL); 1374 ASSERT(frame != NULL);
1396 const Code& code = Code::ZoneHandle(frame->LookupDartCode()); 1375 const Code& code = Code::ZoneHandle(frame->LookupDartCode());
1397 ASSERT(!code.IsNull()); 1376 ASSERT(!code.IsNull());
1398 const Function& function = Function::Handle(code.function()); 1377 const Function& function = Function::Handle(code.function());
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 const intptr_t elm_size = old_data.ElementSizeInBytes(); 1834 const intptr_t elm_size = old_data.ElementSizeInBytes();
1856 const TypedData& new_data = 1835 const TypedData& new_data =
1857 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 1836 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
1858 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 1837 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
1859 typed_data_cell.SetAt(0, new_data); 1838 typed_data_cell.SetAt(0, new_data);
1860 arguments.SetReturn(new_data); 1839 arguments.SetReturn(new_data);
1861 } 1840 }
1862 1841
1863 1842
1864 } // namespace dart 1843 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698