Closed
Bug 687966
Opened 14 years ago
Closed 14 years ago
Use JSScript, not script objects, as keys in Debugger maps
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla10
People
(Reporter: igor, Assigned: igor)
References
Details
Attachments
(1 file)
54.93 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
This is another leftover from the bug 674251. The Debugger still uses script object, not script itself, as keys in its weak map for held scripts or when checking for live scripts. For the bug 684529 this should be fixed.
Assignee | ||
Comment 1•14 years ago
|
||
The patch merges Debugger::(held|nonHeld)Scripts into single Debugger::scripts with JSScript as keys and changes the code to use IsAboutToBeFinalized() on JSScript instances, not script objects. This allowed to eliminate all the code related to non-held support.
The patch still uses the script object in the debugger. Now it became effectively a way to get the global object associated with the script. Removal of that is for the bug 684529.
Assignee: general → igor
Attachment #561596 -
Flags: review?(jorendorff)
Assignee | ||
Comment 2•14 years ago
|
||
Jason: review ping?
Comment 3•14 years ago
|
||
Comment on attachment 561596 [details] [diff] [review]
v1
Great simplification. I've been looking forward to this. Thank
you.
> if (xdr->mode == JSXDR_DECODE) {
>+ JS_ASSERT(!script->compileAndGo);
Thanks for adding this.
In vm/Debugger.cpp, Debugger::init:
> bool ok = (frames.init() &&
> objects.init() &&
> debuggees.init() &&
>- heldScripts.init() &&
>- nonHeldScripts.init());
>+ scripts.init());
While you're in here, could you please kill the extra parentheses around
the right-hand side? House style doesn't overparenthesize here. (Mea
culpa. Old Python habit, reinforced by emacs's auto-indentation.)
>+Debugger::slowPathOnNewScript(JSContext *cx, JSScript *script, JSObject *obj,
>+ GlobalObject *compileAndGoGlobal)
> {
Here please JS_ASSERT(script->compileAndGo == !!compileAndGoGlobal);
Assertions that document the contract are good.
>+ * JSScripts' lifetimes is managed by the garbage collector. Debugger.Script
>+ * instances for scripts are strong references to the script.
>+ * Debugger::scripts weakly maps debuggee scripts to the Debugger.Script
>+ * objects. For a dead script its entry in Debugger::heldScripts will be
>+ * cleaned up by the standard weak table code.
> */
You can just delete this whole comment. All this stuff is either pretty obvious or already said in comments elsewhere.
If you keep it, change heldScripts to scripts.
In DebuggerScript_check:
> /*
> * Check for Debugger.Script.prototype, which is of class DebuggerScript_class
> * but whose holding object is undefined.
> */
> if (thisobj->getReservedSlot(JSSLOT_DEBUGSCRIPT_HOLDER).isUndefined()) {
> JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
> clsname, fnname, "prototype object");
> return NULL;
> }
Please change this to check that GetScriptReferent(thisobj) is NULL
instead of checking the holder slot, and change the comment to say
"...which is of class DebuggerScript_class but has no referent."
>+DebuggerScript_getChildScripts(JSContext *cx, uintN argc, Value *vp)
> {
> THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "get live", args, obj, script);
Another jorendorff typo: the string here should be "getChildScripts", not "get live".
> DebuggerScript_getLineOffsets(JSContext *cx, uintN argc, Value *vp)
> {
>- THIS_DEBUGSCRIPT_LIVE_SCRIPT(cx, argc, vp, "getAllOffsets", args, obj, script);
>+ THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "getAllOffsets", args, obj, script);
Same here.
> DebuggerScript_clearAllBreakpoints(JSContext *cx, uintN argc, Value *vp)
> {
>- THIS_DEBUGSCRIPT_LIVE_SCRIPT(cx, argc, vp, "clearBreakpoint", args, obj, script);
>+ THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "clearBreakpoint", args, obj, script);
And here.
In vm/Debugger.h:
> * The holder object for script, if known, else NULL. This is NULL for
>- * non-held scripts and for JSD1 traps. It is always non-null for JSD2
>+ * cached eval scripts and for JSD1 traps. It is always non-null for JSD2
> * breakpoints in held scripts.
"held scripts" should just say "other scripts" I guess.
Obviously we want to get rid of JSSLOT_DEBUGSCRIPT_HOLDER and
GetScriptHolder; do you have that in a later patch? It has to be done
before Script objects can be killed off.
It will be pretty easy. With the DebuggerScript_check change I requested
above, the only use I see is in setBreakpoint, to check that the script
is actually "observed" (i.e. we're debugging that global). We could keep
the global around instead of the Script object / uncloned Function
object.
Attachment #561596 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 4•14 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #3)
> In DebuggerScript_check:
> > /*
> > * Check for Debugger.Script.prototype, which is of class DebuggerScript_class
> > * but whose holding object is undefined.
> > */
> > if (thisobj->getReservedSl ot(JSSLOT_DEBUGSCRIPT_HOLDER).isUndefined()) {
> > JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
> > clsname, fnname, "prototype object");
> > return NULL;
> > }
>
> Please change this to check that GetScriptReferent(thisobj) is NULL
> instead of checking the holder slot, and change the comment to say
> "...which is of class DebuggerScript_class but has no referent."
This is done in the patch for bug 684529.
Assignee | ||
Comment 5•14 years ago
|
||
Comment 6•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in
before you can comment on or make changes to this bug.
Description
•