| | 422 | |
| | 423 | == Rename and extend current "PMC_Allocator" == |
| | 424 | |
| | 425 | Current PMC_Allocator is pretty fast, well tested and (almost) suitable to be described {{{Allocator}}}. We just have to implement {{{Allocator.is_owned}}} method. Design of {{{PMC_Allocator}}} isn't "tuned" for such usecase, but it should be fine because {{{.is_owned}}} called only during tracing system stack. |
| | 426 | |
| | 427 | Roughly implmentation of {{{.is_owned}}} will be this: |
| | 428 | {{{ |
| | 429 | #!perl |
| | 430 | PMC_Allocator.is_owned($obj) { |
| | 431 | my $arena = self.top_arena; |
| | 432 | while $arena { |
| | 433 | return Bool::True if ptr_diff($arena, $obj) < 4096; |
| | 434 | $arena = $arena.prev; |
| | 435 | } |
| | 436 | return Bool::False; |
| | 437 | } |
| | 438 | |
| | 439 | }}} |