You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specification/terms.md
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -220,3 +220,33 @@ A value, in order to get stored into memory, must first undergo the process of t
220
220
### §4.4 Conversion from Memory
221
221
222
222
Conversion from memory will be a conversion to memory, but in reverse, going from computer-friendly form to pure mathematical object.
223
+
224
+
## §5 Memory
225
+
226
+
### §5.1 Segmentation
227
+
228
+
Rust works on a flat address space - addresses are numbers between
229
+
`0` and `2^wordlen`. However, for semantic purposes, memory is divided into an
230
+
hierarchy of segments, each of which describes a contiguous set of addresses.
231
+
232
+
The addresses `0` and `2^wordlen-1` are not assigned to any segment. This prevents
233
+
segments from wrapping around the end of address space.
234
+
235
+
Coexisting segments may not overlap (unless one is the supersegment of another). However, segments may be added or removed at run-time, possibly through intrinsics that can be triggered from user code.
236
+
237
+
Segments have an identity - removing a segment and creating another with the same address-set does not result in the same segment.
238
+
239
+
During their lifetime, each stack allocation and global variable is contained within a single segment.
240
+
241
+
NOTE: segments are used to represent LLVM objects, and *not* Rust borrowed pointers.
242
+
243
+
Every stack allocation or global variable will contain only addresses for a single
244
+
segment. There MAY exist intrinsics that subdivide segments.
245
+
246
+
Every pointer or reference is associated with a segment. That segment follows
247
+
the pointer as it is stored and loaded from memory, and through projections.
248
+
249
+
Each of the `size_of::<T>()` bytes from the address of a reference to a type `T` must always be contained within that reference's segment.
250
+
251
+
When a raw pointer to type `T` is accessed, each of the `size_of::<T>()` bytes from
0 commit comments