Running Java programs in gem5(or any language which is not C)

后端 未结 2 1294
感动是毒
感动是毒 2021-01-24 02:01

This may be a silly question, but i\'m learning about gem5 recently and i\'m being able to simulate my C programs using this software, in syscall emulation and in full system si

相关标签:
2条回答
  • 2021-01-24 02:12

    You execute Java programs exactly the same way you execute C programs:

    • Gem5 doesn't understand C, so if you want to execute a C program, you first need to compile it to a language Gem5 understands, or you need to interpret it in an interpreter that is written in a language Gem5 understands.
    • Gem5 doesn't understand Java, so if you want to execute a Java program, you first need to compile it to a language Gem5 understands, or you need to interpret it in an interpreter that is written in a language Gem5 understands.

    Here are a couple of possibilities I can think of:

    • use a native code compiler to compile Java to Alpha, ARM, Sparc, or x86 native machine code,
    • use a Java interpreter written in (or compiled to) Alpha, ARM, Sparc, or x86 native machine code to interpret that Java code,
    • use a JVM compiler to compile Java to JVM bytecode, then use a JVM written in (or compiled to) Alpha, ARM, Sparc, or x86 native machine code to interpret that JVM bytecode, or
    • use a JVM compiler to compile Java to JVM bytecode, then use a native code compiler to compile the JVM bytecode to Alpha, ARM, Sparc, or x86 native machine code.

    It is, of course, possible to chain and/or mix any number of the above.

    0 讨论(0)
  • 2021-01-24 02:18

    Similar post: Is it possible to run java -jar on gem5 simulator with ISA x86?

    A full system Ubuntu image will almost certainly work (pre-install Java with QEMU user mode before running gem5).

    X86 syscall emulation could in theory just work, the command line would be something like:

    build/X86/gem5.opt \
      configs/example/se.py \
      --cmd /usr/bin/java \
      --options HelloWorld \
      --param 'system.cpu[0].workload[:].release = "5.2.1"' \
    

    where /usr/bin/java is the Java interpreter ELF executable just like your C program, and HelloWorld.class is the compiled Java class passed as an argument to java.

    However, I tried this on Ubuntu 18.04 and gem5 61005bb9ef455b2ac851f8a992f2cec5686e520f and it failed with:

    /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

    I'm not sure why that was the case, it would require further investigation.

    Analogous for Python: Is it possible to run Python code in Gem5 syscall emulation mode?

    0 讨论(0)
提交回复
热议问题