Hmm. Will the context of document B be somewhere lower in the "entered contexts" stack, or just not entered at all in that case? I don't yet understand the relationship between documents and contexts. When do we enter a context? When do we need to enter a context? Why are we running a function defined in document B in the context of document A? When do we enter a context even though we're already in another context (so, to create a stack of entered contexts)?
Does that mean, that in haraken's example, V8 does enter the context for document B (and thus, it is the topmost in the context stack), but GetEntered still returns context for document A?
Alright, cool, we're getting there :) The relevant piece of new information (to me) was:> "pushing to the context stack" and "entering" are different concepts.
So the next clarifying questions:
1) What's the purpose of the context stack then? I had thought it's a stack of entered contexts, but apparently it's not.
2) What does "entering a context" mean (in addition to pushing it to the stack)?
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAED6dUBsa9BSjX%2BOyjc6%3DPVPMq4qNFCAjagrsB3iS%2BLq55KcYg%40mail.gmail.com.--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
On 19 July 2013 11:07, Marja Hölttä <ma...@chromium.org> wrote:2013/7/19 Wez <w...@chromium.org>
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
Afaik not, but I'm not 100% what you meant by this. Isn't Context only entered if you call Enter on it (or have a Context::Scope which calls it in the ctor) and that's the only way to enter a context?I meant this in terms of what "entered" and "current" mean conceptually, regardless of exactly how entering a scope is actually implemented - IIUC the embedder is expected to always Enter() a context before calling into V8.
My summary of this, based on this thread:
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
- The "current" context is that in which the executing V8 code was defined.
- If you're executing C++ then that's the context of the V8 function that called you.
Adam
Adam
On Fri, Jul 19, 2013 at 11:40 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 14:08, Adam Barth <aba...@chromium.org> wrote:On Fri, Jul 19, 2013 at 9:15 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 11:07, Marja Hölttä <ma...@chromium.org> wrote:2013/7/19 Wez <w...@chromium.org>
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
Afaik not, but I'm not 100% what you meant by this. Isn't Context only entered if you call Enter on it (or have a Context::Scope which calls it in the ctor) and that's the only way to enter a context?I meant this in terms of what "entered" and "current" mean conceptually, regardless of exactly how entering a scope is actually implemented - IIUC the embedder is expected to always Enter() a context before calling into V8.That's not the case. The embedder is only required to have called Enter() more times than Exit() when calling into V8.Oh, interesting. I think the thing I'm missing is what the Entered context is actually useful for.We use the Entered context to implement the concept of the "entry script" from the HTML Standard:We use the Current context to implement the concept of the "incumbent script":You can look at what references each of these definition to get a sense for how each concept is useful for.
On 19 July 2013 14:55, Adam Barth <aba...@chromium.org> wrote:On Fri, Jul 19, 2013 at 11:40 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 14:08, Adam Barth <aba...@chromium.org> wrote:On Fri, Jul 19, 2013 at 9:15 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 11:07, Marja Hölttä <ma...@chromium.org> wrote:2013/7/19 Wez <w...@chromium.org>
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
Afaik not, but I'm not 100% what you meant by this. Isn't Context only entered if you call Enter on it (or have a Context::Scope which calls it in the ctor) and that's the only way to enter a context?I meant this in terms of what "entered" and "current" mean conceptually, regardless of exactly how entering a scope is actually implemented - IIUC the embedder is expected to always Enter() a context before calling into V8.That's not the case. The embedder is only required to have called Enter() more times than Exit() when calling into V8.Oh, interesting. I think the thing I'm missing is what the Entered context is actually useful for.We use the Entered context to implement the concept of the "entry script" from the HTML Standard:We use the Current context to implement the concept of the "incumbent script":You can look at what references each of these definition to get a sense for how each concept is useful for.Aha. Perhaps the GetEntered and GetCurrent API comments should refer to these definitions.
On Fri, Jul 19, 2013 at 11:58 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 14:55, Adam Barth <aba...@chromium.org> wrote:On Fri, Jul 19, 2013 at 11:40 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 14:08, Adam Barth <aba...@chromium.org> wrote:On Fri, Jul 19, 2013 at 9:15 AM, Wez <w...@chromium.org> wrote:On 19 July 2013 11:07, Marja Hölttä <ma...@chromium.org> wrote:2013/7/19 Wez <w...@chromium.org>
- A V8 context is "entered" whenever control passes from C++ into V8, end exited when control returns.
Afaik not, but I'm not 100% what you meant by this. Isn't Context only entered if you call Enter on it (or have a Context::Scope which calls it in the ctor) and that's the only way to enter a context?I meant this in terms of what "entered" and "current" mean conceptually, regardless of exactly how entering a scope is actually implemented - IIUC the embedder is expected to always Enter() a context before calling into V8.That's not the case. The embedder is only required to have called Enter() more times than Exit() when calling into V8.Oh, interesting. I think the thing I'm missing is what the Entered context is actually useful for.We use the Entered context to implement the concept of the "entry script" from the HTML Standard:We use the Current context to implement the concept of the "incumbent script":You can look at what references each of these definition to get a sense for how each concept is useful for.Aha. Perhaps the GetEntered and GetCurrent API comments should refer to these definitions.That's a great idea. Would you be willing to write that CL?
For historical context, these APIs predate the HTML Standard nailing down these concepts. Life used to be much... fuzzier. At some point, I tried to align the terminology in the bindings with the terminology in the HTML Standard, but the spec's terminology has changed since them (much for the better). We might want to update the terminology in the implementation to match the spec again.
I'm happy to add the information if you're willing to give me write access to the doc. :)