Bug 822041 - Do not copy hasPushedSPSFrame() from heap generator frame. r=luke
authorSteve Fink <sfink@mozilla.com>
Mon, 01 Apr 2013 17:58:37 -0700
changeset 127123 88288ea65ef8
parent 127122 b06fa2317215
child 127124 fb7aae8421bc
push id117
push usertomi.aarnio@nokia.com
push dateWed, 03 Apr 2013 12:07:07 +0000
reviewersluke
bugs822041
milestone23.0a1
Bug 822041 - Do not copy hasPushedSPSFrame() from heap generator frame. r=luke
browser/devtools/profiler/test/Makefile.in
js/src/builtin/TestingFunctions.cpp
js/src/tests/js1_8_5/extensions/sps-generators.js
js/src/vm/Stack.cpp
--- a/browser/devtools/profiler/test/Makefile.in
+++ b/browser/devtools/profiler/test/Makefile.in
@@ -10,24 +10,22 @@ relativesrcdir = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_BROWSER_TESTS = \
 		browser_profiler_profiles.js \
 		browser_profiler_remote.js \
 		browser_profiler_bug_834878_source_buttons.js \
 		browser_profiler_cmd.js \
+		browser_profiler_run.js \
+		browser_profiler_controller.js \
+		browser_profiler_bug_830664_multiple_profiles.js \
 		head.js \
 		$(NULL)
 
-# Naughty corner (bug 822041 & bug 822287)
-#		browser_profiler_run.js \
-#		browser_profiler_controller.js \
-#		browser_profiler_bug_830664_multiple_profiles.js \
-
 MOCHITEST_BROWSER_PAGES = \
 		mock_profiler_bug_834878_page.html \
 		mock_profiler_bug_834878_script.js \
 		$(NULL)
 
 MOCHITEST_BROWSER_FILES_PARTS = MOCHITEST_BROWSER_TESTS MOCHITEST_BROWSER_PAGES
 
 include $(topsrcdir)/config/rules.mk
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -878,16 +878,24 @@ EnableSPSProfilingAssertions(JSContext *
     cx->runtime->spsProfiler.enableSlowAssertions(args[0].toBoolean());
     cx->runtime->spsProfiler.enable(true);
 
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return true;
 }
 
 static JSBool
+DisableSPSProfiling(JSContext *cx, unsigned argc, jsval *vp)
+{
+    if (cx->runtime->spsProfiler.installed())
+        cx->runtime->spsProfiler.enable(false);
+    return true;
+}
+
+static JSBool
 DisplayName(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (argc == 0 || !args[0].isObject() || !args[0].toObject().isFunction()) {
         RootedObject arg(cx, &args.callee());
         ReportUsageError(cx, arg, "Must have one function argument");
         return false;
     }
@@ -1042,16 +1050,20 @@ static JSFunctionSpecWithHelp TestingFun
 
     JS_FN_HELP("enableSPSProfilingAssertions", EnableSPSProfilingAssertions, 1, 0,
 "enableSPSProfilingAssertions(slow)",
 "  Enables SPS instrumentation and corresponding assertions. If 'slow' is\n"
 "  true, then even slower assertions are enabled for all generated JIT code.\n"
 "  When 'slow' is false, then instrumentation is enabled, but the slow\n"
 "  assertions are disabled."),
 
+    JS_FN_HELP("disableSPSProfiling", DisableSPSProfiling, 1, 0,
+"disableSPSProfiling()",
+"  Disables SPS instrumentation"),
+
     JS_FN_HELP("displayName", DisplayName, 1, 0,
 "displayName(fn)",
 "  Gets the display name for a function, which can possibly be a guessed or\n"
 "  inferred name based on where the function was defined. This can be\n"
 "  different from the 'name' property on the function."),
 
     JS_FN_HELP("isAsmJSCompilationAvailable", IsAsmJSCompilationAvailable, 0, 0,
 "isAsmJSCompilationAvailable",
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/sps-generators.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!xulRuntime.shell)
+
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 822041;
+var summary = "Live generators should not cache SPS state";
+
+print(BUGNUMBER + ": " + summary);
+
+function gen() {
+  var x = yield turnoff();
+  yield x;
+  yield 'bye';
+}
+
+function turnoff() {
+  print("Turning off profiler\n");
+  disableSPSProfiling();
+  return 'hi';
+}
+
+for (var slowAsserts of [ true, false ]) {
+  // The slowAssertions setting is not expected to matter
+  enableSPSProfilingAssertions(slowAsserts);
+
+  g = gen();
+  assertEq(g.next(), 'hi');
+  assertEq(g.send('gurgitating...'), 'gurgitating...');
+  for (var x in g)
+    assertEq(x, 'bye');
+}
+
+// This is really a crashtest
+reportCompare(0, 0, 'ok');
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -120,16 +120,17 @@ StackFrame::copyFrameAndValues(JSContext
     Value *dst = vp;
     for (const Value *src = othervp; src < srcend; src++, dst++) {
         *dst = *src;
         if (doPostBarrier)
             HeapValue::writeBarrierPost(*dst, dst);
     }
 
     *this = *otherfp;
+    unsetPushedSPSFrame();
     if (doPostBarrier)
         writeBarrierPost();
 
     srcend = othersp;
     dst = slots();
     for (const Value *src = otherfp->slots(); src < srcend; src++, dst++) {
         *dst = *src;
         if (doPostBarrier)