Closed Bug 1428742 Opened 7 years ago Closed 4 years ago

We have two ways of converting a Value to a GCCellPtr

Categories

(Core :: JavaScript: GC, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox60 --- wontfix
firefox87 --- fixed

People

(Reporter: jonco, Assigned: tupos9)

Details

(Keywords: good-first-bug)

Attachments

(3 files)

While looking at bug 1428507 I noticed we have two ways of converting a JS::Value to a GCCellPtr with two different implementations: - GCCellPtr::GCCellPtr(const Value&) - Value::toGCCellPtr() The one in Value looks like it's more efficient. We should probably remove the other one.
Priority: -- → P3
I like to work on this. How can I identify which GCCellPtr calls to replace with toGCCellPtr?
Flags: needinfo?(jorendorff)
(In reply to Venkatesh from comment #1) Great. I was going to suggest removing the GCCellPtr constructor that takes a single Value argument and then fixing all the compilation errors... but then I realised that you can search for calls to a specific constructor directly: https://searchfox.org/mozilla-central/search?q=symbol:_ZN2JS9GCCellPtrC1ERKNS_5ValueE&redirect=false
Flags: needinfo?(jorendorff)
Attachment #8973383 - Flags: review?(jorendorff)
Comment on attachment 8973383 [details] [diff] [review] bug-1428742-attempt-01.patch Review of attachment 8973383 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for working on this. This looks fine so far. Can you remove the GCCellPtr constructor that takes a Value too? I think you'll have to add a toGCCellPtr() method to the WrappedPtrOperations<JS::Value, Wrapper> specialisation in Value.h, along the same lines as the other methods there. That allows calling this on RootedValue, HandleValue, etc. ::: js/src/vm/ProxyObject.cpp @@ +54,4 @@ > MOZ_ASSERT(clasp->shouldDelayMetadataBuilder()); > MOZ_ASSERT_IF(proto.isObject(), cx->compartment() == proto.toObject()->compartment()); > MOZ_ASSERT(clasp->hasFinalize()); > + MOZ_ASSERT_IF(priv.isGCThing(), !JS::GCThingIsMarkedGray(priv.toGCCellPtr()); There's a missing close bracket at the end of the line. @@ +132,4 @@ > ProxyObject::setPrivate(const Value& priv) > { > MOZ_ASSERT_IF(IsMarkedBlack(this) && priv.isGCThing(), > + !JS::GCThingIsMarkedGray(priv.toGCCellPtr()); Ditto above.
Attachment #8973383 - Flags: review?(jorendorff) → feedback+

Since no one was working on this issue since last few years. I picked up this issue as suggested by @jonco . I have made the changes in the files but won't be able to get what you are trying to say in the these lines. Sorry I am newbie to this project and still understanding how things work here.

Can you remove the GCCellPtr constructor that takes a Value too?
I think you'll have to add a toGCCellPtr() method to the
WrappedPtrOperations<JS::Value, Wrapper> specialisation in Value.h, along
the same lines as the other methods there. That allows calling this on
RootedValue, HandleValue, etc.

(In reply to Aman Verma from comment #5)
Can you post your patch so far?

The comments were about removing the GCCellPtr constructor overload that takes a const Value&. This needs to be removed and existing uses of it need to be converted to use Value::toGCCellPtr.

The last comment was about adding a toGCCellPtr() method to the
WrappedPtrOperations specialisation here: https://searchfox.org/mozilla-central/source/js/public/Value.h#1127

This should be implemented in the same way as all the other methods there.

Hope this helps. If you have any questions please ping me on IRC.

Attached patch 1428742.patchSplinter Review

I did remove the constructor while replacing all uses of toGCCellPtr(), along with the check-in file js/src/jsapi-tests/testGCCellPtr.cpp. I'd like to hear some feedback as I'm pretty unfamiliar with c++ language, might run into many compilation errors.

Assignee: nobody → a.neun
Status: NEW → ASSIGNED
Assignee: a.neun → nobody
Status: ASSIGNED → NEW
Assignee: nobody → tupos9
Status: NEW → ASSIGNED
Pushed by archaeopteryx@coole-files.de: https://hg.mozilla.org/integration/autoland/rev/1aee1f6fcd23 use Value::toGCCellPtr and delegating ctr of GCCellPtr. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: