Commit 09896454 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] fix stepping over await calls for ignition generators.

R=bmeurer@chromium.org, caitpotter88@gmail.com, neis@chromium.org
BUG=v8:5099

Review-Url: https://codereview.chromium.org/2067503002
Cr-Commit-Position: refs/heads/master@{#36964}
parent fc59eb8a
......@@ -1382,8 +1382,8 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
void Debug::RecordAsyncFunction(Handle<JSGeneratorObject> generator_object) {
if (last_step_action() <= StepOut) return;
if (!generator_object->function()->shared()->is_async()) return;
DCHECK(!has_suspended_generator());
DCHECK(generator_object->function()->shared()->is_async());
thread_local_.suspended_generator_ = *generator_object;
ClearStepping();
}
......
......@@ -38,9 +38,10 @@ enum StepAction : int8_t {
StepNext = 1, // Step to the next statement in the current function.
StepIn = 2, // Step into new functions invoked or the next statement
// in the current function.
StepFrame = 3 // Step into a new frame or return to previous frame.
};
StepFrame = 3, // Step into a new frame or return to previous frame.
LastStepAction = StepFrame
};
// Type of exception break. NOTE: These values are in macros.py as well.
enum ExceptionBreakType {
......
......@@ -1792,6 +1792,17 @@ void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) {
Node* generator_reg = __ BytecodeOperandReg(0);
Node* generator = __ LoadRegister(generator_reg);
Label if_stepping(assembler, Label::kDeferred), ok(assembler);
Node* step_action_address = __ ExternalConstant(
ExternalReference::debug_last_step_action_address(isolate_));
Node* step_action = __ Load(MachineType::Int8(), step_action_address);
STATIC_ASSERT(StepIn > StepNext);
STATIC_ASSERT(StepFrame > StepNext);
STATIC_ASSERT(LastStepAction == StepFrame);
Node* step_next = __ Int32Constant(StepNext);
__ BranchIfInt32LessThanOrEqual(step_next, step_action, &if_stepping, &ok);
__ Bind(&ok);
Node* array =
__ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset);
Node* context = __ GetContext();
......@@ -1802,6 +1813,13 @@ void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) {
__ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
__ Dispatch();
__ Bind(&if_stepping);
{
Node* context = __ GetContext();
__ CallRuntime(Runtime::kDebugRecordAsyncFunction, context, generator);
__ Goto(&ok);
}
}
// ResumeGenerator <generator>
......
......@@ -1711,6 +1711,15 @@ RUNTIME_FUNCTION(Runtime_DebugPrepareStepInSuspendedGenerator) {
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugRecordAsyncFunction) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
CHECK(isolate->debug()->last_step_action() >= StepNext);
isolate->debug()->RecordAsyncFunction(generator);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
DCHECK(args.length() == 2);
HandleScope scope(isolate);
......
......@@ -53,9 +53,7 @@ RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
DCHECK(frame->function()->shared()->is_compiled());
DCHECK(!frame->function()->IsOptimized());
if (generator_object->function()->shared()->is_async()) {
isolate->debug()->RecordAsyncFunction(generator_object);
}
isolate->debug()->RecordAsyncFunction(generator_object);
// The caller should have saved the context and continuation already.
DCHECK_EQ(generator_object->context(), Context::cast(frame->context()));
......
......@@ -187,6 +187,7 @@ namespace internal {
F(ScriptSourceLine, 2, 1) \
F(DebugPrepareStepInIfStepping, 1, 1) \
F(DebugPrepareStepInSuspendedGenerator, 0, 1) \
F(DebugRecordAsyncFunction, 1, 1) \
F(DebugPushPromise, 2, 1) \
F(DebugPopPromise, 0, 1) \
F(DebugAsyncTaskEvent, 1, 1) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment