This is an archive of the discontinued LLVM Phabricator instance.

[JIT] Towards a working small memory model
ClosedPublic

Authored by davide on Oct 10 2015, 10:26 PM.

Details

Summary

Hi Lang. This patch implements the idea we previously discussed on IRC, introducing --preallocate so that we can get memory upfront and use that in small memory model tests. to It's currently unfinished because we don't keep track of FunctionMemory/DataMemory (it depends on my next review). I hope this was what you had in mind. Comments welcome.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 37045.Oct 10 2015, 10:26 PM
davide retitled this revision from to [JIT] Towards a working small memory model.
davide updated this object.
davide added a reviewer: lhames.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: llvm-commits.
lhames edited edge metadata.Oct 13 2015, 11:03 PM

Hi David,

Excellent! This is exactly the kind of thing I was looking for - thank you.

What do you mean 'don't keep track of function memory / data memory' though? We may run in to issues for platforms that don't allow us to allocate RWX sections, in which case we'd have to make that distinction, but if we can get RWX memory I think we can just use one pool.

  • Lang.
tools/llvm-rtdyld/llvm-rtdyld.cpp
193–200 ↗(On Diff #37045)

allocateFromSlab needs to respect the requested alignment. There's a RoundUpToAlignment function in MathExtras.h that you can use for this.

377–384 ↗(On Diff #37045)

Can you add the preallocate call to linkAndVerify? We'll want it there too so we can write relocation verifier tests for the small code model.

davide updated this revision to Diff 37439.Oct 14 2015, 7:18 PM
davide edited edge metadata.
davide removed rL LLVM as the repository for this revision.

New patch addressing your comments. To answer your question by "not keeping track of memory" I meant that my previous patch didn't push_back allocated data/code section to {Function,Data}Memory vector. I think it was wrong, because e.g., invalidateInstructionCache wouldn't have been called on those regions. I hope my reasoning is correct.
Thanks!

Very gentle ping

lhames accepted this revision.Oct 21 2015, 1:00 PM
lhames edited edge metadata.

Ping appreciated. :)

This looks good to me.

This revision is now accepted and ready to land.Oct 21 2015, 1:00 PM
This revision was automatically updated to reflect the committed changes.