1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! The program's heap, as the allocator `default_allocator!` installs sees
//! it: how much is used, and checkpoints that give it back.
//!
//! A bump allocator never frees, so a handler that builds a temporary
//! `Vec` on every iteration of a loop runs out of heap no matter how small
//! each one is. A checkpoint fixes that without a different allocator:
//!
//! ```ignore
//! let mark = hopper::heap::mark();
//! for item in items {
//! {
//! let scratch = build(item); // allocates
//! apply(&scratch)?;
//! } // every allocation is dropped here
//! // SAFETY: nothing allocated since `mark` is still alive.
//! unsafe { hopper::heap::release_to(mark) };
//! }
//! ```
//!
//! These functions read and write the allocator's cursor, the first word
//! of the VM's heap. They are for programs that installed
//! `default_allocator!`. Off chain there is no VM heap: `used` is zero and
//! a release does nothing.
pub use crateHeapMark;
const HEAP: crateBumpAllocator = crateBumpAllocator ;
/// Bytes the allocator has handed out in this invocation, alignment
/// padding included.
/// The heap's current position.
/// Give back every allocation made since `mark` was taken.
///
/// # Safety
///
/// Nothing allocated after `mark` may be used again: every `Box`, `Vec`,
/// and `String` created since must already be dropped or forgotten. `mark`
/// must have been taken in this invocation.
pub unsafe