tarides / ocaml-jit Goto Github PK
View Code? Open in Web Editor NEWJust In Time compiler for OCaml native toplevel
License: ISC License
Just In Time compiler for OCaml native toplevel
License: ISC License
I'm working on an OCaml program that can be extended with scripts written in OCaml, however the existing Dynlink mechanism (and higher-level approaches like ocaml_plugin
) is too heavyweight and doesn't work in statically compiled programs. I've had a similar implementation in mind (link with the OCaml compiler, generate assembly, assemble it using a custom x86 assembler in memory and make it executable in the running process using mmap/mprotect). I'm curious if this project could be extended to handle this, in particular:
From what I can tell this is technically possible (the old native toplevel already uses Dynlink, and jit_run
in this repository is similar to the native dynlink code in OCaml), although I might be missing some difficulties, especially around changes to the OCaml compiler. If there's anything you need, I'd gladly contribute.
Thanks for this feature -- it will allow OCaml to be used an an extension language! I have two questions:
.eln
file so the compilation does not need to happen afresh the next time some script needs to be evaluatedUsing current main (6e56c4c) on OCaml 4.14.0~alpha:
% ls /tmp/*.so
zsh: no matches found: /tmp/*.so
% dune exec bin/jittop.exe
OCaml version 4.14.0~alpha1 - native toplevel
Enter #help;; for help.
# 3 + 4;;
- : int = 7
#
% ls /tmp/*.so
/tmp/camlTOP1138b62.so
Working on the JIT we detected that the native toplevel wasn't properly reporting locally defined exceptions.
A test case was initially added there to reproduce this.
The native toplevel reports locally defined exceptions with a prefix TOPX.
whereas the bytecode toplevel does not add said prefix.
We need to properly report this upstream and eventually open a PR with a reproduction test case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.