realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

C++ JIT compiliation using asmjit #649

Open peterclemenko opened 11 years ago

peterclemenko commented 11 years ago

It might be worth investigating using asmjit https://code.google.com/p/asmjit/ as a manner of doing runtime compilation of C++ code. This might help with C++ plugin distribution.

cadaver commented 11 years ago

Note that this is only an assembler library, so it would have to be coupled with a C++ compiler. Furthermore actually compiling C++ code at runtime (even if it was possible) would require shipping all the include files of used third party libraries + Tundra core modules.

peterclemenko commented 11 years ago

It is possible, unreal engine does it.

cadaver notifications@github.com wrote:

Note that this is only an assembler library, so it would have to be coupled with a C++ compiler. Furthermore actually compiling C++ code at runtime (even if it was possible) would require shipping all the include files of used third party libraries + Tundra core modules.


Reply to this email directly or view it on GitHub: https://github.com/realXtend/naali/issues/649#issuecomment-16489350

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

peterclemenko commented 11 years ago

I should explicitly note however that odds are this is a bad idea security wise and should only be implemented if a way we're found to sandbox it.

cadaver notifications@github.com wrote:

Note that this is only an assembler library, so it would have to be coupled with a C++ compiler. Furthermore actually compiling C++ code at runtime (even if it was possible) would require shipping all the include files of used third party libraries + Tundra core modules.


Reply to this email directly or view it on GitHub: https://github.com/realXtend/naali/issues/649#issuecomment-16489350

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

cadaver commented 11 years ago

It is true that UE4 does runtime compilation, however what I've seen it has been used to tweak the game code, which interfaces with the engine through its own interfaces. A Tundra plugin on the other hand needs full access to the C/C++ standard library, in addition to the Tundra core and the third party libraries.

Certainly it is doable, but could be an engineering effort on the man-year scale.

For example, if Tundra was to embed clang, which has a nice license, then we would require to always compile the core libraries + dependencies with clang to make sure the C++ ABI and STL implementation matches.

Note that the http://runtimecompiledcplusplus.blogspot.com library, which is available as open source, requires the user to have a C++ compiler installed in the system, but we naturally can not require this.

I'm very tempted to close this as unfeasible in practice.

cadaver commented 11 years ago

Also, I'm quite sure the end-user runtime of UE4 does not include a C++ compiler. This means the don't need to care how large the files required by the compiler are. We on the other hand would require it on the end-user installs.

antont commented 11 years ago

was just thinking that perhaps using this and some other optimization is sometimes possible on servers, or in a CAVE installation where there sometimes is not distribution at all or at least extra work for setting up an efficient env is feasible. also sandboxing / security considerations can be much easier.

just a general observation.