Add "debug" mode to JS, exposing stack frames

When the Debug checkbox is set, or -XDebug passed to the compiler, the
JavaScript backend will track local variables and retain them for
presentation to the user when an exception occurs.