If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Move Debugger objects reflections from private fields to reserved fields.

ASSIGNED
Assigned to

Status

()

Core
JavaScript Engine
ASSIGNED
4 years ago
3 years ago

People

(Reporter: Matt Stults, Assigned: Matt Stults)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

4 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0 (Beta/Release)
Build ID: 20130326150557
(Assignee)

Comment 1

4 years ago
(This bug was suggested by ejpbruel)

Move Debugger objects reflections from private fields to reserved fields.  We want to move the reflections to reserved fields from private fields because:
1) There are up to 16 reserved slots and only one private slot available.
2) Normal (non-magic and non-private) are automatically handled by GC.
3) Because reserved fields are typed, they make debugging easier.

The objects that need to be refactored are:
1) Debugger.Environment
2) Debugger.DebuggeeValue

The Debugger.Script object does not need its "referent" moved out of its private field.  This is because the Debugger.Script referent is a JSScript, and JSScripts do not extend Value, and so cannot be placed directly in reserved fields.
(Assignee)

Comment 2

4 years ago
Created attachment 754331 [details] [diff] [review]
First Pass

Let me know if this is what you're looking for or if I've missed any debug objects.  I've tested using:
jit-test/jit_test.py build-release/js --tbpl
tests/jstests.py build-release/js --args="-m -n"

Thanks for your time.
Attachment #754331 - Flags: review?(ejpbruel)
Hey Matt.

First of all, thank you very much for taking time for this. I'm trying to finish a project before the end of this week, so I'll take a look at your patch this friday.

For future reference, it normally takes a reviewer a couple of days at most to take a look at your patch, though sometimes it can take longer (it depends on how busy that person is and how high priority your patch).

If you haven't gotten any response to your patch, its perfectly acceptable to ping the reviewer and ask for an update :-)

Updated

4 years ago
Attachment #754331 - Attachment is patch: true
Comment on attachment 754331 [details] [diff] [review]
First Pass

Review of attachment 754331 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry this took so long. This looks very good! r+ from me, provided you fix that single comment I had.

Normally, you'd be done now, and you could either check in the patch, or, if you don't have commit rights yet, request somebody else to check it in for you (works the same way as requesting a review, except you use the checkin flag).

However, you need a r+ from the module owner before you can check something in, and unfortuntately, that's not me in this case. I've asked for an additional review from Jim Blandy. He's the module owner for the debugger. Once you get a review from him, you're good to go.

Just so you know, I will be on PTO for the next 3 weeks. During that time, you can direct your questions to Jim (jimb on irc). Feel free to e-mail me if you're having trouble with anything, but I can't promise I'll be able to respond.

::: js/src/vm/Debugger.cpp
@@ +739,5 @@
>                                   : JSMSG_DEBUG_OBJECT_WRONG_OWNER);
>              return false;
>          }
>  
> +        vp.setObject(*static_cast<JSObject*>(dobj->getReservedSlot(JSSLOT_DEBUGOBJECT_REFERENT).toObjectOrNull()));

You don't need the static_cast here anymore, since .toObjectOrNull() already returns as JSObject *
Attachment #754331 - Flags: review?(jimb)
(Assignee)

Comment 5

4 years ago
Created attachment 757068 [details] [diff] [review]
Removing unnecessary static cast.

Thanks for the feedback!  I've made the suggested change and included Jim as the reviewer.  Please let me know if there's anything else I can do for the patch.
Attachment #754331 - Attachment is obsolete: true
Attachment #754331 - Flags: review?(jimb)
Attachment #754331 - Flags: review?(ejpbruel)
Attachment #757068 - Flags: review?(jimb)

Comment 6

4 years ago
Comment on attachment 757068 [details] [diff] [review]
Removing unnecessary static cast.

Review of attachment 757068 [details] [diff] [review]:
-----------------------------------------------------------------

It's great to see this getting done.

I think this patch has pieces missing; see the comments. I've cleared the review flag, waiting for an updated, complete patch.

::: js/src/vm/Debugger.cpp
@@ +1569,5 @@
>       * frames.)
>       */
>      for (FrameMap::Range r = frames.all(); !r.empty(); r.popFront()) {
>          RelocatablePtrObject &frameobj = r.front().value;
> +        JS_ASSERT(frameobj->getReservedSlot(JSSLOT_DEBUGFRAME_REFERENT));

I don't see any definition for JSSLOT_DEBUGFRAME_REFERENT; is this the whole patch?

@@ +4086,5 @@
>      NULL,                 /* checkAccess */
>      NULL,                 /* call        */
>      NULL,                 /* construct   */
>      NULL,                 /* hasInstance */
> +    NULL                  /* trace       */

You can just delete all the trailing NULL initialization values.

@@ +4092,5 @@
>  
>  static JSObject *
> +DebuggerObject_getReferent(JSObject *obj)
> +{
> +    return obj->getReservedSlot(JSSLOT_DEBUGOBJECT_REFERENT).toObjectOrNull();

These accessors are great! But they should have:

JS_ASSERT(obj->getClass() == &DebuggerObject_class);

@@ +4870,5 @@
>      NULL,                 /* checkAccess */
>      NULL,                 /* call        */
>      NULL,                 /* construct   */
>      NULL,                 /* hasInstance */
> +    NULL,                 /* trace       */

Same here.

@@ +4876,5 @@
>  
> +static Env *
> +DebuggerEnv_getReferent(JSObject *obj)
> +{
> +    return static_cast<Env *>(obj->getReservedSlot(JSSLOT_DEBUGENV_REFERENT).toObjectOrNull());

Analogous assertion needed here, too.

Updated

4 years ago
Attachment #757068 - Flags: review?(jimb)
(Assignee)

Comment 7

4 years ago
Created attachment 758374 [details] [diff] [review]
Updating with the correct patch.

This should have the suggested changes--let me know if I missed anything.

JSSLOT_DEBUGFRAME_REFERENT was left from a previous version of the patch--looks like I grabbed the wrong one.

I've tested this with:
tests/jstests.py build-release/js --args="-m -n"
jit-test/jit_test.py build-release/js
and it looks good.  I've also compiled into Firefox and run the debugger to make sure there are no blatant issues, but this is about as far as my verification has gone.  Let me know if there's anything else I can do.
Attachment #757068 - Attachment is obsolete: true
Attachment #758374 - Flags: review?(jimb)

Comment 8

4 years ago
Comment on attachment 758374 [details] [diff] [review]
Updating with the correct patch.

Review of attachment 758374 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great. Just one suggestion, but I can take care of that myself when I land it.

Thanks for the patch!

::: js/src/vm/Debugger.cpp
@@ +739,5 @@
>                                   : JSMSG_DEBUG_OBJECT_WRONG_OWNER);
>              return false;
>          }
>  
> +        vp.setObject(*dobj->getReservedSlot(JSSLOT_DEBUGOBJECT_REFERENT).toObjectOrNull());

Since vp is a MutableValueHandle, and getReservedSlot returns a Value, I think this can be, simply:

vp.set(dobj->getReservedSlot(JSSLOT_DEBUGOBJECT_REFERENT));
Attachment #758374 - Flags: review?(jimb) → review+

Updated

4 years ago
Assignee: general → matt.stults
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
OS: Mac OS X → All
Hardware: x86 → All
(Assignee)

Comment 9

4 years ago
Hey Jimb, thanks again for reviewing this!  Let me know if I should make the change and get someone to check this in or if--what I gather from your previous comment--you're going to submit it with the change yourself.  Just making sure I tie up any remaining loose ends on this before moving on to something else.
jimb: did you forget to land Matt's r+'d patch from last year? Is it still relevant?
Flags: needinfo?(jimb)

Comment 11

3 years ago
Oh, wow, I didn't realize he wasn't able to land it himself. This may be bit-rotted by now. Let me try to refresh it.
Flags: needinfo?(jimb)

Comment 12

3 years ago
Actually, now that I've updated this patch and tried it out: How in the world did this patch manage to store cross-compartment edges directly in object slots?

The patch needs to use private values (i.e. PrivateValue) to store these edges, with all the appropriate casts, because a Debugger.Object's referent is usually in another compartment, and direct cross-compartment edges are forbidden.

If Matt still has any interest in this patch, I'd be happy to help him bring it forward. But this isn't something I should prioritize at the moment.
(Assignee)

Comment 13

3 years ago
I think it has been almost a year from when I worked on this and I no longer have the context to work on this efficiently.  I'm happy with dropping this patch altogether and letting someone else work on the problem.  Just let me know if there's anything I need to do to clean up and close this patch out.

I'm sorry it didn't work out for you out of the box.
You need to log in before you can comment on or make changes to this bug.