How to extract function address from a v8::Local<v8::Function> object

31 views
Skip to first unread message

Hanyun Tao

unread,
Feb 25, 2017, 8:21:20 PM2/25/17
to v8-users
Dear all,

I'm doing research on web java-script event execution with chromium, and I'm trying to log the function address of javascript listener function.

Currently I have found the v8::Local<v8::Function> object that holds the listener function:


v8
::Local<v8::Function> handlerFunction = getListenerFunction(scriptState);


The question I have is, how could I print out the function address of the listener function, or other "ID"  that can be used to identify the java-script function?

Best regards, 

Ben Noordhuis

unread,
Feb 28, 2017, 6:02:08 AM2/28/17
to v8-users
On Sun, Feb 26, 2017 at 8:50 PM, <hy...@umich.edu> wrote:
> Thank you Ben!
>
> So I can use the GetIdentityHash() function to obtain an ID of the object.
> But will this ID be different, if I have two different handlerFunction
> object but they are trying to call the same function but with different
> arguments?
> I'm basically trying to find a way to tell if two handlerFunction contains
> the same callback function.

Is there a reason you sent this to v8-dev instead of v8-users like
your previous message? I've taken the liberty of moving v8-dev to
BCC.

To answer your question: you can use a->StrictEquals(b) or a->SameValue(b).

If you are looking for a unique value that you can use as a key in a
set or map, you're out of luck: functions have identity but not
(partial or total) ordering.

You can of course store them in a hash map and use a mix of
GetIdentityHash() and SameValue() to retrieve them in (on average)
better than linear time.
Reply all
Reply to author
Forward
0 new messages