From 5e3a8ad03e65f572597f69ab25d8f6afcdc41d21 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 9 Jul 2015 11:12:04 +0200 Subject: [PATCH] Bug 1167883 - Avoid huge stack frames and stack overflow issues with MSVC PGO builds. r=nbp --- js/src/vm/Interpreter.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 06194a17a13..27482e5657b 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -614,6 +614,12 @@ struct AutoStopwatch final } +// MSVC with PGO inlines a lot of functions in RunScript, resulting in large +// stack frames and stack overflow issues, see bug 1167883. Turn off PGO to +// avoid this. +#ifdef _MSC_VER +# pragma optimize("g", off) +#endif bool js::RunScript(JSContext* cx, RunState& state) { @@ -654,6 +660,9 @@ js::RunScript(JSContext* cx, RunState& state) return Interpret(cx, state); } +#ifdef _MSC_VER +# pragma optimize("", on) +#endif struct AutoGCIfRequested { @@ -719,10 +728,8 @@ js::Invoke(JSContext* cx, CallArgs args, MaybeConstruct construct) // Check to see if createSingleton flag should be set for this frame. if (construct) { - FrameIter iter(cx); - if (!iter.done() && iter.hasScript()) { - JSScript* script = iter.script(); - jsbytecode* pc = iter.pc(); + jsbytecode* pc; + if (JSScript* script = cx->currentScript(&pc)) { if (ObjectGroup::useSingletonForNewObject(cx, script, pc)) state.setCreateSingleton(); }