diff --git a/dom/media/webaudio/AudioWorkletNode.cpp b/dom/media/webaudio/AudioWorkletNode.cpp index 851572b3a9a7..0130917f521d 100644 --- a/dom/media/webaudio/AudioWorkletNode.cpp +++ b/dom/media/webaudio/AudioWorkletNode.cpp @@ -50,7 +50,7 @@ struct ProcessorErrorDetails { ProcessorErrorDetails() : mLineno(0), mColno(0) {} // Line number (1-origin). unsigned mLineno; - // Column number (1-origin). + // Column number in UTF-16 code units (1-origin). unsigned mColno; nsString mFilename; nsString mMessage; diff --git a/dom/workers/WorkerError.h b/dom/workers/WorkerError.h index 83c78bc73052..43600fbf1ad1 100644 --- a/dom/workers/WorkerError.h +++ b/dom/workers/WorkerError.h @@ -22,8 +22,10 @@ class WorkerErrorBase { public: nsString mMessage; nsString mFilename; - uint32_t mLineNumber; // 1-origin. - uint32_t mColumnNumber; // 1-origin + // Line number (1-origin). + uint32_t mLineNumber; + // Column number in UTF-16 code units (1-origin). + uint32_t mColumnNumber; uint32_t mErrorNumber; WorkerErrorBase() : mLineNumber(0), mColumnNumber(0), mErrorNumber(0) {} diff --git a/js/public/CompileOptions.h b/js/public/CompileOptions.h index 49fb89b242a1..78f9eb22994e 100644 --- a/js/public/CompileOptions.h +++ b/js/public/CompileOptions.h @@ -455,7 +455,7 @@ class JS_PUBLIC_API ReadOnlyCompileOptions : public TransitiveCompileOptions { // Line number of the first character (1-origin). unsigned lineno = 1; - // Column number of the first character (0-origin). + // Column number of the first character in UTF-16 code units (0-origin). unsigned column = 0; // The offset within the ScriptSource's full uncompressed text of the first diff --git a/js/public/ErrorReport.h b/js/public/ErrorReport.h index 793a98081089..b9680e35a713 100644 --- a/js/public/ErrorReport.h +++ b/js/public/ErrorReport.h @@ -120,7 +120,7 @@ class JSErrorBase { // Source line number (1-origin). unsigned lineno; - // Column number in line (1-origin). + // Column number in line in UTF-16 code units (1-origin). unsigned column; // the error number, e.g. see js/public/friend/ErrorNumbers.msg. diff --git a/js/public/JitCodeAPI.h b/js/public/JitCodeAPI.h index 8f2376d8eb1c..a95b5b65ecdb 100644 --- a/js/public/JitCodeAPI.h +++ b/js/public/JitCodeAPI.h @@ -39,7 +39,7 @@ struct JitCodeSourceInfo { // Line number (1-origin). uint32_t lineno = 0; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). uint32_t colno = 0; }; diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index 1016c670f8c1..f684dc8fc450 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -248,7 +248,7 @@ class BaseStackFrame { // Get this frame's line number (1-origin). virtual uint32_t line() const = 0; - // Get this frame's column number (1-origin). + // Get this frame's column number in UTF-16 code units (1-origin). virtual uint32_t column() const = 0; // Get this frame's source name. Never null. diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h index 36a745b91a90..eb9e488134e6 100644 --- a/js/src/builtin/ModuleObject.h +++ b/js/src/builtin/ModuleObject.h @@ -69,8 +69,12 @@ class ImportEntry { const HeapPtr moduleRequest_; const HeapPtr importName_; const HeapPtr localName_; - const uint32_t lineNumber_; // 1-origin - const uint32_t columnNumber_; // 0-origin + + // Line number (1-origin). + const uint32_t lineNumber_; + + // Column number in UTF-16 code units (0-origin). + const uint32_t columnNumber_; public: ImportEntry(Handle moduleRequest, @@ -93,8 +97,12 @@ class ExportEntry { const HeapPtr moduleRequest_; const HeapPtr importName_; const HeapPtr localName_; - const uint32_t lineNumber_; // 1-origin. - const uint32_t columnNumber_; // 0-origin + + // Line number (1-origin). + const uint32_t lineNumber_; + + // Column number in UTF-16 code units (0-origin). + const uint32_t columnNumber_; public: ExportEntry(Handle maybeExportName, @@ -115,8 +123,12 @@ using ExportEntryVector = GCVector; class RequestedModule { const HeapPtr moduleRequest_; - const uint32_t lineNumber_; // 1-origin - const uint32_t columnNumber_; // 0-origin + + // Line number (1-origin). + const uint32_t lineNumber_; + + // Column number in UTF-16 code units (0-origin). + const uint32_t columnNumber_; public: RequestedModule(Handle moduleRequest, diff --git a/js/src/debugger/Script.cpp b/js/src/debugger/Script.cpp index 315cf48ae11d..d08312d7bc4a 100644 --- a/js/src/debugger/Script.cpp +++ b/js/src/debugger/Script.cpp @@ -1136,7 +1136,7 @@ class FlowGraphSummary { // Line number (1-origin). size_t lineno_; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). size_t column_; }; diff --git a/js/src/doc/Debugger/Debugger.Object.md b/js/src/doc/Debugger/Debugger.Object.md index f6f0893ae80c..732ec231ab69 100644 --- a/js/src/doc/Debugger/Debugger.Object.md +++ b/js/src/doc/Debugger/Debugger.Object.md @@ -166,8 +166,8 @@ If the referent is an Error object, this is the 1-origin line number at which the referent was created; `undefined` otherwise. ### `errorColumnNumber` -If the referent is an Error object, this is the 1-origin column number at which -the referent was created; `undefined` otherwise. +If the referent is an Error object, this is the 1-origin column number in +UTF-16 code units at which the referent was created; `undefined` otherwise. ### `isBoundFunction` If the referent is a debuggee function, returns `true` if the referent is a diff --git a/js/src/doc/Debugger/Debugger.Source.md b/js/src/doc/Debugger/Debugger.Source.md index 167c56f1dbf1..6561cdb23b71 100644 --- a/js/src/doc/Debugger/Debugger.Source.md +++ b/js/src/doc/Debugger/Debugger.Source.md @@ -111,9 +111,10 @@ source within the file or URL it was loaded from. This is normally `1`, but may have another value if the source is part of an HTML document. ### `startColumn` -**If the instance refers to JavaScript source**, the 0-origin start column of -the source within the file or URL it was loaded from. This is normally `0`, but -may have another value if the source is part of an HTML document. +**If the instance refers to JavaScript source**, the 0-origin start column in +UTF-16 code units of the source within the file or URL it was loaded from. This +is normally `0`, but may have another value if the source is part of an HTML +document. ### `id` **If the instance refers to JavaScript source**, an int32 counter that identifies diff --git a/js/src/frontend/BytecodeSection.h b/js/src/frontend/BytecodeSection.h index 8b65ace1f0f3..35dc516d6b51 100644 --- a/js/src/frontend/BytecodeSection.h +++ b/js/src/frontend/BytecodeSection.h @@ -340,7 +340,7 @@ class BytecodeSection { // we can get undefined behavior. uint32_t currentLine_; - // 0-origin column index on currentLine_ of last + // 0-origin column index in UTF-16 code units on currentLine_ of last // SrcNoteType::ColSpan-annotated opcode. // // WARNING: If this becomes out of sync with already-emitted srcnotes, diff --git a/js/src/frontend/Stencil.h b/js/src/frontend/Stencil.h index 0b8031ac373f..98c700d2e4bf 100644 --- a/js/src/frontend/Stencil.h +++ b/js/src/frontend/Stencil.h @@ -611,7 +611,7 @@ class StencilModuleEntry { // Line number (1-origin). uint32_t lineno = 0; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). uint32_t column = 0; private: diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index 538899e63caa..e2c1492f11ef 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -597,8 +597,23 @@ uint32_t TokenStreamAnyChars::computePartialColumn( const SourceUnits& sourceUnits) const { lineToken.assertConsistentOffset(offset); - const uint32_t line = lineNumber(lineToken); const uint32_t start = srcCoords.lineStart(lineToken); + const uint32_t offsetInLine = offset - start; + + if constexpr (std::is_same_v) { + // Column number is in UTF-16 code units. + return offsetInLine; + } + + return computePartialColumnForUTF8(lineToken, offset, start, offsetInLine, + sourceUnits); +} + +template +uint32_t TokenStreamAnyChars::computePartialColumnForUTF8( + const LineToken lineToken, const uint32_t offset, const uint32_t start, + const uint32_t offsetInLine, const SourceUnits& sourceUnits) const { + const uint32_t line = lineNumber(lineToken); // Reset the previous offset/column cache for this line, if the previous // lookup wasn't on this line. @@ -630,13 +645,13 @@ uint32_t TokenStreamAnyChars::computePartialColumn( partialOffset += offsetDelta; if (unitsType == UnitsType::GuaranteedSingleUnit) { - MOZ_ASSERT(unicode::CountCodePoints(begin, end) == offsetDelta, + MOZ_ASSERT(unicode::CountUTF16CodeUnits(begin, end) == offsetDelta, "guaranteed-single-units also guarantee pointer distance " - "equals code point count"); + "equals UTF-16 code unit count"); partialCols += offsetDelta; } else { partialCols += - AssertedCast(unicode::CountCodePoints(begin, end)); + AssertedCast(unicode::CountUTF16CodeUnits(begin, end)); } this->lastOffsetOfComputedColumn_ = partialOffset; @@ -644,8 +659,6 @@ uint32_t TokenStreamAnyChars::computePartialColumn( return partialCols; }; - const uint32_t offsetInLine = offset - start; - // We won't add an entry to |longLineColumnInfo_| for lines where the maximum // column has offset less than this value. The most common (non-minified) // long line length is likely 80ch, maybe 100ch, so we use that, rounded up to @@ -786,16 +799,17 @@ uint32_t TokenStreamAnyChars::computePartialColumn( MOZ_ASSERT(chunkLimit <= limit); size_t numUnits = PointerRangeSize(begin, chunkLimit); - size_t numCodePoints = unicode::CountCodePoints(begin, chunkLimit); + size_t numUTF16CodeUnits = + unicode::CountUTF16CodeUnits(begin, chunkLimit); // If this chunk (which will become non-final at the end of the loop) is // all single-unit code points, annotate the chunk accordingly. - if (numUnits == numCodePoints) { + if (numUnits == numUTF16CodeUnits) { lastChunkVectorForLine_->back().guaranteeSingleUnits(); } partialOffset += numUnits; - partialColumn += numCodePoints; + partialColumn += numUTF16CodeUnits; lastChunkVectorForLine_->infallibleEmplaceBack( partialColumn, UnitsType::PossiblyMultiUnit); diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h index 7ed9b969a8dd..a2ef9478cc1f 100644 --- a/js/src/frontend/TokenStream.h +++ b/js/src/frontend/TokenStream.h @@ -363,12 +363,12 @@ class SourceUnits; * * for either |Unit = Utf8Unit| or |Unit = char16_t|. * - * Note that the latter quantity is *not* the same as a column number, which is - * a count of code *points*. Computing a column number requires the offset - * within the line and the source units of that line (including what type |Unit| - * is, to know how to decode them). If you need a column number, functions in - * |GeneralTokenStreamChars| will consult this and source units to compute - * it. + * Note that, if |Unit = Utf8Unit|, the latter quantity is *not* the same as a + * column number, which is a count of UTF-16 code units. Computing a column + * number requires the offset within the line and the source units of that line + * (including what type |Unit| is, to know how to decode them). If you need a + * column number, functions in |GeneralTokenStreamChars| will consult + * this and source units to compute it. */ class SourceCoords { // For a given buffer holding source code, |lineStartOffsets_| has one @@ -515,7 +515,7 @@ enum class UnitsType : unsigned char { class ChunkInfo { private: - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). // Store everything in |unsigned char|s so everything packs. unsigned char column_[sizeof(uint32_t)]; unsigned char unitsType_; @@ -580,6 +580,7 @@ class TokenStreamAnyChars : public TokenStreamShared { JS::ConstUTF8CharsZ filename_; // Column number computation fields. + // Used only for UTF-8 case. /** * A map of (line number => sequence of the column numbers at @@ -911,7 +912,7 @@ class TokenStreamAnyChars : public TokenStreamShared { private: /** - * Compute the "partial" column number in Unicode code points of the absolute + * Compute the "partial" column number in UTF-16 code units of the absolute * |offset| within source text on the line of |lineToken| (which must have * been computed from |offset|). * @@ -944,13 +945,13 @@ class TokenStreamAnyChars : public TokenStreamShared { * the browser before SpiderMonkey would see it. So the partial column of the * "4" in the inequality would be 16, not 19. * - * Code points are not all equal length, so counting requires *some* kind of - * linear-time counting from the start of the line. This function attempts - * various tricks to reduce this cost. If these optimizations succeed, - * repeated calls to this function on a line will pay a one-time cost linear - * in the length of the line, then each call pays a separate constant-time - * cost. If the optimizations do not succeed, this function works in time - * linear in the length of the line. + * UTF-16 code units are not all equal length in UTF-8 source, so counting + * requires *some* kind of linear-time counting from the start of the line. + * This function attempts various tricks to reduce this cost. If these + * optimizations succeed, repeated calls to this function on a line will pay + * a one-time cost linear in the length of the line, then each call pays a + * separate constant-time cost. If the optimizations do not succeed, this + * function works in time linear in the length of the line. * * It's unusual for a function in *this* class to be |Unit|-templated, but * while this operation manages |Unit|-agnostic fields in this class and in @@ -962,6 +963,11 @@ class TokenStreamAnyChars : public TokenStreamShared { const uint32_t offset, const SourceUnits& sourceUnits) const; + template + uint32_t computePartialColumnForUTF8( + const LineToken lineToken, const uint32_t offset, const uint32_t start, + const uint32_t offsetInLine, const SourceUnits& sourceUnits) const; + /** * Update line/column information for the start of a new line at * |lineStartOffset|. diff --git a/js/src/irregexp/RegExpAPI.cpp b/js/src/irregexp/RegExpAPI.cpp index 475d27b49895..9e240c6c4cbe 100644 --- a/js/src/irregexp/RegExpAPI.cpp +++ b/js/src/irregexp/RegExpAPI.cpp @@ -179,7 +179,7 @@ static size_t ComputeColumn(const Latin1Char* begin, const Latin1Char* end) { } static size_t ComputeColumn(const char16_t* begin, const char16_t* end) { - return unicode::CountCodePoints(begin, end); + return unicode::CountUTF16CodeUnits(begin, end); } // This function is varargs purely so it can call ReportCompileErrorLatin1. diff --git a/js/src/jit/MIRGraph.h b/js/src/jit/MIRGraph.h index 52d6b1fe881a..dbe5680550de 100644 --- a/js/src/jit/MIRGraph.h +++ b/js/src/jit/MIRGraph.h @@ -642,7 +642,7 @@ class MBasicBlock : public TempObject, public InlineListNode { // Line number (1-origin). unsigned lineno_; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). unsigned columnIndex_; public: diff --git a/js/src/jsapi-tests/testPrintError.cpp b/js/src/jsapi-tests/testPrintError.cpp index 769a10064549..31d2c2a95f76 100644 --- a/js/src/jsapi-tests/testPrintError.cpp +++ b/js/src/jsapi-tests/testPrintError.cpp @@ -96,13 +96,13 @@ bool cls_testPrintError_PrintWarning::warningSuccess = false; #define BURRITO "\xF0\x9F\x8C\xAF" -BEGIN_TEST(testPrintError_UTF16CodePoints) { +BEGIN_TEST(testPrintError_UTF16CodeUnits) { AutoStreamBuffer buf; static const char utf8code[] = "function f() {\n var x = `\n" BURRITO "`; " BURRITO "; } f();"; - CHECK(!execDontReport(utf8code, "testPrintError_UTF16CodePoints.js", 1)); + CHECK(!execDontReport(utf8code, "testPrintError_UTF16CodeUnits.js", 1)); JS::ExceptionStack exnStack(cx); CHECK(JS::StealPendingExceptionStack(cx, &exnStack)); @@ -112,14 +112,14 @@ BEGIN_TEST(testPrintError_UTF16CodePoints) { JS::PrintError(buf.stream(), builder, false); CHECK( - buf.contains("testPrintError_UTF16CodePoints.js:3:5 SyntaxError: illegal " + buf.contains("testPrintError_UTF16CodeUnits.js:3:6 SyntaxError: illegal " "character U+1F32F:\n" - "testPrintError_UTF16CodePoints.js:3:5 " BURRITO - "`; " BURRITO "; } f();\n" - "testPrintError_UTF16CodePoints.js:3:5 .....^\n")); + "testPrintError_UTF16CodeUnits.js:3:6 " BURRITO "`; " BURRITO + "; } f();\n" + "testPrintError_UTF16CodeUnits.js:3:6 .....^\n")); return true; } -END_TEST(testPrintError_UTF16CodePoints) +END_TEST(testPrintError_UTF16CodeUnits) #undef BURRITO diff --git a/js/src/util/Text.cpp b/js/src/util/Text.cpp index 317fda5ed04f..e26974a10103 100644 --- a/js/src/util/Text.cpp +++ b/js/src/util/Text.cpp @@ -416,8 +416,8 @@ template size_t js::PutEscapedString(char* buffer, size_t bufferSize, const char16_t* chars, size_t length, uint32_t quote); -size_t js::unicode::CountCodePoints(const Utf8Unit* begin, - const Utf8Unit* end) { +size_t js::unicode::CountUTF16CodeUnits(const Utf8Unit* begin, + const Utf8Unit* end) { MOZ_ASSERT(begin <= end); size_t count = 0; @@ -430,36 +430,14 @@ size_t js::unicode::CountCodePoints(const Utf8Unit* begin, continue; } -#ifdef DEBUG - Maybe cp = -#endif - DecodeOneUtf8CodePoint(lead, &ptr, end); + Maybe cp = DecodeOneUtf8CodePoint(lead, &ptr, end); MOZ_ASSERT(cp.isSome()); + if (*cp > unicode::UTF16Max) { + // This uses surrogate pair. + count++; + } } MOZ_ASSERT(ptr == end, "bad code unit count in line?"); return count; } - -size_t js::unicode::CountCodePoints(const char16_t* begin, - const char16_t* end) { - MOZ_ASSERT(begin <= end); - - size_t count = 0; - - const char16_t* ptr = begin; - while (ptr < end) { - count++; - - if (!IsLeadSurrogate(*ptr++)) { - continue; - } - - if (ptr < end && IsTrailSurrogate(*ptr)) { - ptr++; - } - } - MOZ_ASSERT(ptr == end, "should have consumed the full range"); - - return count; -} diff --git a/js/src/util/Text.h b/js/src/util/Text.h index 9851c9dc344f..52d243a6aabf 100644 --- a/js/src/util/Text.h +++ b/js/src/util/Text.h @@ -355,18 +355,20 @@ bool ContainsFlag(const char* str, const char* flag); namespace unicode { -/** Compute the number of code points in the valid UTF-8 range [begin, end). */ -extern size_t CountCodePoints(const mozilla::Utf8Unit* begin, - const mozilla::Utf8Unit* end); +/** + * Compute the number of UTF-16 code units in the valid UTF-8 range + * [begin, end). + */ +extern size_t CountUTF16CodeUnits(const mozilla::Utf8Unit* begin, + const mozilla::Utf8Unit* end); /** - * Count the number of code points in [begin, end). - * - * Unlike the UTF-8 case above, consistent with legacy ECMAScript practice, - * every sequence of 16-bit units is considered valid. Lone surrogates are - * treated as if they represented a code point of the same value. + * Count the number of UTF-16 code units in [begin, end). */ -extern size_t CountCodePoints(const char16_t* begin, const char16_t* end); +inline size_t CountUTF16CodeUnits(const char16_t* begin, const char16_t* end) { + MOZ_ASSERT(begin <= end); + return end - begin; +} } // namespace unicode diff --git a/js/src/vm/BytecodeUtil-inl.h b/js/src/vm/BytecodeUtil-inl.h index f4e5c1c41fe7..25bc300132eb 100644 --- a/js/src/vm/BytecodeUtil-inl.h +++ b/js/src/vm/BytecodeUtil-inl.h @@ -231,7 +231,7 @@ class BytecodeRangeWithPosition : private BytecodeRange { // Line number (1-origin). size_t lineno; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). size_t column; const SrcNote* sn; diff --git a/js/src/vm/ErrorObject.h b/js/src/vm/ErrorObject.h index 9ddc3b994978..43eb533f2f88 100644 --- a/js/src/vm/ErrorObject.h +++ b/js/src/vm/ErrorObject.h @@ -111,7 +111,7 @@ class ErrorObject : public NativeObject { // Line number (1-origin). inline uint32_t lineNumber() const; - // Column number (1-origin). + // Column number in UTF-16 code units (1-origin). inline uint32_t columnNumber() const; inline JSObject* stack() const; diff --git a/js/src/vm/ErrorReporting.h b/js/src/vm/ErrorReporting.h index 1d77546523cc..0e1c797a3b44 100644 --- a/js/src/vm/ErrorReporting.h +++ b/js/src/vm/ErrorReporting.h @@ -41,7 +41,7 @@ struct ErrorMetadata { // Line number (1-origin). uint32_t lineNumber; - // Column number (0-origin). + // Column number in UTF-16 code units (0-origin). uint32_t columnNumber; // If the error occurs at a particular location, context surrounding the diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index 7343bd4aa65a..ba39bd26602d 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -620,7 +620,8 @@ class ScriptSource { // Line number within the file where this source starts (1-origin). uint32_t startLine_ = 0; - // Column number within the file where this source starts (0-origin). + // Column number within the file where this source starts, + // in UTF-16 code units (0-origin). uint32_t startColumn_ = 0; // See: CompileOptions::mutedErrors. @@ -1542,7 +1543,7 @@ class BaseScript : public gc::TenuredCellWithNonGCPointer { // Line number (1-origin) uint32_t lineno() const { return extent_.lineno; } - // Column number in Unicode Code Points (0-origin) + // Column number in UTF-16 code units (0-origin) uint32_t column() const { return extent_.column; } JS::DelazificationOption delazificationMode() const { diff --git a/js/src/vm/SavedFrame.h b/js/src/vm/SavedFrame.h index 12121a361a16..fbf58fe4b336 100644 --- a/js/src/vm/SavedFrame.h +++ b/js/src/vm/SavedFrame.h @@ -50,7 +50,7 @@ class SavedFrame : public NativeObject { uint32_t getSourceId(); // Line number (1-origin). uint32_t getLine(); - // Column number (1-origin). + // Column number in UTF-16 code units (1-origin). uint32_t getColumn(); JSAtom* getFunctionDisplayName(); JSAtom* getAsyncCause(); diff --git a/js/src/vm/SavedStacks.cpp b/js/src/vm/SavedStacks.cpp index df79133c6218..8fe73ff45620 100644 --- a/js/src/vm/SavedStacks.cpp +++ b/js/src/vm/SavedStacks.cpp @@ -218,7 +218,7 @@ struct MOZ_STACK_CLASS SavedFrame::Lookup { // Line number (1-origin). uint32_t line; - // Columm number (1-origin). + // Columm number in UTF-16 code units (1-origin). uint32_t column; JSAtom* functionDisplayName; diff --git a/js/src/vm/SavedStacks.h b/js/src/vm/SavedStacks.h index 8e128d48bdeb..406471dfc1dd 100644 --- a/js/src/vm/SavedStacks.h +++ b/js/src/vm/SavedStacks.h @@ -269,7 +269,7 @@ class SavedStacks { // Line number (1-origin). size_t line; - // Column number (1-origin). + // Column number in UTF-16 code units (1-origin). uint32_t column; }; diff --git a/js/src/vm/SharedStencil.h b/js/src/vm/SharedStencil.h index 2940c0cab3c8..b01579ebea6a 100644 --- a/js/src/vm/SharedStencil.h +++ b/js/src/vm/SharedStencil.h @@ -219,8 +219,10 @@ struct SourceExtent { uint32_t toStringEnd = 0; // Line and column of |sourceStart_| position. - uint32_t lineno = 1; // Line number (1-origin) - uint32_t column = 0; // Column number in Unicode Code Points (0-origin) + // Line number (1-origin). + uint32_t lineno = 1; + // Column number in UTF-16 code units (0-origin). + uint32_t column = 0; FunctionKey toFunctionKey() const { // In eval("x=>1"), the arrow function will have a sourceStart of 0 which diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index c07b39a0ab13..027f67909d76 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -602,8 +602,10 @@ class ErrorBase { nsString mErrorMsg; nsString mFileName; uint32_t mSourceId; - uint32_t mLineNumber; // 1-origin. - uint32_t mColumn; // 1-origin. + // Line number (1-origin). + uint32_t mLineNumber; + // Column number in UTF-16 code units (1-origin). + uint32_t mColumn; ErrorBase() : mSourceId(0), mLineNumber(0), mColumn(0) {}