02:19
<jmdyck>
Does anyone know why ScriptEvaluation asserts that the execution context stack (on exit and presumably entry) isn't empty?
02:20
<jmdyck>
I can understand why HTML might want it to be the case, but that's HTML's problem.
02:21
<jmdyck>
Why does EcmaScript care whether it's empty or not?
02:35
<bakkot>
I would guess it is just there as a consistency check: every time a context is added, it is later removed
02:37
<snek>
i think the spec assumes you have an outer execution context that is kept with the realm
02:37
<snek>
but
02:37
<snek>
i don't think its really necessary
02:38
<jmdyck>
@bakkot: Hm, asserting non-empty on exit isn't a very good way to achieve that consistency check.
02:39
<snek>
we already have that consistency check built into the stack operation itself
02:40
<snek>

Suspend scriptContext and remove it from the execution context stack.

presumably if this is a stack, there's only one thing you can remove

02:41
<jmdyck>
I don't think there was a suggestion of ambiguity as to what to remove
02:42
<jmdyck>
It would be useful to assert, e.g. that ScriptEvaluation leaves the EC stack the way it found it.
02:43
<snek>
idk if it would be more useful than any other op that modifies the stack
02:43
<snek>
(which is not to say it wouldn't be useful)
02:44
<jmdyck>
Some stack-manipulating AOs do this by grabbing the running execution context before pushing, then after popping, saying that the pop restores the former running EC.
02:44
<jmdyck>
But that's not what ScriptEvaluation does.
02:45
<jmdyck>
Merely asserting a non-empty stack on exit doesn't achieve that at all.
02:46
<snek>
can i just say how much i love that SS and RS are grouped together now
02:47
<snek>
i think "Resume the context that is now on the top of the execution context stack as the running execution context." is pretty standard
02:47
<snek>
the assertion is not though
02:50
<jmdyck>
There are 7 occurrences of "Remove X from the EC stack and restore Y as the running EC."
02:51
<snek>
"restore" 🤔
02:53
<jmdyck>
(Actually, they're all literally Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.)
02:57
<jmdyck>
There's 3 occurrences of Resume the context that is now on the top of the execution context stack as the running execution context.
02:59
<snek>
yeah
03:00
<snek>
do we ever define what it means to suspend and resume contexts
03:00
<snek>
"restore" aside
03:01
<jmdyck>
We don't.
03:03
<jmdyck>
But see https://github.com/tc39/ecma262/pull/2962, which gets rid of "suspend" and "resume" as applied to ECs.
03:04
<jmdyck>
(Also, its first commit gets rid of "restore".)