Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entry realm definition #2441

Closed
jensl opened this issue Mar 17, 2017 · 5 comments
Closed

Entry realm definition #2441

jensl opened this issue Mar 17, 2017 · 5 comments
Labels

Comments

@jensl
Copy link

jensl commented Mar 17, 2017

https://html.spec.whatwg.org/#entry

With this in hand, we define the entry execution context to be the most recently pushed entry in the JavaScript execution context stack whose entrance counter value is greater than zero. The entry Realm is the entry execution context's Realm component.

Is there some way that an execution context that has an entrance counter greater than zero from before can be pushed onto the JavaScript execution context stack without an "accompanying" entrance counter increment, and thus at that point become the current entry execution context without being explicitly "entered"?

I'm inclined to think that this should not happen; that entry realm changes should only happen at the points where the entrance counter is now incremented/decremented, effectively. So I think one of these things are wrong:

  1. My understanding of the definition above
  2. My understanding of how things should actually work
  3. The definition above
@domenic
Copy link
Member

domenic commented Mar 17, 2017

I'm pretty confused by this question. Maybe @bzbarsky can help interpret it. It sounds like good fodder for turning into an example though, once I figure out what it's asking.

Would you mind trying to rephrase? Perhaps something of the form "X phrase in the definition seems wrong, because Y".

@domenic domenic added clarification Standard could be clearer topic: multiple globals labels Mar 17, 2017
@bzbarsky
Copy link
Contributor

The situation @jensl is worried about is this. Say we have two realm execution contexts, A and B. We do the following operations:

  1. Push A onto the execution context stack.
  2. Increment A's entrance counter.
  3. Push B onto the execution context stack.
  4. Increment B's entrance counter.
  5. Push A onto the execution context stack.

Note us not incrementing the counter on A after step 5. At this point, per the current spec text, A is the entry execution context. But arguably it should be B.

We do in fact have one place that pushes a realm execution context on the stack without changing its entrance counter: https://html.spec.whatwg.org/#event-handler-attributes:realm-execution-context. But it just wants to change the current Realm and doesn't at all care what the entry execution context or entry Realm is, so there's no problem there.

Which raises the obvious question: do we actually need the entrance counter at all?

@domenic
Copy link
Member

domenic commented Mar 17, 2017

Thanks, that definitely helps. Hmm. So the proposal would be to use the most recent execution context that is a Realm execution context?

I was looking through #473 where we worked most of this out. It does seem like we just assumed there was some need to tag entries on the stack as being "candidates" for entry-ness, possibly because that was what Hixie specced? We then evolved to the counter idea around #473 (comment). But maybe just being a realm execution context is enough, since we push/pop those at exactly the right times...

@bzbarsky
Copy link
Contributor

I think the "entryness" was needed back when incumbents were tracked using the same stack.

@jensl
Copy link
Author

jensl commented Mar 20, 2017

Thank you both for replies and explanations.

Based on what you say, it sounds to me like the entrance counter is probably unnecessary, and that the top-most realm execution context on the stack would be the right one to use regardless.

domenic added a commit that referenced this issue Apr 3, 2017
It turns out that the "entrance counter" concept was unnecessary.
Whenever we run script, we increment it, and whenever we clean up after
running script, we decrement it. So it is always nonzero. Thus we can
simply look for whether it's a realm execution context.

Fixes #2441.
domenic added a commit that referenced this issue Apr 18, 2017
It turns out that the "entrance counter" concept was unnecessary.
Whenever we run script, we increment it, and whenever we clean up after
running script, we decrement it. So it is always nonzero. Thus we can
simply look for whether it's a realm execution context.

Fixes #2441.
inikulin pushed a commit to HTMLParseErrorWG/html that referenced this issue May 9, 2017
It turns out that the "entrance counter" concept was unnecessary.
Whenever we run script, we increment it, and whenever we clean up after
running script, we decrement it. So it is always nonzero. Thus we can
simply look for whether it's a realm execution context.

Fixes whatwg#2441.
inikulin pushed a commit to HTMLParseErrorWG/html that referenced this issue May 9, 2017
It turns out that the "entrance counter" concept was unnecessary.
Whenever we run script, we increment it, and whenever we clean up after
running script, we decrement it. So it is always nonzero. Thus we can
simply look for whether it's a realm execution context.

Fixes whatwg#2441.
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
It turns out that the "entrance counter" concept was unnecessary.
Whenever we run script, we increment it, and whenever we clean up after
running script, we decrement it. So it is always nonzero. Thus we can
simply look for whether it's a realm execution context.

Fixes whatwg#2441.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants