在JVM之上运行/解释C ?

时间:2021-08-18 20:46:15

Is there a way to run plain c code on top of the JVM?
Not connect via JNI, running, like you can run ruby code via JRuby, or javascript via Rhino.

有没有一种方法可以在JVM上运行纯c代码?不通过JNI连接,而是运行,就像可以通过JRuby运行ruby代码,或者通过Rhino运行javascript一样。

If there is no current solution, what would you recommend I should do?
Obviously I want to use as many partials solutions as I can to make it happen.

如果没有目前的解决方案,你建议我做什么?显然我想用尽可能多的偏微分解来实现它。

ANTLR seems like a good place to start, having a full "ANSI C" grammar implementation...
should I build a "toy" VM over the JVM using ANTLR generated code?

ANTLR似乎是一个很好的起点,有一个完整的“ANSI C”语法实现……我应该使用ANTLR生成的代码在JVM上构建一个“玩具”VM吗?

5 个解决方案

#1


13  

Updated 2012-01-26: According to this page on the company's site the product has been bought out and is no longer available.

更新日期:2012-01-26:根据公司网站上的这个页面,该产品已经被买断,不再可用。

Yes.

是的。

Here's a commercial C compiler that produces JVM bytecode.

这是一个生成JVM字节码的商业C编译器。

#2


11  

There are two other possibilities, both open-source:

还有另外两种可能性,都是开源的:

JPC emulates an entire x86 pc within the JVM, and is capable of running both DOS and Linux.

JPC在JVM中模拟了整个x86 pc,并且能够同时运行DOS和Linux。

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

NestedVM为Java字节码提供二进制转换。这是通过将GCC编译为MIPS二进制文件,然后将其转换为Java类文件来实现的。因此,任何用C、c++、Fortran或GCC支持的任何其他语言编写的应用程序都可以使用100%纯Java运行,不需要任何源代码更改。

#3


8  

Maybe not exactly what you need but a commercial option is http://www.axiomsol.com/

也许不完全是你需要的,但是一个商业选项是http://www.axiomsol.com/

#4


3  

It seems that LLJVM can also meet your requirement.

似乎LLJVM也可以满足您的需求。

LLJVM: Source code is first compiled to LLVM intermediate representation (IR) by a frontend such as llvm-gcc or clang. LLVM IR is then translated to Jasmin assembly code, linked against other Java classes, and then assembled to JVM bytecode.

LLJVM:源代码首先由一个前端(如LLVM -gcc或clang)编译为LLVM中间表示(IR)。然后将LLVM IR翻译为Jasmin汇编代码,与其他Java类链接,然后组装到JVM字节码。

#5


2  

As of 2016 there is a young but promissing option called gcc-bridge. Its intend is to leverage the JVM R implementation to make use of R-libaries written in C or Fortran. But gcc-bridge can also be used independently as a maven plugin.

到2016年,还有一个年轻但前途光明的选择,叫做gcc-bridge。它的目的是利用JVM R实现来利用用C或Fortran编写的R-libaries。但是gcc-bridge也可以独立地用作maven插件。

#1


13  

Updated 2012-01-26: According to this page on the company's site the product has been bought out and is no longer available.

更新日期:2012-01-26:根据公司网站上的这个页面,该产品已经被买断,不再可用。

Yes.

是的。

Here's a commercial C compiler that produces JVM bytecode.

这是一个生成JVM字节码的商业C编译器。

#2


11  

There are two other possibilities, both open-source:

还有另外两种可能性,都是开源的:

JPC emulates an entire x86 pc within the JVM, and is capable of running both DOS and Linux.

JPC在JVM中模拟了整个x86 pc,并且能够同时运行DOS和Linux。

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

NestedVM为Java字节码提供二进制转换。这是通过将GCC编译为MIPS二进制文件,然后将其转换为Java类文件来实现的。因此,任何用C、c++、Fortran或GCC支持的任何其他语言编写的应用程序都可以使用100%纯Java运行,不需要任何源代码更改。

#3


8  

Maybe not exactly what you need but a commercial option is http://www.axiomsol.com/

也许不完全是你需要的,但是一个商业选项是http://www.axiomsol.com/

#4


3  

It seems that LLJVM can also meet your requirement.

似乎LLJVM也可以满足您的需求。

LLJVM: Source code is first compiled to LLVM intermediate representation (IR) by a frontend such as llvm-gcc or clang. LLVM IR is then translated to Jasmin assembly code, linked against other Java classes, and then assembled to JVM bytecode.

LLJVM:源代码首先由一个前端(如LLVM -gcc或clang)编译为LLVM中间表示(IR)。然后将LLVM IR翻译为Jasmin汇编代码,与其他Java类链接,然后组装到JVM字节码。

#5


2  

As of 2016 there is a young but promissing option called gcc-bridge. Its intend is to leverage the JVM R implementation to make use of R-libaries written in C or Fortran. But gcc-bridge can also be used independently as a maven plugin.

到2016年,还有一个年轻但前途光明的选择,叫做gcc-bridge。它的目的是利用JVM R实现来利用用C或Fortran编写的R-libaries。但是gcc-bridge也可以独立地用作maven插件。