Thanks for your reply. I checked the code related to *IsolateAddressId::kContextAddress*. In *src/builtins/x64/builtins-x64.cc*, it seems that the function *Generate_JSEntryTrampolineHelper* just loads the *context* but does not overwrites it. I also found that the context is overwrote in *MacroAssembler::EnterExitFramePrologue*. Is it the one I need to instrument? Or is there any misunderstanding on my part?
If i am right, are all JS function calls (including document.cookie etc) going through that function, or are they just cross-frame function calls? Thank you. 在 2019年5月27日星期一 UTC+8下午4:28:14,Ben Noordhuis写道: > > On Sat, May 25, 2019 at 11:34 AM Luo Wu <lwy...@pku.edu.cn <javascript:>> > wrote: > > > > Hi all, > > > > I want to intercept and log the context changing event in v8. > > > > Say I have a script in main.html which invokes a function foo in the > iframe.html. When the function foo is executed, the isolate->context() is > changed to represent for iframe.html. But I cannot find where the v8 sets > the corresponding context variable (isolate->set_context() is not invoked). > My purpose is to immediately know that the context is changed, and log some > information. > > > > Please tell me how can I achieve this goal. Appreciate if there is any > idea for that. > > The short answer is that you can't, at least not easily. > > The context is changed directly from the generated machine code, there > is no associated C++ function call that you can instrument. Grep > src/builtins/*/builtins-*.cc for IsolateAddressId::kContextAddress and > IsolateAddressId::kPendingHandlerContextAddress to find out how it > works. > > It's possible to augment the generated code to call out to a C++ > function but it's not exactly trivial. Grep the aforementioned files > for CallCFunction() and note how e.g. > Runtime::kUnwindAndFindExceptionHandler corresponds to > Runtime_UnwindAndFindExceptionHandler in > src/runtime/runtime-internal.cc. Good luck! > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/33251dc9-461e-44e8-a9b3-a4c9844b542f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.