Skip to content

Moving ScanObjects::do_work to the plan #576

@wks

Description

@wks

TL;DR: If ScanObjects is plan-specific, why not let Plan do what ScanObjects::do_work does, so that ScanObjects is no longer plan-specific?

Status Quo

Now we have

  • ScanObjects
  • ScanObjectsAndMarkLines

Only Immix uses the latter. Because it uses the latter, Immix also has

  • ImmixProcessEdges
  • GenImmixMatureProcessEdges

They only exist because they need the special ScanObjectsAndMarkLines

But we don't want so many plan-specific work packets.

Proposal.

Just one ScanObjects. No ScanObjectsAndMarkLines.

We move ScanObjects::do_work to Plan.

// For implemetation, ScanObjects now needs a Plan type 
struct ScanObjects<E: ProcessEdgesWork, P: Plan> {
   ...
}

impl<E: ProcessEdgesWork, P: Plan> GCWork<E::VM> for ScanObjects<E, P> { 
    fn do_work(&mut self, worker: &mut GCWorker<E::VM>, mmtk: &'static MMTK<E::VM>) {
        // It has to be statically dispatched because it has type parameters.
        P::scan_objects::<E>::(worker.tls, &self.buffer);

        // Alternatively we can give it a `&dyn ProcessEdgesWorkFactory<E>` so it is less efficient but can be dynamically dispatched.
    }
}

trait Plan {
    fn scan_objects<E: ProcessEdgesWork>(tls: VMWorkerThread, buffer: &Vec<ObjectReference>) {
        trace!("Now I do the actual ScanObject");
        {
            let mut closure = ObjectsClosure::<E>::new(worker);
            <E::VM as VMBinding>::VMScanning::scan_objects(tls, buffer, &mut closure);
        }
        trace!("The actual ScanObject End");
    }
}

If Immix is special, it can just override the plan.

impl Plan for Immix {
    fn scan_objects<E: ProcessEdgesWork>(tls: VMWorkerThread, buffer: &Vec<ObjectReference>) {
        trace!("ScanObjectsAndMarkLines");
        let mut closure = ObjectsClosure::<E>::new(worker);
        for object in buffer {
            <E::VM as VMBinding>::VMScanning::scan_object(tls, *object, &mut closure);
            if super::MARK_LINE_AT_SCAN_TIME
                && !super::BLOCK_ONLY
                && self.immix_space.in_space(*object)
            {
                self.immix_space.mark_lines(*object);
            }
        }
    }
}

And we can delete ScanObjectsAndMarkLines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions