Open
Bug 1444103
Opened 8 years ago
Updated 1 month ago
Debugger behavior when forcing return from a generator is weird
Categories
(Core :: JavaScript: Debugger API, enhancement, P3)
Core
JavaScript: Debugger API
Tracking
()
NEW
People
(Reporter: jorendorff, Unassigned)
References
(Blocks 1 open bug)
Details
The behavior seems to be a consequence of the implementation rather than design:
1. onEnterFrame pauses on the first instruction of a generator, before the JSOP_GENERATOR instruction executes. This is already a little strange.
2. Likewise we can pause in prologue-like bytecode at the top of an async function.
3. The debugger can tell the VM to `{return:}` from onEnterFrame, before the initial JSOP_GENERATOR instruction, which causes the generator to return a non-generator-iterator value, or causes the async function to return a non-Promise.
4. But we can also step or break on instructions after the initial JSOP_GENERATOR, which we reach by calling generator.next(). Then a `{return: val}` resumption value has different behavior that is also strange: `val`'s referent is returned from .next(), and the generator is left in a state where it can't be resumed (you get "TypeError: already executing generator").
Of course we don't want it.next() to resume a frame that was not suspended at a yield point. (What would that even do? Would it push an unexpected extra value onto the operand stack? Bad idea.)
I think we should solve 1-3 by refusing to stop on those instructions, somehow. I think we should solve 4 by making `{return: x}` behave like a return-statement when the top frame is a generator frame. It should close the generator.
It would be easier to delete support for `{return:}` resumption values.
| Reporter | ||
Updated•8 years ago
|
Priority: -- → P3
Updated•5 years ago
|
Blocks: js-debugger
Updated•3 years ago
|
Severity: normal → S3
Comment 1•1 month ago
|
||
Moving bugs to Debugger API component. Use castle-terms-potato to filter out.
Component: JavaScript Engine → JavaScript: Debugger API
You need to log in
before you can comment on or make changes to this bug.
Description
•