This is an archive of the discontinued LLVM Phabricator instance.

[ExecutionEngine][MCJIT] Add a freeGeneratedCode hook.
AbandonedPublic

Authored by sanjoy on Jun 10 2015, 8:09 PM.

Details

Reviewers
lhames
Summary

Add ExecutionEngine::freeGeneratedCode and implement for MCJIT.
freeGeneratedCode lets an ExecutionEngine client drop all generated code
and related state. This hook can be used to:

  1. Free code no longer in use. This is useful for MCJIT clients that relocate code generated by MCJIT into space allocated by the rest of the runtime, and don't need the code buffers managed by MCJIT once this is done.
  2. Reset MCJIT from a state after generateCodeForModule has been called but relocations haven't been applied to a good state ready for a new compilation. This is useful for error recovery.

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 27484.Jun 10 2015, 8:09 PM
sanjoy retitled this revision from to [ExecutionEngine][MCJIT] Add a freeGeneratedCode hook..
sanjoy updated this object.
sanjoy edited the test plan for this revision. (Show Details)
sanjoy added a reviewer: lhames.
sanjoy added a subscriber: Unknown Object (MLST).
lhames edited edge metadata.Jun 17 2015, 11:31 AM

Hi Sanjoy,

Sorry for the delay on this review.

How does this differ from destroying the execution engine altogether and creating a new one?

  • Lang.

How does this differ from destroying the execution engine altogether
and creating a new one?

In terms of what it does, I do not think that calling
freeGeneratedCode is very different from destroying and re-creating
the execution engine. But creating a new execution engine, compiling
a module, and immediately destroying it for every compile[1] did not
feel like the right semantic model (it does strictly more than I need
MCJIT to do, and can paper over other lifetime issues).

If you think this create-and-destroy option is the more reasonable
than adding a freeGeneratedCode hook then I can try to get that to
work with our VM and see how that goes.

  • Sanjoy

[1]: We copy out generated code into our custom code arena, so keeping
a second copy of the generated code in MCJIT's memory manager is
unnecessary once the code has been copied out.

sanjoy abandoned this revision.Sep 13 2015, 1:53 PM

We're not pursuing this anymore.