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);
}
}
```
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]
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.