зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1335489 - Fixes Debugger.Script lineCount getter behavior. r=luke
MozReview-Commit-ID: FO0ko60XNPF --HG-- extra : rebase_source : 3fee2fbdc7701d73bbbca149e4becad3a789f62a
This commit is contained in:
Родитель
b862b75cf0
Коммит
8aac283225
|
@ -57,6 +57,8 @@ for (let descriptor of WebAssembly.Module.imports(module)) {
|
|||
var instance = new WebAssembly.Instance(module, imports);
|
||||
`);
|
||||
var wasmScript = dbg.findScripts().filter(s => s.format == 'wasm')[0];
|
||||
assertEq(wasmScript.startLine, 1);
|
||||
assertEq(wasmScript.lineCount > 0, true);
|
||||
var lines = wasmScript.source.text.split('\n');
|
||||
var offsetsFound = 0;
|
||||
lines.forEach(function (l, n) {
|
||||
|
@ -102,6 +104,8 @@ function getWasmScriptAfterDebuggerAttached(wast) {
|
|||
|
||||
var wasmScript1 = getWasmScriptAfterDebuggerAttached('(module (func (nop)))');
|
||||
var wasmLines1 = wasmScript1.source.text.split('\n');
|
||||
assertEq(wasmScript1.startLine, 1);
|
||||
assertEq(wasmScript1.lineCount, 0);
|
||||
assertEq(wasmLines1.every((l, n) => wasmScript1.getLineOffsets(n + 1).length == 0), true);
|
||||
|
||||
// Checking that we must not resolve any location for any offset in a wasm
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// |jit-test| test-also-wasm-baseline
|
||||
// Tests debugEnabled state of wasm when allowUnobservedAsmJS == true.
|
||||
|
||||
load(libdir + "asserts.js");
|
||||
|
||||
if (!wasmIsSupported())
|
||||
quit();
|
||||
|
||||
// Checking that there are no offsets are present in a wasm instance script for
|
||||
// which debug mode was not enabled.
|
||||
function getWasmScriptWithoutAllowUnobservedAsmJS(wast) {
|
||||
var sandbox = newGlobal('');
|
||||
var dbg = new Debugger();
|
||||
dbg.allowUnobservedAsmJS = true;
|
||||
dbg.addDebuggee(sandbox);
|
||||
sandbox.eval(`
|
||||
var wasm = wasmTextToBinary('${wast}');
|
||||
var m = new WebAssembly.Instance(new WebAssembly.Module(wasm));
|
||||
`);
|
||||
// Attaching after wasm instance is created.
|
||||
var wasmScript = dbg.findScripts().filter(s => s.format == 'wasm')[0];
|
||||
return wasmScript;
|
||||
}
|
||||
|
||||
var wasmScript1 = getWasmScriptWithoutAllowUnobservedAsmJS('(module (func (nop)))');
|
||||
var wasmLines1 = wasmScript1.source.text.split('\n');
|
||||
assertEq(wasmScript1.startLine, 1);
|
||||
assertEq(wasmScript1.lineCount, 0);
|
||||
assertEq(wasmLines1.every((l, n) => wasmScript1.getLineOffsets(n + 1).length == 0), true);
|
||||
|
||||
// Checking that we must not resolve any location for any offset in a wasm
|
||||
// instance which debug mode was not enabled.
|
||||
var wasmScript2 = getWasmScriptWithoutAllowUnobservedAsmJS('(module (func (nop)))');
|
||||
for (var i = wasmTextToBinary('(module (func (nop)))').length - 1; i >= 0; i--)
|
||||
assertThrowsInstanceOf(() => wasmScript2.getOffsetLocation(i), Error);
|
|
@ -5677,7 +5677,7 @@ struct DebuggerScriptGetLineCountMatcher
|
|||
}
|
||||
ReturnType match(Handle<WasmInstanceObject*> wasmInstance) {
|
||||
uint32_t result;
|
||||
if (wasmInstance->instance().code().totalSourceLines(cx_, &result))
|
||||
if (!wasmInstance->instance().code().totalSourceLines(cx_, &result))
|
||||
return false;
|
||||
totalLines = double(result);
|
||||
return true;
|
||||
|
|
|
@ -864,12 +864,14 @@ Code::getOffsetLocation(JSContext* cx, uint32_t offset, bool* found, size_t* lin
|
|||
bool
|
||||
Code::totalSourceLines(JSContext* cx, uint32_t* count)
|
||||
{
|
||||
*count = 0;
|
||||
if (!metadata_->debugEnabled)
|
||||
return true;
|
||||
|
||||
if (!ensureSourceMap(cx))
|
||||
return false;
|
||||
|
||||
if (!maybeSourceMap_)
|
||||
*count = 0;
|
||||
else
|
||||
if (maybeSourceMap_)
|
||||
*count = maybeSourceMap_->totalLines() + experimentalWarningLinesCount;
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче