Closed
Bug 1490605
Opened 7 years ago
Closed 7 years ago
Change ValueToSourceForError and GetFunctionNameBytes to use UTF-8 instead of Latin-1 encoding
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla64
| Tracking | Status | |
|---|---|---|
| firefox64 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(4 files, 9 obsolete files)
|
3.55 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
|
21.52 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
|
32.66 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
|
21.05 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
Directly using UTF-8 encoded strings for error reporting is preferable over Latin-1, because it avoids the additional Latin-1 to UTF-8 transformation in [1].
[1] https://searchfox.org/mozilla-central/rev/de7676288a78b70d2b9927c79493adbf294faad5/js/src/vm/JSContext.cpp#644-657
| Assignee | ||
Comment 1•7 years ago
|
||
Preparatory patch to reduce code duplication when ctypes code stringifies error arguments.
- Adds |TypeSourceForError| for the call sequence |BuildTypeSource + EncodeLatin1|.
- Adds |FunctionTypeSourceForError| for the call sequence |BuildFunctionTypeSource + EncodeLatin1|.
- Adds |ConversionPositionForError| for the call sequence |BuildConversionPosition + EncodeLatin1|.
- Adds |IndexCString| for uint32_t/size_t to char* conversion instead of duplicating |char[] + SprintfLiteral| in a couple of places. Also changes the char buffer size to 21 to fit for size_t values.
Attachment #9008337 -
Flags: review?(arai.unmht)
| Assignee | ||
Comment 2•7 years ago
|
||
Change ValueToSourceForError to use UTF-8 which more or less requires that ctypes uses UTF-8 for all its error reporting, too.
Also added |JS::StringIsASCII| assertions in ctypes error reporting functions when |char*| are passed, to ensure the |char*| can be used in UTF-8 error reporting.
Attachment #9008339 -
Flags: review?(arai.unmht)
| Assignee | ||
Comment 3•7 years ago
|
||
ctypes near duplicates the UTF-8 encoding functions from CharacterEncoding.h. The only additional feature ctypes uses, is it disallows unpaired surrogates. Because I don't think this justifies duplicating the code, we should just move the unpaired surrogate detection into a separate function and then directly call into CharacterEncoding.h for UTF-8 encoding.
Drive-by changes:
- Replaced the remaining callers to ASSERT_OK with MOZ_ALWAYS_TRUE.
- Updated ctypes/Library.cpp to use JS::UniqueChars and avoid AutoStableStringChars when the result is unused.
Attachment #9008340 -
Flags: review?(arai.unmht)
| Assignee | ||
Comment 4•7 years ago
|
||
Change GetFunctionNameBytes to use UTF-8 instead of Latin-1 encoding.
Attachment #9008341 -
Flags: review?(arai.unmht)
Comment 5•7 years ago
|
||
Comment on attachment 9008337 [details] [diff] [review]
bug1490605-part1-ctypes-error-value-stringifying.patch
Review of attachment 9008337 [details] [diff] [review]:
-----------------------------------------------------------------
Great! thank you :D
::: js/src/ctypes/CTypes.cpp
@@ +1207,5 @@
> +}
> +
> +class IndexCString final
> +{
> + char indexStr[21];
might be nice to add a comment about the reason of "21"
Attachment #9008337 -
Flags: review?(arai.unmht) → review+
Updated•7 years ago
|
Attachment #9008339 -
Flags: review?(arai.unmht) → review+
Updated•7 years ago
|
Attachment #9008340 -
Flags: review?(arai.unmht) → review+
Updated•7 years ago
|
Attachment #9008341 -
Flags: review?(arai.unmht) → review+
| Assignee | ||
Comment 6•7 years ago
|
||
Updated per review feedback, carrying r+.
Attachment #9008337 -
Attachment is obsolete: true
Attachment #9008698 -
Flags: review+
| Assignee | ||
Comment 7•7 years ago
|
||
Rebased after changing part 1, carrying r+.
Attachment #9008339 -
Attachment is obsolete: true
Attachment #9008699 -
Flags: review+
| Assignee | ||
Comment 8•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f6acdb21c176442a01615d367050d873bff11e69
Keywords: checkin-needed
Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e54bd8035b43
Part 1: Reduce code duplication when stringifying error arguments in ctypes code. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/e911dd693280
Part 2: Return UTF-8 encoded strings from ValueToSourceForError. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/61250a398db0
Part 3: Use existing UTF-8 functions from CharacterEncoding instead of near duplicating them. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/29c2fa7d40f1
Part 4: Return UTF-8 encoded strings from GetFunctionNameBytes. r=arai
Keywords: checkin-needed
Comment 10•7 years ago
|
||
Backed out 4 changesets (bug 1490605) for build bustages CTypes.cpp
push that caused the backout: https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&selectedJob=199068703&revision=29c2fa7d40f1067718eab4a94b0147e3d864b4a3
backout: https://hg.mozilla.org/integration/mozilla-inbound/rev/0c6b0c2d4c82ce208124e76e25a2e3b86d469f44
Flags: needinfo?(andrebargull)
| Assignee | ||
Comment 11•7 years ago
|
||
Change IndexCString to only have a single constructor accepting |size_t|, because -- surprise, surprise -- having two constructors where one accepts |uint32_t| and the other |size_t| doesn't work on 32bit.
Attachment #9008698 -
Attachment is obsolete: true
Flags: needinfo?(andrebargull)
Attachment #9008779 -
Flags: review+
| Assignee | ||
Comment 12•7 years ago
|
||
Rebased after changing part 1.
Attachment #9008699 -
Attachment is obsolete: true
Attachment #9008780 -
Flags: review+
| Assignee | ||
Comment 13•7 years ago
|
||
Add missing rooting to fix rooting hazards.
Attachment #9008340 -
Attachment is obsolete: true
Attachment #9008781 -
Flags: review+
Comment 14•7 years ago
|
||
FWIW, the ctypes patches may conflict with bug 1490630 (still on autoland).
| Assignee | ||
Comment 15•7 years ago
|
||
Rebased after braces changes.
Attachment #9008779 -
Attachment is obsolete: true
Attachment #9009176 -
Flags: review+
| Assignee | ||
Comment 16•7 years ago
|
||
Rebased after braces changes.
Attachment #9009176 -
Attachment is obsolete: true
Attachment #9009177 -
Flags: review+
| Assignee | ||
Comment 17•7 years ago
|
||
Rebased after braces changes.
Attachment #9008780 -
Attachment is obsolete: true
Attachment #9009178 -
Flags: review+
| Assignee | ||
Comment 18•7 years ago
|
||
Rebased after braces changes.
Attachment #9008781 -
Attachment is obsolete: true
Attachment #9009179 -
Flags: review+
| Assignee | ||
Comment 19•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=69d967d129028190703497f289e308a5beabb8b0
Keywords: checkin-needed
Comment 20•7 years ago
|
||
Pushed by btara@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/28bebbb1d4cb
Part 4: Return UTF-8 encoded strings from GetFunctionNameBytes. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/096c2c7d4326
Part 1: Reduce code duplication when stringifying error arguments in ctypes code. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/6a993fa3e3d8
Part 2: Return UTF-8 encoded strings from ValueToSourceForError. r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/0fed430fe00c
Part 3: Use existing UTF-8 functions from CharacterEncoding instead of near duplicating them. r=arai
Keywords: checkin-needed
Comment 21•7 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/28bebbb1d4cb
https://hg.mozilla.org/mozilla-central/rev/096c2c7d4326
https://hg.mozilla.org/mozilla-central/rev/6a993fa3e3d8
https://hg.mozilla.org/mozilla-central/rev/0fed430fe00c
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in
before you can comment on or make changes to this bug.
Description
•