Commit ede19c8
committed
Safely keep track of pending extensions to the Heap
This makes Heap::extend correct and fully infallible. To make this work, a
slight change to the usable size of the last Hole needed to happen.
Significant changes:
- pending_extend added to HoleList, tracks impartial extension amounts
- for odd-sized heaps or extensions, the last Hole will only utilize space up
to the highest usize-aligned address
- the above change forces top to always be aligned to usize
- the correctness of `extend` relies on an aligned top pointer, so a debug
assertion is added to catch any future code changes
- Heap::size() reports usable size for allocations (updated some tests
accordingly)
- pub fn Heap::top() reports top-most pointer of memory claimed by the Heap,
even if thost last bytes aren't usable yet. (private field HoleList.top still
is always aligned)
- documented best values to give to extend
- removed ExtendError and try_extend1 parent c7e3428 commit ede19c8
3 files changed
+99
-109
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| 282 | + | |
281 | 283 | | |
282 | 284 | | |
283 | 285 | | |
| |||
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
331 | 338 | | |
332 | 339 | | |
333 | 340 | | |
| |||
338 | 345 | | |
339 | 346 | | |
340 | 347 | | |
341 | | - | |
| 348 | + | |
| 349 | + | |
342 | 350 | | |
343 | 351 | | |
344 | 352 | | |
| |||
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
352 | | - | |
| 360 | + | |
353 | 361 | | |
| 362 | + | |
354 | 363 | | |
355 | 364 | | |
356 | 365 | | |
357 | 366 | | |
358 | 367 | | |
359 | 368 | | |
360 | | - | |
| 369 | + | |
| 370 | + | |
361 | 371 | | |
362 | 372 | | |
363 | 373 | | |
| |||
443 | 453 | | |
444 | 454 | | |
445 | 455 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 456 | + | |
453 | 457 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | 458 | | |
464 | 459 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
469 | 465 | | |
470 | | - | |
471 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
472 | 470 | | |
473 | | - | |
474 | | - | |
| 471 | + | |
| 472 | + | |
475 | 473 | | |
476 | | - | |
477 | | - | |
478 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
479 | 478 | | |
480 | 479 | | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
486 | 483 | | |
487 | | - | |
488 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
489 | 487 | | |
490 | | - | |
| 488 | + | |
| 489 | + | |
491 | 490 | | |
492 | 491 | | |
493 | 492 | | |
| |||
566 | 565 | | |
567 | 566 | | |
568 | 567 | | |
569 | | - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
570 | 572 | | |
571 | 573 | | |
572 | 574 | | |
| |||
692 | 694 | | |
693 | 695 | | |
694 | 696 | | |
695 | | - | |
| 697 | + | |
| 698 | + | |
696 | 699 | | |
697 | 700 | | |
698 | 701 | | |
| |||
715 | 718 | | |
716 | 719 | | |
717 | 720 | | |
718 | | - | |
719 | | - | |
| 721 | + | |
| 722 | + | |
720 | 723 | | |
721 | 724 | | |
722 | 725 | | |
| |||
727 | 730 | | |
728 | 731 | | |
729 | 732 | | |
730 | | - | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
731 | 737 | | |
732 | 738 | | |
733 | 739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
126 | 136 | | |
127 | 137 | | |
128 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
129 | 144 | | |
130 | 145 | | |
131 | 146 | | |
| |||
197 | 212 | | |
198 | 213 | | |
199 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
200 | 219 | | |
201 | | - | |
| 220 | + | |
202 | 221 | | |
203 | 222 | | |
204 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
205 | 228 | | |
206 | | - | |
| 229 | + | |
207 | 230 | | |
208 | 231 | | |
209 | 232 | | |
| |||
218 | 241 | | |
219 | 242 | | |
220 | 243 | | |
221 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
222 | 248 | | |
223 | 249 | | |
224 | 250 | | |
225 | 251 | | |
226 | 252 | | |
227 | 253 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | 254 | | |
234 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
235 | 258 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
268 | 262 | | |
269 | 263 | | |
270 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
507 | 508 | | |
508 | 509 | | |
509 | 510 | | |
510 | | - | |
| 511 | + | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
| |||
519 | 520 | | |
520 | 521 | | |
521 | 522 | | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 523 | + | |
| 524 | + | |
536 | 525 | | |
537 | 526 | | |
538 | 527 | | |
| |||
546 | 535 | | |
547 | 536 | | |
548 | 537 | | |
| 538 | + | |
549 | 539 | | |
550 | | - | |
| 540 | + | |
551 | 541 | | |
552 | | - | |
| 542 | + | |
553 | 543 | | |
554 | 544 | | |
555 | 545 | | |
0 commit comments