ValueToSource should be useful without toSource methods
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: evilpie, Assigned: evilpie)
References
(Blocks 1 open bug)
Details
Attachments
(7 files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
We use ValueToSource
and JS_ValueToSource
in Gecko and SpiderMonkey code for various purposes, but mostly for error reporting and debugging. Right now ValueToSource
produces useful pretty printed output by calling the toSource
method of the passed in object. Without those there is only a default formatter for objects (and functions since bug 1605658). To avoid regressing error messages for cases like new [1, 2, 3]
or making the JS shell super ugly, we have to start producing better pretty printed output without toSource
.
I think we could follow a similar path to bug 1605658, where we directly call the C++ code of Function.prototype.toSource
. We probably do not need to do this for every kind of object, but array and error objects are definitely the most important from my POV.
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
To make testing easier without uneval
we should expose a JS shell function that calls ValueToSource
.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
We will keep improving this test when we are adding new implementations like ErrorToSource that don't require a toSource method.
(--disable-tosource can be removed in the future)
Assignee | ||
Comment 3•4 years ago
|
||
Assignee | ||
Comment 4•4 years ago
|
||
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/38ffdad9b953 Add a valueToSource method to the shell for testing. r=arai https://hg.mozilla.org/integration/autoland/rev/1536cf66a302 Add ArrayToSource. r=arai
Comment 6•4 years ago
|
||
bugherder |
Assignee | ||
Comment 7•4 years ago
|
||
I am not sure if I should create a separate header just for ValueToSource?
In the future after we remove toSource from chrome-js we can move more ToSource methods to this file.
Assignee | ||
Comment 8•4 years ago
|
||
Depends on D59684
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e0a175e745b6 Add ErrorToSource. r=arai
Comment 10•4 years ago
|
||
bugherder |
Comment 11•4 years ago
|
||
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/6e89f71a08de Move ValueToSource to a new file. r=arai https://hg.mozilla.org/integration/autoland/rev/d1cca1ec8ee0 Add RegExp support to ValueToSource fallback. r=arai
Comment 12•4 years ago
|
||
bugherder |
Assignee | ||
Comment 13•4 years ago
|
||
I think we can implement some generalized handling for Date, Boolean, String, Number etc. by leveraging js:Unbox
, but maybe that is too clever and we should just hardcode it.
Assignee | ||
Comment 14•4 years ago
|
||
Assignee | ||
Comment 15•4 years ago
|
||
Comment 16•4 years ago
|
||
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e02b75f47c9b ValueToSource should be able to handle wrapped objects. r=jwalden https://hg.mozilla.org/integration/autoland/rev/5e253b12e2b6 Add support for Boolean, String, Number and Date objects to ValueToSource. r=jwalden
Assignee | ||
Comment 17•4 years ago
|
||
I think this covers most of the important object types for now.
Assignee | ||
Updated•4 years ago
|
Comment 18•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e02b75f47c9b
https://hg.mozilla.org/mozilla-central/rev/5e253b12e2b6
Description
•