Closed Bug 753277 Opened 12 years ago Closed 12 years ago

Refactor transplant code and improve comments

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: bholley, Assigned: bholley)

Details

Attachments

(6 files, 1 obsolete file)

Some of this stuff is more confusing than it needs to be. I'm about to fix a bug in this stuff (I think), and I felt like clarifying some things first. Patches soon.
Attaching a patch. Flagging mrbkap for review.
Attachment #622351 - Flags: review?(mrbkap)
Comment on attachment 622351 [details] [diff] [review]
Factor out CCW remapping from JS_TransplantObject and add comments. v1

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

::: js/src/jsapi.cpp
@@ +1516,5 @@
> + * identities by altering wrappers.
> + *
> + * The |origobj| argument should be the object whose identity needs to be
> + * remapped, usually to another compartment. The contents of |origobj| are
> + * destroyed, unless |origobj == target|.

Here and below, you refer to the |origobj == target| case, while it's now been outlawed (in favor of JS_RefreshCrossCompartmentWrappers).

@@ +1544,4 @@
>      JSCompartment *destination = target->compartment();
>      WrapperMap &map = destination->crossCompartmentWrappers;
>      Value origv = ObjectValue(*origobj);
>      JSObject *obj;

Is there anything we can do about this name? I could never think of anything better here, but |obj| is pretty generic, especially in the face of |origobj| and |target|... Perhaps |newObj|?
Attachment #622351 - Flags: review?(mrbkap) → review+
(In reply to Blake Kaplan (:mrbkap) from comment #2)

> Is there anything we can do about this name? I could never think of anything
> better here, but |obj| is pretty generic, especially in the face of
> |origobj| and |target|... Perhaps |newObj|?

newIdentity. I'm making that a separate patch with r=mrbkap. Let me know if you disagree. ;-)
It's not wrong, but it's not necessary either, since we'll just unwrap directly to the underlying object during wrapping. And this is confusing enough as-is.
Attachment #623078 - Flags: review?(mrbkap)
Comment on attachment 623078 [details] [diff] [review]
Part 5 - Rename tobj to wrapperGuts, and avoid going through the SCSW on the other side unnecessarily. v1

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

Only the rename happened, no?
(In reply to Ms2ger from comment #10)

> Only the rename happened, no?

No, it's subtle. Note that we previously were pointing to newWrapper, and now we point to targetobj.
Attachment #623076 - Flags: review?(mrbkap) → review+
Attachment #623077 - Flags: review?(mrbkap) → review+
Attachment #623078 - Flags: review?(mrbkap) → review+
Comment on attachment 623079 [details] [diff] [review]
Part 6 - Assert that all cross-scope wrapper reparenting operations are cross-compartment, and remove the conditional. v1

A diff -w would have been nice here.
Attachment #623079 - Flags: review?(mrbkap) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: