[VM interpreter] Consider scheduled interrupts when checking for stack overflow.

Minor cleanup (not a bug): do not share result slot with passed argument in runtime call.
Change-Id: Ib4565b692b03d485de75cc519b98b5ad6f2c8026
Reviewed-on: https://dart-review.googlesource.com/72548
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Régis Crelier
2018-08-31 23:10:30 +00:00
committed by commit-bot@chromium.org
parent 54dc63a5ec
commit 73d8bb13e2
2 changed files with 17 additions and 11 deletions
+14 -11
View File
@@ -1695,15 +1695,16 @@ bool Interpreter::AssertAssignable(Thread* thread,
AssertAssignableCallRuntime:
// TODO(regis): Modify AssertAssignable bytecode to expect arguments in same
// order as the TypeCheck runtime call, so this copying can be avoided.
call_top[1] = args[0]; // instance
call_top[2] = args[3]; // type
call_top[3] = args[1]; // instantiator type args
call_top[4] = args[2]; // function type args
call_top[5] = args[4]; // name
call_top[6] = cache;
call_top[7] = Smi::New(kTypeCheckFromInline);
Exit(thread, FP, call_top + 8, pc);
NativeArguments native_args(thread, 7, call_top + 1, call_top + 1);
call_top[1] = 0; // Unused result.
call_top[2] = args[0]; // Instance.
call_top[3] = args[3]; // Type.
call_top[4] = args[1]; // Instantiator type args.
call_top[5] = args[2]; // Function type args.
call_top[6] = args[4]; // Name.
call_top[7] = cache;
call_top[8] = Smi::New(kTypeCheckFromInline);
Exit(thread, FP, call_top + 9, pc);
NativeArguments native_args(thread, 7, call_top + 2, call_top + 1);
return InvokeRuntime(thread, this, DRT_TypeCheck, native_args);
}
@@ -2086,8 +2087,10 @@ RawObject* Interpreter::Call(RawFunction* function,
{
BYTECODE(CheckStack, A);
{
// Using the interpreter stack limit and not the thread stack limit.
if (reinterpret_cast<uword>(SP) >= stack_limit()) {
// Check the interpreter's own stack limit for actual interpreter's stack
// overflows, and also the thread's stack limit for scheduled interrupts.
if (reinterpret_cast<uword>(SP) >= stack_limit() ||
thread->HasScheduledInterrupts()) {
Exit(thread, FP, SP + 1, pc);
NativeArguments args(thread, 0, NULL, NULL);
INVOKE_RUNTIME(DRT_StackOverflow, args);
+3
View File
@@ -304,6 +304,9 @@ class Thread : public BaseThread {
void ScheduleInterruptsLocked(uword interrupt_bits);
RawError* HandleInterrupts();
uword GetAndClearInterrupts();
bool HasScheduledInterrupts() const {
return (stack_limit_ & kInterruptsMask) != 0;
}
// OSThread corresponding to this thread.
OSThread* os_thread() const { return os_thread_; }