Tidy up NumberToCString API, part deux
Categories
(Core :: JavaScript Engine, task, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox104 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(13 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Bug 1771874 enabled some further clean-ups and improvements for NumberToCString
.
Assignee | ||
Comment 1•2 years ago
|
||
And add an assertion to ensure double_conversion and dtoa use the same limits
for the largest string conversion.
Assignee | ||
Comment 2•2 years ago
|
||
NumberToCStringWithBase
was only ever used with base = 16
. Adding a dedicated
function for hex-strings enables us to perform more clean-ups in the next patches.
Also change Int32ToCStringWithBase
to accept signed and unsigned integers. That
way we don't have to convert unsigned integers larger than UINT32_MAX
to doubles.
Depends on D152066
Assignee | ||
Comment 3•2 years ago
|
||
32-bit integers (signed and unsigned) need less space than provided by
ToCStringBuf
and don't need any dynamically allocated memory, which avoids
calling ToCStringBuf
's out-of-line destructor.
Depends on D152067
Assignee | ||
Comment 4•2 years ago
|
||
Split both cases in preparation for the next patches.
Drive-by change:
base = 10
doesn't need to execute the unsigned(i) < unsigned(base)
and
unsigned(i) < unsigned(base * base)
cases, because StaticStrings::hasInt(i)
covers this case already.
Depends on D152068
Assignee | ||
Comment 5•2 years ago
|
||
This will allow to remove ToCStringBuf::dbuf
in the next part.
Depends on D152069
Assignee | ||
Comment 6•2 years ago
|
||
ToCStringBuf::dbuf
is no longer used after the last part.
Depends on D152070
Assignee | ||
Comment 7•2 years ago
|
||
No external caller is using ToCStringBuf
for a different base than base-10.
This allows to change the buffer size to JS::MaximumNumberToStringLength
, which
is a multiple of 4 resp. 8, which should be more efficiently to stack allocate
than 34 bytes.
Depends on D152071
Assignee | ||
Comment 8•2 years ago
|
||
This avoids another call to strlen
.
Depends on D152072
Assignee | ||
Comment 9•2 years ago
|
||
This avoids another call to strlen
.
Depends on D152073
Assignee | ||
Comment 10•2 years ago
|
||
This was the only caller to JS::NumberToString
within SpiderMonkey (ignoring test code).
Depends on D152074
Assignee | ||
Comment 11•2 years ago
|
||
NumberToString
doesn't accept a base
argument.
Depends on D152075
Assignee | ||
Comment 12•2 years ago
|
||
Depends on D152076
Updated•2 years ago
|
Assignee | ||
Comment 13•2 years ago
|
||
Depends on D152077
Comment 14•2 years ago
|
||
Comment 15•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2dc7b7595fd1
https://hg.mozilla.org/mozilla-central/rev/a203428fface
https://hg.mozilla.org/mozilla-central/rev/b35e532a5c02
https://hg.mozilla.org/mozilla-central/rev/65558ee2c725
https://hg.mozilla.org/mozilla-central/rev/39c3be46d8fc
https://hg.mozilla.org/mozilla-central/rev/5f69be822f72
https://hg.mozilla.org/mozilla-central/rev/fd161c0434e5
https://hg.mozilla.org/mozilla-central/rev/60243a95e18d
https://hg.mozilla.org/mozilla-central/rev/f387bc1fcdfc
https://hg.mozilla.org/mozilla-central/rev/c2ebd8c58db2
https://hg.mozilla.org/mozilla-central/rev/8d22a331a662
https://hg.mozilla.org/mozilla-central/rev/3a3d26fc4d69
https://hg.mozilla.org/mozilla-central/rev/4c221ac039f7
Description
•