Adding Assembly Interpreter implementation of debugger statement;

remove unreachable implementation; revise NotifyDebuggerStmt method.

Signed-off-by: huangtianzhi <huangtianzhi1@huawei.com>
This commit is contained in:
huangtianzhi 2023-06-07 17:51:06 +08:00
parent 56d0ec1ddb
commit be90d85e37
9 changed files with 48 additions and 35 deletions

View File

@ -479,6 +479,7 @@ DECLARE_ASM_HANDLER(HandleThrowDeletesuperpropertyPrefNone)
DECLARE_ASM_HANDLER(HandleDebugger) DECLARE_ASM_HANDLER(HandleDebugger)
{ {
CallRuntime(glue, RTSTUB_ID(OnDebuggerStatement), {});
DISPATCH(DEBUGGER); DISPATCH(DEBUGGER);
} }

View File

@ -846,6 +846,24 @@ void EcmaInterpreter::NotifyBytecodePcChanged(JSThread *thread)
} }
} }
void EcmaInterpreter::NotifyDebuggerStmt(JSThread *thread)
{
FrameHandler frameHandler(thread);
for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) {
if (frameHandler.IsEntryFrame()) {
continue;
}
Method *method = frameHandler.GetMethod();
if (method->IsNativeWithCallField()) {
continue;
}
auto bcOffset = frameHandler.GetBytecodeOffset();
auto *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager();
debuggerMgr->GetNotificationManager()->DebuggerStmtEvent(thread, method, bcOffset);
return;
}
}
const JSPandaFile *EcmaInterpreter::GetNativeCallPandafile(JSThread *thread) const JSPandaFile *EcmaInterpreter::GetNativeCallPandafile(JSThread *thread)
{ {
FrameHandler frameHandler(thread); FrameHandler frameHandler(thread);
@ -3673,20 +3691,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
} }
HANDLE_OPCODE(DEBUGGER) { HANDLE_OPCODE(DEBUGGER) {
LOG_INST() << "intrinsics::debugger"; LOG_INST() << "intrinsics::debugger";
FrameHandler frameHandler(thread); NotifyDebuggerStmt(thread);
for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) {
if (frameHandler.IsEntryFrame()) {
continue;
}
Method *method = frameHandler.GetMethod();
if (method->IsNativeWithCallField()) {
continue;
}
auto bcOffset = frameHandler.GetBytecodeOffset();
auto *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager();
debuggerMgr->GetNotificationManager()->DebuggerStmtEvent(thread, method, bcOffset);
return;
}
DISPATCH(DEBUGGER); DISPATCH(DEBUGGER);
} }
HANDLE_OPCODE(ISTRUE) { HANDLE_OPCODE(ISTRUE) {

View File

@ -59,6 +59,7 @@ public:
static inline JSTaggedValue GetEcmaModule(JSTaggedType *sp); static inline JSTaggedValue GetEcmaModule(JSTaggedType *sp);
static inline bool UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp, JSTaggedValue acc, int32_t offset); static inline bool UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp, JSTaggedValue acc, int32_t offset);
static inline void NotifyBytecodePcChanged(JSThread *thread); static inline void NotifyBytecodePcChanged(JSThread *thread);
static inline void NotifyDebuggerStmt(JSThread *thread);
static inline const JSPandaFile *GetNativeCallPandafile(JSThread *thread); static inline const JSPandaFile *GetNativeCallPandafile(JSThread *thread);
static inline JSTaggedValue GetCurrentEntryPoint(JSThread *thread); static inline JSTaggedValue GetCurrentEntryPoint(JSThread *thread);
static inline JSTaggedValue GetFunction(JSTaggedType *sp); static inline JSTaggedValue GetFunction(JSTaggedType *sp);

View File

@ -2896,7 +2896,6 @@ void InterpreterAssembly::HandleDebugger(
JSTaggedValue acc, int16_t hotnessCounter) JSTaggedValue acc, int16_t hotnessCounter)
{ {
LOG_INST() << "intrinsics::debugger"; LOG_INST() << "intrinsics::debugger";
SlowRuntimeStub::DebuggerStmt(thread);
DISPATCH(DEBUGGER); DISPATCH(DEBUGGER);
} }

View File

@ -1185,22 +1185,4 @@ JSTaggedValue SlowRuntimeStub::NotifyConcurrentResult(JSThread *thread, JSTagged
INTERPRETER_TRACE(thread, NotifyConcurrentResult); INTERPRETER_TRACE(thread, NotifyConcurrentResult);
return RuntimeStubs::RuntimeNotifyConcurrentResult(thread, result, hint); return RuntimeStubs::RuntimeNotifyConcurrentResult(thread, result, hint);
} }
void SlowRuntimeStub::DebuggerStmt(JSThread *thread)
{
FrameHandler frameHandler(thread);
for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) {
if (frameHandler.IsEntryFrame()) {
continue;
}
Method *method = frameHandler.GetMethod();
if (method->IsNativeWithCallField()) {
continue;
}
auto bcOffset = frameHandler.GetBytecodeOffset();
tooling::JsDebuggerManager *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager();
debuggerMgr->GetNotificationManager()->DebuggerStmtEvent(thread, method, bcOffset);
return;
}
}
} // namespace panda::ecmascript } // namespace panda::ecmascript

View File

@ -182,8 +182,6 @@ public:
static JSTaggedValue NotifyConcurrentResult(JSThread *thread, JSTaggedValue result, JSTaggedValue hint); static JSTaggedValue NotifyConcurrentResult(JSThread *thread, JSTaggedValue result, JSTaggedValue hint);
static void DebuggerStmt(JSThread *thread);
private: private:
static JSTaggedValue ThrowSyntaxError(JSThread *thread, const char *message); static JSTaggedValue ThrowSyntaxError(JSThread *thread, const char *message);
static JSTaggedValue GetCallSpreadArgs(JSThread *thread, JSTaggedValue array); static JSTaggedValue GetCallSpreadArgs(JSThread *thread, JSTaggedValue array);

View File

@ -2607,5 +2607,24 @@ JSTaggedValue RuntimeStubs::RuntimeNotifyConcurrentResult(JSThread *thread, JSTa
thread->GetEcmaVM()->TriggerConcurrentCallback(result, hint); thread->GetEcmaVM()->TriggerConcurrentCallback(result, hint);
return JSTaggedValue::Undefined(); return JSTaggedValue::Undefined();
} }
JSTaggedValue RuntimeStubs::RuntimeNotifyDebuggerStatement(JSThread *thread)
{
FrameHandler frameHandler(thread);
for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) {
if (frameHandler.IsEntryFrame() || frameHandler.IsBuiltinFrame()) {
continue;
}
Method *method = frameHandler.GetMethod();
if (method->IsNativeWithCallField()) {
continue;
}
auto bcOffset = frameHandler.GetBytecodeOffset();
auto *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager();
debuggerMgr->GetNotificationManager()->DebuggerStmtEvent(thread, method, bcOffset);
return JSTaggedValue::Hole();
}
return JSTaggedValue::Hole();
}
} // namespace panda::ecmascript } // namespace panda::ecmascript
#endif // ECMASCRIPT_STUBS_RUNTIME_STUBS_INL_H #endif // ECMASCRIPT_STUBS_RUNTIME_STUBS_INL_H

View File

@ -1508,6 +1508,12 @@ DEF_RUNTIME_STUBS(NotifyBytecodePcChanged)
return JSTaggedValue::Hole().GetRawData(); return JSTaggedValue::Hole().GetRawData();
} }
DEF_RUNTIME_STUBS(NotifyDebuggerStatement)
{
RUNTIME_STUBS_HEADER(NotifyDebuggerStatement);
return RuntimeNotifyDebuggerStatement(thread).GetRawData();
}
DEF_RUNTIME_STUBS(CreateEmptyObject) DEF_RUNTIME_STUBS(CreateEmptyObject)
{ {
RUNTIME_STUBS_HEADER(CreateEmptyObject); RUNTIME_STUBS_HEADER(CreateEmptyObject);

View File

@ -275,6 +275,7 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
V(OptGetUnmapedArgs) \ V(OptGetUnmapedArgs) \
V(OptCopyRestArgs) \ V(OptCopyRestArgs) \
V(NotifyBytecodePcChanged) \ V(NotifyBytecodePcChanged) \
V(NotifyDebuggerStatement) \
V(OptNewLexicalEnvWithName) \ V(OptNewLexicalEnvWithName) \
V(OptSuspendGenerator) \ V(OptSuspendGenerator) \
V(OptAsyncGeneratorResolve) \ V(OptAsyncGeneratorResolve) \
@ -678,6 +679,7 @@ private:
const JSHandle<JSTaggedValue> &value); const JSHandle<JSTaggedValue> &value);
static inline JSTaggedValue RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result, static inline JSTaggedValue RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result,
JSTaggedValue hint); JSTaggedValue hint);
static inline JSTaggedValue RuntimeNotifyDebuggerStatement(JSThread *thread);
friend class SlowRuntimeStub; friend class SlowRuntimeStub;
}; };
} // namespace panda::ecmascript } // namespace panda::ecmascript