Closed Bug 841625 Opened 12 years ago Closed 2 years ago

[jsdbg2] In debug mode, closures should retain all bindings in enclosing environments

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jimb, Unassigned)

Details

As an optimization, if a variable is not referred to by any nested functions within its scope, SpiderMonkey will omit that variable from the scope chain those functions' closures capture. However, in debug mode, SpiderMonkey should retain all variables' values, to make expression evaluation in captured environments behave as expected.
Assignee: general → nobody
This isn't just a performance optimization, note: there's lots of web code that doesn't leak normally but will leak with this optimization turned off..... :(
Yes, but if you're debugging, don't you want to see those values? I guess we could argue about whether "avoiding a leak" counts as a "performance optimization". The case in favor is that leaks don't affect the content-visible behavior of the code, only its resource consumption.
> Yes, but if you're debugging, don't you want to see those values? Possibly yes.... > don't affect the content-visible behavior of the code, only its resource consumption OOM exceptions and browser crashes are content-visible.... I'm not sure there are any great solutions here. :(
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #3) > > don't affect the content-visible behavior of the code, only its resource consumption > > OOM exceptions and browser crashes are content-visible.... I'm not sure > there are any great solutions here. :( I think this is over-stating the case. SpiderMonkey retains values it doesn't need already, today. It retains locals that closures will never use; global variables that will never be referenced; properties that will never be used, and so on. Every one of those could be responsible for an OOM or a browser crash. There's nothing magically correct about the behavior we happen to have today. There is a middle ground: as long as the debugger *says* that the variable has been optimized out (instead of simply not mentioning it) then at least people won't experience it as a bug. However, although the Debugger API does report optimized-out variables, the new debugger doesn't display it. Filed bug 1318164.
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.