Skip to main content

RegWindow

Struct RegWindow 

Source
pub struct RegWindow { /* private fields */ }
Expand description

Contiguous register window (e.g. four slots for make_msg natives).

Implementations§

Source§

impl RegWindow

Source

pub fn base(self) -> Reg

First register in the window (native result lands here for make_msg).

Source

pub fn at(self, i: u8) -> Reg

Register at offset i within the window (0 <= i < len).

Examples found in repository?
examples/atomic_actors.rs (line 55)
22fn atomic_actors_chunk() -> Chunk {
23    let mut program = Program::new("atomic-actors");
24    let server = program.function("server", 0, |f| {
25        let loop_lbl = f.label();
26        f.bind(loop_lbl);
27        let req = f.receive_match_imm(TAG_REQ as u16);
28        let payload = f.hop_payload(req);
29        f.add_imm(payload, 1);
30        f.send_reply(req, TAG_REP, payload);
31        f.jump(loop_lbl);
32    });
33    let client = program.function("client", 2, |f| {
34        let server_cap = f.reg(0);
35        let parent_cap = f.reg(1);
36        let acc = f.load_i32(0);
37        let i = f.load_i32(0);
38        let n = f.load_i32(ROUNDS);
39        f.while_lt(i, n, |f| {
40            let req = f.hop_fresh(TAG_REQ, i);
41            let reply = f.ask(server_cap, req);
42            let got = f.hop_payload(reply);
43            let sum = f.add(acc, got);
44            f.mov(acc, sum);
45            f.add_imm(i, 1);
46        });
47        let done = f.hop_fresh(TAG_REP, acc);
48        f.send(parent_cap, done);
49        f.return_(acc);
50    });
51    program.function("main", 0, |f| {
52        let server_cap = f.spawn(server, 0);
53        let me = f.self_cap();
54        let w1 = f.window(3);
55        f.mov(w1.at(1), server_cap);
56        f.mov(w1.at(2), me);
57        f.spawn_at(w1.at(0), client, 2);
58        let w2 = f.window(3);
59        f.mov(w2.at(1), server_cap);
60        f.mov(w2.at(2), me);
61        f.spawn_at(w2.at(0), client, 2);
62        let a = f.receive_match_imm(TAG_REP as u16);
63        let b = f.receive_match_imm(TAG_REP as u16);
64        let pa = f.hop_payload(a);
65        let pb = f.hop_payload(b);
66        let out = f.add(pa, pb);
67        f.return_(out);
68    });
69    program.build()
70}

Trait Implementations§

Source§

impl Clone for RegWindow

Source§

fn clone(&self) -> RegWindow

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RegWindow

Source§

impl Debug for RegWindow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.