◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 0 additions & 2 deletions Cargo.lock
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ num-integer = "0.1.46"
num-traits = "0.2"
num_enum = { version = "0.7", default-features = false }
optional = "0.5"
once_cell = "1.20.3"
parking_lot = "0.12.3"
paste = "1.0.15"
proc-macro2 = "1.0.105"
Expand Down
1 change: 0 additions & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ malachite-bigint = { workspace = true }
malachite-q = { workspace = true }
malachite-base = { workspace = true }
num-traits = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true, optional = true }
unicode_names2 = { workspace = true }
radium = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/lock.rs
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@ cfg_if::cfg_if! {
if #[cfg(feature = "threading")] {
pub use parking_lot::{RawMutex, RawRwLock, RawThreadId};

pub use once_cell::sync::{Lazy, OnceCell};
} else {
mod cell_lock;
pub use cell_lock::{RawCellMutex as RawMutex, RawCellRwLock as RawRwLock, SingleThreadId as RawThreadId};

pub use once_cell::unsync::{Lazy, OnceCell};
}
}

Expand Down
25 changes: 21 additions & 4 deletions crates/common/src/static_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ mod threading {
where
F: FnOnce() -> Result<T, E>,
{
self.inner.get_or_try_init(f)
}
}

Expand Down Expand Up @@ -92,8 +97,15 @@ mod non_threading {
where
F: FnOnce() -> Result<T, E>,
{
self.inner
.with(|x| x.get_or_try_init(|| f().map(leak)).copied())
}
}

Expand Down Expand Up @@ -156,7 +168,12 @@ mod no_std {
where
F: FnOnce() -> Result<T, E>,
{
self.inner.0.get_or_try_init(f)
}
}

19 changes: 10 additions & 9 deletions crates/vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,15 +816,16 @@ impl PyFunction {
#[cfg(feature = "jit")]
#[pymethod]
fn __jit__(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<()> {
zelf.jitted_code
.get_or_try_init(|| {
let arg_types = jit::get_jit_arg_types(&zelf, vm)?;
let ret_type = jit::jit_ret_type(&zelf, vm)?;
let code = zelf.code.lock();
rustpython_jit::compile(&code.code, &arg_types, ret_type)
.map_err(|err| jit::new_jit_error(err.to_string(), vm))
})
.map(drop)
}
}

Expand Down
Loading
Toggle all file notes Toggle all file annotations