This commit is contained in:
Horis
2025-05-11 16:40:00 +08:00
parent b8cb3c8f46
commit 331e545606
@@ -77,6 +77,7 @@ class AnalyzeRule(
private val regexCache = hashMapOf<String, Regex?>() private val regexCache = hashMapOf<String, Regex?>()
private val scriptCache = hashMapOf<String, CompiledScript>() private val scriptCache = hashMapOf<String, CompiledScript>()
private var topScopeRef: WeakReference<Scriptable>? = null private var topScopeRef: WeakReference<Scriptable>? = null
private var evalJSCallCount = 0
private var coroutineContext: CoroutineContext = EmptyCoroutineContext private var coroutineContext: CoroutineContext = EmptyCoroutineContext
@@ -781,7 +782,9 @@ class AnalyzeRule(
val topScope = source?.getShareScope(coroutineContext) ?: topScopeRef?.get() val topScope = source?.getShareScope(coroutineContext) ?: topScopeRef?.get()
val scope = if (topScope == null) { val scope = if (topScope == null) {
RhinoScriptEngine.getRuntimeScope(bindings).apply { RhinoScriptEngine.getRuntimeScope(bindings).apply {
topScopeRef = WeakReference(prototype) if (evalJSCallCount++ > 16) {
topScopeRef = WeakReference(prototype)
}
} }
} else { } else {
bindings.apply { bindings.apply {