Open
Bug 1595986
Opened 5 years ago
Updated 6 months ago
[jsdbg2] Force return completions are a weird special case currently as neither a termination nor an exception
Categories
(Core :: JavaScript Engine, enhancement, P3)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: loganfsmyth, Unassigned)
References
(Blocks 1 open bug)
Details
I came across this while investigating https://bugzilla.mozilla.org/show_bug.cgi?id=1556033 and I wanted to file it as something as motivation to think through this. With the way things are now:
- If the debugger forces a throw, e.g. by returning something like
{ throw: "thrown string" }
, this behaves just like a traditional abrupt completion from the standpoint of JS execution which means that if the instruction is inside of a try/catch, then the exception is reachable inside thecatch
block. Similarly, it means thatfinally
blocks will execute. - It the debugger forces a return, e.g.
{ return: "returned result" }
, it is treated as if control jumped straight to the end of the function, which skipscatch/finally
blocks. This makes it an exceptionally special case, which causes bugs like https://bugzilla.mozilla.org/show_bug.cgi?id=1556033
It seems like we should consider if this is functionality we actually want. I can see a few possibilities:
- Leave things as-is (as a difficult implementation special case)
- Support
return
completions generally, but treat then like any other abrupt completion, running finally blocks and such, which potentially means they could be intercepted or overridden if the function has lateryield
,return
, orthrow
calls.
The only downside here being that JS code can't normally get areturn
abrupt completion from arbitrary opcodes, so it could cause issues in other ways? I assume it'd be fine for the interpreter and baseline interpreter, but harder to say for baseline codegen? Since we already have to support other arbitrary abrupt completions through, I'm hopeful. - Drop support for
return
completions anywhere exceptonPop
. I guess here there is also the question of whether we'd want that in allonPop
or if we'd want to ignoreonPop
foryield
andawait
suspensions. - Drop support for
return
completions at all.
One interesting thing to note is that even if we did option 2 or 3, I think it would be easier to actually implement, and users could continue to emulate the current behavior by using return null
to terminate the execution of the function, but then having their onPop
handler force a return completion value. That also makes it clearer that with return null
the debugger is truly terminating the function.
Updated•5 years ago
|
Priority: -- → P2
Updated•2 years ago
|
Severity: normal → S3
Updated•6 months ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•