Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Macros | Functions
OOJSEngineTimeManagement.h File Reference
import "OOJavaScriptEngine.h"
+ Include dependency graph for OOJSEngineTimeManagement.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OOJSStartTimeLimiter()   OOJSStartTimeLimiterWithTimeLimit(0.0)
 
#define OOJSStartTimeLimiterWithTimeLimit(limit)   OOJSStartTimeLimiterWithTimeLimit_(limit, OOLOG_FILE_NAME, __LINE__)
 
#define OOJSStopTimeLimiter()   OOJSStopTimeLimiter_(OOLOG_FILE_NAME, __LINE__)
 
#define kOOJSLongTimeLimit   (5.0)
 

Functions

void OOJSStartTimeLimiterWithTimeLimit_ (OOTimeDelta limit, const char *file, unsigned line)
 
void OOJSStopTimeLimiter_ (const char *file, unsigned line)
 
void OOJSTimeManagementInit (OOJavaScriptEngine *engine, JSRuntime *runtime)
 

Macro Definition Documentation

◆ kOOJSLongTimeLimit

#define kOOJSLongTimeLimit   (5.0)

Definition at line 63 of file OOJSEngineTimeManagement.h.

◆ OOJSStartTimeLimiter

#define OOJSStartTimeLimiter ( )    OOJSStartTimeLimiterWithTimeLimit(0.0)

Definition at line 50 of file OOJSEngineTimeManagement.h.

Referenced by JSFunctionPredicate(), and OOStringFromDeciCredits().

◆ OOJSStartTimeLimiterWithTimeLimit

#define OOJSStartTimeLimiterWithTimeLimit ( limit)    OOJSStartTimeLimiterWithTimeLimit_(limit, OOLOG_FILE_NAME, __LINE__)

Definition at line 53 of file OOJSEngineTimeManagement.h.

Referenced by OOJSFrameCallbacksInvoke().

◆ OOJSStopTimeLimiter

#define OOJSStopTimeLimiter ( )    OOJSStopTimeLimiter_(OOLOG_FILE_NAME, __LINE__)

Function Documentation

◆ OOJSStartTimeLimiterWithTimeLimit_()

void OOJSStartTimeLimiterWithTimeLimit_ ( OOTimeDelta limit,
const char * file,
unsigned line )

Definition at line 82 of file OOJSEngineTimeManagement.m.

86{
87#if OOJS_DEBUG_LIMITER
88 OOLog(@"script.javaScript.timeLimit.debug",@"Limiter starting: %u => %u",sLimiterStartDepth,sLimiterStartDepth+1);
89#endif
90 if (sLimiterStartDepth++ == 0)
91 {
92 if (limit <= 0.0) limit = OOJS_TIME_LIMIT;
93 sLimiterTimeLimit = limit;
95
98 }
99
100#ifndef NDEBUG
101 sLastStartedFile = file;
102 sLastStartedLine = line;
103#endif
104}
#define OOJS_TIME_LIMIT
static const char * sLastStartedFile
static double sLimiterTimeLimit
static int sLimiterPauseDepth
static unsigned sLimiterStartDepth
static OOHighResTimeValue sLimiterStart
static unsigned sLastStartedLine
#define OOLog(class, format,...)
Definition OOLogging.h:88
#define OOGetHighResTime
#define OODisposeHighResTime(time)

References OODisposeHighResTime, OOGetHighResTime, OOJS_TIME_LIMIT, OOLog, sLastStartedFile, sLastStartedLine, sLimiterPauseDepth, sLimiterStart, sLimiterStartDepth, and sLimiterTimeLimit.

◆ OOJSStopTimeLimiter_()

void OOJSStopTimeLimiter_ ( const char * file,
unsigned line )

Definition at line 108 of file OOJSEngineTimeManagement.m.

112{
113#ifndef NDEBUG
114 if (sLimiterStartDepth == 0)
115 {
116 OOLog(@"bug.javaScript.limiterDepth", @"Attempt to stop JavaScript time limiter while it is already fully stopped. This is an internal bug, please report it. (Last start: %@:%u, last valid stop: %@:%u, this stop attempt: %@:%u.)", OOLogAbbreviatedFileName(sLastStartedFile), sLastStartedLine, OOLogAbbreviatedFileName(sLastStoppedFile), sLastStoppedLine, OOLogAbbreviatedFileName(file), line);
117 return;
118 }
119
120 sLastStoppedFile = file;
121 sLastStoppedLine = line;
122
123#if OOJS_DEBUG_LIMITER
124 OOLog(@"script.javaScript.timeLimit.debug",@"Limiter ending: %u <= %u",sLimiterStartDepth-1,sLimiterStartDepth);
125#endif
126
127#endif
128
129 if (--sLimiterStartDepth == 0) sLimiterTimeLimit = 0.0;
130}
static unsigned sLastStoppedLine
static const char * sLastStoppedFile
NSString * OOLogAbbreviatedFileName(const char *inName)
Definition OOLogging.m:839

References OOLog, OOLogAbbreviatedFileName(), sLastStartedFile, sLastStartedLine, sLastStoppedFile, sLastStoppedLine, sLimiterStartDepth, and sLimiterTimeLimit.

+ Here is the call graph for this function:

◆ OOJSTimeManagementInit()

void OOJSTimeManagementInit ( OOJavaScriptEngine * engine,
JSRuntime * runtime )

Definition at line 254 of file OOJSEngineTimeManagement.m.

255{
256 [NSThread detachNewThreadSelector:@selector(watchdogTimerThread)
257 toTarget:engine
258 withObject:nil];
259
260 JS_SetContextCallback(runtime, ContextCallback);
261}
static JSBool ContextCallback(JSContext *context, uintN contextOp)
return nil