On Tue, May 18, 2021 at 3:03 AM Sam Cao <sjtucao...@gmail.com> wrote: > > Hi Camillo, > > Thank you for the quick response. I failed to find any public API that could > meet my need, so I had to use the internal one. > > The requirement I got is: To tell whether a function is a user defined JS > function or not. > > However, I failed to find any API in v8::Function could tell that. The only > possible one is ToString() which usually returns [native code]. But, > ToString() can be easily polyfilled to avoid the detection. I had to turn to > v8::internal for the solution and found > SharedFunctionInfo::IsUserJavaScript() is a reliable source. When I was > testing v9.0, this API core dumped and I had to use that workaround. Hope > this makes sense. > > Thank you, > Sam
There's a v8::Function::FunctionProtoToString() method for exactly that reason. :-) A solution I've used in the past is to remember the script ids of user scripts, then compare v8::Function::ScriptId() against them. -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAHQurc_jkQ%2BmvGszeQF81e0LK1Q-EvEnaM_wwe8xHnOeWw0zKg%40mail.gmail.com.