summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2019-10-01 22:59:38 -0500
committerathenian200 <athenian200@outlook.com>2019-10-21 04:53:40 -0500
commitc0d814c1d52b0e9ae884b83f214218b954133acb (patch)
treef2a4e47d82975f5b3cd219638d082124ffd129f7 /js
parent3647f42c27761472e4ee204bade964e8ffad4679 (diff)
downloadUXP-c0d814c1d52b0e9ae884b83f214218b954133acb.tar
UXP-c0d814c1d52b0e9ae884b83f214218b954133acb.tar.gz
UXP-c0d814c1d52b0e9ae884b83f214218b954133acb.tar.lz
UXP-c0d814c1d52b0e9ae884b83f214218b954133acb.tar.xz
UXP-c0d814c1d52b0e9ae884b83f214218b954133acb.zip
MoonchildProductions#1251 - Part 8: Align pointer for char_16t.
https://bugzilla.mozilla.org/show_bug.cgi?id=1352449 Mozilla patch that's been in the code since Firefox 55. Seems like there have been no ill effects from implementing it, and it would only increase the portability of the UXP code. All the Solaris Firefox repos I've seen implement some variation on the jsexn patch, and this seems to be the cleanest version of it. I can add ifdefs if needed or there are performance concerns associated with this patch, but I get the impression this alignment backlog issue might affect a few platforms other than Solaris, though none were named. Otherwise I think they wouldn't have used "platforms that need it" in plural form or failed to ifdef it.
Diffstat (limited to 'js')
-rw-r--r--js/src/jsexn.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp
index 65cc81a1a..3fc9200c1 100644
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -205,7 +205,12 @@ size_t
ExtraMallocSize(JSErrorReport* report)
{
if (report->linebuf())
- return (report->linebufLength() + 1) * sizeof(char16_t);
+ /*
+ * Mozilla bug 1352449. Count with null
+ * terminator and alignment. See CopyExtraData for
+ * the details about alignment.
+ */
+ return (report->linebufLength() + 1) * sizeof(char16_t) + 1;
return 0;
}
@@ -220,10 +225,20 @@ bool
CopyExtraData(JSContext* cx, uint8_t** cursor, JSErrorReport* copy, JSErrorReport* report)
{
if (report->linebuf()) {
+ /*
+ * Make sure cursor is properly aligned for char16_t for platforms
+ * which need it and it's at the end of the buffer on exit.
+ */
+ size_t alignment_backlog = 0;
+ if (size_t(*cursor) % 2)
+ (*cursor)++;
+ else
+ alignment_backlog = 1;
+
size_t linebufSize = (report->linebufLength() + 1) * sizeof(char16_t);
const char16_t* linebufCopy = (const char16_t*)(*cursor);
js_memcpy(*cursor, report->linebuf(), linebufSize);
- *cursor += linebufSize;
+ *cursor += linebufSize + alignment_backlog;
copy->initBorrowedLinebuf(linebufCopy, report->linebufLength(), report->tokenOffset());
}