Bug 1330491 - Always provide wasm bytecode for debuggable instance. r=luke
authorYury Delendik <ydelendik@mozilla.com>
Thu, 12 Jan 2017 10:16:41 -0600
changeset 374391 6e2a6c6c3881562e942d67a66acccfd8e1007dde
parent 374390 6d67b80ede88eedb11b42a13e52393a657a3ba5b
child 374392 af1e1981ddc8806263292f1f72f01e13eed1f35d
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1330491
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1330491 - Always provide wasm bytecode for debuggable instance. r=luke MozReview-Commit-ID: 4QTn0giN0wb
js/src/jit-test/tests/debug/bug1330491.js
js/src/wasm/WasmModule.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1330491.js
@@ -0,0 +1,21 @@
+// |jit-test| test-also-wasm-baseline; error: TestComplete
+
+if (!wasmIsSupported())
+     throw "TestComplete";
+
+(function createShortLivedDebugger() {
+    var g = newGlobal();
+    g.debuggeeGlobal = this;
+    g.eval("(" + function () {
+        dbg = new Debugger(debuggeeGlobal);
+    } + ")();");
+})();
+
+let module = new WebAssembly.Module(wasmTextToBinary('(module (func))'));
+new WebAssembly.Instance(module);
+
+gcslice(1000000);
+
+new WebAssembly.Instance(module);
+
+throw "TestComplete";
\ No newline at end of file
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -888,22 +888,26 @@ Module::instantiate(JSContext* cx,
     SharedTableVector tables;
     if (!instantiateTable(cx, &table, &tables))
         return false;
 
     // To support viewing the source of an instance (Instance::createText), the
     // instance must hold onto a ref of the bytecode (keeping it alive). This
     // wastes memory for most users, so we try to only save the source when a
     // developer actually cares: when the compartment is debuggable (which is
-    // true when the web console is open) or a names section is present (since
-    // this going to be stripped for non-developer builds).
+    // true when the web console is open), has code compiled with debug flag
+    // enabled or a names section is present (since this going to be stripped
+    // for non-developer builds).
 
     const ShareableBytes* maybeBytecode = nullptr;
-    if (cx->compartment()->isDebuggee() || !metadata_->funcNames.empty())
+    if (cx->compartment()->isDebuggee() || metadata_->debugEnabled ||
+        !metadata_->funcNames.empty())
+    {
         maybeBytecode = bytecode_.get();
+    }
 
     auto codeSegment = CodeSegment::create(cx, code_, linkData_, *metadata_, memory);
     if (!codeSegment)
         return false;
 
     auto code = cx->make_unique<Code>(Move(codeSegment), *metadata_, maybeBytecode);
     if (!code)
         return false;