Skip to content

Commit 22f045e

Browse files
authored
fix: do not collect backtrace on each gc_runtime access (#11068) (#11074)
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent b3ae195 commit 22f045e

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

crates/wasmtime/src/engine.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,8 @@ impl Engine {
671671
self.inner.allocator.as_ref()
672672
}
673673

674-
pub(crate) fn gc_runtime(&self) -> Result<&Arc<dyn GcRuntime>> {
675-
if let Some(rt) = &self.inner.gc_runtime {
676-
Ok(rt)
677-
} else {
678-
bail!("no GC runtime: GC disabled at compile time or configuration time")
679-
}
674+
pub(crate) fn gc_runtime(&self) -> Option<&Arc<dyn GcRuntime>> {
675+
self.inner.gc_runtime.as_ref()
680676
}
681677

682678
pub(crate) fn profiler(&self) -> &dyn crate::profiling_agent::ProfilingAgent {

crates/wasmtime/src/runtime/store.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,12 +1377,13 @@ impl StoreOpaque {
13771377

13781378
// Then, allocate the actual GC heap, passing in that memory
13791379
// storage.
1380-
let (index, heap) = engine.allocator().allocate_gc_heap(
1381-
engine,
1382-
&**engine.gc_runtime()?,
1383-
mem_alloc_index,
1384-
mem,
1385-
)?;
1380+
let gc_runtime = engine
1381+
.gc_runtime()
1382+
.context("no GC runtime: GC disabled at compile time or configuration time")?;
1383+
let (index, heap) =
1384+
engine
1385+
.allocator()
1386+
.allocate_gc_heap(engine, &**gc_runtime, mem_alloc_index, mem)?;
13861387

13871388
Ok(GcStore::new(index, heap))
13881389
}

crates/wasmtime/src/runtime/type_registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Engine {
133133

134134
let engine = self.clone();
135135
let registry = engine.signatures();
136-
let gc_runtime = engine.gc_runtime().ok().map(|rt| &**rt);
136+
let gc_runtime = engine.gc_runtime().map(|rt| &**rt);
137137

138138
// First, register these types in this engine's registry.
139139
let (rec_groups, types) = registry
@@ -336,7 +336,7 @@ impl RegisteredType {
336336
let (entry, index, ty, layout) = {
337337
log::trace!("RegisteredType::new({ty:?})");
338338

339-
let gc_runtime = engine.gc_runtime().ok().map(|rt| &**rt);
339+
let gc_runtime = engine.gc_runtime().map(|rt| &**rt);
340340
let mut inner = engine.signatures().0.write();
341341

342342
// It shouldn't be possible for users to construct non-canonical

0 commit comments

Comments
 (0)