Commit c7e3428
committed
safe but infallible extend (wip)
This is a work in progress idea I had to use heap.first.size to cache pending
extend requests that were too small to safely execute. Once there *is* enough
space to align and store a Hole, we can do so.
This does introduce possible "dead_space" between the last allocation and the
newly created Hole after extending, due to the need to align upward before
writing the new Hole. The dead space may be reclaimed sometimes, but perhaps
it's impossible to guarantee that. So this idea might be bad, though it only
affects odd-aligned heap.top() situations.
When we dealloc, would it be sound to *align_up_size* the Layout being free'd,
knowing that we only ever put Holes at aligned addresses?
Example (assume 64-bit arch):
1. New heap: aligned bottom, but size 17
2. Alloc is requested of size 17, align 1, and succeeds. No free holes exist.
3. Heap extend by 15 (to align for Hole) + 16 (Hole size). Extend succeeds.
4. Heap looks like this: [17b in use][15b dead][16b Hole]
5. First allocation is free'd, and the Hole size is rounded up
Note: we need to check against heap.size() and heap.pending_extend() before
rounding up all the way
6. Heap looks like this: [32b Hole][16b Hole]1 parent d0f8d62 commit c7e3428
2 files changed
+54
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
446 | 452 | | |
447 | | - | |
448 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
449 | 459 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
454 | 474 | | |
455 | 475 | | |
456 | | - | |
457 | | - | |
458 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
459 | 479 | | |
460 | 480 | | |
461 | 481 | | |
462 | | - | |
463 | | - | |
464 | | - | |
| 482 | + | |
465 | 483 | | |
466 | | - | |
| 484 | + | |
467 | 485 | | |
468 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
469 | 490 | | |
470 | 491 | | |
471 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | | - | |
| 507 | + | |
508 | 508 | | |
509 | | - | |
510 | | - | |
511 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
| 519 | + | |
520 | 520 | | |
521 | | - | |
522 | | - | |
523 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
| 531 | + | |
530 | 532 | | |
531 | | - | |
| 533 | + | |
532 | 534 | | |
533 | | - | |
534 | | - | |
535 | | - | |
| 535 | + | |
| 536 | + | |
536 | 537 | | |
537 | 538 | | |
538 | 539 | | |
| |||
543 | 544 | | |
544 | 545 | | |
545 | 546 | | |
546 | | - | |
| 547 | + | |
547 | 548 | | |
548 | | - | |
549 | | - | |
550 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
551 | 555 | | |
0 commit comments