Remove JS_New and use JS::Construct in JS_New consumers
Categories
(Core :: JavaScript Engine, enhancement, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox88 | --- | fixed |
People
(Reporter: sfink, Assigned: snehasai01, Mentored)
Details
(Keywords: good-first-bug, Whiteboard: [lang=c++])
Attachments
(1 file, 3 obsolete files)
Comment 1•7 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Hello. I'd like to work on this as my first bug. Is this still a bug that needs to be addressed? If so, I'd appreciate any pointers you can give me about where to start!
Comment 5•6 years ago
|
||
yes, this is still valid
- to work on this, you first need to be able to build Firefox [1].
- once you've built, check the above link that shows definition/delaration/consumers of JS_New.
- replace consumers of JS_New to use JS::Construct [2]
- remove definition/declaration of JS_New
- rebuild Firefox and see if it compiles
- after that, submit your patch with moz-phab [3] (the document provides 2 options, moz-phab and arcanist, but I suggest using moz-phab)
if you have other questions, feel free to ask here, or in #jsapi channel in irc.mozilla.org [4]
[1] https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_build
[2] https://searchfox.org/mozilla-central/rev/3e0f1d95fcf8832413457e3bec802113bdd1f8e8/js/src/jsapi.h#1878-1905
[3] https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
[4] https://wiki.mozilla.org/index.php?title=IRC
Comment 6•6 years ago
|
||
Working on it now, think I've found a fix and my build successfully compiles. However, I wonder if there is a method for me to test my implementation? And speaking of tests, should I remove the test cases/file testNewObject.cpp in my patch?
Comment 7•6 years ago
|
||
testNewObject should be rewritten to use JS::Construct.
you can run it by running jsapi-test in object directory, jsapi-test binary, with ./jsapi-test testNewObject command
Comment 8•6 years ago
|
||
Hey, Is this bug open to being worked on? I'd like to get involved if so. I see it is unassigned. cheers :)
Comment 9•6 years ago
|
||
(Please ignore my last comment- I didn't realise this was in C++, I thought it was in JS :) )
Comment 10•6 years ago
|
||
Updated•6 years ago
|
Comment 11•4 years ago
|
||
This good-first-bug hasn't had any activity for 6 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.
Updated•4 years ago
|
Comment 12•4 years ago
|
||
Hi, can i work on this bug if it's still open.
Thanks,
Murali
Comment 13•4 years ago
|
||
Yes, it's still open.
For the details, see comment #5.
If you got any question, feel free to ask here, or in https://chat.mozilla.org/#/room/#spidermonkey:mozilla.org (irc.mozilla.org is discontinued)
Comment 14•4 years ago
|
||
Could you please explain the reason to switch from JS::Construct to JS_New, wasn't able to figure it out from (https://bugzilla.mozilla.org/show_bug.cgi?id=1491055#c0).
Comment 15•4 years ago
|
||
this bug is about switching from JS_New to JS::Construct.
Reasons are the following:
JS_NewacceptsHandleObject, but what it want isHandleValueHandleObjectis an alias ofJS::Handle<JSObject*>HandleValueis an alias ofJS::Handle<JS::Value>RootedObjectis an alias ofJS::Rooted<JSObject*>RootedValueis an alias ofJS::Rooted<JS::Value>JSObjectis a class that represents object in JSJS::Valueis a class that represents any value in JSJS::Rootedis a class to register the value to GC's root listJS::Handleis a reference toJS::Rootedand implicitly convertible fromJS::RootedJSObjectcan be wrapped intoJS::ValuebyObjectValue- Whether
JS::ValuecontainsJSObjector not can be queried byJS::Value::isObject JSObjectinsideJS::Valuecan be unwrapped byJS::Value::toObjectJS_Newwraps the receivedHandleObject ctorintoRootedValue ctorVal, and use it throughout the function (theRootedValueis implicitly converted toHandleValuewhen passing to other function)- Usually the constructor (
ctor) is retrieved asJS::Value, so it's better just receive it asHandleValue, instead of letting the API consumer to convert it toHandleObject
- So, originally this bug was about to add a variant of
JS_Newthat acceptsHandleValue- actually, this doesn't apply to the remaining consumer, there it holds
JSObjectinnsJSObjWrapper::mJSObj - but in general, receiving
HandleValueis better
- actually, this doesn't apply to the remaining consumer, there it holds
- There's
JS::Constructthat does almost same thing asJS_New(for historical reason)- it matches the requirement (accepts
HandleValue) - it has more callsites than
JS_New
- it matches the requirement (accepts
- So, this bug's purpose is changed to replace remaining
JS_Newconsumer to useJS::Construct, and removeJS_New
| Assignee | ||
Comment 16•4 years ago
|
||
| Assignee | ||
Comment 17•4 years ago
|
||
please review my changes
Updated•4 years ago
|
Comment 18•4 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #15)
this bug is about switching from
JS_NewtoJS::Construct.Reasons are the following:
JS_NewacceptsHandleObject, but what it want isHandleValue
HandleObjectis an alias ofJS::Handle<JSObject*>HandleValueis an alias ofJS::Handle<JS::Value>RootedObjectis an alias ofJS::Rooted<JSObject*>RootedValueis an alias ofJS::Rooted<JS::Value>JSObjectis a class that represents object in JSJS::Valueis a class that represents any value in JSJS::Rootedis a class to register the value to GC's root listJS::Handleis a reference toJS::Rootedand implicitly convertible fromJS::RootedJSObjectcan be wrapped intoJS::ValuebyObjectValue- Whether
JS::ValuecontainsJSObjector not can be queried byJS::Value::isObjectJSObjectinsideJS::Valuecan be unwrapped byJS::Value::toObjectJS_Newwraps the receivedHandleObject ctorintoRootedValue ctorVal, and use it throughout the function (theRootedValueis implicitly converted toHandleValuewhen passing to other function)- Usually the constructor (
ctor) is retrieved asJS::Value, so it's better just receive it asHandleValue, instead of letting the API consumer to convert it toHandleObject- So, originally this bug was about to add a variant of
JS_Newthat acceptsHandleValue
- actually, this doesn't apply to the remaining consumer, there it holds
JSObjectinnsJSObjWrapper::mJSObj- but in general, receiving
HandleValueis better- There's
JS::Constructthat does almost same thing asJS_New(for historical reason)
- it matches the requirement (accepts
HandleValue)- it has more callsites than
JS_New- So, this bug's purpose is changed to replace remaining
JS_Newconsumer to useJS::Construct, and removeJS_New
Thanks for the elaborate explanation :arai, maybe i need to look for another bug.
| Assignee | ||
Comment 19•4 years ago
|
||
Depends on D105875
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 20•4 years ago
|
||
Comment 21•4 years ago
|
||
Comment 22•4 years ago
|
||
| bugherder | ||
Description
•