Optimized java.util.zip.ZipFile#getNextEntry()
Optimized sequential access to zip entries by keeping an array of those in JavaZipFile
(a custom subclass of ZipArchive). When we could access entry directly by it's index,
not having to walk through linked list of ZipMembers
--- a/JavaNativeMethodImpl_OpenJDK6.st Fri Jul 25 00:51:04 2014 +0100
+++ b/JavaNativeMethodImpl_OpenJDK6.st Fri Jul 25 01:52:23 2014 +0100
@@ -14062,7 +14062,7 @@
"Created: / 27-03-2011 / 16:59:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 01-04-2011 / 16:03:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 18-08-2011 / 19:44:56 / jv"
- "Modified: / 10-12-2013 / 00:57:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-07-2014 / 01:26:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_util_zip_ZipFile_getMethod: this _:a1 _: a2
@@ -14083,37 +14083,24 @@
<javanative: 'java/util/zip/ZipFile' name: 'getNextEntry(JI)J'>
- | zipArchive i |
+ | zipArchive member jzentry |
zipArchive := self getZipArchiveAt:jzfile.
- i := 0.
- zipArchive zipMembersDo:[:member |
- index == i ifTrue:[
- "/^ ZipEntryCache indexOf: member ifAbsent:[
- | index |
-
- ZipEntryCacheLock critical:[
- ZipEntryCacheFirstFree == 0 ifTrue:[
- ZipEntryCache add: member.
- index := ZipEntryCache size.
- ] ifFalse:[
- index := ZipEntryCacheFirstFree.
- ZipEntryCacheFirstFree := ZipEntryCache at: index.
- ZipEntryCache at: index put: member.
- ].
- ].
- "/Logger
- "/ log: 'java.util.zip.ZipFile.getNextEntry() called for ', index printString
- "/ severity: #debug
- "/ facility: 'JVM'.
- ^ index.
- "/].
- ].
- i := i + 1.
- ].
- ^0
-
- "Modified: / 10-12-2013 / 00:56:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ (index between: 0 and: zipArchive members size - 1) ifFalse:[ ^ 0 ].
+ member := zipArchive members at: index + 1.
+ ZipEntryCacheLock critical:[
+ ZipEntryCacheFirstFree == 0 ifTrue:[
+ ZipEntryCache add: member.
+ jzentry := ZipEntryCache size.
+ ] ifFalse:[
+ jzentry := ZipEntryCacheFirstFree.
+ ZipEntryCacheFirstFree := ZipEntryCache at: jzentry.
+ ZipEntryCache at: jzentry put: member.
+ ].
+ ].
+ ^ jzentry.
+
+ "Modified: / 25-07-2014 / 01:45:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_util_zip_ZipFile_getSize: this _:a1 _: a2
@@ -14183,7 +14170,7 @@
ZipCacheLastAccessed notNil ifTrue:[
ZipCacheLastAccessed closeFile.
].
- zar := ZipArchive readingFrom: result readStream.
+ zar := JavaZipFile readingFrom: result readStream.
zar checkZipArchive ifFalse:[
JavaVM throwZipException:'Cannot open zip file: not a zip archive'.
].
@@ -14200,7 +14187,7 @@
]
"Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 23-04-2013 / 00:52:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-07-2014 / 01:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_util_zip_ZipFile_read: this _:a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaZipFile.st Fri Jul 25 01:52:23 2014 +0100
@@ -0,0 +1,81 @@
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+ of one of the above copright owners. For exact set of such code,
+ see the differences between this version and version stx:libjava
+ as of 1.9.2010
+"
+"{ Package: 'stx:libjava' }"
+
+ZipArchive subclass:#JavaZipFile
+ instanceVariableNames:'members'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Support-Native'
+!
+
+!JavaZipFile class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+ of one of the above copright owners. For exact set of such code,
+ see the differences between this version and version stx:libjava
+ as of 1.9.2010
+
+"
+! !
+
+!JavaZipFile methodsFor:'accessing'!
+
+members
+ ^ members
+! !
+
+!JavaZipFile methodsFor:'private - directory stuff'!
+
+readDirectory
+ "read the zip directory into a linked-list of zipMembers"
+
+ | i member |
+
+ super readDirectory.
+ members := Array new: centralDirectory centralDirectoryTotalNoOfEntries.
+ i := 1.
+ member := firstEntry.
+ [ member notNil ] whileTrue:[
+ members at: i put: member.
+ i := i + 1.
+ member := member next.
+ ].
+
+ "Created: / 25-07-2014 / 00:53:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/Make.proto Fri Jul 25 00:51:04 2014 +0100
+++ b/Make.proto Fri Jul 25 01:52:23 2014 +0100
@@ -226,6 +226,7 @@
$(OUTDIR)JavaVMData.$(O) JavaVMData.$(H): JavaVMData.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)JavaView.$(O) JavaView.$(H): JavaView.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libview/DisplaySurface.$(H) $(INCLUDE_TOP)/stx/libview/GraphicsMedium.$(H) $(INCLUDE_TOP)/stx/libview/SimpleView.$(H) $(INCLUDE_TOP)/stx/libview/View.$(H) $(STCHDR)
$(OUTDIR)JavaZipDeflater.$(O) JavaZipDeflater.$(H): JavaZipDeflater.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)JavaZipFile.$(O) JavaZipFile.$(H): JavaZipFile.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic2/ZipArchive.$(H) $(STCHDR)
$(OUTDIR)JavaZipInflater.$(O) JavaZipInflater.$(H): JavaZipInflater.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)ProxyMethod.$(O) ProxyMethod.$(H): ProxyMethod.st $(INCLUDE_TOP)/stx/libbasic/CompiledCode.$(H) $(INCLUDE_TOP)/stx/libbasic/ExecutableFunction.$(H) $(INCLUDE_TOP)/stx/libbasic/Method.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)ProxyMethodCompiler.$(O) ProxyMethodCompiler.$(H): ProxyMethodCompiler.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/Make.spec Fri Jul 25 00:51:04 2014 +0100
+++ b/Make.spec Fri Jul 25 01:52:23 2014 +0100
@@ -111,6 +111,7 @@
JavaVMData \
JavaView \
JavaZipDeflater \
+ JavaZipFile \
JavaZipInflater \
ProxyMethod \
ProxyMethodCompiler \
@@ -254,6 +255,7 @@
$(OUTDIR_SLASH)JavaVMData.$(O) \
$(OUTDIR_SLASH)JavaView.$(O) \
$(OUTDIR_SLASH)JavaZipDeflater.$(O) \
+ $(OUTDIR_SLASH)JavaZipFile.$(O) \
$(OUTDIR_SLASH)JavaZipInflater.$(O) \
$(OUTDIR_SLASH)ProxyMethod.$(O) \
$(OUTDIR_SLASH)ProxyMethodCompiler.$(O) \
--- a/abbrev.stc Fri Jul 25 00:51:04 2014 +0100
+++ b/abbrev.stc Fri Jul 25 01:52:23 2014 +0100
@@ -78,6 +78,7 @@
JavaVMData JavaVMData stx:libjava 'Languages-Java-Support' 0
JavaView JavaView stx:libjava 'Languages-Java-Views-Support' 2
JavaZipDeflater JavaZipDeflater stx:libjava 'Languages-Java-Support-Native' 0
+JavaZipFile JavaZipFile stx:libjava 'Languages-Java-Support-Native' 0
JavaZipInflater JavaZipInflater stx:libjava 'Languages-Java-Support-Native' 0
ProxyMethod ProxyMethod stx:libjava 'System-Compiler-Interop' 0
ProxyMethodCompiler ProxyMethodCompiler stx:libjava 'System-Compiler-Interop' 0
--- a/bc.mak Fri Jul 25 00:51:04 2014 +0100
+++ b/bc.mak Fri Jul 25 01:52:23 2014 +0100
@@ -159,6 +159,7 @@
$(OUTDIR)JavaVMData.$(O) JavaVMData.$(H): JavaVMData.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)JavaView.$(O) JavaView.$(H): JavaView.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libview\DisplaySurface.$(H) $(INCLUDE_TOP)\stx\libview\GraphicsMedium.$(H) $(INCLUDE_TOP)\stx\libview\SimpleView.$(H) $(INCLUDE_TOP)\stx\libview\View.$(H) $(STCHDR)
$(OUTDIR)JavaZipDeflater.$(O) JavaZipDeflater.$(H): JavaZipDeflater.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)JavaZipFile.$(O) JavaZipFile.$(H): JavaZipFile.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic2\ZipArchive.$(H) $(STCHDR)
$(OUTDIR)JavaZipInflater.$(O) JavaZipInflater.$(H): JavaZipInflater.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)ProxyMethod.$(O) ProxyMethod.$(H): ProxyMethod.st $(INCLUDE_TOP)\stx\libbasic\CompiledCode.$(H) $(INCLUDE_TOP)\stx\libbasic\ExecutableFunction.$(H) $(INCLUDE_TOP)\stx\libbasic\Method.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)ProxyMethodCompiler.$(O) ProxyMethodCompiler.$(H): ProxyMethodCompiler.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/libInit.cc Fri Jul 25 00:51:04 2014 +0100
+++ b/libInit.cc Fri Jul 25 01:52:23 2014 +0100
@@ -88,6 +88,7 @@
_JavaVMData_Init(pass,__pRT__,snd);
_JavaView_Init(pass,__pRT__,snd);
_JavaZipDeflater_Init(pass,__pRT__,snd);
+_JavaZipFile_Init(pass,__pRT__,snd);
_JavaZipInflater_Init(pass,__pRT__,snd);
_ProxyMethod_Init(pass,__pRT__,snd);
_ProxyMethodCompiler_Init(pass,__pRT__,snd);
--- a/libjava.rc Fri Jul 25 00:51:04 2014 +0100
+++ b/libjava.rc Fri Jul 25 01:52:23 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\n SWING Research Group, Czech Technical University In Prague\0"
VALUE "ProductName", "Smalltalk/X\0"
VALUE "ProductVersion", "6.2.4.0\0"
- VALUE "ProductDate", "Thu, 24 Jul 2014 23:47:49 GMT\0"
+ VALUE "ProductDate", "Fri, 25 Jul 2014 00:47:34 GMT\0"
END
END
--- a/stx_libjava.st Fri Jul 25 00:51:04 2014 +0100
+++ b/stx_libjava.st Fri Jul 25 01:52:23 2014 +0100
@@ -383,6 +383,7 @@
JavaVMData
JavaView
JavaZipDeflater
+ JavaZipFile
JavaZipInflater
ProxyMethod
ProxyMethodCompiler