I'm working on a research project that adds instrumentation code to Blink 
and V8. As part of that instrumentation, I want to get the script ID of the 
currently executing script from the Isolate while the script is executing, 
and how I'm doing this is (in isolate.cc):

```
int Isolate::GetScriptId() {
JavaScriptFrameIterator it(this);

while (!it.done()) {
JavaScriptFrame* frame = it.frame();
Handle<JSFunction> function(frame->function(), this);

Object maybe_script = function->shared().script();
if (!maybe_script.IsScript()) {
  it.Advance();
  continue;
}
Script script = Script::cast(maybe_script);
return script.id();
}
}
```
Then I call this from various places in Blink code. One such place is 
`StorageArea::getItem` 
(third_party/blink/renderer/modules/storage/storage_area.cc) to record 
which script called getItem. 

This normally works fine, but for one particular script on one particular 
website, I get an empty stack (i.e. JavaScriptFrameIterator `it.done()` is 
true right after instantiation). This is the output of `PrintStack(stdout, 
Isolate::kPrintStackConcise)`:

```
==== JS stack trace =========================================

    0: ExitFrame [pc: 0x10f5993bf]
    1: StubFrame [pc: 0x10f6dbf1b]
Security context: 0x001e08333019 <String[#47]: 
https://hbr.org978B69E968F091D0A4963181648E7306>
    2: /* anonymous */(aka /* anonymous */) 
[0x1e081af4c9](this=0x001e0804030d <undefined>,0x001e08b4ee41 <Storage map 
= 0x1e082e6191>#0#)
    3: StubFrame [pc: 0x10f6d8894]
    4: StubFrame [pc: 0x10f40b328]
    5: EntryFrame [pc: 0x10f371d58]
=====================
```

I realize this is a bit involved: and relates to both Blink and V8, just 
wondering if anyone knows why this might be the case or have any tips for 
debugging. 

-- 
-- 
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/c2696729-2dcd-4aca-9ad1-fac793dc88aen%40googlegroups.com.

Reply via email to