diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 318eb53303d..1ac7b606aa2 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -1245,8 +1245,11 @@ ReadSPSProfilingStack(JSContext *cx, unsigned argc, jsval *vp) CallArgs args = CallArgsFromVp(argc, vp); args.rval().setUndefined(); - if (!cx->runtime()->spsProfiler.enabled()) + // Return boolean 'false' if profiler is not enabled. + if (!cx->runtime()->spsProfiler.enabled()) { args.rval().setBoolean(false); + return true; + } // Array holding physical jit stack frames. RootedObject stack(cx, NewDenseEmptyArray(cx)); diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index 670c05fa93d..9565cde6428 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -1719,6 +1719,9 @@ JS::ProfilingFrameIterator::ProfilingFrameIterator(JSRuntime *rt, const Register activation_(rt->profilingActivation()), savedPrevJitTop_(nullptr) { + // Should only be instantiated when profiling is enabled. + MOZ_ASSERT(rt_->spsProfiler.enabled()); + if (!activation_) return;