Added :trace console macro. Attempted fix for a crash apparently caused by dereferencing a NULL JS function pointer in profiler.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4327 127b21dd-08f5-0310-b4b7-95ae10353056
master
Jens Ayton 2011-02-12 12:27:14 +00:00
parent c9a5f98212
commit 19a0cbe07c
2 changed files with 5 additions and 14 deletions

View File

@ -113,7 +113,10 @@
"test" = "mission.runScreen({model:PARAM})";
// ":time <expression>" -- time a JavaScript expression.
"time" = "eval(\"this._profileFunc = function() { \" + PARAM + \" };\"); console.profile(this._profileFunc, this);";
"time" = "eval(\"this._profileFunc = function() { \" + PARAM + \" };\"); console.profile(this._profileFunc, this); delete this._profileFunc;";
// ":trace <expression>" -- trace a JavaScript expression.
"trace" = "eval(\"this._traceFunc = function() { \" + PARAM + \" };\"); console.trace(this._traceFunc, this); delete this._profileFunc;";
// For calling old-school scripting methods (on player), as in ":: gui_screen_string", or ":: playSound: boop.ogg"
":" = "performLegacyCommand(PARAM)";

View File

@ -48,19 +48,6 @@ static OOHighResTimeValue sLimiterPauseStart;
static double sLimiterTimeLimit;
enum
{
/* Inverse proportion of BranchCallback calls on which we test the time
limit. Must be a power of two!
*/
#if OOJS_DEBUG_LIMITER
kMaxBranchCount = (1 << 8) // 256
#else
kMaxBranchCount = (1 << 18) // 262144
#endif
};
#if OOJS_DEBUG_LIMITER
#define OOJS_TIME_LIMIT (0.2) // seconds
#else
@ -462,6 +449,7 @@ static void FunctionCallback(JSFunction *function, JSScript *script, JSContext *
// Ignore native functions. Ours get their own entries anyway, SpiderMonkey's are elided.
if (!sTracing && JS_GetFunctionNative(context, function) != NULL) return;
if (EXPECT_NOT(function == NULL)) return;
OOHighResTimeValue start = OOGetHighResTime();