Bug 1341080: Provide an empty filename if the wasm caller doesn't have one in DescribeScriptedCaller; r=luke a=gchang
authorBenjamin Bouvier <benj@benj.me>
Mon, 20 Feb 2017 20:18:23 +0100
changeset 378643 8e4f44727c5bb84cd613de9ec81b8c65ca8c51c3
parent 378642 0fc2172500a97355bfd91b37e26b1c23e77d5d32
child 378644 66dc4881acf7b15bc9bce7186a9f5cbaaf1f8201
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, gchang
bugs1341080
milestone53.0a2
Bug 1341080: Provide an empty filename if the wasm caller doesn't have one in DescribeScriptedCaller; r=luke a=gchang MozReview-Commit-ID: 8h0NbN7jOBq
js/src/jit-test/tests/wasm/regress/null-metadata-filename.js
js/src/jsapi.cpp
--- a/js/src/jit-test/tests/wasm/regress/null-metadata-filename.js
+++ b/js/src/jit-test/tests/wasm/regress/null-metadata-filename.js
@@ -2,8 +2,20 @@ if (typeof enableSPSProfiling === 'undef
     quit();
 
 enableSPSProfiling();
 var code = evaluate("(function() { 'use asm'; function g() { return 43 } return g })", {
     fileName: null
 });
 
 assertEq(code()(), 43);
+
+evaluate(`
+let f = evalReturningScope.bind(null, '');
+
+(function(glob, stdlib) {
+    "use asm";
+    var f = stdlib.f;
+    function _() { f(); }
+    return _;
+})(this, { f })();
+`, { fileName: null });
+
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6557,17 +6557,17 @@ DescribeScriptedCaller(JSContext* cx, Au
     // If the caller is hidden, the embedding wants us to return false here so
     // that it can check its own stack (see HideScriptedCaller).
     if (i.activation()->scriptedCallerIsHidden())
         return false;
 
     if (filename) {
         if (i.isWasm()) {
             // For Wasm, copy out the filename, there is no script source.
-            UniqueChars copy = DuplicateString(i.filename());
+            UniqueChars copy = DuplicateString(i.filename() ? i.filename() : "");
             if (!copy)
                 filename->setUnowned("out of memory");
             else
                 filename->setOwned(Move(copy));
         } else {
             // All other frames have a script source to read the filename from.
             filename->setScriptSource(i.scriptSource());
         }