[vmkit-commits] [vmkit] r52953 - in /vmkit/trunk/lib/JnJVM/VMCore: Jnjvm.cpp Jnjvm.h Reader.cpp Reader.h VirtualTables.cpp Zip.cpp Zip.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue Jul 1 02:33:46 PDT 2008
Author: geoffray
Date: Tue Jul 1 04:33:44 2008
New Revision: 52953
URL: http://llvm.org/viewvc/llvm-project?rev=52953&view=rev
Log:
JnJVM can now take glibj.zip and other .zip files as the
base libraries.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp
vmkit/trunk/lib/JnJVM/VMCore/Reader.h
vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp
vmkit/trunk/lib/JnJVM/VMCore/Zip.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue Jul 1 04:33:44 2008
@@ -151,7 +151,14 @@
bootClasspath.push_back(temp);
free(rp);
} else {
- bootClasspath.push_back(rp);
+ ArrayUInt8* bytes = Reader::openFile(this, rp);
+ free(rp);
+ if (bytes) {
+ ZipArchive *archive = new ZipArchive(bytes);
+ if (archive) {
+ bootArchives.push_back(archive);
+ }
+ }
}
} else {
free(rp);
@@ -278,26 +285,30 @@
ArrayUInt8* Jnjvm::openName(const UTF8* utf8) {
char* asciiz = utf8->UTF8ToAsciiz();
uint32 alen = strlen(asciiz);
- uint32 nbcp = bootClasspath.size();
- uint32 idx = 0;
ArrayUInt8* res = 0;
- while ((res == 0) && (idx < nbcp)) {
- char* str = bootClasspath[idx];
+ for (std::vector<const char*>::iterator i = bootClasspath.begin(),
+ e = bootClasspath.end(); i != e; ++i) {
+ const char* str = *i;
unsigned int strLen = strlen(str);
- char* buf = (char*)alloca(strLen + alen + 16);
+ char* buf = (char*)alloca(strLen + alen + 7);
- if (str[strLen - 1] == dirSeparator[0]) {
- sprintf(buf, "%s%s.class", str, asciiz);
- res = Reader::openFile(this, buf);
- } else {
- sprintf(buf, "%s.class", asciiz);
- res = Reader::openZip(this, str, buf);
- }
- idx++;
+ sprintf(buf, "%s%s.class", str, asciiz);
+ res = Reader::openFile(this, buf);
+ if (res) return res;
}
- return res;
+ for (std::vector<ZipArchive*>::iterator i = bootArchives.begin(),
+ e = bootArchives.end(); i != e; ++i) {
+
+ ZipArchive* archive = *i;
+ char* buf = (char*)alloca(alen + 7);
+ sprintf(buf, "%s.class", asciiz);
+ res = Reader::openZip(this, archive, buf);
+ if (res) return res;
+ }
+
+ return 0;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Tue Jul 1 04:33:44 2008
@@ -53,7 +53,7 @@
class FunctionDefMap;
class FunctionDefMap;
class AllocationMap;
-
+class ZipArchive;
class Jnjvm : public mvm::Object{
public:
@@ -228,7 +228,8 @@
void* jniEnv;
const void* javavmEnv;
std::vector< std::pair<char*, char*> > postProperties;
- std::vector<char*> bootClasspath;
+ std::vector<const char*> bootClasspath;
+ std::vector<ZipArchive*> bootArchives;
std::vector<void*> nativeLibs;
const char* classpath;
const char* libClasspathEnv;
Modified: vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp Tue Jul 1 04:33:44 2008
@@ -38,16 +38,13 @@
return res;
}
-ArrayUInt8* Reader::openZip(Jnjvm* vm, char* zipname, char* filename) {
- ZipArchive* archive = ZipArchive::hashedArchive(vm, zipname);
+ArrayUInt8* Reader::openZip(Jnjvm* vm, ZipArchive* archive, char* filename) {
ArrayUInt8* ret = 0;
- if (archive != 0) {
- ZipFile* file = archive->getFile(filename);
- if (file != 0) {
- ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte, vm);
- if (archive->readFile(res, file) != 0) {
- ret = res;
- }
+ ZipFile* file = archive->getFile(filename);
+ if (file != 0) {
+ ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte, vm);
+ if (archive->readFile(res, file) != 0) {
+ ret = res;
}
}
return ret;
Modified: vmkit/trunk/lib/JnJVM/VMCore/Reader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Reader.h?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Reader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Reader.h Tue Jul 1 04:33:44 2008
@@ -20,6 +20,7 @@
namespace jnjvm {
class Jnjvm;
+class ZipArchive;
class Reader {
public:
@@ -76,7 +77,7 @@
static const int SeekEnd;
static ArrayUInt8* openFile(Jnjvm* vm, char* path);
- static ArrayUInt8* openZip(Jnjvm* vm, char* zipname, char* filename);
+ static ArrayUInt8* openZip(Jnjvm* vm, ZipArchive* archive, char* filename);
uint8 readU1() {
return bytes->elements[cursor++];
Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Tue Jul 1 04:33:44 2008
@@ -104,6 +104,12 @@
statics->MARK_AND_TRACE;
delegatees->MARK_AND_TRACE;
#endif
+
+ for (std::vector<ZipArchive*>::iterator i = bootArchives.begin(),
+ e = bootArchives.end(); i != e; ++i) {
+ (*i)->bytes->MARK_AND_TRACE;
+ }
+
}
void JavaIsolate::TRACER {
Modified: vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp Tue Jul 1 04:33:44 2008
@@ -15,11 +15,6 @@
using namespace jnjvm;
-ZipArchive* ZipArchive::hashedArchive(Jnjvm* vm, const char* name) {
- assert(0 && "implement hashedArchive");
- return 0;
-}
-
ZipArchive::ZipArchive(ArrayUInt8* bytes) {
this->bytes = bytes;
findOfscd();
Modified: vmkit/trunk/lib/JnJVM/VMCore/Zip.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Zip.h?rev=52953&r1=52952&r2=52953&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Zip.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Zip.h Tue Jul 1 04:33:44 2008
@@ -15,6 +15,7 @@
namespace jnjvm {
class ArrayUInt8;
+class Jnjvm;
struct ZipFile {
char* filename;
@@ -30,6 +31,7 @@
class ZipArchive {
+ friend class Jnjvm;
private:
struct ltstr
@@ -62,7 +64,6 @@
int getOfscd() { return ofscd; }
ZipArchive(ArrayUInt8* bytes);
- static ZipArchive* hashedArchive(Jnjvm* vm, const char* archname);
ZipFile* getFile(const char* filename);
int readFile(ArrayUInt8* array, const ZipFile* file);
More information about the vmkit-commits
mailing list