Running VMKit's AOT Java Compiler

Hi,
I’m new to VMKit and I’m trying to use its AOT Java compiler but I’m immediately getting an error message which I don’t understand.

Everything was compiler as suggested in the Getting Started tutorial, using GNU Classpath. I try to run:

llcj …/…/tools/trainer/Release+Asserts/HelloWorld.class

and get the following output:

Can not materiale a function in AOT mode.0 vmjc 0x0000000000f2cea5 llvm::sys::PrintStackTrace(_IO_FILE*) + 37
1 vmjc 0x0000000000f2d363
2 libpthread.so.0 0x00007f4fbbe83880
3 libc.so.6 0x00007f4fbb0e2389 gsignal + 57
4 libc.so.6 0x00007f4fbb0e3788 abort + 328
5 vmjc 0x000000000052f6f9
6 vmjc 0x00000000005739cc
7 vmjc 0x0000000000573795
8 vmjc 0x0000000000572d24 j3::JavaMethod::invokeIntStatic(j3::Jnjvm*, j3::Class*, …) + 116
9 vmjc 0x0000000000587c9e j3::Class::initialiseClass(j3::Jnjvm*) + 574
10 vmjc 0x0000000000574c82
11 vmjc 0x0000000000574a45
12 vmjc 0x00000000005735a4 j3::JavaMethod::invokeJavaObjectStatic(j3::Jnjvm*, j3::Class*, …) + 116
13 vmjc 0x000000000058a921 j3::Jnjvm::noClassDefFoundError(j3::Class*, vmkit::UTF8 const*) + 1665
14 vmjc 0x000000000056c2bb j3::Class::readClass() + 427
15 vmjc 0x0000000000591a78 j3::JnjvmClassLoader::constructClass(vmkit::UTF8 const*, j3::ClassBytes*) + 360
16 vmjc 0x0000000000591743 j3::JnjvmBootstrapLoader::internalLoad(vmkit::UTF8 const*, bool, j3::JavaString*) + 131
17 vmjc 0x0000000000591d76 j3::JnjvmClassLoader::loadName(vmkit::UTF8 const*, bool, bool, j3::JavaString*) + 38
18 vmjc 0x000000000052b43a mainCompilerStart(j3::JavaThread*) + 586
19 vmjc 0x00000000005b0300 vmkit::thread::internalThreadStart(vmkit::Thread*) + 528
20 libpthread.so.0 0x00007f4fbbe7c0a2
21 libc.so.6 0x00007f4fbb192d1d clone + 109

This is produced inside the JavaAOTCompiler.h, in method materializeFunction which is called from JavaMethod::compiledPtr. What am I doing wrong?

Cheers,
David

Hi David,

I don't know where is the problem, but I'm investigating that :slight_smile:
Basically, I never had to use llcj and I don't know how and if it
works... I send you a mail as soon as I understand how llcj should
work.

Gaël

Hi Gaël

Thanks for looking into this. I’ve made a little progress myself. “llcj” must be run from the root directory of the compiled Java class files, i.e. the “tools/trainer/Release+Asserts” directory. Then its call to “vmjc” succeeds, it calls “opt”, but then it fails again when it tries to run “llc”, saying that it cannot find the vmkit garbage collector. So I added the “static-gc-printer.so” with a “-load” option.

Now it finds the GC, but that still fails with:

llc: VmkitGCPrinter.cpp:270: llvm::Constant FindMetadata(const llvm::Function &): Assertion `0 && “Should have found a JavaMethod”’ failed.
0 llc 0x0000000000ff1295 llvm::sys::PrintStackTrace(_IO_FILE
) + 37
1 llc 0x0000000000ff1753
2 libpthread.so.0 0x00007fce83f1b880
3 libc.so.6 0x00007fce8317a389 gsignal + 57
4 libc.so.6 0x00007fce8317b788 abort + 328
5 libc.so.6 0x00007fce831734a6
6 libc.so.6 0x00007fce83173552
7 static-gc-printer.so 0x00007fce82f41a7e
8 static-gc-printer.so 0x00007fce82f41fe2
9 llc 0x0000000000b58781 llvm::AsmPrinter::doFinalization(llvm::Module&) + 1217
10 llc 0x0000000000f8fa1e llvm::FPPassManager::doFinalization(llvm::Module&) + 94
11 llc 0x0000000000f8fd2e llvm::MPPassManager::runOnModule(llvm::Module&) + 686
12 llc 0x0000000000f904df llvm::PassManagerImpl::run(llvm::Module&) + 543
13 llc 0x0000000000524f2a main + 6506
14 libc.so.6 0x00007fce83166b05 __libc_start_main + 245
15 llc 0x00000000005234f3
Stack dump:
0. Program arguments: /home/db538/vmkit/llvm-3.3.src/Release+Asserts/bin/llc /tmp/llvm_xJHwnR/HelloWorld.bc -disable-fp-elim -load /home/db538/vmkit/vmkit/Release+Asserts/lib/static-gc-printer.so -o /tmp/llvm_xJHwnR/HelloWorld.s

I checked and the method it’s looking for is “JnJVM_HelloWorld_main___3Ljava_lang_String_2”. Thoughts?

Thanks,
Dave