From af6f2bbc4644d8e77bf8596e952332224cb5e105 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Aug 2007 20:30:22 -0600 Subject: [PATCH 1/6] always call bitsetHasMore() from bitsetNext(), regardless of whether assertions are enabled --- src/heap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/heap.cpp b/src/heap.cpp index 35dab96254..9b0a8d95c5 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -744,7 +744,7 @@ bitsetSet(uintptr_t* p, unsigned i, bool v) } } -unsigned +bool bitsetHasMore(uintptr_t* p) { switch (*p) { @@ -770,7 +770,8 @@ bitsetHasMore(uintptr_t* p) unsigned bitsetNext(Context* c, uintptr_t* p) { - assert(c, bitsetHasMore(p)); + bool more UNUSED = bitsetHasMore(p); + assert(c, more); switch (*p) { case 0: abort(c); From ec68b60204051ebb0e11bafd8dfbc56551fdd9b9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Aug 2007 20:30:56 -0600 Subject: [PATCH 2/6] add profile-jscheme target to makefile --- makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/makefile b/makefile index ff0ad44095..f4b84a877e 100644 --- a/makefile +++ b/makefile @@ -173,6 +173,14 @@ debug-jscheme: $(executable) $(input) vg-jscheme: $(executable) $(input) LD_LIBRARY_PATH=$(bld) $(vg) $(<) -cp $(cls):$(jscheme) $(jscheme-command) +.PHONY: profile-jscheme +profile-jscheme: $(executable) $(input) + opcontrol --start; \ + echo '(+ 5 6)' | LD_LIBRARY_PATH=$(bld) \ + $(<) -cp $(cls):$(jscheme) jscheme/REPL; \ + opcontrol --stop; \ + opreport -l $(<) + .PHONY: clean clean: @echo "removing build" From a68505ff48df1182e232b3f72b50f4b597b5ccca Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 21 Aug 2007 22:00:46 -0600 Subject: [PATCH 3/6] implement Hashtable.toString() (defer to HashMap) --- classpath/java/util/Hashtable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classpath/java/util/Hashtable.java b/classpath/java/util/Hashtable.java index 2043fc0633..6bfd96b68d 100644 --- a/classpath/java/util/Hashtable.java +++ b/classpath/java/util/Hashtable.java @@ -11,6 +11,10 @@ public class Hashtable implements Map { this(0); } + public String toString() { + return map.toString(); + } + public synchronized int size() { return map.size(); } From 84028e7f519692da231e2ca325b63e3990b9a70f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 21 Aug 2007 22:01:37 -0600 Subject: [PATCH 4/6] fix reversed logic in LinkedList.addFirst()/addLast() --- classpath/java/util/LinkedList.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classpath/java/util/LinkedList.java b/classpath/java/util/LinkedList.java index 5deae40931..3cfa4447e1 100644 --- a/classpath/java/util/LinkedList.java +++ b/classpath/java/util/LinkedList.java @@ -32,8 +32,8 @@ public class LinkedList implements List { if (front == null) { front = rear = c; } else { - c.prev = rear; - rear = c; + c.next = front; + front = c; } } @@ -43,8 +43,8 @@ public class LinkedList implements List { if (front == null) { front = rear = c; } else { - c.next = front; - front = c; + c.prev = rear; + rear = c; } } From 57d57ff7bf290010d0df3faaf8fe2dfb40fa59ae Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 21 Aug 2007 22:02:17 -0600 Subject: [PATCH 5/6] use identity hash code in Object.toString() --- src/builtin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 1f4cf5f0a6..4307107f15 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -16,10 +16,11 @@ replace(char a, char b, char* c) jstring Object_toString(Thread* t, jobject this_) { + unsigned hash = objectHash(t, *this_); object s = makeString - (t, "%s@%p", + (t, "%s@0x%x", &byteArrayBody(t, className(t, objectClass(t, *this_)), 0), - *this_); + hash); return pushReference(t, s); } From a1caf06955781c6d71a874c17b620d0fd8e3a404 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 21 Aug 2007 22:03:03 -0600 Subject: [PATCH 6/6] properly handle classes with no interface table in isAssignableFrom() --- src/machine.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 8ed1ef56f6..886d4f684a 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1694,9 +1694,11 @@ isAssignableFrom(Thread* t, object a, object b) if (classFlags(t, a) & ACC_INTERFACE) { for (; b; b = classSuper(t, b)) { object itable = classInterfaceTable(t, b); - for (unsigned i = 0; i < arrayLength(t, itable); i += 2) { - if (arrayBody(t, itable, i) == a) { - return true; + if (itable) { + for (unsigned i = 0; i < arrayLength(t, itable); i += 2) { + if (arrayBody(t, itable, i) == a) { + return true; + } } } }