Enable SCOPE_POOL globally across all platforms and refactor pooling logic to enhance robustness, efficiency, and cleanup mechanisms. Update documentation to reflect changes.
This commit is contained in:
1 parent
8f04b25fcb
commit
f6deabaa38
13 files changed
+101
-74
No files matched your search
@@ -1734,7 +1734,7 @@ class Compiler(
|
||||
// Rebind error scope to the throw-site position so ScriptError.pos is accurate
|
||||
val throwScope = sc.createChildScope(pos = start)
|
||||
if (errorObject is ObjString) {
|
||||
errorObject = ObjException(throwScope, errorObject.value)
|
||||
errorObject = ObjException(throwScope, errorObject.value).apply { getStackTrace() }
|
||||
}
|
||||
if (!errorObject.isInstanceOf(ObjException.Root)) {
|
||||
throwScope.raiseError("this is not an exception object: $errorObject")
|
||||
@@ -1746,7 +1746,7 @@ class Compiler(
|
||||
errorObject.message,
|
||||
errorObject.extraData,
|
||||
errorObject.useStackTrace
|
||||
)
|
||||
).apply { getStackTrace() }
|
||||
throwScope.raiseError(errorObject)
|
||||
} else {
|
||||
val msg = errorObject.invokeInstanceMethod(sc, "message").toString(sc).value
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,7 @@ import net.sergeych.lyng.obj.Obj
|
||||
|
||||
/**
|
||||
* Expect/actual portable scope frame pool. Used only when [PerfFlags.SCOPE_POOL] is true.
|
||||
* JVM actual provides a ThreadLocal-backed pool; other targets may use a simple global deque.
|
||||
* Provides per-thread pooling on JVM, Android, and Native; global pooling on JS and Wasm.
|
||||
*/
|
||||
expect object ScopePool {
|
||||
fun borrow(parent: Scope, args: Arguments, pos: Pos, thisObj: Obj): Scope
|
||||
|
||||
@@ -129,7 +129,9 @@ open class ObjException(
|
||||
|
||||
override suspend fun callOn(scope: Scope): Obj {
|
||||
val message = scope.args.getOrNull(0)?.toString(scope) ?: ObjString(name)
|
||||
return ObjException(this, scope, message)
|
||||
val ex = ObjException(this, scope, message)
|
||||
ex.getStackTrace()
|
||||
return ex
|
||||
}
|
||||
|
||||
override fun toString(): String = name
|
||||
|
||||
Reference in new issue
Block a user