Comments (4)
That would be awesome! It shouldn't even be so hard to fix. IIRC we only patch the callee address in the data segment. We could just keep an array of function pointers on the side and use FctId to index into this array.
If you are interested in working on this, I would definitely be glad to help or guide you.
from dora.
I would like to work on this! As I understand I should look at gc/space.rs
and baseline/fct.rs
?
from dora.
The code that patches the address into memory lives in dora_compile.rs
(look into the functions compile_request
and patch_fct_call
). It implements the function (called compiler_thunk
in src/vm.rs
) that is called instead of the actual function if it wasn't compiled already.
Right now a function call loads the target function address from the constant pool (or also called data segment) of the current function. It either loads the actual address of the compiled function or the address of the compiler thunk (in case the function wasn't compiled already, see ensure_jit_or_stub_ptr
in src/baseline/ast/expr.rs
.
In the future we want to embed a "function table" address in the constant pool and use a constant index to load our function's address from that table. So we only need to patch an entry in that table and that table doesn't need to be executable.
The challenge: the function table shouldn't change its address. So we can't use Vec<Address>
and push into it. That vector would need to be allocated with a large enough size at the beginning (there should probably also be a command line parameter for changing its size). However I don't think we know how many functions we are going to have in a program (because of generics).
Maybe we should implement this table as a a linked list of tables. When one table becomes full, we can simply allocate another table. Then we wouldn't need an upper limit for functions in a program.
Not sure whether we can use JitFctId
as index into that vector already without changes. Right now we only create a JitFct
(and therefore JitFctId
) when a function is compiled. However then we would need a JitFctId
as soon as the function is referenced from a function that is compiled. I think we could add another kind of JitFct
(in addition to the already existing Base and Opt): Uncompiled. And also use it to store all data needed for compilation there.
Only in the very end you should change arena::commit
to not make memory writable+executable.
When writing this I realized this is a bit harder than expected. However it would be great to get rid of this soon before more code depends on it. In case you still want to work on this: don't refrain from asking. I think it would be helpful for us both if you create multiple small PRs (e.g. one for the function table, another for JitFctId::Uncompiled, etc). You get feedback much sooner and for me its easier to review.
from dora.
I will start work on this as soon as possible! Also I think I could fix some code to allow Dora work on Windows.
from dora.
Related Issues (20)
- Unified Condition Expressions HOT 1
- panic: enum value and `is` HOT 3
- Extending the reach of enums HOT 1
- `toStringHex` and `toStringBinary` strip off leading zeros HOT 1
- Consider turning asserts in @test annotated methods into soft asserts
- Allow defining and calling methods without parentheses
- `--emit-ast` doesn't do anything HOT 2
- The JIT implementation of dora is very cool HOT 1
- reinstate class syntax
- replace `fn` keyword with `fun` keyword
- reinstate `=` for function definition
- implement named parameters
- implement string hash caching
- implement definitional enums
- implement modules (singletons and holders of static functions)
- remove unary operators
- remove bitshift operators
- implement unified condition expressions
- replace procedure syntax with functions having return type `Unit` HOT 1
- How lazy compilation is protected in case of multiple threads? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dora.