From efdfb796d9009d988ff7f5018fecc73bf073ea87 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 29 Oct 2009 16:19:33 -0600 Subject: [PATCH 1/4] implement SocketChannel.isConnected --- classpath/java/nio/channels/SocketChannel.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/classpath/java/nio/channels/SocketChannel.java b/classpath/java/nio/channels/SocketChannel.java index a452085248..809142a56f 100644 --- a/classpath/java/nio/channels/SocketChannel.java +++ b/classpath/java/nio/channels/SocketChannel.java @@ -42,6 +42,10 @@ public class SocketChannel extends SelectableChannel return blocking; } + public boolean isConnected() { + return connected; + } + public Socket socket() { return new Handle(); } @@ -59,7 +63,10 @@ public class SocketChannel extends SelectableChannel } public boolean finishConnect() throws IOException { - return natFinishConnect(socket); + if (! connected) { + connected = natFinishConnect(socket); + } + return connected; } public void close() throws IOException { From e825da60aa99057a330bd9c8633b265025a3392a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 30 Oct 2009 00:45:46 +0000 Subject: [PATCH 2/4] update continuation constants to reflect new field offsets --- makefile | 2 ++ src/compile-powerpc.S | 8 ++++---- src/continuations-x86.S | 16 ++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/makefile b/makefile index 000548b7aa..b6ce200fba 100644 --- a/makefile +++ b/makefile @@ -507,6 +507,8 @@ clean-native: @echo "removing $(native-build)" rm -rf $(native-build) +$(native-build)/compile-x86-asm.o: $(src)/continuations-x86.S + gen-arg = $(shell echo $(1) | sed -e 's:$(native-build)/type-\(.*\)\.cpp:\1:') $(generated-code): %.cpp: $(src)/types.def $(generator) $(classpath-dep) @echo "generating $(@)" diff --git a/src/compile-powerpc.S b/src/compile-powerpc.S index 03e85b1ff9..c90f16c625 100644 --- a/src/compile-powerpc.S +++ b/src/compile-powerpc.S @@ -24,11 +24,11 @@ # define GLOBAL(x) x #endif -#define THREAD_CONTINUATION 96 +#define THREAD_CONTINUATION 100 #define THREAD_EXCEPTION 36 -#define THREAD_EXCEPTION_STACK_ADJUSTMENT 100 -#define THREAD_EXCEPTION_OFFSET 104 -#define THREAD_EXCEPTION_HANDLER 108 +#define THREAD_EXCEPTION_STACK_ADJUSTMENT 104 +#define THREAD_EXCEPTION_OFFSET 108 +#define THREAD_EXCEPTION_HANDLER 112 #define CONTINUATION_NEXT 4 #define CONTINUATION_ADDRESS 16 diff --git a/src/continuations-x86.S b/src/continuations-x86.S index bc19003758..59f11d2a28 100644 --- a/src/continuations-x86.S +++ b/src/continuations-x86.S @@ -1,10 +1,10 @@ #ifdef __x86_64__ -#define THREAD_CONTINUATION 168 +#define THREAD_CONTINUATION 176 #define THREAD_EXCEPTION 64 -#define THREAD_EXCEPTION_STACK_ADJUSTMENT 176 -#define THREAD_EXCEPTION_OFFSET 184 -#define THREAD_EXCEPTION_HANDLER 192 +#define THREAD_EXCEPTION_STACK_ADJUSTMENT 184 +#define THREAD_EXCEPTION_OFFSET 192 +#define THREAD_EXCEPTION_HANDLER 200 #define CONTINUATION_NEXT 8 #define CONTINUATION_ADDRESS 32 @@ -75,11 +75,11 @@ LOCAL(vmInvoke_exit): #elif defined __i386__ -#define THREAD_CONTINUATION 96 +#define THREAD_CONTINUATION 100 #define THREAD_EXCEPTION 36 -#define THREAD_EXCEPTION_STACK_ADJUSTMENT 100 -#define THREAD_EXCEPTION_OFFSET 104 -#define THREAD_EXCEPTION_HANDLER 108 +#define THREAD_EXCEPTION_STACK_ADJUSTMENT 104 +#define THREAD_EXCEPTION_OFFSET 108 +#define THREAD_EXCEPTION_HANDLER 112 #define CONTINUATION_NEXT 4 #define CONTINUATION_ADDRESS 16 From ef00ff80ef1b15d2baa5e566e51dba33628299d5 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 30 Oct 2009 08:55:55 -0600 Subject: [PATCH 3/4] avoid EAGAIN or EWOULDBLOCK errors due to SocketSelector.wakup being called many times between calls to select --- classpath/java/nio/channels/SocketSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java/nio/channels/SocketSelector.java b/classpath/java/nio/channels/SocketSelector.java index 0b7c1d6b4b..9726d1a9ed 100644 --- a/classpath/java/nio/channels/SocketSelector.java +++ b/classpath/java/nio/channels/SocketSelector.java @@ -65,7 +65,7 @@ class SocketSelector extends Selector { public int doSelect(long interval) throws IOException { selectedKeys.clear(); - if (clearWoken()) return 0; + if (clearWoken()) interval = -1; int max=0; for (Iterator it = keys.iterator(); From ed4206b06d4ece534e4eea5a1ad404f15ba8e841 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 2 Nov 2009 21:11:39 -0700 Subject: [PATCH 4/4] fix order-of-operations bug in compile loop The code was capturing branch snapshots too early - before the call to populateSources which might perform further moves. --- src/compiler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index 0d91fb714d..f6dc25e27a 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -5182,8 +5182,6 @@ populateSiteTables(Context* c, Event* e, SiteRecordList* frozen) resolveJunctionSites(c, e, frozen); resolveBranchSites(c, e, frozen); - - captureBranchSnapshots(c, e); } void @@ -5452,12 +5450,17 @@ compile(Context* c) populateSources(c, e); + if (branch and e->successors) { + captureBranchSnapshots(c, e); + } + thaw(c, &frozen); e->compile(c); if ((not branch) and e->successors) { populateSiteTables(c, e, &frozen); + captureBranchSnapshots(c, e); thaw(c, &frozen); }