Git Product home page Git Product logo

Comments (4)

dinfuehr avatar dinfuehr commented on May 5, 2024

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.

playXE avatar playXE commented on May 5, 2024

I would like to work on this! As I understand I should look at gc/space.rs and baseline/fct.rs?

from dora.

dinfuehr avatar dinfuehr commented on May 5, 2024

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.

playXE avatar playXE commented on May 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.