Hi all,
  Sorry if this post disturbs you, I have some specific questions about v8 
function events but I cannot find anything on google.
  
  For some reason I want to instrument the JSFunction events (especially 
for closures), e.g., I want to instrument the creation/invocation events of 
JSFunction activities. I want to make v8 call some my own function if a 
JSFunction get allocated and accessed.
  
  The high level idea is when a JSFunction is created on heap, I will 
create a persistent handle for it and put it in a hash table (currently I 
am using unordered_set). I will also make it weak so I can instrument the 
deallocation of this JSFunction object.
  I also modified runtime function traceEnter & traceExit so I can add my 
hooks for function invocation.

  However, I do have two questions about this:
  1. The way I instrument function creation is add a hook in 
Factory::NewFunction(...). Unfortunately some closures are created through 
FastNewClosureStub which will not call the factory methods. My work around 
is to force all closure are allocated through runtime function NewClosure 
but it seems a bad idea. I guess somewhere in the FastNewClosureStub will 
also call some heap allocation procedure which created a JSFunction object 
but I cannot find it. Does anyone know where is it?

  2. I want to put the persistent handles in a hash table, but I have 
trouble find a useful hash function. I tried Local->GetIdentityHash() but 
it seems it will break my code somehow, especially when I call it in 
kTraceEnter, Here is my code:
  
RUNTIME_FUNCTION(Runtime_TraceEnter) {
    ...
    JavaScriptFrameIterator it(isolate);
    if (!it.done()) {
      if (it.frame()->is_java_script()) {
        JavaScriptFrame* frame = it.frame();
        JSFunction* function = frame->function();
        Handle<JSFunction> handle(function);
                 Local<Function> local = Utils::ToLocal(handle);
        local->GetIdentityHash(); // my program always crash is I call 
GetIdentityHash here
      }
    }
}

  Please let me know if you have any question or other concern. Thank you 
for reading my post.

Thanks,
Wenzhi Cui

-- 
-- 
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to