[vmkit-commits] [vmkit] r199603 - process some command line
Gael Thomas
gael.thomas at lip6.fr
Sun Jan 19 07:37:33 PST 2014
Author: gthomas
Date: Sun Jan 19 09:37:33 2014
New Revision: 199603
URL: http://llvm.org/viewvc/llvm-project?rev=199603&view=rev
Log:
process some command line
Modified:
vmkit/branches/mcjit/include/j3/j3options.h
vmkit/branches/mcjit/lib/j3/vm/j3.cc
vmkit/branches/mcjit/lib/j3/vm/j3options.cc
Modified: vmkit/branches/mcjit/include/j3/j3options.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3options.h?rev=199603&r1=199602&r2=199603&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3options.h (original)
+++ vmkit/branches/mcjit/include/j3/j3options.h Sun Jan 19 09:37:33 2014
@@ -1,6 +1,7 @@
#ifndef _J3_CMD_LINE_H_
#define _J3_CMD_LINE_H_
+#include <sys/types.h>
#include <stdint.h>
namespace j3 {
@@ -33,6 +34,11 @@ namespace j3 {
const char* classpath;
+ const char* jarFile;
+ const char* mainClass;
+ char** args;
+ size_t nbArgs;
+
bool debugEnterIndent;
uint32_t genDebugExecute;
uint32_t debugExecute;
@@ -45,6 +51,8 @@ namespace j3 {
uintptr_t stackSize;
+ bool isAOT;
+
J3Options();
void process(int argc, char** argv);
Modified: vmkit/branches/mcjit/lib/j3/vm/j3.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=199603&r1=199602&r2=199603&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Sun Jan 19 09:37:33 2014
@@ -178,19 +178,37 @@ void J3::run() {
//options()->debugExecute = 0;
+#define LM_CLASS 1
+#define LM_JAR 2
+
+ uint32_t mode;
+ const char* what;
+
+ if(options()->mainClass) {
+ mode = LM_CLASS;
+ what = options()->mainClass;
+ } else {
+ mode = LM_JAR;
+ what = options()->jarFile;
+ }
+
J3Class* main = J3ObjectType::nativeClass(z_method(J3Cst::ACC_STATIC,
z_class("sun.launcher.LauncherHelper"),
names()->get("checkAndLoadMain"),
names()->get("(ZILjava/lang/String;)Ljava/lang/Class;"))
- ->invokeStatic(1, 1, utfToString("HelloWorld")).valObject)->asClass();
+ ->invokeStatic(1, mode, utfToString(what)).valObject)->asClass();
if(options()->debugLifeCycle)
fprintf(stderr, " Launch the application\n");
+ J3ObjectHandle* args = J3ObjectHandle::doNewArray(stringClass->getArray(), options()->nbArgs);
+ for(uint32_t i=0; i<options()->nbArgs; i++)
+ args->setObjectAt(i, utfToString(options()->args[i]));
+
main
->findMethod(J3Cst::ACC_STATIC, names()->get("main"), initialClassLoader->getSignature(0, names()->get("([Ljava/lang/String;)V")))
- ->invokeStatic((J3ObjectHandle*)0);
+ ->invokeStatic(args);
}
JNIEnv* J3::jniEnv() {
Modified: vmkit/branches/mcjit/lib/j3/vm/j3options.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3options.cc?rev=199603&r1=199602&r2=199603&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Sun Jan 19 09:37:33 2014
@@ -11,21 +11,24 @@ using namespace j3;
J3Options::J3Options() {
assertionsEnabled = 1;
selfBitCodePath = SELF_BITCODE;
- classpath = ".";
+ classpath = getenv("CLASSPATH");
+ classpath = classpath ? classpath : ".";
debugEnterIndent = 1;
- debugExecute = 1;
+ debugExecute = 0;
debugLoad = 0;
debugResolve = 0;
debugIniting = 0;
debugTranslate = 0;
debugLinking = 0;
- debugLifeCycle = 0;
+ debugLifeCycle = 1;
- genDebugExecute = 1;//debugExecute ? 1 : 0;
+ genDebugExecute = 0;//debugExecute ? 1 : 0;
stackSize = 0x80*0x1000;
+
+ isAOT = 0;
}
#define nyi(cmd) ({ fprintf(stderr, "option '%s' not yet implemented\n", cmd); })
@@ -40,14 +43,15 @@ J3CmdLineParser::J3CmdLineParser(J3Optio
#define optbeg(opt) (!memcmp(argv[cur], opt, strlen(opt)))
void J3CmdLineParser::process() {
+ bool done = 0;
cur = 1;
- while(cur < argc) {
+ while(!done && cur < argc) {
if(opteq("-jar")) {
- nyi("-jar");
- return;
+ options->jarFile = argv[++cur];
+ done = 1;
} else if(opteq("-cp") || opteq("-classpath"))
- nyi("-cp/-classpath");
+ options->classpath = argv[++cur];
else if(optbeg("-D"))
nyi("-D<name>=<value>");
else if(opteq("-verbose:class"))
@@ -70,6 +74,10 @@ void J3CmdLineParser::process() {
nyi("-no-jre-restrict-search");
else if(opteq("-?") || opteq("-help"))
help();
+ else if(opteq("-Xaot"))
+ options->isAOT = 1;
+ else if(opteq("-Xno-aot"))
+ options->isAOT = 0;
else if(optbeg("-X"))
nyi("-X");
else if(optbeg("-ea:") || optbeg("-enableassertions:"))
@@ -93,13 +101,18 @@ void J3CmdLineParser::process() {
else if(optbeg("-"))
help();
else {
- nyi("class args");
- return;
+ options->mainClass = argv[cur];
+ done = 1;
}
+
cur++;
}
- help();
+ if(!options->jarFile && !options->mainClass)
+ help();
+
+ options->args = argv + cur;
+ options->nbArgs = argc - cur;
}
void J3CmdLineParser::help() {
More information about the vmkit-commits
mailing list