Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NOTE: Don't run this in the playground if the allocation is huge
- // use the `...` button and view assembly only.
- extern crate crossbeam; // 0.7.2
- use crossbeam::atomic::AtomicCell;
- fn main() {
- // call is required to avoid dead-code elimination
- // norun();
- }
- fn norun() {
- const MAX_VOCAB: usize = 2 << 28;
- let mut wordidx: Vec<AtomicCell<Option<u32>>> =
- Vec::with_capacity(MAX_VOCAB); wordidx.resize_with(MAX_VOCAB, || AtomicCell::new(None));
- // compiler trick to ensure the assembly is actually emitted:
- // because the address of the allocation is displayed, the optimizer
- // assumes that it actually has to write to the allocated memory.
- // See the llvm docs for `nocapture` attribute and Wikipedia
- // "Escape Analysis" for more.
- println!("{:p}", wordidx.as_ptr());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement