This commit is contained in:
Horis
2025-05-11 16:40:00 +08:00
parent b8cb3c8f46
commit 331e545606

View File

@@ -77,6 +77,7 @@ class AnalyzeRule(
private val regexCache = hashMapOf<String, Regex?>()
private val scriptCache = hashMapOf<String, CompiledScript>()
private var topScopeRef: WeakReference<Scriptable>? = null
private var evalJSCallCount = 0
private var coroutineContext: CoroutineContext = EmptyCoroutineContext
@@ -781,7 +782,9 @@ class AnalyzeRule(
val topScope = source?.getShareScope(coroutineContext) ?: topScopeRef?.get()
val scope = if (topScope == null) {
RhinoScriptEngine.getRuntimeScope(bindings).apply {
topScopeRef = WeakReference(prototype)
if (evalJSCallCount++ > 16) {
topScopeRef = WeakReference(prototype)
}
}
} else {
bindings.apply {