Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug 1862693) for causing bustage on nsRFPService.cpp. CLOSED TREE

Backed out changeset a4f3e7625abf (bug 1865005)
Backed out changeset ab38141e470b (bug 1862814)
Backed out changeset a679b50dc4a9 (bug 1862814)
Backed out changeset e340886ce62a (bug 1862814)
Backed out changeset 1378502e64b0 (bug 1862814)
Backed out changeset 8ee94e5e79c2 (bug 1862814)
Backed out changeset 6d4ef1cdfabb (bug 1864168)
Backed out changeset 2c30c4d757fc (bug 1864168)
Backed out changeset d4db9576559b (bug 1864168)
Backed out changeset 8ffec0d83028 (bug 1864168)
Backed out changeset fa77d852b494 (bug 1864168)
Backed out changeset f6646771a26a (bug 1864168)
Backed out changeset 7bd0ff6986df (bug 1864155)
Backed out changeset 39867b503289 (bug 1862693)
This commit is contained in:
Natalia Csoregi 2023-11-22 14:01:55 +02:00
Родитель 000c9b4bb4
Коммит 705aa81869
124 изменённых файлов: 452 добавлений и 505 удалений

Просмотреть файл

@ -555,7 +555,7 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(
csp->LogViolationDetails(violationType,
nullptr, // triggering element
cspEventListener, fileName, scriptSample, lineNum,
columnNum.oneOriginValue(), u""_ns, u""_ns);
columnNum.zeroOriginValue(), u""_ns, u""_ns);
}
return evalOK;

Просмотреть файл

@ -27,10 +27,10 @@ export function createLocation({
sourceActor,
sourceActorId: sourceActor?.id,
// `line` and `column` are 1-based.
// `line` is 1-based while `column` is 0-based.
// This data is mostly coming from and driven by
// JSScript::lineno and JSScript::column
// https://searchfox.org/mozilla-central/rev/90dce6b0223b4dc17bb10f1125b44f70951585f9/js/src/vm/JSScript.h#1545-1548
// https://searchfox.org/mozilla-central/rev/d81e60336d9f498ad3985491dc17c2b77969ade4/js/src/vm/JSScript.h#1544-1547
line,
column,
};

Просмотреть файл

@ -39,7 +39,7 @@ add_task(async function () {
`Content-Security-Policy: The pages settings blocked` +
` the loading of a resource at inline (“style-src”).`;
const VIOLATION_LOCATION_HTML = "test-csp-violation-inline.html:18:1";
const VIOLATION_LOCATION_JS = "test-csp-violation-inline.html:14:25";
const VIOLATION_LOCATION_JS = "test-csp-violation-inline.html:14:24";
await navigateTo(TEST_VIOLATION);
// Triggering the Violation via HTML
let msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION));
@ -70,7 +70,7 @@ add_task(async function () {
"https://example.com/browser/devtools/client/webconsole/" +
"test/browser/test-csp-violation-base-uri.html";
const CSP_VIOLATION = `Content-Security-Policy: The pages settings blocked the loading of a resource at https://evil.com/ (“base-uri”).`;
const VIOLATION_LOCATION = "test-csp-violation-base-uri.html:15:25";
const VIOLATION_LOCATION = "test-csp-violation-base-uri.html:15:24";
await navigateTo(TEST_VIOLATION);
let msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION));
ok(msg, "Base-URI validation was Printed");
@ -95,7 +95,7 @@ add_task(async function () {
"https://example.com/browser/devtools/client/webconsole/" +
"test/browser/test-csp-violation-form-action.html";
const CSP_VIOLATION = `Content-Security-Policy: The pages settings blocked the loading of a resource at https://evil.com/evil.com (“form-action”).`;
const VIOLATION_LOCATION = "test-csp-violation-form-action.html:14:40";
const VIOLATION_LOCATION = "test-csp-violation-form-action.html:14:39";
await navigateTo(TEST_VIOLATION);
const msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION));

Просмотреть файл

@ -47,7 +47,7 @@ async function testHeaderNotReturningJsonMl(hud) {
info(`Test for "header" not returning JsonML`);
await testCustomFormatting(hud, {
messageText: `Custom formatter failed: devtoolsFormatters[1].header should return an array, got number`,
source: "test-console-custom-formatters-errors.html:19:19",
source: "test-console-custom-formatters-errors.html:19:18",
});
}

Просмотреть файл

@ -174,7 +174,7 @@ The functions described below may only be called with a ``this`` value referring
The elements of the array are objects, each of which describes a single entry point, and contains the following properties:
- lineNumber: the line number for which offset is an entry point
- columnNumber: the 1-based column number for which offset is an entry point
- columnNumber: the column number for which offset is an entry point
- offset: the bytecode instruction offset of the entry point
@ -191,10 +191,10 @@ The functions described below may only be called with a ``this`` value referring
.. code-block:: javascript
[{ lineNumber: 0, columnNumber: 1, offset: 0 },
{ lineNumber: 1, columnNumber: 6, offset: 5 },
{ lineNumber: 1, columnNumber: 11, offset: 20 },
{ lineNumber: 3, columnNumber: 5, offset: 10 }]
[{ lineNumber: 0, columnNumber: 0, offset: 0 },
{ lineNumber: 1, columnNumber: 5, offset: 5 },
{ lineNumber: 1, columnNumber: 10, offset: 20 },
{ lineNumber: 3, columnNumber: 4, offset: 10 }]
**If the instance refers to WebAssembly code**, throw a ``TypeError``.
@ -205,7 +205,7 @@ The functions described below may only be called with a ``this`` value referring
**If the instance refers to a JSScript**, return an object describing the source code location responsible for the bytecode at *offset* in this script. The object has the following properties:
- lineNumber: the line number for which offset is an entry point
- columnNumber: the 1-based column number for which offset is an entry point
- columnNumber: the column number for which offset is an entry point
- isEntryPoint: true if the offset is a column entry point, as would be reported by getAllColumnOffsets(); otherwise false.
@ -213,7 +213,7 @@ The functions described below may only be called with a ``this`` value referring
**If the instance refers to a JSScript**, return ``null`` or an array which contains information about the coverage of all opcodes. The elements of the array are objects, each of which describes a single opcode, and contains the following properties:
- lineNumber: the line number of the current opcode.
- columnNumber: the 1-based column number of the current opcode.
- columnNumber: the column number of the current opcode.
- offset: the bytecode instruction offset of the current opcode.
- count: the number of times the current opcode got executed.

Просмотреть файл

@ -238,6 +238,8 @@ The functions described below may only be called with a ``this`` value referring
The scripts ``source`` property must be equal to this value.
``line``
The script must at least partially cover the given source line. If this property is present, the ``url`` property must be present as well.
``column``
The script must include given column on the line given by the ``line`` property. If this property is present, the ``url`` and ``line`` properties must both be present as well.
``innermost``
If this property is present and true, the script must be the innermost script covering the given source location; scripts of enclosing code are omitted.
``global``

Просмотреть файл

@ -968,13 +968,8 @@ class EventCollector {
if (script) {
const scriptSource = script.source.text;
// NOTE: Debugger.Script.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
line = script.startLine;
column = script.startColumn - columnBase;
column = script.startColumn;
url = script.url;
const actor = this.targetActor.sourcesManager.getOrCreateSourceActor(
script.source

Просмотреть файл

@ -506,15 +506,10 @@ class NodeActor extends Actor {
return undefined;
}
// NOTE: Debugger.Script.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = customElementDO.script.format === "wasm" ? 0 : 1;
return {
url: customElementDO.script.url,
line: customElementDO.script.startLine,
column: customElementDO.script.startColumn - columnBase,
column: customElementDO.script.startColumn,
};
}

Просмотреть файл

@ -156,14 +156,10 @@ const previewers = {
grip.isGenerator = obj.isGeneratorFunction;
if (obj.script) {
// NOTE: Debugger.Script.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = obj.script.format === "wasm" ? 0 : 1;
grip.location = {
url: obj.script.url,
line: obj.script.startLine,
column: obj.script.startColumn - columnBase,
column: obj.script.startColumn,
};
}

Просмотреть файл

@ -193,11 +193,6 @@ class SourceActor extends Actor {
introductionType = "scriptElement";
}
// NOTE: Debugger.Source.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = source.introductionType === "wasm" ? 0 : 1;
return {
actor: this.actorID,
extensionName: this.extensionName,
@ -211,7 +206,7 @@ class SourceActor extends Actor {
introductionType,
isInlineSource: this._isInlineSource,
sourceStartLine: source.startLine,
sourceStartColumn: source.startColumn - columnBase,
sourceStartColumn: source.startColumn,
sourceLength: source.text?.length,
};
}
@ -416,15 +411,10 @@ class SourceActor extends Actor {
return false;
}
// NOTE: Debugger.Script.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
if (
script.startLine > endLine ||
script.startLine + lineCount <= startLine ||
(script.startLine == endLine &&
script.startColumn - columnBase > endColumn)
(script.startLine == endLine && script.startColumn > endColumn)
) {
return false;
}
@ -432,7 +422,7 @@ class SourceActor extends Actor {
if (
lineCount == 1 &&
script.startLine == startLine &&
script.startColumn - columnBase + script.sourceLength <= startColumn
script.startColumn + script.sourceLength <= startColumn
) {
return false;
}
@ -479,25 +469,20 @@ class SourceActor extends Actor {
end: { line: endLine = Infinity, column: endColumn = Infinity } = {},
} = query || {};
// NOTE: Debugger.Script.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
const offsets = script.getPossibleBreakpoints();
for (const { lineNumber, columnNumber } of offsets) {
if (
lineNumber < startLine ||
(lineNumber === startLine && columnNumber - columnBase < startColumn) ||
(lineNumber === startLine && columnNumber < startColumn) ||
lineNumber > endLine ||
(lineNumber === endLine && columnNumber - columnBase >= endColumn)
(lineNumber === endLine && columnNumber >= endColumn)
) {
continue;
}
positions.push({
line: lineNumber,
column: columnNumber - columnBase,
column: columnNumber,
});
}
}
@ -625,11 +610,6 @@ class SourceActor extends Actor {
script => !actor.hasScript(script)
);
// NOTE: Debugger.Script.prototype.getPossibleBreakpoints returns
// columnNumber in 1-based.
// The following code uses columnNumber only for comparing against
// other columnNumber, and we don't need to convert to 0-based.
// This is a line breakpoint, so we add a breakpoint on the first
// breakpoint on the line.
const lineMatches = [];
@ -664,19 +644,13 @@ class SourceActor extends Actor {
);
for (const script of scripts) {
// NOTE: getPossibleBreakpoints's minColumn/maxColumn parameters are
// 1-based.
// Convert to 1-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
// Check to see if the script contains a breakpoint position at
// this line and column.
const possibleBreakpoint = script
.getPossibleBreakpoints({
line,
minColumn: column + columnBase,
maxColumn: column + columnBase + 1,
minColumn: column,
maxColumn: column + 1,
})
.pop();

Просмотреть файл

@ -2254,11 +2254,7 @@ class ThreadActor extends Actor {
...content.substring(0, scriptStartOffset).matchAll("\n"),
];
const startLine = 1 + allLineBreaks.length;
// NOTE: Debugger.Source.prototype.startColumn is 1-based.
// Create 1-based column here for the following comparison,
// and also the createSource call below.
const startColumn =
1 +
scriptStartOffset -
(allLineBreaks.length ? allLineBreaks.at(-1).index - 1 : 0);
@ -2274,7 +2270,6 @@ class ThreadActor extends Actor {
try {
const global = this.dbg.getDebuggees()[0];
// NOTE: Debugger.Object.prototype.createSource takes 1-based column.
this._addSource(
global.createSource({
text,

Просмотреть файл

@ -149,20 +149,8 @@ class TracerActor extends Actor {
const { lineNumber, columnNumber } = script.getOffsetMetadata(frame.offset);
const url = script.source.url;
// NOTE: Debugger.Script.prototype.getOffsetMetadata returns
// columnNumber in 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
// Ignore blackboxed sources
if (
this.sourcesManager.isBlackBoxed(
url,
lineNumber,
columnNumber - columnBase
)
) {
if (this.sourcesManager.isBlackBoxed(url, lineNumber, columnNumber)) {
return false;
}
@ -197,7 +185,7 @@ class TracerActor extends Actor {
this.throttledConsoleMessages.push({
filename: url,
lineNumber,
columnNumber: columnNumber - columnBase,
columnNumber,
arguments: args,
styles: CONSOLE_ARGS_STYLES,
level: "logTrace",

Просмотреть файл

@ -228,14 +228,10 @@ class SourcesManager extends EventEmitter {
*/
getScriptOffsetLocation(script, offset) {
const { lineNumber, columnNumber } = script.getOffsetMetadata(offset);
// NOTE: Debugger.Source.prototype.startColumn is 1-based.
// Convert to 0-based, while keeping the wasm's column (1) as is.
// (bug 1863878)
const columnBase = script.format === "wasm" ? 0 : 1;
return new SourceLocation(
this.createSourceActor(script.source),
lineNumber,
columnNumber - columnBase
columnNumber
);
}

Просмотреть файл

@ -442,14 +442,8 @@ DevToolsStartup.prototype = {
}
}
// line and column are supposed to be 1-based.
const { url, line, column } = match.groups;
// Debugger internal uses 0-based column number.
// NOTE: Non-debugger view-source doesn't use column number.
const columnOneBased = parseInt(column || 0, 10);
const columnZeroBased = columnOneBased > 0 ? columnOneBased - 1 : 0;
// If for any reason the final url is invalid, ignore it
try {
Services.io.newURI(url);
@ -487,7 +481,7 @@ DevToolsStartup.prototype = {
toolbox.viewSourceInDebugger(
url,
parseInt(line, 10),
columnZeroBased,
parseInt(column || 0, 10),
null,
"CommandLine"
);

Просмотреть файл

@ -121,7 +121,7 @@ add_task(async function openingWithDevToolsAndKnownSource() {
});
is(selectedLocation.source.url, URL_ROOT + "command-line.js");
is(selectedLocation.line, 5);
is(selectedLocation.column, 1);
is(selectedLocation.column, 2);
info("Open another URL with only a line");
const url2 = URL_ROOT + "command-line.js:6";

Просмотреть файл

@ -378,7 +378,7 @@ EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
mIsShutDown(false),
mSharedData(SharedData{aEventSource}, "EventSourceImpl::mSharedData"),
mScriptLine(0),
mScriptColumn(1),
mScriptColumn(0),
mInnerWindowID(0),
mCookieJarSettings(aCookieJarSettings),
mTargetThread(NS_GetCurrentThread()) {

Просмотреть файл

@ -37,7 +37,7 @@ class TimeoutHandler : public nsISupports {
virtual void MarkForCC() {}
protected:
TimeoutHandler() : mFileName(""), mLineNo(0), mColumn(1) {}
TimeoutHandler() : mFileName(""), mLineNo(0), mColumn(0) {}
explicit TimeoutHandler(JSContext* aCx);
virtual ~TimeoutHandler() = default;

Просмотреть файл

@ -1177,7 +1177,7 @@ class nsContentUtils {
contains the error (may be empty).
* @param [aLineNumber=0] (Optional) Line number within resource
containing error.
* @param [aColumnNumber=1] (Optional) Column number within resource
* @param [aColumnNumber=0] (Optional) Column number within resource
containing error.
If aURI is null, then aDocument->GetDocumentURI() is used.
* @param [aLocationMode] (Optional) Specifies the behavior if
@ -1187,7 +1187,7 @@ class nsContentUtils {
const nsAString& aErrorText, uint32_t aErrorFlags,
const nsACString& aCategory, uint64_t aInnerWindowID,
nsIURI* aURI = nullptr, const nsString& aSourceLine = u""_ns,
uint32_t aLineNumber = 0, uint32_t aColumnNumber = 1,
uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0,
MissingErrorLocationMode aLocationMode = eUSE_CALLING_LOCATION);
/**

Просмотреть файл

@ -456,7 +456,7 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx,
do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
nsAutoString filename;
uint32_t lineno = 0, column = 1;
uint32_t lineno = 0, column = 0;
nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column);
nsCOMPtr<nsIScriptError> error(
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));

Просмотреть файл

@ -56,7 +56,7 @@ bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
return false;
}
if (aColumn) {
*aColumn = column.oneOriginValue();
*aColumn = column.zeroOriginValue();
}
return aFilename.Assign(filename.get(), fallible);
@ -70,7 +70,7 @@ bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename,
return false;
}
if (aColumn) {
*aColumn = column.oneOriginValue();
*aColumn = column.zeroOriginValue();
}
return aFilename.Assign(NS_ConvertUTF8toUTF16(filename.get()), fallible);

Просмотреть файл

@ -181,7 +181,7 @@ void nsStyledElement::ParseStyleAttribute(const nsAString& aValue,
if (!isNativeAnon &&
!nsStyleUtil::CSPAllowsInlineStyle(this, doc, aMaybeScriptedPrincipal, 0,
1, aValue, nullptr))
0, aValue, nullptr))
return;
if (aForceInDataDoc || !doc->IsLoadedAsData() || GetExistingStyle() ||

Просмотреть файл

@ -4237,7 +4237,7 @@ void MaybeReportDeprecation(const GlobalObject& aGlobal,
Nullable<uint32_t> lineNumber;
Nullable<uint32_t> columnNumber;
uint32_t line = 0;
uint32_t column = 1;
uint32_t column = 0;
if (nsJSUtils::GetCallingLocation(aGlobal.Context(), fileName, &line,
&column)) {
lineNumber.SetValue(line);

Просмотреть файл

@ -1046,7 +1046,7 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
true, // aParserCreated (true because attribute event handler)
aElement,
nullptr, // nsICSPEventListener
aBody, lineNum, columnNum.oneOriginValue(), &allowsInlineScript);
aBody, lineNum, columnNum.zeroOriginValue(), &allowsInlineScript);
NS_ENSURE_SUCCESS(rv, rv);
// return early if CSP wants us to block inline scripts

Просмотреть файл

@ -1694,7 +1694,7 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
u""_ns, // aSourceFile
u""_ns, // aScriptSample
0, // aLineNumber
1, // aColumnNumber
0, // aColumnNumber
nsIScriptError::warningFlag, "upgradeInsecureRequest"_ns,
document->InnerWindowID(),
!!document->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId);

Просмотреть файл

@ -184,8 +184,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "HTML"_ns, OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, "ScriptSourceInvalidUri", params,
nullptr, u""_ns, GetScriptLineNumber(),
GetScriptColumnNumber().oneOriginValue());
nullptr, u""_ns, GetScriptLineNumber(), GetScriptColumnNumber());
}
} else {
AutoTArray<nsString, 1> params = {u"src"_ns};
@ -193,8 +192,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "HTML"_ns, OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, "ScriptSourceEmpty", params, nullptr,
u""_ns, GetScriptLineNumber(),
GetScriptColumnNumber().oneOriginValue());
u""_ns, GetScriptLineNumber(), GetScriptColumnNumber());
}
// At this point mUri will be null for invalid URLs.

Просмотреть файл

@ -161,7 +161,7 @@ static bool AllowedByCSP(nsIContentSecurityPolicy* aCSP,
nullptr, // nsICSPEventListener
NS_ConvertASCIItoUTF16(aJavaScriptURL), // aContent
0, // aLineNumber
1, // aColumnNumber
0, // aColumnNumber
&allowsInlineScript);
return (NS_SUCCEEDED(rv) && allowsInlineScript);

Просмотреть файл

@ -81,7 +81,7 @@ void WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID,
}
nsAutoString spec;
uint32_t aLineNumber = 0, aColumnNumber = 1;
uint32_t aLineNumber = 0, aColumnNumber = 0;
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx) {
nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber, &aColumnNumber);

Просмотреть файл

@ -35,7 +35,7 @@ function test_deprecatedInterface() {
"We have a sourceFile"
);
is(report.body.lineNumber, 48, "We have a lineNumber");
is(report.body.columnNumber, 24, "We have a columnNumber");
is(report.body.columnNumber, 23, "We have a columnNumber");
obs.disconnect();
resolve();
@ -87,7 +87,7 @@ function test_deprecatedMethod() {
"We have a sourceFile"
);
is(report.body.lineNumber, 100, "We have a lineNumber");
is(report.body.columnNumber, 22, "We have a columnNumber");
is(report.body.columnNumber, 21, "We have a columnNumber");
obs.disconnect();
resolve();
@ -168,7 +168,7 @@ function test_deprecatedAttribute() {
"We have a sourceFile"
);
is(report.body.lineNumber, 181, "We have a lineNumber");
is(report.body.columnNumber, 8, "We have a columnNumber");
is(report.body.columnNumber, 7, "We have a columnNumber");
obs.disconnect();
resolve();

Просмотреть файл

@ -60,7 +60,7 @@ function runTests(extraParams = "") {
is(report.body.body.message, "TestingDeprecatedInterface is a testing-only interface and this is its testing deprecation message.", "We have a report.body.message");
is(report.body.body.sourceFile, "https://example.org/tests/dom/reporting/tests/iframe_delivering.html", "report.body.sourceFile");
is(report.body.body.lineNumber, 40, "report.body.lineNumber");
is(report.body.body.columnNumber, 5, "report.body.columnNumber");
is(report.body.body.columnNumber, 4, "report.body.columnNumber");
});
}

Просмотреть файл

@ -8,7 +8,6 @@
#define mozilla_dom_ScriptLoadContext_h
#include "js/AllocPolicy.h"
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
#include "js/CompileOptions.h" // JS::OwningCompileOptions
#include "js/experimental/JSStencil.h" // JS::FrontendContext, JS::Stencil, JS::InstantiationStorage
#include "js/RootingAPI.h"
@ -235,7 +234,7 @@ class ScriptLoadContext : public JS::loader::LoadContextBase,
RefPtr<CompileOrDecodeTask> mCompileOrDecodeTask;
uint32_t mLineNo;
JS::ColumnNumberOneOrigin mColumnNo;
uint32_t mColumnNo;
// Set on scripts and top level modules.
bool mIsPreload;

Просмотреть файл

@ -919,8 +919,8 @@ static bool CSPAllowsInlineScript(nsIScriptElement* aElement,
nsIContentSecurityPolicy::SCRIPT_SRC_ELEM_DIRECTIVE,
false /* aHasUnsafeHash */, aNonce, parserCreated, element,
nullptr /* nsICSPEventListener */, u""_ns,
aElement->GetScriptLineNumber(),
aElement->GetScriptColumnNumber().oneOriginValue(), &allowInlineScript);
aElement->GetScriptLineNumber(), aElement->GetScriptColumnNumber(),
&allowInlineScript);
return NS_SUCCEEDED(rv) && allowInlineScript;
}
@ -2331,7 +2331,8 @@ nsresult ScriptLoader::FillCompileOptionsForRequest(
if (aRequest->GetScriptLoadContext()->mIsInline &&
aRequest->GetScriptLoadContext()->GetParserCreated() ==
FROM_PARSER_NETWORK) {
aOptions->setColumn(aRequest->GetScriptLoadContext()->mColumnNo);
aOptions->setColumn(JS::ColumnNumberOneOrigin::fromZeroOrigin(
aRequest->GetScriptLoadContext()->mColumnNo));
}
aOptions->setIsRunOnce(true);
aOptions->setNoScriptRval(true);
@ -3415,15 +3416,12 @@ void ScriptLoader::ReportErrorToConsole(ScriptLoadRequest* aRequest,
nsIScriptElement* element =
aRequest->GetScriptLoadContext()->GetScriptElement();
uint32_t lineNo = element ? element->GetScriptLineNumber() : 0;
JS::ColumnNumberOneOrigin columnNo;
if (element) {
columnNo = element->GetScriptColumnNumber();
}
uint32_t columnNo = element ? element->GetScriptColumnNumber() : 0;
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "Script Loader"_ns, mDocument,
nsContentUtils::eDOM_PROPERTIES, message, params, nullptr, u""_ns, lineNo,
columnNo.oneOriginValue());
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"Script Loader"_ns, mDocument,
nsContentUtils::eDOM_PROPERTIES, message,
params, nullptr, u""_ns, lineNo, columnNo);
}
void ScriptLoader::ReportWarningToConsole(
@ -3432,14 +3430,11 @@ void ScriptLoader::ReportWarningToConsole(
nsIScriptElement* element =
aRequest->GetScriptLoadContext()->GetScriptElement();
uint32_t lineNo = element ? element->GetScriptLineNumber() : 0;
JS::ColumnNumberOneOrigin columnNo;
if (element) {
columnNo = element->GetScriptColumnNumber();
}
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "Script Loader"_ns, mDocument,
nsContentUtils::eDOM_PROPERTIES, aMessageName, aParams, nullptr, u""_ns,
lineNo, columnNo.oneOriginValue());
uint32_t columnNo = element ? element->GetScriptColumnNumber() : 0;
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"Script Loader"_ns, mDocument,
nsContentUtils::eDOM_PROPERTIES, aMessageName,
aParams, nullptr, u""_ns, lineNo, columnNo);
}
void ScriptLoader::ReportPreloadErrorsToConsole(ScriptLoadRequest* aRequest) {

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef nsIScriptElement_h___
#define nsIScriptElement_h___
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
#include "js/loader/ScriptKind.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Assertions.h"
@ -159,11 +158,11 @@ class nsIScriptElement : public nsIScriptLoaderObserver {
uint32_t GetScriptLineNumber() { return mLineNumber; }
void SetScriptColumnNumber(JS::ColumnNumberOneOrigin aColumnNumber) {
void SetScriptColumnNumber(uint32_t aColumnNumber) {
mColumnNumber = aColumnNumber;
}
JS::ColumnNumberOneOrigin GetScriptColumnNumber() { return mColumnNumber; }
uint32_t GetScriptColumnNumber() { return mColumnNumber; }
void SetIsMalformed() { mMalformed = true; }
@ -300,7 +299,7 @@ class nsIScriptElement : public nsIScriptLoaderObserver {
/**
* The start column number of the script.
*/
JS::ColumnNumberOneOrigin mColumnNumber;
uint32_t mColumnNumber;
/**
* The "already started" flag per HTML5.

Просмотреть файл

@ -131,7 +131,7 @@ nsresult CSPEvalChecker::CheckForWindow(JSContext* aCx,
// Get the calling location.
uint32_t lineNum = 0;
uint32_t columnNum = 1;
uint32_t columnNum = 0;
nsAutoString fileNameString;
if (!nsJSUtils::GetCallingLocation(aCx, fileNameString, &lineNum,
&columnNum)) {
@ -164,7 +164,7 @@ nsresult CSPEvalChecker::CheckForWorker(JSContext* aCx,
// Get the calling location.
uint32_t lineNum = 0;
uint32_t columnNum = 1;
uint32_t columnNum = 0;
nsAutoString fileNameString;
if (!nsJSUtils::GetCallingLocation(aCx, fileNameString, &lineNum,
&columnNum)) {

Просмотреть файл

@ -36,7 +36,7 @@ void DOMSecurityMonitor::AuditParsingOfHTMLXMLFragments(
// originating from JS code.
nsAutoString filename;
uint32_t lineNum = 0;
uint32_t columnNum = 1;
uint32_t columnNum = 0;
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (!cx ||
!nsJSUtils::GetCallingLocation(cx, filename, &lineNum, &columnNum)) {

Просмотреть файл

@ -210,13 +210,13 @@ bool nsCSPContext::permitsInternal(
// nonce, and will incorrectly fail the unit tests.
if (aSendViolationReports) {
uint32_t lineNumber = 0;
uint32_t columnNumber = 1;
uint32_t columnNumber = 0;
nsAutoString spec;
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx) {
nsJSUtils::GetCallingLocation(cx, spec, &lineNumber, &columnNumber);
// If GetCallingLocation fails linenumber & columnNumber are set to
// (0, 1) anyway so we can skip checking if that is the case.
// If GetCallingLocation fails linenumber & columnNumber are set to 0
// anyway so we can skip checking if that is the case.
}
AsyncReportViolation(
aTriggeringElement, aCSPEventListener,
@ -732,13 +732,13 @@ nsCSPContext::GetAllowsNavigateTo(nsIURI* aURI, bool aIsFormSubmission,
// Lines numbers and source file for the violation report
uint32_t lineNumber = 0;
uint32_t columnNumber = 1;
uint32_t columnNumber = 0;
nsAutoCString spec;
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx) {
nsJSUtils::GetCallingLocation(cx, spec, &lineNumber, &columnNumber);
// If GetCallingLocation fails linenumber & columnNumber are set to
// (0, 1) anyway so we can skip checking if that is the case.
// If GetCallingLocation fails linenumber & columnNumber are set to 0
// anyway so we can skip checking if that is the case.
}
// Report the violation
@ -1848,7 +1848,7 @@ nsCSPContext::GetCSPSandboxFlags(uint32_t* aOutSandboxFlags) {
NS_ConvertUTF16toUTF8(policy).get()));
AutoTArray<nsString, 1> params = {policy};
logToConsole("ignoringReportOnlyDirective", params, u""_ns, u""_ns, 0, 1,
logToConsole("ignoringReportOnlyDirective", params, u""_ns, u""_ns, 0, 0,
nsIScriptError::warningFlag);
}
}

Просмотреть файл

@ -174,7 +174,7 @@ void nsCSPParser::logWarningErrorToConsole(uint32_t aSeverityFlag,
u""_ns, // aSourceName
u""_ns, // aSourceLine
0, // aLineNumber
1, // aColumnNumber
0, // aColumnNumber
aSeverityFlag); // aFlags
}

Просмотреть файл

@ -687,7 +687,7 @@ bool nsContentSecurityUtils::IsEvalAllowed(JSContext* cx,
// Check the allowlist for the provided filename. getFilename is a helper
// function
nsAutoCString fileName;
uint32_t lineNumber = 0, columnNumber = 1;
uint32_t lineNumber = 0, columnNumber = 0;
nsJSUtils::GetCallingLocation(cx, fileName, &lineNumber, &columnNumber);
if (fileName.IsEmpty()) {
fileName = "unknown-file"_ns;
@ -1152,7 +1152,7 @@ void EnforceXFrameOptionsCheck(nsIChannel* aChannel,
u""_ns, // no sourcefile
u""_ns, // no scriptsample
0, // no linenumber
1, // no columnnumber
0, // no columnnumber
nsIScriptError::warningFlag,
"IgnoringSrcBecauseOfDirective"_ns, innerWindowID,
privateWindow);

Просмотреть файл

@ -810,7 +810,7 @@ nsresult nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect,
u""_ns, // aSourceFile
u""_ns, // aScriptSample
0, // aLineNumber
1, // aColumnNumber
0, // aColumnNumber
nsIScriptError::errorFlag, "blockAllMixedContent"_ns,
requestingWindow->Id(),
!!aLoadInfo->GetOriginAttributes().mPrivateBrowsingId);

Просмотреть файл

@ -140,8 +140,8 @@ function run_test() {
null, // nsICSPEventListener
"", // aContentOfPseudoScript
0, // aLineNumber
1 // aColumnNumber
);
0
); // aColumnNumber
// this is not a report only policy, so it better block inline scripts
Assert.ok(!inlineOK);
@ -181,8 +181,8 @@ function run_test() {
// note that JSON is UTF8 encoded.
"\u00a3\u00a5\u00b5\u5317\ud841\udf79",
1, // line number
2 // column number
);
2
); // column number
}
}
);
@ -220,8 +220,8 @@ function run_test() {
null, // nsICSPEventListener
"", // aContentOfPseudoScript
0, // aLineNumber
1 // aColumnNumber
);
0
); // aColumnNumber
// this is a report only policy, so it better allow inline scripts
Assert.ok(inlineOK);
@ -248,8 +248,8 @@ function run_test() {
selfuri.asciiSpec,
"script sample",
4, // line number
5 // column number
);
5
); // column number
}
});

Просмотреть файл

@ -112,7 +112,7 @@ CancelChannelRunnable::Run() {
FetchEvent::FetchEvent(EventTarget* aOwner)
: ExtendableEvent(aOwner),
mPreventDefaultLineNumber(0),
mPreventDefaultColumnNumber(1),
mPreventDefaultColumnNumber(0),
mWaitToRespond(false) {}
FetchEvent::~FetchEvent() = default;
@ -771,7 +771,7 @@ void FetchEvent::RespondWith(JSContext* aCx, Promise& aArg, ErrorResult& aRv) {
// a file:// string here because service workers require http/https.
nsCString spec;
uint32_t line = 0;
uint32_t column = 1;
uint32_t column = 0;
nsJSUtils::GetCallingLocation(aCx, spec, &line, &column);
SafeRefPtr<InternalRequest> ir = mRequest->GetInternalRequest();
@ -865,7 +865,7 @@ class WaitUntilHandler final : public PromiseNativeHandler {
: mWorkerPrivate(aWorkerPrivate),
mScope(mWorkerPrivate->ServiceWorkerScope()),
mLine(0),
mColumn(1) {
mColumn(0) {
mWorkerPrivate->AssertIsOnWorkerThread();
// Save the location of the waitUntil() call itself as a fallback

Просмотреть файл

@ -453,7 +453,7 @@ void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID,
}
Document* doc = aTargetElement->GetComposedDoc();
if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 1,
if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 0,
aString, nullptr)) {
return;
}
@ -490,7 +490,7 @@ SMILValue SMILCSSValueType::ValueFromAnimationValue(
// and an intermediate CSS value is not likely to be particularly useful
// in that case, we just use a generic placeholder string instead.
static const nsLiteralString kPlaceholderText = u"[SVG animation of CSS]"_ns;
if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 1,
if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 0,
kPlaceholderText, nullptr)) {
return result;
}

Просмотреть файл

@ -141,8 +141,7 @@ void SVGScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "SVG"_ns, OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, "ScriptSourceInvalidUri", params,
nullptr, u""_ns, GetScriptLineNumber(),
GetScriptColumnNumber().oneOriginValue());
nullptr, u""_ns, GetScriptLineNumber(), GetScriptColumnNumber());
}
} else {
AutoTArray<nsString, 1> params = {isHref ? u"href"_ns : u"xlink:href"_ns};
@ -150,8 +149,7 @@ void SVGScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) {
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag, "SVG"_ns, OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES, "ScriptSourceEmpty", params, nullptr,
u""_ns, GetScriptLineNumber(),
GetScriptColumnNumber().oneOriginValue());
u""_ns, GetScriptLineNumber(), GetScriptColumnNumber());
}
// At this point mUri will be null for invalid URLs.

Просмотреть файл

@ -301,7 +301,7 @@ static bool AssertParentProcessWithCallerLocationImpl(GlobalObject& aGlobal,
NS_ENSURE_TRUE(scriptFilename.get(), false);
reason.AppendPrintf(" Called from %s:%d:%d.", scriptFilename.get(), lineNo,
colNo.oneOriginValue());
colNo.zeroOriginValue());
return false;
}

Просмотреть файл

@ -134,7 +134,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL),
mPort(0),
mScriptLine(0),
mScriptColumn(1),
mScriptColumn(0),
mInnerWindowID(0),
mPrivateBrowsing(false),
mIsChromeContext(false),
@ -229,8 +229,8 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
// Web Socket owner information:
// - the script file name, UTF8 encoded.
// - source code line number and 1-origin column number where the Web Socket
// object was constructed.
// - source code line number and column number where the Web Socket object
// was constructed.
// - the ID of the Web Socket owner window. Note that this may not
// be the same as the inner window where the script lives.
// e.g within iframes
@ -1382,7 +1382,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
workerPrivate, webSocketImpl,
workerPrivate->GlobalScope()->GetClientInfo(), !!aTransportProvider,
aUrl, protocolArray, nsDependentCString(file.get()), lineno,
column.oneOriginValue());
column.zeroOriginValue());
runnable->Dispatch(Canceling, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
@ -1615,7 +1615,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) {
mScriptFile = file.get();
mScriptLine = lineno;
mScriptColumn = column.oneOriginValue();
mScriptColumn = column.zeroOriginValue();
}
}
@ -1728,7 +1728,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
u""_ns, // aSourceFile
u""_ns, // aScriptSample
0, // aLineNumber
1, // aColumnNumber
0, // aColumnNumber
nsIScriptError::warningFlag,
"upgradeInsecureRequest"_ns, mInnerWindowID,
mPrivateBrowsing);

Просмотреть файл

@ -531,7 +531,7 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::RuntimeCode aKind,
RefPtr<LogViolationDetailsRunnable> runnable =
new LogViolationDetailsRunnable(worker, violationType, fileName,
lineNum, columnNum.oneOriginValue(),
lineNum, columnNum.zeroOriginValue(),
scriptSample);
ErrorResult rv;

Просмотреть файл

@ -53,7 +53,6 @@
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/UseCounter.h"
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
using namespace mozilla;
using namespace mozilla::dom;
@ -488,8 +487,7 @@ nsresult nsXMLContentSink::CreateElement(
aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_SVG)) {
if (nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(element)) {
sele->SetScriptLineNumber(aLineNumber);
sele->SetScriptColumnNumber(
JS::ColumnNumberOneOrigin::fromZeroOrigin(aColumnNumber));
sele->SetScriptColumnNumber(aColumnNumber);
sele->SetCreatorParser(GetParser());
} else {
MOZ_ASSERT(nsNameSpaceManager::GetInstance()->mSVGDisabled,
@ -521,7 +519,7 @@ nsresult nsXMLContentSink::CreateElement(
}
if (!aNodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
linkStyle->SetLineNumber(aFromParser ? aLineNumber : 0);
linkStyle->SetColumnNumber(aFromParser ? aColumnNumber + 1 : 1);
linkStyle->SetColumnNumber(aFromParser ? aColumnNumber : 0);
}
}
@ -1324,7 +1322,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText,
parsererror.Append((char16_t)0xFFFF);
parsererror.AppendLiteral("parsererror");
rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1, 0);
rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = HandleCharacterData(aErrorText, NS_strlen(aErrorText), false);
@ -1334,7 +1332,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText,
sourcetext.Append((char16_t)0xFFFF);
sourcetext.AppendLiteral("sourcetext");
rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1, 0);
rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = HandleCharacterData(aSourceText, NS_strlen(aSourceText), false);

Просмотреть файл

@ -7,7 +7,6 @@
#ifndef nsXMLContentSink_h__
#define nsXMLContentSink_h__
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
#include "mozilla/Attributes.h"
#include "nsContentSink.h"
#include "nsIXMLContentSink.h"

Просмотреть файл

@ -5,15 +5,9 @@
// [SMDOC] Column numbers
//
// Inside SpiderMonkey, column numbers are represented as 1-origin 32-bit
// unsigned integers. Some parts of the engine use the highest bit of a column
// number as a tag to indicate Wasm frame.
//
// These classes help clarifying the origin of the column number, and also
// figuring out whether the column number uses the wasm's tag or not, and also
// help converting between them.
//
// Also these classes support converting from 0-origin column number.
// Inside SpiderMonkey, column numbers are represented as 32-bit unsigned
// integers, either with 0-origin or 1-origin. Also, some parts of the engine
// use the highest bit of a column number as a tag to indicate Wasm frame.
//
// In a 0-origin context, column 0 is the first character of the line.
// In a 1-origin context, column 1 is the first character of the line,
@ -23,6 +17,15 @@
// ^ ^
// 0-origin: 0 15
// 1-origin: 1 16
//
// The column 0 in 1-origin is an invalid sentinel value used in some places,
// such as differential testing (bug 1848467).
//
// These classes help figuring out which origin and tag the column number
// uses, and also help converting between them.
//
// Eventually all SpiderMonkey API and internal use should switch to 1-origin
// (bug 1144340).
#ifndef js_ColumnNumber_h
#define js_ColumnNumber_h
@ -48,6 +51,7 @@ struct WasmFunctionIndex {
// information can be used to synthesize a proper wasm frame. But when raw
// column numbers are handed out, we just fix them to the first column to
// avoid confusion.
static constexpr uint32_t DefaultBinarySourceColumnNumberZeroOrigin = 0;
static constexpr uint32_t DefaultBinarySourceColumnNumberOneOrigin = 1;
private:
@ -229,6 +233,12 @@ struct MaybeLimitedColumnNumber {
return value_ >= rhs.value_;
}
// Convert between origins.
uint32_t zeroOriginValue() const {
MOZ_ASSERT(valid());
return value_ - 1;
}
uint32_t oneOriginValue() const {
MOZ_ASSERT(valid());
@ -402,6 +412,11 @@ struct TaggedColumnNumberOneOrigin {
return WasmFunctionIndex(value_ & ~WasmFunctionTag);
}
uint32_t zeroOriginValue() const {
return isWasmFunctionIndex()
? WasmFunctionIndex::DefaultBinarySourceColumnNumberZeroOrigin
: toLimitedColumnNumber().zeroOriginValue();
}
uint32_t oneOriginValue() const {
return isWasmFunctionIndex()
? WasmFunctionIndex::DefaultBinarySourceColumnNumberOneOrigin

Просмотреть файл

@ -483,7 +483,7 @@ class JS_PUBLIC_API ReadOnlyCompileOptions : public TransitiveCompileOptions {
this->TransitiveCompileOptions::dumpWith(print);
# define PrintFields_(Name) print(#Name, Name)
PrintFields_(lineno);
print("column", column.oneOriginValue());
print("column", column.zeroOriginValue());
PrintFields_(scriptSourceOffset);
PrintFields_(isRunOnce);
PrintFields_(noScriptRval);

Просмотреть файл

@ -744,7 +744,7 @@ bool NodeBuilder::newNodeLoc(TokenPos* pos, MutableHandleValue dst) {
if (!defineProperty(to, "line", val)) {
return false;
}
val.setNumber(startColumnIndex.oneOriginValue());
val.setNumber(startColumnIndex.zeroOriginValue());
if (!defineProperty(to, "column", val)) {
return false;
}
@ -760,7 +760,7 @@ bool NodeBuilder::newNodeLoc(TokenPos* pos, MutableHandleValue dst) {
if (!defineProperty(to, "line", val)) {
return false;
}
val.setNumber(endColumnIndex.oneOriginValue());
val.setNumber(endColumnIndex.zeroOriginValue());
if (!defineProperty(to, "column", val)) {
return false;
}

Просмотреть файл

@ -86,10 +86,10 @@ bool js::ParseCompileOptions(JSContext* cx, JS::CompileOptions& options,
if (!JS::ToInt32(cx, v, &c)) {
return false;
}
if (c < 1) {
c = 1;
if (c < 0) {
c = 0;
}
options.setColumn(JS::ColumnNumberOneOrigin(c));
options.setColumn(JS::ColumnNumberOneOrigin::fromZeroOrigin(c));
}
if (!JS_GetProperty(cx, opts, "sourceIsLazy", &v)) {

Просмотреть файл

@ -1246,9 +1246,6 @@ bool DebuggerObject::CallData::createSource() {
if (!ToUint32(cx, v, &startColumn)) {
return false;
}
if (startColumn == 0) {
startColumn = 1;
}
if (!JS_GetProperty(cx, options, "sourceMapURL", &v)) {
return false;
@ -1270,7 +1267,8 @@ bool DebuggerObject::CallData::createSource() {
JS::CompileOptions compileOptions(cx);
compileOptions.lineno = startLine;
compileOptions.column = JS::ColumnNumberOneOrigin(startColumn);
compileOptions.column =
JS::ColumnNumberOneOrigin::fromZeroOrigin(startColumn);
if (!JS::StringHasLatin1Chars(url)) {
JS_ReportErrorASCII(cx, "URL must be a narrow string");

Просмотреть файл

@ -384,7 +384,7 @@ bool DebuggerScript::CallData::getStartColumn() {
return JS::LimitedColumnNumberOneOrigin(
JS::WasmFunctionIndex::DefaultBinarySourceColumnNumberOneOrigin);
});
args.rval().setNumber(column.oneOriginValue());
args.rval().setNumber(column.zeroOriginValue());
return true;
}
@ -691,7 +691,7 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
return false;
}
value = NumberValue(colno.oneOriginValue());
value = NumberValue(colno.zeroOriginValue());
if (!DefineDataProperty(cx_, entry, cx_->names().columnNumber, value)) {
return false;
}
@ -727,7 +727,12 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
}
bool parseColumnValue(HandleValue value,
JS::LimitedColumnNumberOneOrigin* result) {
return parseIntValueImpl(value, result->addressOfValueForTranscode());
uint32_t tmp;
if (!parseIntValueImpl(value, &tmp)) {
return false;
}
*result = JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(tmp);
return true;
}
bool parseSizeTValue(HandleValue value, size_t* result) {
return parseIntValueImpl(value, result);
@ -937,7 +942,16 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
for (uint32_t i = 0; i < offsets.length(); i++) {
uint32_t lineno = offsets[i].lineno;
JS::LimitedColumnNumberOneOrigin column(offsets[i].column);
// FIXME: wasm::ExprLoc::column contains "1". which is "1 in 1-origin",
// but currently the debugger API returns 0-origin column number,
// and the value becomes "0 in 0-origin".
// the existing wasm debug functionality expects the observable
// column number be "1", so it is "1 in 0-origin".
// Once the debugger API is rewritten to use 1-origin, this
// part also needs to be rewritten to directly pass the
// "1 in 1-origin" (bug 1863878).
JS::LimitedColumnNumberOneOrigin column =
JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(offsets[i].column);
size_t offset = offsets[i].offset;
if (!maybeAppendEntry(offset, lineno, column, true)) {
return false;
@ -1016,7 +1030,7 @@ class DebuggerScript::GetOffsetMetadataMatcher {
return false;
}
value = NumberValue(r.frontColumnNumber().oneOriginValue());
value = NumberValue(r.frontColumnNumber().zeroOriginValue());
if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value)) {
return false;
}
@ -1355,7 +1369,7 @@ class DebuggerScript::GetOffsetLocationMatcher {
return false;
}
value = NumberValue(column.oneOriginValue());
value = NumberValue(column.zeroOriginValue());
if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value)) {
return false;
}
@ -1823,7 +1837,7 @@ class DebuggerScript::GetAllColumnOffsetsMatcher {
return false;
}
value = NumberValue(column.oneOriginValue());
value = NumberValue(column.zeroOriginValue());
if (!DefineDataProperty(cx_, entry, cx_->names().columnNumber, value)) {
return false;
}
@ -1892,7 +1906,9 @@ class DebuggerScript::GetAllColumnOffsetsMatcher {
for (uint32_t i = 0; i < offsets.length(); i++) {
uint32_t lineno = offsets[i].lineno;
JS::LimitedColumnNumberOneOrigin column(offsets[i].column);
// See the comment in GetPossibleBreakpointsMatcher::parseQuery.
JS::LimitedColumnNumberOneOrigin column =
JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(offsets[i].column);
size_t offset = offsets[i].offset;
if (!appendColumnOffsetEntry(lineno, column, offset)) {
return false;
@ -2413,7 +2429,8 @@ bool DebuggerScript::CallData::getOffsetsCoverage() {
offsetValue.setNumber(double(offset));
lineNumberValue.setNumber(double(r.frontLineNumber()));
columnNumberValue.setNumber(double(r.frontColumnNumber().oneOriginValue()));
columnNumberValue.setNumber(
double(r.frontColumnNumber().zeroOriginValue()));
countValue.setNumber(double(hits));
// Create a new object with the offset, line number, column number, the

Просмотреть файл

@ -363,7 +363,7 @@ class DebuggerSourceGetStartColumnMatcher {
bool DebuggerSource::CallData::getStartColumn() {
DebuggerSourceGetStartColumnMatcher matcher;
JS::LimitedColumnNumberOneOrigin column = referent.match(matcher);
args.rval().setNumber(column.oneOriginValue());
args.rval().setNumber(column.zeroOriginValue());
return true;
}

Просмотреть файл

@ -173,36 +173,37 @@ into the system; the entire string is not a valid URL. For
**If the instance refers to WebAssembly code**, throw a `TypeError`.
### `startLine`
**If the instance refers to a `JSScript`**, the 1-origin number of the line at
**If the instance refers to a `JSScript`**, the number of the line at
which this script's code starts, within the file or document named by
`url`.
### `startColumn`
**If the instance refers to a `JSScript`**, the 1-origin column number at
which this script's code starts, within the file or document named by `url`.
For functions, this is the start of the function's arguments:
**If the instance refers to a `JSScript`**, the zero-indexed number of the
column at which this script's code starts, within the file or document
named by `url`. For functions, this is the start of the function's
arguments:
```js
function f() { ... }
// ^ start (column 11)
// ^ start (column 10)
let g = x => x*x;
// ^ start (column 9)
// ^ start (column 8)
let h = (x) => x*x;
// ^ start (column 9)
// ^ start (column 8)
```
For default class constructors, it is the start of the `class` keyword:
```js
let MyClass = class { };
// ^ start (column 15)
// ^ start (column 14)
```
For scripts from other sources, such as `eval` or the `Function`
constructor, it is typically 0:
```js
let f = new Function(" console.log('hello world');");
// ^ start (column 1, from the string's perspective)
// ^ start (column 0, from the string's perspective)
```
### `lineCount`
**If the instance refers to a `JSScript`**, the 1-origin number of lines this
**If the instance refers to a `JSScript`**, the number of lines this
script's code occupies, within the file or document named by `url`.
### `source`
@ -231,7 +232,7 @@ by `source`.
**If the instance refers to WebAssembly code**, throw a `TypeError`.
### `mainOffset`
**If the instance refers to a `JSScript`**, the 0-origin offset of the main
**If the instance refers to a `JSScript`**, the offset of the main
entry point of the script, excluding any prologue.
**If the instance refers to WebAssembly code**, throw a `TypeError`.
@ -266,9 +267,9 @@ children can be reached by walking the tree.
### `getPossibleBreakpoints(query)`
Query for the recommended breakpoint locations available in SpiderMonkey.
Returns a result array of objects with the following properties:
* `offset: number` - The 0-origin offset the breakpoint.
* `lineNumber: number` - The 1-origin line number of the breakpoint.
* `columnNumber: number` - The 1-origin column number of the breakpoint.
* `offset: number` - The offset the breakpoint.
* `lineNumber: number` - The line number of the breakpoint.
* `columnNumber: number` - The column number of the breakpoint.
* `isStepStart: boolean` - True if SpiderMonkey recommends that the
breakpoint be treated as a step location when users of debuggers
step to the next item. This _roughly_ translates to the start of
@ -277,13 +278,13 @@ Returns a result array of objects with the following properties:
The `query` argument can be used to filter the set of breakpoints.
The `query` object can contain the following properties:
* `minOffset: number` - The inclusive lower bound of `offset` values to include (0-origin).
* `maxOffset: number` - The exclusive upper bound of `offset` values to include (0-origin).
* `line: number` - Limit to breakpoints on the given line (1-origin).
* `minLine: number` - The inclusive lower bound of lines to include (1-origin).
* `minColumn: number` - The inclusive lower bound of the line/minLine column to include (1-origin).
* `maxLine: number` - The exclusive upper bound of lines to include (1-origin).
* `maxColumn: number` - The exclusive upper bound of the line/maxLine column to include (1-origin).
* `minOffset: number` - The inclusive lower bound of `offset` values to include.
* `maxOffset: number` - The exclusive upper bound of `offset` values to include.
* `line: number` - Limit to breakpoints on the given line.
* `minLine: number` - The inclusive lower bound of lines to include.
* `minColumn: number` - The inclusive lower bound of the line/minLine column to include.
* `maxLine: number` - The exclusive upper bound of lines to include.
* `maxColumn: number` - The exclusive upper bound of the line/maxLine column to include.
### `getPossibleBreakpointOffsets(query)`
Query for the recommended breakpoint locations available in SpiderMonkey.
@ -291,10 +292,10 @@ Identical to getPossibleBreakpoints except this returns an array of `offset`
values instead of offset metadata objects.
### `getOffsetMetadata(offset)`
Get metadata about a given bytecode offset (0-origin).
Get metadata about a given bytecode offset.
Returns an object with the following properties:
* `lineNumber: number` - The 1-origin line number of the breakpoint.
* `columnNumber: number` - The 1-origin column number of the breakpoint.
* `lineNumber: number` - The line number of the breakpoint.
* `columnNumber: number` - The column number of the breakpoint.
* `isBreakpoint: boolean` - True if this offset qualifies as a breakpoint,
defined using the same semantics used for `getPossibleBreakpoints()`.
* `isStepStart: boolean` - True if SpiderMonkey recommends that the
@ -304,8 +305,8 @@ Returns an object with the following properties:
### `setBreakpoint(offset, handler)`
**If the instance refers to a `JSScript`**, set a breakpoint at the
bytecode instruction at <i>offset</i> (0-origin) in this script, reporting hits
to the `hit` method of <i>handler</i>. If <i>offset</i> is not a valid offset
bytecode instruction at <i>offset</i> in this script, reporting hits to
the `hit` method of <i>handler</i>. If <i>offset</i> is not a valid offset
in this script, throw an error. Also, even if <i>offset</i> is valid offset
in this script, some instructions for engine-internal operation (e.g.
SetAliasedVar in the generator function initialization) don't allow setting
@ -336,7 +337,7 @@ global's scripts.
### `getBreakpoints([offset])`
**If the instance refers to a `JSScript`**, return an array containing the
handler objects for all the breakpoints set at <i>offset</i> (0-origin) in this
handler objects for all the breakpoints set at <i>offset</i> in this
script. If <i>offset</i> is omitted, return the handlers of all
breakpoints set anywhere in this script. If <i>offset</i> is present, but
not a valid offset in this script, throw an error.
@ -346,24 +347,24 @@ not a valid offset in this script, throw an error.
### `clearBreakpoint(handler, [offset])`
**If the instance refers to a `JSScript`**, remove all breakpoints set in
this [`Debugger`][debugger-object] instance that use <i>handler</i> as
their handler. If <i>offset</i> (0-origin) is given, remove only those
breakpoints set at <i>offset</i> that use <i>handler</i>; if <i>offset</i> is
not a valid offset in this script, throw an error.
their handler. If <i>offset</i> is given, remove only those breakpoints
set at <i>offset</i> that use <i>handler</i>; if <i>offset</i> is not a
valid offset in this script, throw an error.
Note that, if breakpoints using other handler objects are set at the
same location(s) as <i>handler</i>, they remain in place.
### `clearAllBreakpoints([offset])`
**If the instance refers to a `JSScript`**, remove all breakpoints set in
this script. If <i>offset</i> (0-origin) is present, remove all breakpoints set
at that offset in this script; if <i>offset</i> is not a valid bytecode
this script. If <i>offset</i> is present, remove all breakpoints set at
that offset in this script; if <i>offset</i> is not a valid bytecode
offset in this script, throw an error.
### `getEffectfulOffsets()`
**If the instance refers to a `JSScript`**, return an array
containing the 0-origin offsets of all bytecodes in the script which can have
direct side effects that are visible outside the currently executing frame.
This includes, for example, operations that set properties or elements on
containing the offsets of all bytecodes in the script which can have direct
side effects that are visible outside the currently executing frame. This
includes, for example, operations that set properties or elements on
objects, or that may set names in environments created outside the frame.
This doesn't include some instructions for engine-internal operation (e.g.
@ -377,11 +378,11 @@ contains information about the coverage of all opcodes. The elements of
the array are objects, each of which describes a single opcode, and
contains the following properties:
* `lineNumber`: the 1-origin line number of the current opcode.
* `lineNumber`: the line number of the current opcode.
* `columnNumber`: the 1-origin column number of the current opcode.
* `columnNumber`: the column number of the current opcode.
* `offset`: the 0-origin bytecode instruction offset of the current opcode.
* `offset`: the bytecode instruction offset of the current opcode.
* `count`: the number of times the current opcode got executed.
@ -392,8 +393,8 @@ the flag `Debugger.collectCoverageInfo` should be set to `true`.
**If the instance refers to WebAssembly code**, throw a `TypeError`.
### `isInCatchScope([offset])`
**If the instance refers to a `JSScript`**, this is `true` if this 0-origin
offset falls within the scope of a try block, and `false` otherwise.
**If the instance refers to a `JSScript`**, this is `true` if this offset
falls within the scope of a try block, and `false` otherwise.
**If the instance refers to WebAssembly code**, throw a `TypeError`.
@ -406,7 +407,7 @@ in their results.
#### `getAllOffsets()`
**If the instance refers to a `JSScript`**, return an array <i>L</i>
describing the relationship between bytecode instruction offsets (0-origin) and
describing the relationship between bytecode instruction offsets and
source code positions in this script. <i>L</i> is sparse, and indexed by
source line number. If a source line number <i>line</i> has no code, then
<i>L</i> has no <i>line</i> property. If there is code for <i>line</i>,
@ -425,20 +426,20 @@ for (i=1; i < 10; i++)
Calling `getAllOffsets()` on that code might yield an array like this:
```js
[, [0], [16, 75], , [52]]
[[0], [5, 20], , [10]]
```
This array indicates that:
* the first line's code starts at offset 0 in the script;
* the `for` statement head has two entry points at offsets 16 and 75 (for
* the `for` statement head has two entry points at offsets 5 and 20 (for
the initialization, which is performed only once, and the loop test,
which is performed at the start of each iteration);
* the third line has no code;
* and the fourth line begins at offset 52.
* and the fourth line begins at offset 10.
**If the instance refers to WebAssembly code**, throw a `TypeError`.
@ -452,11 +453,11 @@ all offsets that are entry points for each (line, column) pair.
The elements of the array are objects, each of which describes a single
entry point, and contains the following properties:
* lineNumber: the 1-origin line number for which offset is an entry point
* lineNumber: the line number for which offset is an entry point
* columnNumber: the 1-origin column number for which offset is an entry point
* columnNumber: the column number for which offset is an entry point
* offset: the 0-origin bytecode instruction offset of the entry point
* offset: the bytecode instruction offset of the entry point
For example, suppose we have a script for the following source code:
@ -470,12 +471,10 @@ for (i=1; i < 10; i++)
Calling `getAllColumnOffsets()` on that code might yield an array like this:
```js
[{ lineNumber: 1, columnNumber: 1, offset: 0 },
{ lineNumber: 2, columnNumber: 6, offset: 16 },
{ lineNumber: 2, columnNumber: 11, offset: 28 },
{ lineNumber: 4, columnNumber: 5, offset: 52 },
{ lineNumber: 4, columnNumber: 14, offset: 67 },
{ lineNumber: 2, columnNumber: 19, offset: 75 }]
[{ lineNumber: 0, columnNumber: 0, offset: 0 },
{ lineNumber: 1, columnNumber: 5, offset: 5 },
{ lineNumber: 1, columnNumber: 10, offset: 20 },
{ lineNumber: 3, columnNumber: 4, offset: 10 }]
```
**If the instance refers to WebAssembly code**, throw a `TypeError`.
@ -483,17 +482,17 @@ Calling `getAllColumnOffsets()` on that code might yield an array like this:
#### `getLineOffsets(line)`
**If the instance refers to a `JSScript`**, return an array of bytecode
instruction offsets representing the entry points to source line
<i>line</i> (1-origin). If the script contains no executable code at that line,
the array returned is empty.
<i>line</i>. If the script contains no executable code at that line, the
array returned is empty.
#### `getOffsetLocation(offset)`
**If the instance refers to a `JSScript`**, return an object describing the
source code location responsible for the bytecode at <i>offset</i> in this
script. The object has the following properties:
* `lineNumber`: the 1-origin line number for which offset is an entry point
* `lineNumber`: the line number for which offset is an entry point
* `columnNumber`: the 1-origin column number for which offset is an entry point
* `columnNumber`: the column number for which offset is an entry point
* `isEntryPoint`: true if the offset is a column entry point, as
would be reported by getAllColumnOffsets(); otherwise false.

Просмотреть файл

@ -111,9 +111,9 @@ 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 1-origin start column in
**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 `1`, but may have another value if the source is part of an HTML
is normally `0`, but may have another value if the source is part of an HTML
document.
### `id`

Просмотреть файл

@ -398,6 +398,12 @@ instances for all debuggee scripts.
The script must at least partially cover the given source line. If this
property is present, the `url` property must be present as well.
* `column`
The script must include given column on the line given by the `line`property.
If this property is present, the `url` and `line` properties must both be
present as well.
* `innermost`
If this property is present and true, the script must be the innermost

Просмотреть файл

@ -4428,7 +4428,7 @@ void ScriptStencilExtra::dumpFields(js::JSONPrinter& json) const {
json.property("toStringStart", extent.toStringStart);
json.property("toStringEnd", extent.toStringEnd);
json.property("lineno", extent.lineno);
json.property("column", extent.column.oneOriginValue());
json.property("column", extent.column.zeroOriginValue());
json.endObject();
json.property("memberInitializers", memberInitializers_);
@ -4591,7 +4591,7 @@ static void DumpInputScriptFields(js::JSONPrinter& json,
json.property("toStringStart", extent.toStringStart);
json.property("toStringEnd", extent.toStringEnd);
json.property("lineno", extent.lineno);
json.property("column", extent.column.oneOriginValue());
json.property("column", extent.column.zeroOriginValue());
}
json.endObject();

Просмотреть файл

@ -41,7 +41,7 @@ function assertOffsetColumns(code, expectedBpts, expectedOrdering = null) {
const { script } = debuggeeFn;
for (const offset of script.getAllColumnOffsets()) {
assertEq(offset.lineNumber, 1);
assertEq(offset.columnNumber <= execCode.length, true);
assertEq(offset.columnNumber < execCode.length, true);
bpts.add(offset.columnNumber);
script.setBreakpoint(offset.offset, {
@ -53,7 +53,7 @@ function assertOffsetColumns(code, expectedBpts, expectedOrdering = null) {
global.f(3);
const actualBpts = Array.from(execCode, (_, i) => {
return bpts.has(i + 1) ? "^" : " ";
return bpts.has(i) ? "^" : " ";
}).join("");
if (actualBpts.trimEnd() !== expectedBpts.trimEnd()) {

Просмотреть файл

@ -2,4 +2,4 @@ const backtrace = evaluate(`
this.getBacktrace(this);
`, { fileName: "\u86D9" });
assertEq(backtrace.includes(`["\u86D9":2:6]`), true);
assertEq(backtrace.includes(`["\u86D9":2:5]`), true);

Просмотреть файл

@ -55,7 +55,7 @@ for (text of source.split("\n")) {
// Check lineno/column.
assertEq(getStartLine(className), lineno);
assertEq(getStartColumn(className), column + 1);
assertEq(getStartColumn(className), column);
// Check sourceStart/sourceEnd.
offset = source.indexOf("class " + className)

Просмотреть файл

@ -55,4 +55,4 @@ C();
D();
new E();
`);
assertEq(g.log.join(","), "A,pop(8:1),B,pop(14:1),C,pop(20:1),D,pop(26:1),E,pop(27:17),pop(34:5)");
assertEq(g.log.join(","), "A,pop(8:0),B,pop(14:0),C,pop(20:0),D,pop(26:0),E,pop(27:16),pop(34:4)");

Просмотреть файл

@ -8,13 +8,13 @@ let source = gdbg.createSource({
text: "x = 3",
url: "foo.js",
startLine: 3,
startColumn: 43,
startColumn: 42,
sourceMapURL: "sourceMapURL",
isScriptElement: true,
});
assertEq(source.text, "x = 3");
assertEq(source.url, "foo.js");
assertEq(source.startLine, 3);
assertEq(source.startColumn, 43);
assertEq(source.startColumn, 42);
assertEq(source.sourceMapURL, "sourceMapURL");
assertEq(source.introductionType, "inlineScript");

Просмотреть файл

@ -29,31 +29,31 @@ function onDebuggerStatement(frame) {
assertBPCount({ line: 9 }, 1);
assertBPCount({ line: 10 }, 1);
assertBPCount({ line: 6, minColumn: 8 }, 3);
assertBPCount({ line: 6, maxColumn: 17 }, 3);
assertBPCount({ line: 6, minColumn: 8, maxColumn: 17 }, 2);
assertBPCount({ line: 6, minColumn: 7 }, 3);
assertBPCount({ line: 6, maxColumn: 16 }, 3);
assertBPCount({ line: 6, minColumn: 7, maxColumn: 16 }, 2);
assertBPError({ line: 1, minLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'");
assertBPError({ line: 1, maxLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'");
assertBPError({ line: "1" }, "line", "not an integer");
assertBPCount({ minLine: 9 }, 2);
assertBPCount({ minLine: 9, minColumn: 1 }, 2);
assertBPCount({ minLine: 9, minColumn: 9 }, 1);
assertBPCount({ minLine: 9, minColumn: 0 }, 2);
assertBPCount({ minLine: 9, minColumn: 8 }, 1);
assertBPError({ minLine: "1" }, "minLine", "not an integer");
assertBPError({ minColumn: 2 }, "minColumn", "not allowed without 'line' or 'minLine'");
assertBPError({ minLine: 1, minColumn: "2" }, "minColumn", "not an integer");
assertBPError({ minColumn: 1 }, "minColumn", "not allowed without 'line' or 'minLine'");
assertBPError({ minLine: 1, minColumn: "1" }, "minColumn", "not an integer");
assertBPCount({ maxLine: 7 }, 5);
assertBPCount({ maxLine: 7, maxColumn: 1 }, 5);
assertBPCount({ maxLine: 7, maxColumn: 9 }, 6);
assertBPCount({ maxLine: 7, maxColumn: 0 }, 5);
assertBPCount({ maxLine: 7, maxColumn: 8 }, 6);
assertBPError({ maxLine: "1" }, "maxLine", "not an integer");
assertBPError({ maxColumn: 2 }, "maxColumn", "not allowed without 'line' or 'maxLine'");
assertBPError({ maxLine: 1, maxColumn: "2" }, "maxColumn", "not an integer");
assertBPError({ maxColumn: 1 }, "maxColumn", "not allowed without 'line' or 'maxLine'");
assertBPError({ maxLine: 1, maxColumn: "1" }, "maxColumn", "not an integer");
assertBPCount({ minLine: 6, maxLine: 8 }, 6);
assertBPCount({ minLine: 6, minColumn: 9, maxLine: 8 }, 5);
assertBPCount({ minLine: 6, maxLine: 8, maxColumn: 9 }, 7);
assertBPCount({ minLine: 6, minColumn: 9, maxLine: 8, maxColumn: 9 }, 6);
assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8 }, 5);
assertBPCount({ minLine: 6, maxLine: 8, maxColumn: 8 }, 7);
assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8, maxColumn: 8 }, 6);
assertBPCount({
minOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset,

Просмотреть файл

@ -379,6 +379,6 @@ function createOffsetLookup(code) {
if (!lineOffsets.hasOwnProperty(line)) {
throw new Error("Unknown line " + line + " column " + column);
}
return lineOffsets[line] + column - 1;
return lineOffsets[line] + column;
};
}

Просмотреть файл

@ -13,33 +13,33 @@ function test(f, expected) {
g.eval(`
function f1() { }
`);
test(g.f1, 12);
test(g.f1, 11);
g.eval(`
var f2 = function({ a, b, c }, d, e, ...more) { };
`);
test(g.f2, 18);
test(g.f2, 17);
g.eval(`
var f3 = function *() { };
`);
test(g.f3, 20);
test(g.f3, 19);
g.eval(`
var f4 = async function
() { };
`);
test(g.f4, 3);
test(g.f4, 2);
g.eval(`
var f5 = (a, b) => a + b;
`);
test(g.f5, 10);
test(g.f5, 9);
g.eval(`
var f6 = a => a + 1;
`);
test(g.f6, 10);
test(g.f6, 9);
g.eval(`
var MyClass = class {
@ -47,8 +47,8 @@ var MyClass = class {
};
var myInstance = new MyClass();
`);
test(g.myInstance.method, 11);
test(g.myInstance.constructor, 15);
test(g.myInstance.method, 10);
test(g.myInstance.constructor, 14);
const g2 = newGlobal({newCompartment: true, useWindowProxy: true});
const dbg2 = Debugger(g2);
@ -60,20 +60,20 @@ function f7() { }
});
const f7w = g2Wrapped.makeDebuggeeValue(g2.f7);
assertEq(f7w.callable, true);
assertEq(f7w.script.startColumn, 12);
assertEq(f7w.script.startColumn, 11);
g.eval(`
function f8() {
return function f8Inner() { }
}
`);
test(g.f8, 12);
test(g.f8(), 28);
test(g.f8, 11);
test(g.f8(), 27);
g.eval(`
var f9 = new Function(\"\");
`);
test(g.f9, 1);
test(g.f9, 0);
let hit = 0;
let column;
@ -83,7 +83,7 @@ dbg.onDebuggerStatement = function (frame) {
};
g.eval(` debugger;`);
assertEq(column, 1);
assertEq(column, 0);
assertEq(hit, 1);
const location = { fileName: "column.js", lineNumber: 1, columnNumber: 1 };
@ -98,4 +98,4 @@ test(g.f10, 20);
g.evaluate(`
var f11 = function () { };
`, location);
test(g.f11, 20);
test(g.f11, 19);

Просмотреть файл

@ -23,11 +23,7 @@ function g() {
}
f();
`, {
fileName: "foobar.js",
lineNumber: 3,
columnNumber: 42,
});
`, { fileName: "foobar.js", lineNumber: 3, columnNumber: 42 });
let onNewScriptCalls = 0;
dbg.onNewScript = script => { onNewScriptCalls++; };

Просмотреть файл

@ -6,7 +6,7 @@ var gw = dbg.addDebuggee(g);
g.evaluate("function f(x) {}");
var fw = gw.getOwnPropertyDescriptor("f").value;
assertEq(fw.script.source.startLine, 1);
assertEq(fw.script.source.startColumn, 1);
assertEq(fw.script.source.startColumn, 0);
g.evaluate("function g(x) {}", { lineNumber: 10, columnNumber: 5 });
var gw = gw.getOwnPropertyDescriptor("g").value;
assertEq(gw.script.source.startLine, 10);

Просмотреть файл

@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(frame.older.type, "call");
const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset);
assertEq(lineNumber, 3);
assertEq(columnNumber, 5);
assertEq(columnNumber, 4);
const isInCatchScope = frame.script.isInCatchScope(frame.offset);
assertEq(isInCatchScope, false);
@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(older.type, "call");
const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset);
assertEq(lineNumber, 7);
assertEq(columnNumber, 5);
assertEq(columnNumber, 4);
const isInCatchScope = older.script.isInCatchScope(older.offset);
assertEq(isInCatchScope, false);

Просмотреть файл

@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(frame.older.type, "call");
const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset);
assertEq(lineNumber, 3);
assertEq(columnNumber, 5);
assertEq(columnNumber, 4);
const isInCatchScope = frame.script.isInCatchScope(frame.offset);
assertEq(isInCatchScope, false);
@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(older.type, "call");
const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset);
assertEq(lineNumber, 8);
assertEq(columnNumber, 7);
assertEq(columnNumber, 6);
const isInCatchScope = older.script.isInCatchScope(older.offset);
assertEq(isInCatchScope, true);

Просмотреть файл

@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(frame.older.type, "call");
const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset);
assertEq(lineNumber, 3);
assertEq(columnNumber, 5);
assertEq(columnNumber, 4);
const isInCatchScope = frame.script.isInCatchScope(frame.offset);
assertEq(isInCatchScope, false);
@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) {
assertEq(older.type, "call");
const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset);
assertEq(lineNumber, 8);
assertEq(columnNumber, 7);
assertEq(columnNumber, 6);
const isInCatchScope = older.script.isInCatchScope(older.offset);
assertEq(isInCatchScope, true);

Просмотреть файл

@ -45,8 +45,8 @@ for (var i = 0; i < NumInitializers; ++i) {
// Check the initializer lambda has expected line/column
assertEq(script.startLine, START + 1 + i);
assertEq(script.startColumn, 21);
assertEq(script.startColumn, 20);
// Check that source length matches expectations.
assertEq(script.startColumn + script.sourceLength + ';'.length, lineText.length + 1);
assertEq(script.startColumn + script.sourceLength + ';'.length, lineText.length);
}

Просмотреть файл

@ -460,9 +460,9 @@ var loc = parseAsModule("export { a as b } from 'c'", {
}).body[0].loc;
assertEq(loc.start.line, 1);
assertEq(loc.start.column, 1);
assertEq(loc.start.column, 0);
assertEq(loc.start.line, 1);
assertEq(loc.end.column, 27);
assertEq(loc.end.column, 26);
assertThrowsInstanceOf(function () {
parseAsModule("function f() { export a }");

Просмотреть файл

@ -402,9 +402,9 @@ var loc = parseAsModule("import { a as b } from 'c'", {
}).body[0].loc;
assertEq(loc.start.line, 1);
assertEq(loc.start.column, 1);
assertEq(loc.start.column, 0);
assertEq(loc.start.line, 1);
assertEq(loc.end.column, 27);
assertEq(loc.end.column, 26);
assertThrowsInstanceOf(function () {
parseAsModule("function f() { import a from 'b' }");

Просмотреть файл

@ -1,3 +1,3 @@
// Test that lazy scripts can handle OOB column numbers.
assertEq(evaluate(`var f = x=>saveStack().column; f()`, { columnNumber: 1730 }), 1741);
assertEq(evaluate(`var f = x=>saveStack().column; f()`, { columnNumber: 1729 }), 1741);

Просмотреть файл

@ -1,7 +1,7 @@
var loc = Reflect.parse("f()").body[0].expression.loc;
assertEq(loc.start.column, 1);
assertEq(loc.end.column, 4);
assertEq(loc.start.column, 0);
assertEq(loc.end.column, 3);
loc = Reflect.parse("f(x)").body[0].expression.loc;
assertEq(loc.start.column, 1);
assertEq(loc.end.column, 5);
assertEq(loc.start.column, 0);
assertEq(loc.end.column, 4);

Просмотреть файл

@ -3,9 +3,9 @@
load(libdir + 'asserts.js');
assertEq(evaluate("saveStack().column"), 1);
assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1729);
assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1730);
assertEq(evaluate("\nsaveStack().column", { columnNumber: 1729 }), 1);
assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 42);
assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 43);
// columnNumber < 1 is fixed to 1.
assertEq(evaluate("saveStack().column", { columnNumber: -10 }), 1);
assertThrowsInstanceOf(() => evaluate("saveStack().column", { columnNumber: Math.pow(2,30) }),
@ -27,7 +27,7 @@ if (helperThreadCount() > 0) {
print("offThreadCompileToStencil 3");
offThreadCompileToStencil("saveStack().column", { columnNumber: 10000 });
stencil = finishOffThreadStencil();
assertEq(evalStencil(stencil), 10000);
assertEq(evalStencil(stencil), 10001);
}
// Check handling of columns near the limit of our ability to represent them.
@ -35,7 +35,7 @@ if (helperThreadCount() > 0) {
// it's probably not worth it to be thorough.)
const maxColumn = Math.pow(2, 30) - 2;
assertEq(evaluate("saveStack().column", { columnNumber: maxColumn }),
maxColumn);
maxColumn + 1);
// Check the saturation behavior when we reach the limit of the column
// representation.

Просмотреть файл

@ -38,7 +38,7 @@ function getScriptSourceExtent(source) {
// to test multi-line sources, this will need to be updated.
for (let script of scripts) {
assertEq(script.startLine, 1);
assertEq(script.startColumn, script.sourceStart + 1);
assertEq(script.startColumn, script.sourceStart);
}
// Map each found script to a source extent string.
@ -334,4 +334,4 @@ testSourceExtent(` class C { static set #prop(v) { } }`,
// Static Class Blocks
testSourceExtent(` class C { static { 10; } }`,
` ^-------------^ `,
` ^-------------------------`);
` ^-------------------------`);

Просмотреть файл

@ -25,7 +25,7 @@ function testBasic() {
// Test non-function frames.
assertStack(evaluate("eval(`(function foo() { return readGeckoInterpProfilingStack(); })()`)"),
["testBasic", "@evaluate", "@evaluate line 1 > eval:1:1", "foo"]);
["testBasic", "@evaluate", "@evaluate line 1 > eval:1:0", "foo"]);
}
testBasic();
testBasic();

Просмотреть файл

@ -479,7 +479,7 @@ bool BaselineStackBuilder::initFrame() {
JitSpew(JitSpew_BaselineBailouts, " Unpacking %s:%u:%u",
script_->filename(), script_->lineno(),
script_->column().oneOriginValue());
script_->column().zeroOriginValue());
JitSpew(JitSpew_BaselineBailouts, " [BASELINE-JS FRAME]");
// Write the previous frame pointer value. For the outermost frame we reuse
@ -1496,7 +1496,7 @@ bool BaselineStackBuilder::buildOneFrame() {
" Resuming %s pc offset %d (op %s) (line %u) of %s:%u:%u",
resumeAfter() ? "after" : "at", (int)pcOff, CodeName(op_),
PCToLineNumber(script_, pc()), script_->filename(), script_->lineno(),
script_->column().oneOriginValue());
script_->column().zeroOriginValue());
JitSpew(JitSpew_BaselineBailouts, " Bailout kind: %s",
BailoutKindString(bailoutKind()));
#endif
@ -1582,7 +1582,7 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation,
JitSpew(JitSpew_BaselineBailouts,
"Bailing to baseline %s:%u:%u (IonScript=%p) (FrameType=%d)",
iter.script()->filename(), iter.script()->lineno(),
iter.script()->column().oneOriginValue(), (void*)iter.ionScript(),
iter.script()->column().zeroOriginValue(), (void*)iter.ionScript(),
(int)prevFrameType);
if (excInfo) {
@ -1628,7 +1628,7 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation,
if (iter.maybeCallee()) {
JitSpew(JitSpew_BaselineBailouts, " Callee function (%s:%u:%u)",
iter.script()->filename(), iter.script()->lineno(),
iter.script()->column().oneOriginValue());
iter.script()->column().zeroOriginValue());
} else {
JitSpew(JitSpew_BaselineBailouts, " No callee!");
}
@ -1733,8 +1733,8 @@ static void HandleLexicalCheckFailure(JSContext* cx, HandleScript outerScript,
JitSpew(JitSpew_IonBailouts,
"Lexical check failure %s:%u:%u, inlined into %s:%u:%u",
innerScript->filename(), innerScript->lineno(),
innerScript->column().oneOriginValue(), outerScript->filename(),
outerScript->lineno(), outerScript->column().oneOriginValue());
innerScript->column().zeroOriginValue(), outerScript->filename(),
outerScript->lineno(), outerScript->column().zeroOriginValue());
if (!innerScript->failedLexicalCheck()) {
innerScript->setFailedLexicalCheck();
@ -1962,10 +1962,10 @@ bool jit::FinishBailoutToBaseline(BaselineBailoutInfo* bailoutInfoArg) {
" Restored outerScript=(%s:%u:%u,%u) innerScript=(%s:%u:%u,%u) "
"(bailoutKind=%u)",
outerScript->filename(), outerScript->lineno(),
outerScript->column().oneOriginValue(), outerScript->getWarmUpCount(),
innerScript->filename(), innerScript->lineno(),
innerScript->column().oneOriginValue(), innerScript->getWarmUpCount(),
(unsigned)bailoutKind);
outerScript->column().zeroOriginValue(),
outerScript->getWarmUpCount(), innerScript->filename(),
innerScript->lineno(), innerScript->column().zeroOriginValue(),
innerScript->getWarmUpCount(), (unsigned)bailoutKind);
BailoutAction action = BailoutAction::InvalidateImmediately;
DebugOnly<bool> saveFailedICHash = false;

Просмотреть файл

@ -2591,7 +2591,7 @@ ICAttachResult js::jit::AttachBaselineCacheIRStub(
JitSpew(JitSpew_BaselineICFallback,
"Tried attaching identical stub for (%s:%u:%u)",
outerScript->filename(), outerScript->lineno(),
outerScript->column().oneOriginValue());
outerScript->column().zeroOriginValue());
return ICAttachResult::DuplicateStub;
}

Просмотреть файл

@ -201,11 +201,11 @@ MethodStatus BaselineCompiler::compile() {
Rooted<JSScript*> script(cx, handler.script());
JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%u:%u (%p)",
script->filename(), script->lineno(),
script->column().oneOriginValue(), script.get());
script->column().zeroOriginValue(), script.get());
JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%u:%u",
script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
AutoIncrementalTimer timer(cx->realm()->timers.baselineCompileTime);
@ -286,7 +286,7 @@ MethodStatus BaselineCompiler::compile() {
JitSpew(JitSpew_BaselineScripts,
"Created BaselineScript %p (raw %p) for %s:%u:%u",
(void*)baselineScript.get(), (void*)code->raw(), script->filename(),
script->lineno(), script->column().oneOriginValue());
script->lineno(), script->column().zeroOriginValue());
baselineScript->copyRetAddrEntries(handler.retAddrEntries().begin());
baselineScript->copyOSREntries(handler.osrEntries().begin());
@ -312,7 +312,7 @@ MethodStatus BaselineCompiler::compile() {
JitSpew(JitSpew_Profiling,
"Added JitcodeGlobalEntry for baseline script %s:%u:%u (%p)",
script->filename(), script->lineno(),
script->column().oneOriginValue(), baselineScript.get());
script->column().zeroOriginValue(), baselineScript.get());
// Generate profiling string.
UniqueChars str = GeckoProfilerRuntime::allocProfileString(cx, script);

Просмотреть файл

@ -206,7 +206,7 @@ static void SpewPatchBaselineFrame(const uint8_t* oldReturnAddress,
JitSpew(JitSpew_BaselineDebugModeOSR,
"Patch return %p -> %p on BaselineJS frame (%s:%u:%u) from %s at %s",
oldReturnAddress, newReturnAddress, script->filename(),
script->lineno(), script->column().oneOriginValue(),
script->lineno(), script->column().zeroOriginValue(),
RetAddrEntryKindToString(frameKind), CodeName(JSOp(*pc)));
}
@ -412,7 +412,7 @@ static bool RecompileBaselineScriptForDebugMode(
JitSpew(JitSpew_BaselineDebugModeOSR, "Recompiling (%s:%u:%u) for %s",
script->filename(), script->lineno(),
script->column().oneOriginValue(),
script->column().zeroOriginValue(),
observing ? "DEBUGGING" : "NORMAL EXECUTION");
AutoKeepJitScripts keepJitScripts(cx);

Просмотреть файл

@ -158,9 +158,10 @@ void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...) {
JitSpew(
JitSpew_BaselineICFallback,
"Fallback hit for (%s:%u:%u) (pc=%zu,line=%u,uses=%u,stubs=%zu): %s",
script->filename(), script->lineno(), script->column().oneOriginValue(),
script->pcToOffset(pc), PCToLineNumber(script, pc),
script->getWarmUpCount(), stub->numOptimizedStubs(), fmtbuf);
script->filename(), script->lineno(),
script->column().zeroOriginValue(), script->pcToOffset(pc),
PCToLineNumber(script, pc), script->getWarmUpCount(),
stub->numOptimizedStubs(), fmtbuf);
}
}
#endif // JS_JITSPEW

Просмотреть файл

@ -321,7 +321,7 @@ bool BytecodeAnalysis::init(TempAllocator& alloc) {
JitSpew_IonAbort,
"Disabling Warp support for %s:%d:%d due to Yield being in a loop",
script_->filename(), script_->lineno(),
script_->column().oneOriginValue());
script_->column().zeroOriginValue());
script_->disableIon();
}
}
@ -337,7 +337,7 @@ void BytecodeAnalysis::checkWarpSupport(JSOp op) {
if (script_->canIonCompile()) {
JitSpew(JitSpew_IonAbort, "Disabling Warp support for %s:%d:%d due to %s",
script_->filename(), script_->lineno(),
script_->column().oneOriginValue(), CodeName(op));
script_->column().zeroOriginValue(), CodeName(op));
script_->disableIon();
}
break;

Просмотреть файл

@ -142,7 +142,8 @@ void CacheIRHealth::spewShapeInformation(AutoStructuredSpewer& spew,
{
spew->property("filename", baseScript->filename());
spew->property("line", baseScript->lineno());
spew->property("column", baseScript->column().oneOriginValue());
spew->property("column",
baseScript->column().zeroOriginValue());
}
spew->endObject();
}
@ -273,7 +274,7 @@ bool CacheIRHealth::spewICEntryHealth(AutoStructuredSpewer& spew, JSContext* cx,
// API call below.
JS::LimitedColumnNumberOneOrigin column;
spew->property("lineno", PCToLineNumber(script, pc, &column));
spew->property("column", column.oneOriginValue());
spew->property("column", column.zeroOriginValue());
ICStub* firstStub = entry->firstStub();
if (!firstStub->isFallback()) {
@ -306,7 +307,7 @@ void CacheIRHealth::spewScriptFinalWarmUpCount(JSContext* cx,
spew->property("filename", filename);
spew->property("line", script->lineno());
spew->property("column", script->column().oneOriginValue());
spew->property("column", script->column().zeroOriginValue());
spew->property("finalWarmUpCount", warmUpCount);
}

Просмотреть файл

@ -343,7 +343,7 @@ void CacheIRSpewer::beginCache(const IRGenerator& gen) {
if (jsbytecode* pc = gen.pc_) {
JS::LimitedColumnNumberOneOrigin column;
j.property("line", PCToLineNumber(gen.script_, pc, &column));
j.property("column", column.oneOriginValue());
j.property("column", column.zeroOriginValue());
j.formatProperty("pc", "%p", pc);
}
}

Просмотреть файл

@ -7313,7 +7313,7 @@ bool CodeGenerator::generateBody() {
JitSpew(JitSpew_Codegen, "--------------------------------");
JitSpew(JitSpew_Codegen, "# block%zu %s:%zu:%u%s:", i,
filename ? filename : "?", lineNumber,
columnNumber.oneOriginValue(),
columnNumber.zeroOriginValue(),
current->mir()->isLoopHeader() ? " (loop header)" : "");
#endif
@ -14118,7 +14118,7 @@ bool CodeGenerator::generate() {
JitSpew(JitSpew_Codegen, "# Emitting code for script %s:%u:%u",
gen->outerInfo().script()->filename(),
gen->outerInfo().script()->lineno(),
gen->outerInfo().script()->column().oneOriginValue());
gen->outerInfo().script()->column().zeroOriginValue());
// Initialize native code table with an entry to the start of
// top-level script.

Просмотреть файл

@ -242,7 +242,7 @@ JitCode* JitRuntime::generateEntryTrampolineForScript(JSContext* cx,
JitSpew(JitSpew_Codegen,
"# Emitting Interpreter Entry Trampoline for %s (%s:%u:%u)",
funName ? funName.get() : "*", script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
}
TempAllocator temp(&cx->tempLifoAlloc());

Просмотреть файл

@ -1676,7 +1676,7 @@ static AbortReason IonCompile(JSContext* cx, HandleScript script,
"Can't log script %s:%u:%u"
". (Compiled on background thread.)",
script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
IonCompileTask* task = alloc->new_<IonCompileTask>(cx, *mirGen, snapshot);
if (!task) {
@ -1792,7 +1792,7 @@ static bool ScriptIsTooLarge(JSContext* cx, JSScript* script) {
JitSpew(JitSpew_IonAbort,
"Script too large (%zu bytes) (%zu locals/args) @ %s:%u:%u",
script->length(), numLocalsAndArgs, script->filename(),
script->lineno(), script->column().oneOriginValue());
script->lineno(), script->column().zeroOriginValue());
return true;
}
@ -1838,7 +1838,7 @@ static MethodStatus Compile(JSContext* cx, HandleScript script,
if (!CanIonCompileScript(cx, script)) {
JitSpew(JitSpew_IonAbort, "Aborted compilation of %s:%u:%u",
script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
return Method_CantCompile;
}
@ -2104,7 +2104,7 @@ static bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame,
"WarmUpCounter for %s:%u:%u reached %d at pc %p, trying to switch to "
"Ion!",
script->filename(), script->lineno(),
script->column().oneOriginValue(), (int)script->getWarmUpCount(),
script->column().zeroOriginValue(), (int)script->getWarmUpCount(),
(void*)pc);
MethodStatus stat;
@ -2299,7 +2299,7 @@ static void InvalidateActivation(JS::GCContext* gcx,
JitSpew(JitSpew_IonInvalidate,
"#%zu %s JS frame @ %p, %s:%u:%u (fun: %p, script: %p, pc %p)",
frameno, type, frame.fp(), script->maybeForwardedFilename(),
script->lineno(), script->column().oneOriginValue(),
script->lineno(), script->column().zeroOriginValue(),
frame.maybeCallee(), script, frame.resumePCinCurrentFrame());
break;
}
@ -2474,7 +2474,7 @@ void jit::Invalidate(JSContext* cx, const RecompileInfoVector& invalid,
JitSpew(JitSpew_IonInvalidate, " Invalidate %s:%u:%u, IonScript %p",
info.script()->filename(), info.script()->lineno(),
info.script()->column().oneOriginValue(), ionScript);
info.script()->column().zeroOriginValue(), ionScript);
// Keep the ion script alive during the invalidation and flag this
// ionScript as being invalidated. This increment is removed by the
@ -2561,7 +2561,7 @@ void jit::Invalidate(JSContext* cx, JSScript* script, bool resetUses,
// Construct the descriptive string.
UniqueChars buf = JS_smprintf("%s:%u:%u", filename, script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
// Ignore the event on allocation failure.
if (buf) {
@ -2596,7 +2596,7 @@ void jit::FinishInvalidation(JS::GCContext* gcx, JSScript* script) {
void jit::ForbidCompilation(JSContext* cx, JSScript* script) {
JitSpew(JitSpew_IonAbort, "Disabling Ion compilation of script %s:%u:%u",
script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
CancelOffThreadIonCompile(script);

Просмотреть файл

@ -567,7 +567,7 @@ void jit::JitSpewBaselineICStats(JSScript* script, const char* dumpReason) {
spew->property("op", CodeName(JSOp(*pc)));
spew->property("pc", pcOffset);
spew->property("line", line);
spew->property("column", column.oneOriginValue());
spew->property("column", column.zeroOriginValue());
spew->beginListProperty("counts");
ICStub* stub = entry.firstStub();

Просмотреть файл

@ -1007,7 +1007,7 @@ bool JitcodeIonTable::WriteIonTable(CompactBufferWriter& writer,
JitSpew(JitSpew_Profiling,
"Writing native to bytecode map for %s:%u:%u (%zu entries)",
scriptList[0].script->filename(), scriptList[0].script->lineno(),
scriptList[0].script->column().oneOriginValue(),
scriptList[0].script->column().zeroOriginValue(),
mozilla::PointerRangeSize(start, end));
JitSpew(JitSpew_Profiling, " ScriptList of size %u",
@ -1015,7 +1015,7 @@ bool JitcodeIonTable::WriteIonTable(CompactBufferWriter& writer,
for (uint32_t i = 0; i < scriptList.length(); i++) {
JitSpew(JitSpew_Profiling, " Script %u - %s:%u:%u", i,
scriptList[i].script->filename(), scriptList[i].script->lineno(),
scriptList[i].script->column().oneOriginValue());
scriptList[i].script->column().zeroOriginValue());
}
// Write out runs first. Keep a vector tracking the positive offsets from

Просмотреть файл

@ -158,7 +158,7 @@ static void WriteJitDumpDebugEntry(uint64_t addr, const char* filename,
uint32_t lineno,
JS::LimitedColumnNumberOneOrigin colno,
AutoLockPerfSpewer& lock) {
JitDumpDebugEntry entry = {addr, lineno, colno.oneOriginValue()};
JitDumpDebugEntry entry = {addr, lineno, colno.zeroOriginValue()};
WriteToJitDumpFile(&entry, sizeof(entry), lock);
WriteToJitDumpFile(filename, strlen(filename) + 1, lock);
}
@ -884,11 +884,11 @@ static UniqueChars GetFunctionDesc(const char* tierName, JSContext* cx,
if (stubName) {
return JS_smprintf("%s: %s : %s (%s:%u:%u)", tierName, stubName,
funName ? funName.get() : "*", script->filename(),
script->lineno(), script->column().oneOriginValue());
script->lineno(), script->column().zeroOriginValue());
}
return JS_smprintf("%s: %s (%s:%u:%u)", tierName,
funName ? funName.get() : "*", script->filename(),
script->lineno(), script->column().oneOriginValue());
script->lineno(), script->column().zeroOriginValue());
}
void PerfSpewer::saveDebugInfo(JSScript* script, JitCode* code,

Просмотреть файл

@ -92,7 +92,7 @@ bool DoTrialInlining(JSContext* cx, BaselineFrame* frame) {
"Trial inlining for %s script '%s' (%s:%u:%u (%p)) (inliningRoot=%p)",
(isRecursive ? "inner" : "outer"),
funName ? funName.get() : "<unnamed>", script->filename(),
script->lineno(), script->column().oneOriginValue(), frame->script(),
script->lineno(), script->column().zeroOriginValue(), frame->script(),
root);
JitSpewIndent spewIndent(JitSpew_WarpTrialInlining);
}
@ -547,7 +547,7 @@ TrialInliningDecision TrialInliner::getInliningDecision(JSFunction* target,
funName ? funName.get() : "<unnamed>",
baseScript ? baseScript->filename() : "<not-scripted>",
baseScript ? baseScript->lineno() : 0,
baseScript ? baseScript->column().oneOriginValue() : 0);
baseScript ? baseScript->column().zeroOriginValue() : 0);
JitSpewIndent spewIndent(JitSpew_WarpTrialInlining);
}
#endif

Просмотреть файл

@ -144,7 +144,7 @@ AbortReasonOr<WarpSnapshot*> WarpOracle::createSnapshot() {
JitSpew(JitSpew_IonScripts,
"Warp %s script %s:%u:%u (%p) (warmup-counter=%" PRIu32 ",%s%s)",
mode, outerScript_->filename(), outerScript_->lineno(),
outerScript_->column().oneOriginValue(),
outerScript_->column().zeroOriginValue(),
static_cast<JSScript*>(outerScript_), outerScript_->getWarmUpCount(),
outerScript_->isGenerator() ? " isGenerator" : "",
outerScript_->isAsync() ? " isAsync" : "");
@ -803,7 +803,7 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
"fallback stub (entered-count: %" PRIu32
") for JSOp::%s @ %s:%u:%u",
fallbackStub->enteredCount(), CodeName(loc.getOp()),
script_->filename(), line, column.oneOriginValue());
script_->filename(), line, column.zeroOriginValue());
// If the fallback stub was used but there's no optimized stub, use an IC.
if (fallbackStub->enteredCount() != 0) {
@ -828,7 +828,7 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
JitSpew(JitSpew_WarpTranspiler, "Failed to attach for JSOp::%s @ %s:%u:%u",
CodeName(loc.getOp()), script_->filename(), line,
column.oneOriginValue());
column.zeroOriginValue());
return Ok();
}
@ -866,7 +866,7 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
JitSpew(JitSpew_WarpTranspiler,
"multiple active stubs for JSOp::%s @ %s:%u:%u",
CodeName(loc.getOp()), script_->filename(), line,
column.oneOriginValue());
column.zeroOriginValue());
return Ok();
}
@ -893,7 +893,7 @@ AbortReasonOr<Ok> WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots,
JitSpew(JitSpew_WarpTranspiler,
"unsupported CacheIR opcode %s for JSOp::%s @ %s:%u:%u",
CacheIROpNames[size_t(op)], CodeName(loc.getOp()),
script_->filename(), line, column.oneOriginValue());
script_->filename(), line, column.zeroOriginValue());
return Ok();
}

Просмотреть файл

@ -78,7 +78,7 @@ void WarpScriptSnapshot::dump(GenericPrinter& out) const {
out.printf("WarpScriptSnapshot (0x%p)\n", this);
out.printf("------------------------------\n");
out.printf("Script: %s:%u:%u (0x%p)\n", script_->filename(),
script_->lineno(), script_->column().oneOriginValue(),
script_->lineno(), script_->column().zeroOriginValue(),
static_cast<JSScript*>(script_));
out.printf(" moduleObject: 0x%p\n", moduleObject());
out.printf(" isArrowFunction: %u\n", isArrowFunction());

Просмотреть файл

@ -311,7 +311,7 @@ void CodeGeneratorShared::dumpNativeToBytecodeEntries() {
InlineScriptTree* topTree = gen->outerInfo().inlineScriptTree();
JitSpewStart(JitSpew_Profiling, "Native To Bytecode Entries for %s:%u:%u\n",
topTree->script()->filename(), topTree->script()->lineno(),
topTree->script()->column().oneOriginValue());
topTree->script()->column().zeroOriginValue());
for (unsigned i = 0; i < nativeToBytecodeList_.length(); i++) {
dumpNativeToBytecodeEntry(i);
}
@ -337,12 +337,12 @@ void CodeGeneratorShared::dumpNativeToBytecodeEntry(uint32_t idx) {
JitSpew_Profiling, " %08zx [+%-6u] => %-6ld [%-4u] {%-10s} (%s:%u:%u",
ref.nativeOffset.offset(), nativeDelta, (long)(ref.pc - script->code()),
pcDelta, CodeName(JSOp(*ref.pc)), script->filename(), script->lineno(),
script->column().oneOriginValue());
script->column().zeroOriginValue());
for (tree = tree->caller(); tree; tree = tree->caller()) {
JitSpewCont(JitSpew_Profiling, " <= %s:%u:%u", tree->script()->filename(),
tree->script()->lineno(),
tree->script()->column().oneOriginValue());
tree->script()->column().zeroOriginValue());
}
JitSpewCont(JitSpew_Profiling, ")");
JitSpewFin(JitSpew_Profiling);

Просмотреть файл

@ -21,7 +21,7 @@ assertExpr('a= {[1]: 1, 2 : 2}',
// Bug 924688: computed property names - location information
var node = Reflect.parse("a = {[field1]: 5}");
Pattern({ body: [ { expression: { right: { properties: [ {key: { loc:
{ start: { line: 1, column: 6 }, end: { line: 1, column: 14 }}}}]}}}]}).match(node);
{ start: { line: 1, column: 5 }, end: { line: 1, column: 13 }}}}]}}}]}).match(node);
// Bug 1048384 - Getter/setter syntax with computed names
assertExpr("b = { get [meth]() { } }", aExpr("=", ident("b"),

Просмотреть файл

@ -6,22 +6,22 @@ var withoutFileOrLine = Reflect.parse("42");
var withFile = Reflect.parse("42", {source:"foo.js"});
var withFileAndLine = Reflect.parse("42", {source:"foo.js", line:111});
Pattern({ source: null, start: { line: 1, column: 1 }, end: { line: 1, column: 3 } }).match(withoutFileOrLine.loc);
Pattern({ source: "foo.js", start: { line: 1, column: 1 }, end: { line: 1, column: 3 } }).match(withFile.loc);
Pattern({ source: "foo.js", start: { line: 111, column: 1 }, end: { line: 111, column: 3 } }).match(withFileAndLine.loc);
Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withoutFileOrLine.loc);
Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withFile.loc);
Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 111, column: 2 } }).match(withFileAndLine.loc);
var withoutFileOrLine2 = Reflect.parse("foo +\nbar");
var withFile2 = Reflect.parse("foo +\nbar", {source:"foo.js"});
var withFileAndLine2 = Reflect.parse("foo +\nbar", {source:"foo.js", line:111});
Pattern({ source: null, start: { line: 1, column: 1 }, end: { line: 2, column: 4 } }).match(withoutFileOrLine2.loc);
Pattern({ source: "foo.js", start: { line: 1, column: 1 }, end: { line: 2, column: 4 } }).match(withFile2.loc);
Pattern({ source: "foo.js", start: { line: 111, column: 1 }, end: { line: 112, column: 4 } }).match(withFileAndLine2.loc);
Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withoutFileOrLine2.loc);
Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withFile2.loc);
Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 112, column: 3 } }).match(withFileAndLine2.loc);
var nested = Reflect.parse("(-b + sqrt(sqr(b) - 4 * a * c)) / (2 * a)", {source:"quad.js"});
var fourAC = nested.body[0].expression.left.right.arguments[0].right;
Pattern({ source: "quad.js", start: { line: 1, column: 21 }, end: { line: 1, column: 30 } }).match(fourAC.loc);
Pattern({ source: "quad.js", start: { line: 1, column: 20 }, end: { line: 1, column: 29 } }).match(fourAC.loc);
// No source location

Просмотреть файл

@ -26,13 +26,13 @@ assertExpr("func`hey${4}``${5}there``mine`",
// multi-line template string - line numbers
var node = Reflect.parse("`\n\n ${2}\n\n\n`");
Pattern({loc:{start:{line:1, column:1}, end:{line:6, column:2}, source:null}, type:"Program",
body:[{loc:{start:{line:1, column:1}, end:{line:6, column:2}, source:null},
type:"ExpressionStatement", expression:{loc:{start:{line:1, column:1}, end:{line:6, column:2},
source:null}, type:"TemplateLiteral", elements:[{loc:{start:{line:1, column:1}, end:{line:3,
column:6}, source:null}, type:"Literal", value:"\n\n "}, {loc:{start:{line:3, column:6},
end:{line:3, column:7}, source:null}, type:"Literal", value:2}, {loc:{start:{line:3, column:7},
end:{line:6, column:2}, source:null}, type:"Literal", value:"\n\n\n"}]}}]}).match(node);
Pattern({loc:{start:{line:1, column:0}, end:{line:6, column:1}, source:null}, type:"Program",
body:[{loc:{start:{line:1, column:0}, end:{line:6, column:1}, source:null},
type:"ExpressionStatement", expression:{loc:{start:{line:1, column:0}, end:{line:6, column:1},
source:null}, type:"TemplateLiteral", elements:[{loc:{start:{line:1, column:0}, end:{line:3,
column:5}, source:null}, type:"Literal", value:"\n\n "}, {loc:{start:{line:3, column:5},
end:{line:3, column:6}, source:null}, type:"Literal", value:2}, {loc:{start:{line:3, column:6},
end:{line:6, column:1}, source:null}, type:"Literal", value:"\n\n\n"}]}}]}).match(node);
assertStringExpr("\"hey there\"", literal("hey there"));

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше