[vmkit-commits] [vmkit] r54675 - in /vmkit/trunk: lib/JnJVM/LLVMRuntime/runtime-default.ll lib/Main.cpp lib/Makefile lib/Mvm/Runtime/CommandLine.cpp lib/Mvm/Runtime/CommandLine.h tools/Makefile tools/jnjvm/Main.cpp tools/jnjvm/Makefile tools/n3-mono/Main.cpp tools/n3-mono/Makefile tools/n3-pnetlib/Main.cpp tools/n3-pnetlib/Makefile tools/vmkit/ tools/vmkit/CommandLine.cpp tools/vmkit/CommandLine.h tools/vmkit/Launcher.cpp tools/vmkit/Makefile
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue Aug 12 01:04:01 PDT 2008
Author: geoffray
Date: Tue Aug 12 03:03:45 2008
New Revision: 54675
URL: http://llvm.org/viewvc/llvm-project?rev=54675&view=rev
Log:
The Main.cpp file is not shared anymore.
The new tool, vmkit, is a vm launcher that can run java
apps uising vmkit -java, .Net apps with vmkit -net. There's
also an interactive mode with just vmkit.
Added:
vmkit/trunk/tools/jnjvm/Main.cpp
vmkit/trunk/tools/n3-mono/Main.cpp
vmkit/trunk/tools/n3-pnetlib/Main.cpp
vmkit/trunk/tools/vmkit/
vmkit/trunk/tools/vmkit/CommandLine.cpp
vmkit/trunk/tools/vmkit/CommandLine.h
vmkit/trunk/tools/vmkit/Launcher.cpp
vmkit/trunk/tools/vmkit/Makefile (with props)
Removed:
vmkit/trunk/lib/Main.cpp
vmkit/trunk/lib/Mvm/Runtime/CommandLine.cpp
vmkit/trunk/lib/Mvm/Runtime/CommandLine.h
Modified:
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/Makefile
vmkit/trunk/tools/Makefile
vmkit/trunk/tools/jnjvm/Makefile
vmkit/trunk/tools/n3-mono/Makefile
vmkit/trunk/tools/n3-pnetlib/Makefile
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Tue Aug 12 03:03:45 2008
@@ -81,7 +81,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; virtualLookup - Used for interface calls.
-declare i8* @virtualLookup(%CacheNode*, %JavaObject*)
+declare i8* @jnjvmVirtualLookup(%CacheNode*, %JavaObject*)
;;; multiCallNew - Allocate multi-dimensional arrays. This will go to allocation
;;; specific methods.
@@ -143,8 +143,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Exception methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare void @nullPointerException()
-declare void @classCastException(%JavaObject*, %JavaClass*)
+declare void @jnjvmNullPointerException()
+declare void @jnjvmClassCastException(%JavaObject*, %JavaClass*)
declare void @indexOutOfBoundsException(%JavaObject*, i32)
declare void @negativeArraySizeException(i32)
declare void @outOfMemoryError(i32)
Removed: vmkit/trunk/lib/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Main.cpp?rev=54674&view=auto
==============================================================================
--- vmkit/trunk/lib/Main.cpp (original)
+++ vmkit/trunk/lib/Main.cpp (removed)
@@ -1,34 +0,0 @@
-//===--------- Main.cpp - Simple execution of JnJVM -----------------------===//
-//
-// JnJVM
-//
-// This file is distributed under the University of Pierre et Marie Curie
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MvmGC.h"
-#include "mvm/JIT.h"
-#include "mvm/Object.h"
-#include "mvm/Threads/Thread.h"
-
-#include "llvm/Support/ManagedStatic.h"
-
-using namespace mvm;
-
-extern "C" int boot();
-extern "C" int start_app(int, char**);
-
-int main(int argc, char **argv, char **envp) {
- llvm::llvm_shutdown_obj X;
- int base;
-
- jit::initialise();
- Object::initialise();
- Thread::initialise();
- Collector::initialise(0, &base);
- boot();
- start_app(argc, argv);
-
- return 0;
-}
Modified: vmkit/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Makefile?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/lib/Makefile (original)
+++ vmkit/trunk/lib/Makefile Tue Aug 12 03:03:45 2008
@@ -18,7 +18,5 @@
PARALLEL_DIRS += N3
-LIBRARYNAME = Main
-
include $(LEVEL)/Makefile.common
Removed: vmkit/trunk/lib/Mvm/Runtime/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/CommandLine.cpp?rev=54674&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/CommandLine.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/CommandLine.cpp (removed)
@@ -1,165 +0,0 @@
-//===------- CommandLine.cpp - Parses the command line --------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "CommandLine.h"
-#include "MvmGC.h"
-#include "mvm/Threads/Thread.h"
-
-using namespace mvm;
-
-typedef struct thread_arg_t {
- int argc;
- char** argv;
- vmlet_main_t func;
-} thread_arg_t;
-
-typedef int (*boot_t)();
-
-
-CommandLine::CommandLine() {
- resetString();
- resetArgv();
-}
-
-void CommandLine::appendChar(char c) {
- assert(_yytext);
- _yytext[_yylen++]= c;
- if (_yylen == _yylenMax) {
- _yylenMax *= 2;
- _yytext= (char *)realloc(_yytext, _yylenMax);
- }
-}
-
-void CommandLine::appendString(char* str) {
- assert(argv);
- appendChar(0);
- argv[argc++] = str;
- if (argc == argcMax) {
- argcMax *= 2;
- argv = (char **)realloc(argv, argcMax * sizeof(char*));
- }
-}
-
-void CommandLine::resetString() {
- _yytext = (char *)malloc(_yylenMax= 32);
- _yylen = 0;
-}
-
-void CommandLine::resetArgv() {
- argv = (char **)malloc(sizeof(char*) * (argcMax= 10));
- argc = 0;
-}
-
-
-void CommandLine::start() {
- printf("> ");
- _yyChar = getc(stdin);
-
- while (true) {
- switch(_yyChar) {
- case ' ' :
- do { _yyChar = getc(stdin); } while (_yyChar == ' ');
- if (_yylen != 0) {
- appendString(_yytext);
- resetString();
- }
- break;
-
- case '\n' :
- if (_yylen != 0) {
- appendString(_yytext);
- resetString();
- }
- if (argc > 1) {
- executeInstr();
- resetArgv();
- printf("> ");
- }
- _yyChar = getc(stdin);
- break;
-
- case EOF :
- printf("\n");
- return;
-
- default :
- appendChar(_yyChar);
- _yyChar = getc(stdin);
- }
- }
-}
-
-extern "C" int startApp(thread_arg_t* arg) {
- int argc = arg->argc;
- char** argv = arg->argv;
- vmlet_main_t func = arg->func;
- free(arg);
-#ifndef MULTIPLE_GC
- Collector::inject_my_thread(&argc);
- func(argc, argv);
- Collector::remove_my_thread();
- Collector::collect();
-#else
- Collector* GC = Collector::allocate();
- GC->inject_my_thread(&argc);
- func(argc, argv);
- GC->remove_my_thread();
- GC->collect();
-#endif
- return 0;
-}
-
-void CommandLine::executeInstr() {
- if (!strcmp(argv[0], "load")) {
- char* buf = (char*)alloca(sizeof(argv[1]) + 7);
- sprintf(buf, "lib%s.so", argv[1]);
- void* handle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
- if (handle == 0) {
- fprintf(stderr, "\t Unable to load %s\n", argv[1]);
- printf("\t error = %s\n", dlerror());
- return;
- }
-
- boot_t func = (boot_t)(intptr_t)dlsym(handle, "boot");
-
- if (func == 0) {
- fprintf(stderr, "\t Unable to find %s boot method\n", argv[1]);
- dlclose(handle);
- return;
- }
- func();
-
- vmlet_main_t vmlet = (vmlet_main_t)(intptr_t)dlsym(handle, "start_app");
-
- vmlets[argv[1]] = vmlet;
-
- } else {
- vmlet_main_t func = vmlets[argv[0]];
- if (!func) {
- fprintf(stderr, "\t Unknown vmlet %s\n", argv[0]);
- } else {
-#if 0
- thread_arg_t* thread_arg = (thread_arg_t*)malloc(sizeof (thread_arg_t));
- thread_arg->argc = argc;
- thread_arg->argv = argv;
- thread_arg->func = func;
- int tid = 0;
- Thread::start(&tid, (int (*)(void *))startApp, thread_arg);
-#else
- func(argc, argv);
-#endif
- }
- }
-}
Removed: vmkit/trunk/lib/Mvm/Runtime/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/CommandLine.h?rev=54674&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/CommandLine.h (original)
+++ vmkit/trunk/lib/Mvm/Runtime/CommandLine.h (removed)
@@ -1,57 +0,0 @@
-//===--------- CommandLine.h - Parses the command line --------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef COMMAND_LINE_H
-#define COMMAND_LINE_H
-
-#include <map>
-
-#include <string.h>
-
-namespace mvm {
-
-typedef int (*vmlet_main_t)(int argc, char** argv);
-
-struct ltstr
-{
- bool operator()(const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) < 0;
- }
-};
-
-class CommandLine {
-public:
- char** argv;
- unsigned argc;
- unsigned argcMax;
-
- char* _yytext;
- unsigned _yylen;
- unsigned _yylenMax;
- char _yyChar;
-
- std::map<const char*, vmlet_main_t, ltstr> vmlets;
-
- CommandLine();
-
- void appendChar(char c);
- void appendString(char* str);
-
- void start();
- void executeInstr();
-
- void resetArgv();
- void resetString();
-
-};
-
-} // end namespace mvm
-
-#endif // COMMAND_LINE_H
Modified: vmkit/trunk/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/Makefile?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/tools/Makefile (original)
+++ vmkit/trunk/tools/Makefile Tue Aug 12 03:03:45 2008
@@ -8,7 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ..
-PARALLEL_DIRS =
+PARALLEL_DIRS = vmkit
include $(LEVEL)/Makefile.config
Added: vmkit/trunk/tools/jnjvm/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Main.cpp?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/jnjvm/Main.cpp (added)
+++ vmkit/trunk/tools/jnjvm/Main.cpp Tue Aug 12 03:03:45 2008
@@ -0,0 +1,34 @@
+//===--------- Main.cpp - Simple execution of JnJVM -----------------------===//
+//
+// JnJVM
+//
+// This file is distributed under the University of Pierre et Marie Curie
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MvmGC.h"
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
+#include "mvm/VirtualMachine.h"
+#include "mvm/Threads/Thread.h"
+
+#include "llvm/Support/ManagedStatic.h"
+
+using namespace mvm;
+
+int main(int argc, char **argv, char **envp) {
+ llvm::llvm_shutdown_obj X;
+ int base;
+
+ jit::initialise();
+ Object::initialise();
+ Thread::initialise();
+ Collector::initialise(0, &base);
+
+ VirtualMachine::initialiseJVM();
+ VirtualMachine* vm = VirtualMachine::createJVM();
+ vm->runApplication(argc, argv);
+
+ return 0;
+}
Modified: vmkit/trunk/tools/jnjvm/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Makefile?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/tools/jnjvm/Makefile (original)
+++ vmkit/trunk/tools/jnjvm/Makefile Tue Aug 12 03:03:45 2008
@@ -11,7 +11,7 @@
include $(LEVEL)/Makefile.config
TOOLNAME = jnjvm
-USEDLIBS = Allocator CommonThread Mvm JnJVM Classpath Main $(GCLIB)
+USEDLIBS = Allocator CommonThread Mvm JnJVM Classpath $(GCLIB)
LINK_COMPONENTS = engine scalaropts instrumentation ipa ipo
include $(LEVEL)/Makefile.common
Added: vmkit/trunk/tools/n3-mono/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-mono/Main.cpp?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/n3-mono/Main.cpp (added)
+++ vmkit/trunk/tools/n3-mono/Main.cpp Tue Aug 12 03:03:45 2008
@@ -0,0 +1,34 @@
+//===--------- Main.cpp - Simple execution of JnJVM -----------------------===//
+//
+// JnJVM
+//
+// This file is distributed under the University of Pierre et Marie Curie
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MvmGC.h"
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
+#include "mvm/VirtualMachine.h"
+#include "mvm/Threads/Thread.h"
+
+#include "llvm/Support/ManagedStatic.h"
+
+using namespace mvm;
+
+int main(int argc, char **argv, char **envp) {
+ llvm::llvm_shutdown_obj X;
+ int base;
+
+ jit::initialise();
+ Object::initialise();
+ Thread::initialise();
+ Collector::initialise(0, &base);
+
+ VirtualMachine::initialiseCLIVM();
+ VirtualMachine* vm = VirtualMachine::createCLIVM();
+ vm->runApplication(argc, argv);
+
+ return 0;
+}
Modified: vmkit/trunk/tools/n3-mono/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-mono/Makefile?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-mono/Makefile (original)
+++ vmkit/trunk/tools/n3-mono/Makefile Tue Aug 12 03:03:45 2008
@@ -12,7 +12,7 @@
TOOLNAME = n3-mono
LINK_COMPONENTS = engine scalaropts instrumentation ipa ipo
-USEDLIBS = Allocator CommonThread Mvm N3 Main $(GCLIB) Mono
+USEDLIBS = Allocator CommonThread Mvm N3 $(GCLIB) Mono
include $(LEVEL)/Makefile.common
Added: vmkit/trunk/tools/n3-pnetlib/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-pnetlib/Main.cpp?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/n3-pnetlib/Main.cpp (added)
+++ vmkit/trunk/tools/n3-pnetlib/Main.cpp Tue Aug 12 03:03:45 2008
@@ -0,0 +1,34 @@
+//===--------- Main.cpp - Simple execution of JnJVM -----------------------===//
+//
+// JnJVM
+//
+// This file is distributed under the University of Pierre et Marie Curie
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MvmGC.h"
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
+#include "mvm/VirtualMachine.h"
+#include "mvm/Threads/Thread.h"
+
+#include "llvm/Support/ManagedStatic.h"
+
+using namespace mvm;
+
+int main(int argc, char **argv, char **envp) {
+ llvm::llvm_shutdown_obj X;
+ int base;
+
+ jit::initialise();
+ Object::initialise();
+ Thread::initialise();
+ Collector::initialise(0, &base);
+
+ VirtualMachine::initialiseCLIVM();
+ VirtualMachine* vm = VirtualMachine::createCLIVM();
+ vm->runApplication(argc, argv);
+
+ return 0;
+}
Modified: vmkit/trunk/tools/n3-pnetlib/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-pnetlib/Makefile?rev=54675&r1=54674&r2=54675&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-pnetlib/Makefile (original)
+++ vmkit/trunk/tools/n3-pnetlib/Makefile Tue Aug 12 03:03:45 2008
@@ -12,7 +12,7 @@
TOOLNAME = n3-pnetlib
LINK_COMPONENTS = engine scalaropts instrumentation ipa ipo
-USEDLIBS = Allocator CommonThread Mvm N3 Main $(GCLIB) PNetLib
+USEDLIBS = Allocator CommonThread Mvm N3 $(GCLIB) PNetLib
include $(LEVEL)/Makefile.common
Added: vmkit/trunk/tools/vmkit/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/CommandLine.cpp?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/vmkit/CommandLine.cpp (added)
+++ vmkit/trunk/tools/vmkit/CommandLine.cpp Tue Aug 12 03:03:45 2008
@@ -0,0 +1,175 @@
+//===------- CommandLine.cpp - Parses the command line --------------------===//
+//
+// The Micro Virtual Machine
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "CommandLine.h"
+#include "MvmGC.h"
+#include "mvm/Threads/Thread.h"
+
+using namespace mvm;
+
+typedef struct thread_arg_t {
+ int argc;
+ char** argv;
+ create_vm_t func;
+} thread_arg_t;
+
+
+
+CommandLine::CommandLine() {
+ resetString();
+ resetArgv();
+}
+
+void CommandLine::appendChar(char c) {
+ assert(_yytext);
+ _yytext[_yylen++]= c;
+ if (_yylen == _yylenMax) {
+ _yylenMax *= 2;
+ _yytext= (char *)realloc(_yytext, _yylenMax);
+ }
+}
+
+void CommandLine::appendString(char* str) {
+ assert(argv);
+ appendChar(0);
+ argv[argc++] = str;
+ if (argc == argcMax) {
+ argcMax *= 2;
+ argv = (char **)realloc(argv, argcMax * sizeof(char*));
+ }
+}
+
+void CommandLine::resetString() {
+ _yytext = (char *)malloc(_yylenMax= 32);
+ _yylen = 0;
+}
+
+void CommandLine::resetArgv() {
+ argv = (char **)malloc(sizeof(char*) * (argcMax= 10));
+ argc = 0;
+}
+
+
+void CommandLine::start() {
+ printf("> ");
+ _yyChar = getc(stdin);
+
+ while (true) {
+ switch(_yyChar) {
+ case ' ' :
+ do { _yyChar = getc(stdin); } while (_yyChar == ' ');
+ if (_yylen != 0) {
+ appendString(_yytext);
+ resetString();
+ }
+ break;
+
+ case '\n' :
+ if (_yylen != 0) {
+ appendString(_yytext);
+ resetString();
+ }
+ if (argc > 1) {
+ executeInstr();
+ resetArgv();
+ printf("> ");
+ }
+ _yyChar = getc(stdin);
+ break;
+
+ case EOF :
+ printf("\n");
+ return;
+
+ default :
+ appendChar(_yyChar);
+ _yyChar = getc(stdin);
+ }
+ }
+}
+
+extern "C" int startApp(thread_arg_t* arg) {
+ int argc = arg->argc;
+ char** argv = arg->argv;
+ create_vm_t func = arg->func;
+ free(arg);
+#ifndef MULTIPLE_GC
+ Collector::inject_my_thread(&argc);
+ VirtualMachine* VM = func();
+ VM->runApplication(argc, argv);
+ Collector::remove_my_thread();
+ Collector::collect();
+#else
+ Collector* GC = Collector::allocate();
+ GC->inject_my_thread(&argc);
+ func(argc, argv);
+ GC->remove_my_thread();
+ GC->collect();
+#endif
+ return 0;
+}
+
+void CommandLine::executeInstr() {
+ if (!strcmp(argv[0], "load")) {
+#if defined(__APPLE__)
+ char* buf = (char*)alloca(sizeof(argv[1]) + 7);
+ sprintf(buf, "%s.dylib", argv[1]);
+#else
+ char* buf = (char*)alloca(sizeof(argv[1]) + 4);
+ sprintf(buf, "%s.so", argv[1]);
+#endif
+ void* handle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
+ if (handle == 0) {
+ fprintf(stderr, "\t Unable to load %s\n", argv[1]);
+ printf("\t error = %s\n", dlerror());
+ return;
+ }
+
+ boot_t func = (boot_t)(intptr_t)dlsym(handle, "initialiseVirtualMachine");
+
+ if (func == 0) {
+ fprintf(stderr, "\t Unable to find %s boot method\n", argv[1]);
+ dlclose(handle);
+ return;
+ }
+ func();
+
+ create_vm_t vmlet = (create_vm_t)(intptr_t)dlsym(handle, "createVirtualMachine");
+
+ vmlets[argv[1]] = vmlet;
+
+ } else {
+ create_vm_t func = vmlets[argv[0]];
+ if (!func) {
+ fprintf(stderr, "\t Unknown vm %s\n", argv[0]);
+ } else {
+#if 0
+ thread_arg_t* thread_arg = (thread_arg_t*)malloc(sizeof (thread_arg_t));
+ thread_arg->argc = argc;
+ thread_arg->argv = argv;
+ thread_arg->func = func;
+ int tid = 0;
+ Thread::start(&tid, (int (*)(void *))startApp, thread_arg);
+#else
+ VirtualMachine* VM = func();
+ try {
+ VM->runApplication(argc, argv);
+ } catch(...) {
+ printf("Caught exception when running the VM");
+ }
+#endif
+ }
+ }
+}
Added: vmkit/trunk/tools/vmkit/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/CommandLine.h?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/vmkit/CommandLine.h (added)
+++ vmkit/trunk/tools/vmkit/CommandLine.h Tue Aug 12 03:03:45 2008
@@ -0,0 +1,73 @@
+//===--------- CommandLine.h - Parses the command line --------------------===//
+//
+// The Micro Virtual Machine
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef COMMAND_LINE_H
+#define COMMAND_LINE_H
+
+#include <map>
+
+#include <string.h>
+
+#include "mvm/VirtualMachine.h"
+
+#if defined(__APPLE__)
+#define JNJVM_LIB "Jnjvm.dylib"
+#define CLASSPATH_LIB "Classpath.dylib"
+#define N3_LIB "N3.dylib"
+#define PNET_LIB "Pnetlib.dylib"
+#else
+#define JNJVM_LIB "Jnjvm.so"
+#define CLASSPATH_LIB "Classpath.so"
+#define N3_LIB "N3.so"
+#define PNET_LIB "Pnetlib.so"
+#endif
+
+typedef int (*boot_t)();
+typedef mvm::VirtualMachine* (*create_vm_t)();
+
+namespace mvm {
+
+
+struct ltstr
+{
+ bool operator()(const char* s1, const char* s2) const
+ {
+ return strcmp(s1, s2) < 0;
+ }
+};
+
+class CommandLine {
+public:
+ char** argv;
+ unsigned argc;
+ unsigned argcMax;
+
+ char* _yytext;
+ unsigned _yylen;
+ unsigned _yylenMax;
+ char _yyChar;
+
+ std::map<const char*, create_vm_t, ltstr> vmlets;
+
+ CommandLine();
+
+ void appendChar(char c);
+ void appendString(char* str);
+
+ void start();
+ void executeInstr();
+
+ void resetArgv();
+ void resetString();
+
+};
+
+} // end namespace mvm
+
+#endif // COMMAND_LINE_H
Added: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (added)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Tue Aug 12 03:03:45 2008
@@ -0,0 +1,75 @@
+//===--------- Launcher.cpp - Launch command line -------------------------===//
+//
+// JnJVM
+//
+// This file is distributed under the University of Pierre et Marie Curie
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <dlfcn.h>
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
+
+#include "MvmGC.h"
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
+#include "mvm/VirtualMachine.h"
+#include "mvm/Threads/Thread.h"
+
+#include "CommandLine.h"
+
+static llvm::cl::opt<bool> Java("java", llvm::cl::desc("Run the JVM"));
+static llvm::cl::opt<bool> Net("net", llvm::cl::desc("Run the .Net VM"));
+
+int found(char** argv, int argc, const char* name) {
+ int i = 1;
+ for (; i < argc; i++) {
+ if (!(strcmp(name, argv[i]))) return i + 1;
+ }
+ return 0;
+}
+
+int main(int argc, char** argv) {
+ llvm::llvm_shutdown_obj X;
+ int base;
+
+ mvm::jit::initialise();
+ mvm::Object::initialise();
+ mvm::Thread::initialise();
+ Collector::initialise(0, &base);
+ Collector::enable(0);
+ int pos = found(argv, argc, "-java");
+ if (pos) {
+ llvm::cl::ParseCommandLineOptions(pos, argv);
+ } else {
+ pos = found(argv, argc, "-net");
+ if (pos) {
+ llvm::cl::ParseCommandLineOptions(pos, argv);
+ } else {
+ llvm::cl::ParseCommandLineOptions(argc, argv);
+ }
+ }
+
+ if (Java) {
+ mvm::VirtualMachine::initialiseJVM();
+ mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM();
+ vm->runApplication(argc, argv);
+ } else if (Net) {
+ mvm::VirtualMachine::initialiseCLIVM();
+ mvm::VirtualMachine* vm = mvm::VirtualMachine::createCLIVM();
+ vm->runApplication(argc, argv);
+ } else {
+ mvm::VirtualMachine::initialiseJVM();
+ mvm::VirtualMachine::initialiseCLIVM();
+ mvm::VirtualMachine* bootstrapJVM = mvm::VirtualMachine::createJVM();
+ mvm::VirtualMachine* bootstrapNet = mvm::VirtualMachine::createCLIVM();
+ mvm::CommandLine MyCl;
+ MyCl.vmlets["java"] = (mvm::VirtualMachine::createJVM);
+ MyCl.vmlets["net"] = (mvm::VirtualMachine::createCLIVM);
+ MyCl.start();
+ }
+
+ return 0;
+}
Added: vmkit/trunk/tools/vmkit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Makefile?rev=54675&view=auto
==============================================================================
--- vmkit/trunk/tools/vmkit/Makefile (added)
+++ vmkit/trunk/tools/vmkit/Makefile Tue Aug 12 03:03:45 2008
@@ -0,0 +1,20 @@
+##===- tools/jnjvm/Makefile --------------------------------*- Makefile -*-===##
+#
+# The vmkit project
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
+include $(LEVEL)/Makefile.config
+
+TOOLNAME = vmkit
+USEDLIBS = Allocator CommonThread Mvm $(GCLIB) JnJVM Classpath PNetLib N3
+LINK_COMPONENTS = engine scalaropts instrumentation ipa ipo
+
+include $(LEVEL)/Makefile.common
+
+LIBS += $(PNETLIB)/engine/libILEngine.a $(PNETLIB)/image/libILImage.a $(PNETLIB)/support/libILSupport.a \
+ $(PNETLIB)/libffi/.libs/libffi.a $(PNETLIB)//dumpasm/libILDumpAsm.a
Propchange: vmkit/trunk/tools/vmkit/Makefile
------------------------------------------------------------------------------
svn:executable = *
More information about the vmkit-commits
mailing list