tangled
alpha
login
or
join now
tjh.dev
/
um32
1
fork
atom
Implementation of the UM-32 "Universal Machine" as described by the
Cult of the Bound Variable
1
fork
atom
overview
issues
pulls
pipelines
add timing feature
tjh
1 year ago
61d725d1
890c4632
+9
2 changed files
expand all
collapse all
unified
split
Cargo.toml
src
main.rs
+1
Cargo.toml
···
10
10
default = ["reclaim-memory"]
11
11
reclaim-memory = []
12
12
smallvec = ["dep:smallvec"]
13
13
+
timing = []
+8
src/main.rs
···
1
1
#[cfg(feature = "smallvec")]
2
2
use smallvec::SmallVec;
3
3
+
#[cfg(feature = "timing")]
3
4
use std::time::Instant;
4
5
5
6
#[cfg(feature = "smallvec")]
···
178
179
179
180
/// Begins the spin-cycle of the universal machine.
180
181
pub fn run(mut self) {
182
182
+
#[cfg(feature = "timing")]
183
183
+
let start = Instant::now();
184
184
+
181
185
loop {
182
186
match self.ops[self.program_counter as usize] {
183
187
// Operator #0. Conditional Move.
···
357
361
358
362
self.program_counter += 1;
359
363
}
364
364
+
365
365
+
#[cfg(feature = "timing")]
366
366
+
eprintln!("um complete: {:?}", start.elapsed());
360
367
}
361
368
362
369
/// Loads the value from the specified register.
···
419
426
}
420
427
}
421
428
429
429
+
#[cold]
422
430
#[inline(never)]
423
431
fn panic(&self) -> ! {
424
432
panic!(