faster startup and fix asan error

This commit is contained in:
2026-02-19 03:47:30 -06:00
parent 06ad466b1a
commit 38f368c6d6
5 changed files with 21 additions and 23 deletions

View File

@@ -331,7 +331,10 @@ var wildcard_sinks = []
var warned_channels = {}
var stack_channels = {}
var log_quiet_channels = { shop: true }
function log(name, args) {
if (log_quiet_channels[name]) return
var msg = args[0]
if (msg == null) msg = ""
os.print(`[${text(_cell.id, 0, 5)}] [${name}]: ${msg}\n`)
@@ -559,13 +562,7 @@ log = function(name, args) {
var stack = null
var rec = null
if (!sinks && length(wildcard_sinks) == 0) {
if (!warned_channels[name]) {
warned_channels[name] = true
os.print(`[warn] log channel '${name}' has no sinks configured\n`)
}
return
}
if (!sinks && length(wildcard_sinks) == 0) return
// C-provided stack (from JS_Log callback) overrides caller_info/os.stack
if (c_stack && length(c_stack) > 0) {
@@ -1247,17 +1244,21 @@ $_.clock(_ => {
var pkg = file_info ? file_info.package : null
// Pre-build C modules for all transitive dependencies
// Verify all transitive dependency packages are present
var _deps = null
var _di = 0
if (pkg && shop.ensure_package_dylibs) {
var _dep_dir = null
if (pkg) {
_deps = package.gather_dependencies(pkg)
_di = 0
while (_di < length(_deps)) {
shop.ensure_package_dylibs(_deps[_di])
_dep_dir = package.get_dir(_deps[_di])
if (!fd.is_dir(_dep_dir)) {
log.error('missing dependency package: ' + _deps[_di])
disrupt
}
_di = _di + 1
}
shop.ensure_package_dylibs(pkg)
}
env.use = function(path) {

View File

@@ -34,14 +34,10 @@
static JSClassID js_dylib_class_id;
static void js_dylib_finalizer(JSRuntime *rt, JSValue val) {
void *handle = JS_GetOpaque(val, js_dylib_class_id);
if (handle) {
#ifdef _WIN32
FreeLibrary((HMODULE)handle);
#else
dlclose(handle);
#endif
}
/* Do NOT dlclose here. Loaded dylibs contain finalizer functions for other
JS objects; if the dylib is freed before those objects during
JS_FreeContext teardown, calling their finalizers would SEGV.
The OS reclaims all loaded libraries on process exit. */
}
static JSClassDef js_dylib_class = {