[vmkit-commits] [vmkit] r107859 - in /vmkit/trunk/lib/J3: Compiler/JavaAOTCompiler.cpp VMCore/Jnjvm.cpp VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h VMCore/VirtualTables.cpp VMCore/Zip.cpp VMCore/Zip.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu Jul 8 00:12:59 PDT 2010
Author: geoffray
Date: Thu Jul 8 02:12:59 2010
New Revision: 107859
URL: http://llvm.org/viewvc/llvm-project?rev=107859&view=rev
Log:
ZipArchive should have direct access to the bytes, as they are alive throughout the lifetime of the applications.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
vmkit/trunk/lib/J3/VMCore/VirtualTables.cpp
vmkit/trunk/lib/J3/VMCore/Zip.cpp
vmkit/trunk/lib/J3/VMCore/Zip.h
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Thu Jul 8 02:12:59 2010
@@ -1885,7 +1885,7 @@
JavaAOTCompiler* M,
JnjvmBootstrapLoader* bootstrapLoader,
std::vector<Class*>& classes) {
- ZipArchive archive(&bytes, bootstrapLoader->allocator);
+ ZipArchive archive(bytes, bootstrapLoader->allocator);
char* realName = (char*)alloca(4096);
for (ZipArchive::table_iterator i = archive.filetable.begin(),
Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Thu Jul 8 02:12:59 2010
@@ -865,13 +865,17 @@
return;
}
- ZipArchive archive(&bytes, vm->allocator);
- if (archive.getOfscd() != -1) {
- ZipFile* file = archive.getFile(PATH_MANIFEST);
+ mvm::BumpPtrAllocator allocator;
+ ZipArchive* archive = new(allocator, "TempZipArchive")
+ ZipArchive(bytes, allocator);
+ // Make sure it gets GC'd.
+ vm->bootstrapLoader->bootArchives.push_back(archive);
+ if (archive->getOfscd() != -1) {
+ ZipFile* file = archive->getFile(PATH_MANIFEST);
if (file != NULL) {
UserClassArray* array = vm->bootstrapLoader->upcalls->ArrayOfByte;
res = (ArrayUInt8*)array->doNew(file->ucsize, vm);
- int ok = archive.readFile(res, file);
+ int ok = archive->readFile(res, file);
if (ok) {
char* mainClass = findInformation(vm, res, MAIN_CLASS,
LENGTH_MAIN_CLASS);
@@ -893,6 +897,8 @@
} else {
printf("Can't find archive %s\n", jarFile);
}
+ // We don't need this archive anymore.
+ vm->bootstrapLoader->bootArchives.pop_back();
}
void ClArgumentsInfo::nyi() {
Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Thu Jul 8 02:12:59 2010
@@ -343,7 +343,6 @@
ZipArchive* archive = *i;
char* buf = (char*)alloca(alen + 7);
sprintf(buf, "%s.class", asciiz);
- // This array is not allocated by the GC.
res = Reader::openZip(this, archive, buf);
if (res) return res;
}
@@ -936,6 +935,8 @@
}
void JnjvmBootstrapLoader::analyseClasspathEnv(const char* str) {
+ ArrayUInt8* bytes = NULL;
+ llvm_gcroot(bytes, 0);
if (str != 0) {
unsigned int len = strlen(str);
char* buf = new char[len + 1];
@@ -963,10 +964,10 @@
temp[len + 1] = 0;
bootClasspath.push_back(temp);
} else {
- ArrayUInt8* bytes = Reader::openFile(this, rp);
+ bytes = Reader::openFile(this, rp);
if (bytes) {
ZipArchive *archive = new(allocator, "ZipArchive")
- ZipArchive(&bytes, allocator);
+ ZipArchive(bytes, allocator);
if (archive) {
bootArchives.push_back(archive);
}
Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Thu Jul 8 02:12:59 2010
@@ -419,6 +419,8 @@
}
virtual ~JnjvmBootstrapLoader();
+
+ friend class ClArgumentsInfo;
};
/// VMClassLoader - The vmdata object that will be placed in and will only
Modified: vmkit/trunk/lib/J3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/VirtualTables.cpp?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/VirtualTables.cpp Thu Jul 8 02:12:59 2010
@@ -240,7 +240,7 @@
for (std::vector<ZipArchive*>::iterator i = bootArchives.begin(),
e = bootArchives.end(); i != e; i++) {
- mvm::Collector::markAndTraceRoot((*i)->bytes, closure);
+ mvm::Collector::markAndTraceRoot(&((*i)->bytes), closure);
}
}
Modified: vmkit/trunk/lib/J3/VMCore/Zip.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Zip.cpp?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Zip.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Zip.cpp Thu Jul 8 02:12:59 2010
@@ -17,7 +17,8 @@
using namespace j3;
-ZipArchive::ZipArchive(ArrayUInt8** bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
+ZipArchive::ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
+ llvm_gcroot(bytes, 0);
this->bytes = bytes;
findOfscd();
if (ofscd > -1) addFiles();
@@ -73,7 +74,7 @@
sint32 minOffs = 0;
sint32 st = END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4;
- Reader reader(bytes);
+ Reader reader(&bytes);
curOffs = reader.max;
if (curOffs >= (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4)) {
minOffs = curOffs - (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4);
@@ -103,8 +104,8 @@
if (searchPos >= st) {
sint32 searchPtr = temp + (searchPos - st);
while (searchPtr > temp) {
- if (ArrayUInt8::getElement(*(reader.bytes), searchPtr) == 'P' &&
- !(memcmp(ArrayUInt8::getElements(*(reader.bytes)) + searchPtr, HDR_ENDCENTRAL, 4))) {
+ if (ArrayUInt8::getElement(bytes, searchPtr) == 'P' &&
+ !(memcmp(ArrayUInt8::getElements(bytes) + searchPtr, HDR_ENDCENTRAL, 4))) {
sint32 offset = searchPtr + 4 + E_OFFSET_START_CENTRAL_DIRECTORY;
reader.cursor = offset;
this->ofscd = readEndianDep4(reader);
@@ -119,11 +120,11 @@
void ZipArchive::addFiles() {
sint32 temp = ofscd;
- Reader reader(bytes);
+ Reader reader(&bytes);
reader.cursor = temp;
while (true) {
- if (memcmp(ArrayUInt8::getElements(*(reader.bytes)) + temp, HDR_CENTRAL, 4)) return;
+ if (memcmp(ArrayUInt8::getElements(bytes) + temp, HDR_CENTRAL, 4)) return;
ZipFile* ptr = new(allocator, "ZipFile") ZipFile();
reader.cursor = temp + 4 + C_COMPRESSION_METHOD;
ptr->compressionMethod = readEndianDep2(reader);
@@ -147,7 +148,7 @@
ptr->filename = (char*)allocator.Allocate(ptr->filenameLength + 1,
"Zip file name");
- memcpy(ptr->filename, ArrayUInt8::getElements(*(reader.bytes)) + temp,
+ memcpy(ptr->filename, ArrayUInt8::getElements(bytes) + temp,
ptr->filenameLength);
ptr->filename[ptr->filenameLength] = 0;
@@ -167,10 +168,10 @@
uint32 extraFieldLength = 0;
uint32 temp = 0;
- Reader reader(bytes);
+ Reader reader(&bytes);
reader.cursor = file->rolh;
- if (!(memcmp(ArrayUInt8::getElements(*(reader.bytes)) + file->rolh, HDR_LOCAL, 4))) {
+ if (!(memcmp(ArrayUInt8::getElements(bytes) + file->rolh, HDR_LOCAL, 4))) {
reader.cursor += 4;
temp = reader.cursor;
reader.cursor += L_FILENAME_LENGTH;
@@ -181,7 +182,7 @@
temp + extraFieldLength + filenameLength + LOCAL_FILE_HEADER_SIZE;
if (file->compressionMethod == ZIP_STORE) {
- memcpy(ArrayUInt8::getElements(array), ArrayUInt8::getElements(*(reader.bytes)) + reader.cursor, file->ucsize);
+ memcpy(ArrayUInt8::getElements(array), ArrayUInt8::getElements(bytes) + reader.cursor, file->ucsize);
return 1;
} else if (file->compressionMethod == ZIP_DEFLATE) {
z_stream stre;
@@ -201,7 +202,7 @@
while (bytesLeft) {
uint32 size = 0;
- stre.next_in = ArrayUInt8::getElements(*(reader.bytes)) + reader.cursor;
+ stre.next_in = ArrayUInt8::getElements(bytes) + reader.cursor;
if (bytesLeft > 1024) size = 1024;
else size = bytesLeft;
Modified: vmkit/trunk/lib/J3/VMCore/Zip.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Zip.h?rev=107859&r1=107858&r2=107859&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Zip.h (original)
+++ vmkit/trunk/lib/J3/VMCore/Zip.h Thu Jul 8 02:12:59 2010
@@ -49,7 +49,7 @@
public:
std::map<const char*, ZipFile*, ltstr> filetable;
typedef std::map<const char*, ZipFile*, ltstr>::iterator table_iterator;
- ArrayUInt8** bytes;
+ ArrayUInt8* bytes;
private:
@@ -70,7 +70,7 @@
}
int getOfscd() { return ofscd; }
- ZipArchive(ArrayUInt8** bytes, mvm::BumpPtrAllocator& allocator);
+ ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& allocator);
ZipFile* getFile(const char* filename);
int readFile(ArrayUInt8* array, const ZipFile* file);
More information about the vmkit-commits
mailing list