Get a callback in C++ code from v8

59 views
Skip to first unread message

Nupoor Kotasthane

unread,
Jul 17, 2019, 7:15:16 PM7/17/19
to v8-users

Hi v8 users,

 

I would like to know if there is any way through which I can get a callback from v8 before and after evaluation of every JavaScript statement. Are there any C++ hooks or callbacks or APIs that I can use? I need to get notified by v8 and on receiving these notifications I want to make some calls to the v8 inspector in the same thread.

Does anyone have any examples?

 

Thank you,

Nupoor

Yang Gao

unread,
Jul 18, 2019, 9:07:57 AM7/18/19
to v8-users
you can hook builtins with the help of Runtime function. Or you can write your own builtins. I have done something like this.

在 2019年7月18日星期四 UTC+8上午7:15:16,Nupoor Kotasthane写道:

Nupoor Kotasthane

unread,
Jul 18, 2019, 11:51:52 AM7/18/19
to v8-users
Hi Yang,

Thank you for your reply. Can you elaborate a little? I am new to v8. Do you have an example?

Yang Gao

unread,
Jul 18, 2019, 9:02:42 PM7/18/19
to v8-users
First, you need to find the builtin bytecode that responsible for executing the evaluation. How to find the builtin bytecode?  Debug the execution of V8 handly, there is Runtime_InterpreterTraceBytecodeEntry in V8 source, you can use it to debug.
After you find the builtin, call a new runtime function in the builtin. please exam the runtime.h, you will know how to construct your own runtime function. When the builtin is igniting(means the evaluation is executing), the runtime will be called. 
Can you elaborate on what you want to do? I think there must have a more suitable way for you.
在 2019年7月18日星期四 UTC+8下午11:51:52,Nupoor Kotasthane写道:
Reply all
Reply to author
Forward
0 new messages