Commit 9e1c16b
committed
Merge pull request #2326 from bettio/updated-aliases
Add support for process aliases
Implement process aliases, so a process can hand out a reference that
works as a send target and deactivate it again once it is done with
it. This is the OTP mechanism behind request/reply patterns that must
not accept a late reply, and AtomVM had no equivalent. The series
rebases the original implementation on `release-0.7` and lands the
fixes found while reviewing it.
Highlights:
- `erlang:alias/0,1`, `erlang:unalias/1`, `erlang:monitor/3` with the
`{alias, Mode}` option, and `spawn_opt` `{monitor, MonitorOpts}`.
- Sending to an alias from `erlang:send/2`, the send opcode and the
JIT send path, and from a remote node over distribution.
- A new process reference term that carries the owner process id next
to the ref ticks, with BEAM compliant ordering and
`binary_to_term`/`term_to_binary` round tripping.
- Alias sends are posted as a mailbox signal, so a sender never walks
the owner's monitor list and send order is preserved.
- Three pre-existing defects surfaced along the way are fixed in their
own commits: a leaked process lock in `erlang:monitor/2,3`, a switch
fall through in `context_demonitor`, and a dangling scheduler queue
entry left behind by `context_destroy`.
A send addressed to a remote alias is dropped instead of being routed
over distribution, and the OTP `{tag, Term}` monitor option and the
`alias/1` `priority` option raise `unsupported`. All three are
documented.
Supersedes #2027
Closes #2027
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later42 files changed
Lines changed: 1988 additions & 191 deletions
File tree
- doc/src
- apidocs/libatomvm
- libs/estdlib/src
- src
- libAtomVM
- platforms
- emscripten/src/lib
- esp32/components/avm_builtins
- rp2/src/lib
- stm32/src/lib
- tests
- erlang_tests
- libs
- eavmlib
- estdlib
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
328 | 335 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
178 | 182 | | |
179 | 183 | | |
180 | 184 | | |
| |||
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
215 | | - | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
220 | | - | |
| 225 | + | |
| 226 | + | |
221 | 227 | | |
222 | 228 | | |
223 | 229 | | |
| |||
238 | 244 | | |
239 | 245 | | |
240 | 246 | | |
| 247 | + | |
| 248 | + | |
241 | 249 | | |
242 | 250 | | |
243 | 251 | | |
| |||
1222 | 1230 | | |
1223 | 1231 | | |
1224 | 1232 | | |
1225 | | - | |
1226 | | - | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
1227 | 1237 | | |
1228 | 1238 | | |
1229 | 1239 | | |
| |||
1236 | 1246 | | |
1237 | 1247 | | |
1238 | 1248 | | |
1239 | | - | |
1240 | | - | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1241 | 1253 | | |
1242 | 1254 | | |
1243 | 1255 | | |
| |||
1277 | 1289 | | |
1278 | 1290 | | |
1279 | 1291 | | |
1280 | | - | |
| 1292 | + | |
1281 | 1293 | | |
1282 | 1294 | | |
1283 | | - | |
| 1295 | + | |
| 1296 | + | |
1284 | 1297 | | |
1285 | 1298 | | |
1286 | 1299 | | |
| |||
1306 | 1319 | | |
1307 | 1320 | | |
1308 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
1309 | 1348 | | |
1310 | 1349 | | |
1311 | 1350 | | |
| |||
2147 | 2186 | | |
2148 | 2187 | | |
2149 | 2188 | | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
0 commit comments