int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; // Initialize base components. VmkitModule::initialise(argc, argv); Collector::initialise(argc, argv); // Create the allocator that will allocate the bootstrap loader and the JVM. vmkit::BumpPtrAllocator Allocator; JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader") JnjvmBootstrapLoader(Allocator, Comp, true); Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, initialFrametables, loader); // Run the application. vm->runApplication(argc, argv); vm->waitForExit(); System::Exit(0); // Destroy everyone. // vm->~Jnjvm(); // loader->~JnjvmBootstrapLoader(); return 0; }
int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; // Initialize base components. MvmModule::initialise(); Collector::initialise(); // Tell the compiler to run all optimizations. StandardCompileOpts = true; // Create the allocator that will allocate the bootstrap loader and the JVM. mvm::BumpPtrAllocator Allocator; JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader") JnjvmBootstrapLoader(Allocator, Comp, true); Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader); // Run the application. vm->runApplication(argc, argv); vm->waitForExit(); exit(0); // Destroy everyone. // vm->~Jnjvm(); // loader->~JnjvmBootstrapLoader(); return 0; }
int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; bool EmitClassBytes = false; static const char* EmitClassBytesStr = "-emit-class-bytes"; for (int i = 0; i < argc; i++) { if (!strncmp(argv[i], EmitClassBytesStr, strlen(EmitClassBytesStr))) { EmitClassBytes = true; break; } } std::string OutputFilename; // Initialize base components. VmkitModule::initialise(argc, argv); Collector::initialise(argc, argv); // Create the allocator that will allocate the bootstrap loader and the JVM. vmkit::BumpPtrAllocator Allocator; JavaAOTCompiler* AOT; if (EmitClassBytes) { AOT = new JavaAOTCompiler("AOT"); OutputFilename = "classes.bc"; JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader") JnjvmBootstrapLoader(Allocator, AOT, true); AOT->generateClassBytes(loader); } else { OutputFilename = "generated.bc"; JavaJITCompiler* JIT = JavaJITCompiler::CreateCompiler("JIT"); JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader") JnjvmBootstrapLoader(Allocator, JIT, true); Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, frametables, loader); // Run the application. vm->runApplication(argc, argv); vm->waitForExit(); // Now AOT Compile all compiled methods. vm->doExit = false; JavaThread* th = new JavaThread(vm); vm->setMainThread(th); th->start((void (*)(vmkit::Thread*))mainCompilerLoaderStart); vm->waitForExit(); AOT = (JavaAOTCompiler*)loader->getCompiler(); } // Emit the bytecode in file. std::string ErrorInfo; std::auto_ptr<llvm::raw_ostream> Out (new llvm::raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, llvm::raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { llvm::errs() << ErrorInfo << '\n'; return 1; } // Make sure that the Out file gets unlinked from the disk if we get a // SIGINT. llvm::sys::RemoveFileOnSignal(llvm::sys::Path(OutputFilename)); llvm::WriteBitcodeToFile(AOT->getLLVMModule(), *Out); return 0; }