This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi, On Sat, 2003-01-18 at 04:57, Jeff Sturm wrote: > Indeed. What's interesting about this example is that the gij test takes > over 60 seconds on my x86-linux laptop if compiled with gcj -C, but > finishes in only 4 seconds if compiled with javac! > > Without looking at the bytecode, I'd guess javac is hoisting the > SyncTest.class lookup out of the while loop, whereas gcj -C performs no > optimizations. > > Doing this by hand might be appropriate for the test case, to prevent > annoying timeouts: Good observation. The same speedup can be seen by compiling with jikes. The timeouts disappear with your patch (but see below). Attached is the jcf-dump output for the run() method as compiled with gcj -C and jikes. The trick that jikes uses is to create a new static field to store the result of the call to SyncTest.class$() which eventually calls Class.forName(). This field is initialized to null and then initialized only once. We could do the same kind of thing, but this does not seem to be the root cause of this problem. The SyncTest as compiled by gcj -C seems to have a real deadlock some of the times (this does never happen with gij 3.2 it seems, which is also much faster on this test then gij 3.3). Also attached is the stackdump of all threads when SyncTest is deadlocked. All threads are in the garbage collector and I believe this is the same issue that I sometimes had when running Eclipse with gij. One of the threads calls dl_iterate_phdr and Hans Boehm explained to me that method acquires a lock which is a problem when that thread is stopped by the garbage collector as seems to be the case here. I believe that he had a fix for this. Cheers, Mark
SyncTest.run() as compiled by gcj -C: Method name:"run" public Signature: 34=()void Attribute "Code", length:94, max_stack:2, max_locals:5, code_length:50 0: iconst_0 1: istore_1 2: iload_1 3: ldc #35=<Integer 1000000> 5: if_icmpge 49 8: ldc #36=<String "SyncTest"> 10: invokestatic #38=<Method SyncTest.class$ (java.lang.String)java.lang.Class> 13: astore_2 14: aload_2 15: monitorenter 16: getstatic #40=<Field SyncTest.counter int> 19: iconst_1 20: iadd 21: putstatic #40=<Field SyncTest.counter int> 24: jsr 38 27: goto 43 30: astore 4 32: jsr 38 35: aload 4 37: athrow 38: astore_3 39: aload_2 40: monitorexit 41: ret 3 43: iinc 1 1 46: goto 2 49: return Exceptions (count: 1): start: 16, end: 24, handler: 30, type: 0 /* finally */ Attribute "LineNumberTable", length:18, count: 4 line: 6 at pc: 0 line: 6 at pc: 2 line: 8 at pc: 16 line: 6 at pc: 43 SyncTest.run() as compiled by jikes: Method name:"run" public Signature: 13=()void Attribute "Code", length:116, max_stack:2, max_locals:4, code_length:52 0: iconst_0 1: istore_1 2: goto 45 5: goto 11 8: aload_2 9: monitorexit 10: athrow 11: getstatic #17=<Field SyncTest.class$SyncTest java.lang.Class> 14: dup 15: ifnonnull 29 18: pop 19: ldc #18=<String "[LSyncTest;"> 21: iconst_0 22: invokestatic #23=<Method SyncTest.class$ (java.lang.String,boolean)java.lang.Class> 25: dup 26: putstatic #17=<Field SyncTest.class$SyncTest java.lang.Class> 29: dup 30: astore_2 31: monitorenter 32: getstatic #25=<Field SyncTest.counter int> 35: iconst_1 36: iadd 37: putstatic #25=<Field SyncTest.counter int> 40: aload_2 41: monitorexit 42: iinc 1 1 45: iload_1 46: ldc #26=<Integer 1000000> 48: if_icmplt 5 51: return Exceptions (count: 2): start: 8, end: 10, handler: 8, type: 0 /* finally */ start: 32, end: 42, handler: 8, type: 0 /* finally */ Attribute "LineNumberTable", length:30, count: 7 line: 6 at pc: 0 line: 6 at pc: 0 line: 7 at pc: 5 line: 8 at pc: 32 line: 6 at pc: 42 line: 6 at pc: 45 line: 10 at pc: 51
Attachment:
stack
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |