Bug 1492301 - Baldr: remove unneeded Debugger.allowWasmBinarySource option (r=yury)

--HG--
extra : rebase_source : 397043cf3cc70f46bf2ba10f6c69a11540ec1c79
This commit is contained in:
Luke Wagner 2018-11-19 16:45:51 -06:00
parent 256980ac39
commit 22d962a57d
13 changed files with 14 additions and 128 deletions

View File

@ -355,7 +355,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
}
}
if (isWasm && this.dbg.allowWasmBinarySource) {
if (isWasm) {
const wasm = this.source.binary;
const buffer = wasm.buffer;
assert(

View File

@ -439,9 +439,6 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
if ("observeAsmJS" in options) {
this.dbg.allowUnobservedAsmJS = !options.observeAsmJS;
}
if ("wasmBinarySource" in options) {
this.dbg.allowWasmBinarySource = !!options.wasmBinarySource;
}
Object.assign(this._options, options);

View File

@ -73,16 +73,12 @@ from its prototype:
`FunctionDeclaration`, or `FunctionExpression` productions in the
ECMAScript standard.
**If the instance refers to WebAssembly code**, the serialized text
representation. The format is yet to be specified in the WebAssembly
standard. Currently, the text is an s-expression based syntax. The text
generation is disabled if the Debugger has the `allowWasmBinarySource`
property set, the `"[wasm]"` value will be returned in this case.
**If the instance refers to WebAssembly code**, the `"[wasm]"` value will
be returned.
`binary`
: **If the instance refers to WebAssembly code** and the Debugger has
the `allowWasmBinarySource` property set, a Uint8Array that contains the
WebAssembly bytecode.
: **If the instance refers to WebAssembly code**, a Uint8Array that contains
the WebAssembly bytecode.
`url`
: **If the instance refers to JavaScript source**, the filename or URL from

View File

@ -37,10 +37,6 @@ its prototype:
Debugger API (e.g, [`Debugger.Source`][source]) for purposes other than
step debugging a target JavaScript program.
`allowWasmBinarySource`
: A boolean value indicating whether WebAssembly sources will be available
in binary form. The WebAssembly text generation will be disabled.
`collectCoverageInfo`
: A boolean value indicating whether code coverage should be enabled inside
each debuggee of this `Debugger` instance. Changing this flag value will

View File

@ -132,9 +132,6 @@ function wasmRunWithDebugger(wast, lib, init, done) {
let g = newGlobal('');
let dbg = new Debugger(g);
// Enable binary source mode.
dbg.allowWasmBinarySource = true;
g.eval(`
var wasm = wasmTextToBinary('${wast}');
var lib = ${lib || 'undefined'};

View File

@ -20,10 +20,6 @@ var source = s.source;
// The text is never generated with the native Debugger API.
assertEq(source.text.includes('module'), false);
assertThrowsInstanceOf(() => source.binary, Error);
// Enable binary sources.
dbg.allowWasmBinarySource = true;
g.eval(`o = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func) (export "" 0))')));`);
assertEq(s.format, "wasm");

View File

@ -703,7 +703,6 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg)
uncaughtExceptionHook(nullptr),
enabled(true),
allowUnobservedAsmJS(false),
allowWasmBinarySource(false),
collectCoverageInfo(false),
observedGCs(cx->zone()),
allocationsLog(cx),
@ -3092,15 +3091,6 @@ Debugger::observesAsmJS() const
return NotObserving;
}
Debugger::IsObserving
Debugger::observesBinarySource() const
{
if (enabled && allowWasmBinarySource) {
return Observing;
}
return NotObserving;
}
Debugger::IsObserving
Debugger::observesCoverage() const
{
@ -3208,21 +3198,6 @@ Debugger::updateObservesAsmJSOnDebuggees(IsObserving observing)
}
}
void
Debugger::updateObservesBinarySourceDebuggees(IsObserving observing)
{
for (WeakGlobalObjectSet::Range r = debuggees.all(); !r.empty(); r.popFront()) {
GlobalObject* global = r.front();
Realm* realm = global->realm();
if (realm->debuggerObservesBinarySource() == observing) {
continue;
}
realm->updateDebuggerObservesBinarySource();
}
}
/*** Allocations Tracking *************************************************************************/
@ -3720,7 +3695,6 @@ Debugger::setEnabled(JSContext* cx, unsigned argc, Value* vp)
// stack frame, thus the coverage does not depend on the enabled flag.
dbg->updateObservesAsmJSOnDebuggees(dbg->observesAsmJS());
dbg->updateObservesBinarySourceDebuggees(dbg->observesBinarySource());
}
args.rval().setUndefined();
@ -3930,33 +3904,6 @@ Debugger::setAllowUnobservedAsmJS(JSContext* cx, unsigned argc, Value* vp)
return true;
}
/* static */ bool
Debugger::getAllowWasmBinarySource(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGGER(cx, argc, vp, "get allowWasmBinarySource", args, dbg);
args.rval().setBoolean(dbg->allowWasmBinarySource);
return true;
}
/* static */ bool
Debugger::setAllowWasmBinarySource(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGGER(cx, argc, vp, "set allowWasmBinarySource", args, dbg);
if (!args.requireAtLeast(cx, "Debugger.set allowWasmBinarySource", 1)) {
return false;
}
dbg->allowWasmBinarySource = ToBoolean(args[0]);
for (WeakGlobalObjectSet::Range r = dbg->debuggees.all(); !r.empty(); r.popFront()) {
GlobalObject* global = r.front();
Realm* realm = global->realm();
realm->updateDebuggerObservesBinarySource();
}
args.rval().setUndefined();
return true;
}
/* static */ bool
Debugger::getCollectCoverageInfo(JSContext* cx, unsigned argc, Value* vp)
{
@ -4441,7 +4388,6 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global)
AutoRestoreRealmDebugMode debugModeGuard(debuggeeRealm);
debuggeeRealm->setIsDebuggee();
debuggeeRealm->updateDebuggerObservesAsmJS();
debuggeeRealm->updateDebuggerObservesBinarySource();
debuggeeRealm->updateDebuggerObservesCoverage();
if (observesAllExecution() && !ensureExecutionObservabilityOfRealm(cx, debuggeeRealm)) {
return false;
@ -4583,7 +4529,6 @@ Debugger::removeDebuggeeGlobal(FreeOp* fop, GlobalObject* global,
} else {
global->realm()->updateDebuggerObservesAllExecution();
global->realm()->updateDebuggerObservesAsmJS();
global->realm()->updateDebuggerObservesBinarySource();
global->realm()->updateDebuggerObservesCoverage();
}
}
@ -5818,8 +5763,6 @@ const JSPropertySpec Debugger::properties[] = {
Debugger::setUncaughtExceptionHook, 0),
JS_PSGS("allowUnobservedAsmJS", Debugger::getAllowUnobservedAsmJS,
Debugger::setAllowUnobservedAsmJS, 0),
JS_PSGS("allowWasmBinarySource", Debugger::getAllowWasmBinarySource,
Debugger::setAllowWasmBinarySource, 0),
JS_PSGS("collectCoverageInfo", Debugger::getCollectCoverageInfo,
Debugger::setCollectCoverageInfo, 0),
JS_PSG("memory", Debugger::getMemory, 0),
@ -6292,7 +6235,7 @@ struct DebuggerScriptGetLineCountMatcher
ReturnType match(Handle<WasmInstanceObject*> instanceObj) {
wasm::Instance& instance = instanceObj->instance();
if (instance.debugEnabled()) {
totalLines = double(instance.debug().totalSourceLines());
totalLines = double(instance.debug().bytecode().length());
} else {
totalLines = 0;
}
@ -8073,7 +8016,7 @@ DebuggerSource_getBinary(JSContext* cx, unsigned argc, Value* vp)
RootedWasmInstanceObject instanceObj(cx, referent.as<WasmInstanceObject*>());
wasm::Instance& instance = instanceObj->instance();
if (!instance.debugEnabled() || !instance.debug().binarySource()) {
if (!instance.debugEnabled()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_DEBUG_NO_BINARY_SOURCE);
return false;

View File

@ -454,7 +454,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
js::GCPtrObject uncaughtExceptionHook; /* Strong reference. */
bool enabled;
bool allowUnobservedAsmJS;
bool allowWasmBinarySource;
// Whether to enable code coverage on the Debuggee.
bool collectCoverageInfo;
@ -755,8 +754,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
static bool setUncaughtExceptionHook(JSContext* cx, unsigned argc, Value* vp);
static bool getAllowUnobservedAsmJS(JSContext* cx, unsigned argc, Value* vp);
static bool setAllowUnobservedAsmJS(JSContext* cx, unsigned argc, Value* vp);
static bool getAllowWasmBinarySource(JSContext* cx, unsigned argc, Value* vp);
static bool setAllowWasmBinarySource(JSContext* cx, unsigned argc, Value* vp);
static bool getCollectCoverageInfo(JSContext* cx, unsigned argc, Value* vp);
static bool setCollectCoverageInfo(JSContext* cx, unsigned argc, Value* vp);
static bool getMemory(JSContext* cx, unsigned argc, Value* vp);
@ -829,8 +826,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
// execution.
IsObserving observesCoverage() const;
IsObserving observesBinarySource() const;
private:
static MOZ_MUST_USE bool ensureExecutionObservabilityOfFrame(JSContext* cx,
AbstractFramePtr frame);
@ -842,7 +837,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
MOZ_MUST_USE bool updateObservesAllExecutionOnDebuggees(JSContext* cx, IsObserving observing);
MOZ_MUST_USE bool updateObservesCoverageOnDebuggees(JSContext* cx, IsObserving observing);
void updateObservesAsmJSOnDebuggees(IsObserving observing);
void updateObservesBinarySourceDebuggees(IsObserving observing);
JSObject* getHook(Hook hook) const;
bool hasAnyLiveHooks(JSRuntime* rt) const;

View File

@ -817,8 +817,7 @@ Realm::updateDebuggerObservesFlag(unsigned flag)
MOZ_ASSERT(isDebuggee());
MOZ_ASSERT(flag == DebuggerObservesAllExecution ||
flag == DebuggerObservesCoverage ||
flag == DebuggerObservesAsmJS ||
flag == DebuggerObservesBinarySource);
flag == DebuggerObservesAsmJS);
GlobalObject* global = zone()->runtimeFromMainThread()->gc.isForegroundSweeping()
? unsafeUnbarrieredMaybeGlobal()
@ -828,8 +827,7 @@ Realm::updateDebuggerObservesFlag(unsigned flag)
Debugger* dbg = *p;
if (flag == DebuggerObservesAllExecution ? dbg->observesAllExecution() :
flag == DebuggerObservesCoverage ? dbg->observesCoverage() :
flag == DebuggerObservesAsmJS ? dbg->observesAsmJS() :
dbg->observesBinarySource())
flag == DebuggerObservesAsmJS && dbg->observesAsmJS())
{
debugModeBits_ |= flag;
return;

View File

@ -387,14 +387,12 @@ class JS::Realm : public JS::shadow::Realm
DebuggerObservesAllExecution = 1 << 1,
DebuggerObservesAsmJS = 1 << 2,
DebuggerObservesCoverage = 1 << 3,
DebuggerObservesBinarySource = 1 << 4,
DebuggerNeedsDelazification = 1 << 5
DebuggerNeedsDelazification = 1 << 4
};
static const unsigned DebuggerObservesMask = IsDebuggee |
DebuggerObservesAllExecution |
DebuggerObservesCoverage |
DebuggerObservesAsmJS |
DebuggerObservesBinarySource;
DebuggerObservesAsmJS;
unsigned debugModeBits_ = 0;
friend class js::AutoRestoreRealmDebugMode;
@ -766,15 +764,6 @@ class JS::Realm : public JS::shadow::Realm
updateDebuggerObservesFlag(DebuggerObservesAsmJS);
}
bool debuggerObservesBinarySource() const {
static const unsigned Mask = IsDebuggee | DebuggerObservesBinarySource;
return (debugModeBits_ & Mask) == Mask;
}
void updateDebuggerObservesBinarySource() {
updateDebuggerObservesFlag(DebuggerObservesBinarySource);
}
// True if this realm's global is a debuggee of some Debugger object
// whose collectCoverageInfo flag is true.
bool debuggerObservesCoverage() const {

View File

@ -34,10 +34,9 @@ using namespace js::wasm;
using mozilla::BinarySearchIf;
DebugState::DebugState(const Code& code, const Module& module, bool binarySource)
DebugState::DebugState(const Code& code, const Module& module)
: code_(&code),
module_(&module),
binarySource_(binarySource),
enterFrameTrapsEnabled_(false),
enterAndLeaveFrameTrapsCounter_(0)
{
@ -60,9 +59,6 @@ SlowCallSiteSearchByOffset(const MetadataTier& metadata, uint32_t offset)
bool
DebugState::getLineOffsets(JSContext* cx, size_t lineno, Vector<uint32_t>* offsets)
{
if (!binarySource_) {
return true;
}
const CallSite* callsite = SlowCallSiteSearchByOffset(metadata(Tier::Debug), lineno);
if (callsite && !offsets->append(lineno)) {
return false;
@ -73,9 +69,6 @@ DebugState::getLineOffsets(JSContext* cx, size_t lineno, Vector<uint32_t>* offse
bool
DebugState::getAllColumnOffsets(JSContext* cx, Vector<ExprLoc>* offsets)
{
if (!binarySource_) {
return true;
}
for (const CallSite& callSite : metadata(Tier::Debug).callSites) {
if (callSite.kind() != CallSite::Breakpoint) {
continue;
@ -91,9 +84,6 @@ DebugState::getAllColumnOffsets(JSContext* cx, Vector<ExprLoc>* offsets)
bool
DebugState::getOffsetLocation(uint32_t offset, size_t* lineno, size_t* column)
{
if (!binarySource_) {
return false;
}
if (!SlowCallSiteSearchByOffset(metadata(Tier::Debug), offset)) {
return false;
}
@ -102,12 +92,6 @@ DebugState::getOffsetLocation(uint32_t offset, size_t* lineno, size_t* column)
return true;
}
uint32_t
DebugState::totalSourceLines()
{
return binarySource_ ? bytecode().length() : 0;
}
bool
DebugState::stepModeEnabled(uint32_t funcIndex) const
{

View File

@ -56,7 +56,6 @@ class DebugState
{
const SharedCode code_;
const SharedModule module_;
bool binarySource_;
// State maintained when debugging is enabled. In this case, the Code is
// not actually shared, but is referenced uniquely by the instance that is
@ -70,15 +69,13 @@ class DebugState
void toggleDebugTrap(uint32_t offset, bool enabled);
public:
DebugState(const Code& code, const Module& module, bool binarySource);
DebugState(const Code& code, const Module& module);
const Bytes& bytecode() const { return module_->debugBytecode(); }
bool binarySource() const { return binarySource_; }
bool getLineOffsets(JSContext* cx, size_t lineno, Vector<uint32_t>* offsets);
bool getAllColumnOffsets(JSContext* cx, Vector<ExprLoc>* offsets);
bool getOffsetLocation(uint32_t offset, size_t* lineno, size_t* column);
uint32_t totalSourceLines();
// The Code can track enter/leave frame events. Any such event triggers
// debug trap. The enter/leave frame events enabled or disabled across

View File

@ -1324,8 +1324,7 @@ Module::instantiate(JSContext* cx,
return false;
}
bool binarySource = cx->realm()->debuggerObservesBinarySource();
maybeDebug = cx->make_unique<DebugState>(*code, *this, binarySource);
maybeDebug = cx->make_unique<DebugState>(*code, *this);
if (!maybeDebug) {
return false;
}