diff options
Diffstat (limited to 'deps/v8/src/runtime/runtime-debug.cc')
-rw-r--r-- | deps/v8/src/runtime/runtime-debug.cc | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc index 4381fa6dcf..98aa3b98e7 100644 --- a/deps/v8/src/runtime/runtime-debug.cc +++ b/deps/v8/src/runtime/runtime-debug.cc @@ -6,6 +6,7 @@ #include "src/arguments-inl.h" #include "src/compiler.h" +#include "src/counters.h" #include "src/debug/debug-coverage.h" #include "src/debug/debug-evaluate.h" #include "src/debug/debug-frames.h" @@ -19,6 +20,7 @@ #include "src/interpreter/interpreter.h" #include "src/isolate-inl.h" #include "src/objects/debug-objects-inl.h" +#include "src/objects/heap-object-inl.h" #include "src/objects/js-collection-inl.h" #include "src/objects/js-generator-inl.h" #include "src/objects/js-promise-inl.h" @@ -39,6 +41,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) { DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); HandleScope scope(isolate); + // Return value can be changed by debugger. Last set value will be used as // return value. ReturnValueScope result_scope(isolate->debug()); @@ -51,12 +54,19 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) { handle(it.frame()->function(), isolate)); } + // If we are dropping frames, there is no need to get a return value or + // bytecode, since we will be restarting execution at a different frame. + if (isolate->debug()->will_restart()) { + return MakePair(ReadOnlyRoots(isolate).undefined_value(), + Smi::FromInt(static_cast<uint8_t>(Bytecode::kIllegal))); + } + // Return the handler from the original bytecode array. DCHECK(it.frame()->is_interpreted()); InterpretedFrame* interpreted_frame = reinterpret_cast<InterpretedFrame*>(it.frame()); - SharedFunctionInfo* shared = interpreted_frame->function()->shared(); - BytecodeArray* bytecode_array = shared->GetBytecodeArray(); + SharedFunctionInfo shared = interpreted_frame->function()->shared(); + BytecodeArray bytecode_array = shared->GetBytecodeArray(); int bytecode_offset = interpreted_frame->GetBytecodeOffset(); Bytecode bytecode = Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); @@ -80,14 +90,13 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) { // We need to deserialize now to ensure we don't hit the debug break again // after deserializing. OperandScale operand_scale = OperandScale::kSingle; - isolate->interpreter()->GetAndMaybeDeserializeBytecodeHandler(bytecode, - operand_scale); + isolate->interpreter()->GetBytecodeHandler(bytecode, operand_scale); if (side_effect_check_failed) { return MakePair(ReadOnlyRoots(isolate).exception(), Smi::FromInt(static_cast<uint8_t>(bytecode))); } - Object* interrupt_object = isolate->stack_guard()->HandleInterrupts(); + Object interrupt_object = isolate->stack_guard()->HandleInterrupts(); if (interrupt_object->IsException(isolate)) { return MakePair(interrupt_object, Smi::FromInt(static_cast<uint8_t>(bytecode))); @@ -479,7 +488,7 @@ int ScriptLinePosition(Handle<Script> script, int line) { Script::InitLineEnds(script); - FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); + FixedArray line_ends_array = FixedArray::cast(script->line_ends()); const int line_count = line_ends_array->length(); DCHECK_LT(0, line_count); @@ -566,8 +575,8 @@ Handle<Object> ScriptLocationFromLine(Isolate* isolate, Handle<Script> script, // Slow traversal over all scripts on the heap. bool GetScriptById(Isolate* isolate, int needle, Handle<Script>* result) { Script::Iterator iterator(isolate); - Script* script = nullptr; - while ((script = iterator.Next()) != nullptr) { + for (Script script = iterator.Next(); !script.is_null(); + script = iterator.Next()) { if (script->id() == needle) { *result = handle(script, isolate); return true; @@ -737,20 +746,22 @@ RUNTIME_FUNCTION(Runtime_IncBlockCounter) { // coverage collection mode, which triggers deletion of all coverage infos in // order to avoid memory leaks. - SharedFunctionInfo* shared = function->shared(); + SharedFunctionInfo shared = function->shared(); if (shared->HasCoverageInfo()) { - CoverageInfo* coverage_info = shared->GetCoverageInfo(); + CoverageInfo coverage_info = shared->GetCoverageInfo(); coverage_info->IncrementBlockCount(coverage_array_slot_index); } return ReadOnlyRoots(isolate).undefined_value(); } -RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) { +RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionEntered) { DCHECK_EQ(1, args.length()); HandleScope scope(isolate); CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); - isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionSuspended); + isolate->RunPromiseHook(PromiseHookType::kInit, promise, + isolate->factory()->undefined_value()); + if (isolate->debug()->is_active()) isolate->PushPromise(promise); return ReadOnlyRoots(isolate).undefined_value(); } @@ -764,6 +775,14 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) { isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionFinished); } + return *promise; +} + +RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) { + DCHECK_EQ(1, args.length()); + HandleScope scope(isolate); + CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); + isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionSuspended); return ReadOnlyRoots(isolate).undefined_value(); } |