Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate position independent code #50

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

janvrany
Copy link
Owner

This commit adds basic support for generating position independent code.

The idea is that a result of single compilation is always "position independent". It is the responsibility of
"runtime" to properly link together. This means compiler has to provide relocation when necessary.

Just like with shingarov/Pharo-ArchC#39, this is work in progress. I need to get bit more hands-on experience with compiling "real code" (that is, AoT)

janvrany added 4 commits June 18, 2024 13:45
This commit removes unused `#addPreDependencyOf:on:` and
`#addPostDependencyOf:on:` from `TRRegisterDependencies`
This commit moves `TRCompilationTestShell` and subclasses to category
"Tinyrossa-Tests-Shells", removing "-SmalltalkX". These classes are no
longer Smalltalk/X specific.
This commit removes `compilation`  instvar introduced in commit 84b2519
"Implement `TRCompilationTestShell >> #call` and `#call:`".

In a hindsight, this does not seem proper. We need to be able to test
compilation of multiple functions calling each other, so the there'll
be "multiple compilations".

Removing `compilation` from shell prompted refactoring of `call`, `call:`
and `call:_:` utility methods - they need to take `compilation` as a
first parameter. While at it, split code injection and call to actual
function into two method to facilitate tests with multiple functions.
@janvrany
Copy link
Owner Author

CI fails because missing support for relocations in ArchC

janvrany added 8 commits June 27, 2024 11:46
This commit uses symbols (sub-instances of `TRSymbol`) as labels rather
than just plain strings. This is a preparation for using (function)
symbols exports.
This is a preparation for introducing `TRRuntime` and related classes
that will also make use of target. So it is no longer just target for
compilation.
This commit introduces a `TRRuntime`, a class that provides an entry
point for runtime services.

Downstream projects (if any) may (should) provide customized subclass.
Note that "runtime" is only useful / used in JIT scenarios.
This commit adds new class - `TRCodeCache` - that implements simple
runtime code cache to put compiled code (result of compilation) for
later execution.

Downstream project may need to provide customized implementations
of code cache fitting the needs of particular runtime. `TRCodeCache`
should serves (i) as  example implementation, (ii) possibly as a base
class for downstream projects and finally (iii) as code cache
implementation to be used in tests.

As of now, the implementation is fairly simple. Its functionality
will be expanded in further commits.
This commit makes use of `TRCodeCache` introduced in previous commit.
This is a necessary step for writing tests that compile multiple functions
and/or refer to external (relocatable) symbols.
This tests compilation of relocatable calls.
This commit changes `TRRV64GSystemLinkage` to compile relocatable calls
using pair of `auipc` and `jalr` with `R_RISCV_CALL_PLT` relocation.
@janvrany janvrany force-pushed the pr/generate-position-independent-code branch from 858e9ef to 8882676 Compare June 27, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant