Closed
Bug 218440
Opened 21 years ago
Closed 21 years ago
Compiled scripts should not contain references to scope
Categories
(Rhino Graveyard :: Core, defect)
Rhino Graveyard
Core
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: igor, Assigned: norrisboyd)
Details
Attachments
(4 files)
534 bytes,
application/x-javascript
|
Details | |
14.08 KB,
patch
|
Details | Diff | Splinter Review | |
17.95 KB,
patch
|
Details | Diff | Splinter Review | |
24.66 KB,
patch
|
Details | Diff | Splinter Review |
Currently in Rhino a Script object generated by the the interpreter contain a reference to scope object as long as there is at least one regular expression present in the script. It prevents the original scope from garbage collection if script is executed against a new scope and can wrong references to be used when using regular expressions. The optimizer does not have this problem since it creates regexp objects during script execution.
Reporter | ||
Comment 1•21 years ago
|
||
Reporter | ||
Comment 2•21 years ago
|
||
One way to fix the problem is to implement the optimizer logic in the interpreter as well when regular expression is compiled when a function is created or when a script is executed. But it would mean that regexps are recompiled each time script is executed. A better way would be to have an option to create scope-independent compiled regexp presentation and then wrap it into a Scriptable when a function is created and this is what the patch addresses. It splits newRegExp from RegExpProxy into compileRegExp and wrapRegExp where compileRegExp creates a self-contained object that does not have any references to scope and wrapRegExp generates a Scriptable wrap for it.
Reporter | ||
Comment 3•21 years ago
|
||
The patch is an extension of the previous fix which dresses compiled regexps into Scriptable clothes only during script execution and function construction so InterpretedScript has no reference to scope.
Reporter | ||
Comment 4•21 years ago
|
||
Since compiled regexps is self-contained object, storing them as static fields in a generated class would not cause any memory leaks even if the generated classes are produced by JS compiler and used as a part of an application. This patch extends the previous one to include this optimization as well so regexp literals are compiled only once while their Scriptable wrappers are generated during function construction or script execution.
Reporter | ||
Comment 5•21 years ago
|
||
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•