break native hashMap type into hashMap and weakHashMap; start investgating GC stress failures related to or uncovered by new string interning support

This commit is contained in:
Joel Dice 2007-07-29 12:52:08 -06:00
parent 51943427ad
commit d5a00c4556
4 changed files with 25 additions and 21 deletions

View File

@ -18,7 +18,7 @@ const unsigned MinimumGen2SizeInBytes = 128 * 1024;
const unsigned Top = ~static_cast<unsigned>(0); const unsigned Top = ~static_cast<unsigned>(0);
const bool Verbose = true; const bool Verbose = true;
const bool Debug = false; const bool Debug = true;
class Context; class Context;

View File

@ -637,7 +637,7 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
PROTECT(t, class_); PROTECT(t, class_);
PROTECT(t, pool); PROTECT(t, pool);
object map = makeHashMap(t, NormalMap, 0, 0); object map = makeHashMap(t, 0, 0);
PROTECT(t, map); PROTECT(t, map);
if (classSuper(t, class_)) { if (classSuper(t, class_)) {
@ -844,10 +844,10 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
PROTECT(t, class_); PROTECT(t, class_);
PROTECT(t, pool); PROTECT(t, pool);
object virtualMap = makeHashMap(t, NormalMap, 0, 0); object virtualMap = makeHashMap(t, 0, 0);
PROTECT(t, virtualMap); PROTECT(t, virtualMap);
object nativeMap = makeHashMap(t, NormalMap, 0, 0); object nativeMap = makeHashMap(t, 0, 0);
PROTECT(t, nativeMap); PROTECT(t, nativeMap);
unsigned virtualCount = 0; unsigned virtualCount = 0;
@ -1374,14 +1374,14 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
classVmFlags(t, arrayBody(t, m->types, Machine::PhantomReferenceType)) classVmFlags(t, arrayBody(t, m->types, Machine::PhantomReferenceType))
|= ReferenceFlag | WeakReferenceFlag; |= ReferenceFlag | WeakReferenceFlag;
m->bootstrapClassMap = makeHashMap(this, NormalMap, 0, 0); m->bootstrapClassMap = makeHashMap(this, 0, 0);
#include "type-java-initializations.cpp" #include "type-java-initializations.cpp"
m->classMap = makeHashMap(this, NormalMap, 0, 0); m->classMap = makeHashMap(this, 0, 0);
m->builtinMap = makeHashMap(this, NormalMap, 0, 0); m->builtinMap = makeHashMap(this, 0, 0);
m->monitorMap = makeHashMap(this, WeakMap, 0, 0); m->monitorMap = makeWeakHashMap(this, 0, 0);
m->stringMap = makeHashMap(this, WeakMap, 0, 0); m->stringMap = makeWeakHashMap(this, 0, 0);
populateBuiltinMap(t, m->builtinMap); populateBuiltinMap(t, m->builtinMap);
@ -1789,7 +1789,9 @@ hashMapFindNode(Thread* t, object map, object key,
uint32_t (*hash)(Thread*, object), uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object)) bool (*equal)(Thread*, object, object))
{ {
bool weak = hashMapType(t, map) == WeakMap; bool weak = objectClass(t, map)
== arrayBody(t, t->vm->types, Machine::WeakHashMapType);
object array = hashMapArray(t, map); object array = hashMapArray(t, map);
if (array) { if (array) {
unsigned index = hash(t, key) & (arrayLength(t, array) - 1); unsigned index = hash(t, key) & (arrayLength(t, array) - 1);
@ -1827,7 +1829,8 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
newArray = makeArray(t, newLength, true); newArray = makeArray(t, newLength, true);
if (oldArray) { if (oldArray) {
bool weak = hashMapType(t, map) == WeakMap; bool weak = objectClass(t, map)
== arrayBody(t, t->vm->types, Machine::WeakHashMapType);
for (unsigned i = 0; i < arrayLength(t, oldArray); ++i) { for (unsigned i = 0; i < arrayLength(t, oldArray); ++i) {
object next; object next;
@ -1855,7 +1858,9 @@ void
hashMapInsert(Thread* t, object map, object key, object value, hashMapInsert(Thread* t, object map, object key, object value,
uint32_t (*hash)(Thread*, object)) uint32_t (*hash)(Thread*, object))
{ {
bool weak = hashMapType(t, map) == WeakMap; bool weak = objectClass(t, map)
== arrayBody(t, t->vm->types, Machine::WeakHashMapType);
object array = hashMapArray(t, map); object array = hashMapArray(t, map);
PROTECT(t, array); PROTECT(t, array);
@ -1892,7 +1897,9 @@ hashMapRemove(Thread* t, object map, object key,
uint32_t (*hash)(Thread*, object), uint32_t (*hash)(Thread*, object),
bool (*equal)(Thread*, object, object)) bool (*equal)(Thread*, object, object))
{ {
bool weak = hashMapType(t, map) == WeakMap; bool weak = objectClass(t, map)
== arrayBody(t, t->vm->types, Machine::WeakHashMapType);
object array = hashMapArray(t, map); object array = hashMapArray(t, map);
object o = 0; object o = 0;
if (array) { if (array) {
@ -2246,14 +2253,14 @@ objectMonitor(Thread* t, object o)
object object
intern(Thread* t, object s) intern(Thread* t, object s)
{ {
PROTECT(t, s);
ACQUIRE(t, t->vm->referenceLock); ACQUIRE(t, t->vm->referenceLock);
object n = hashMapFindNode(t, t->vm->stringMap, s, stringHash, stringEqual); object n = hashMapFindNode(t, t->vm->stringMap, s, stringHash, stringEqual);
if (n) { if (n) {
return jreferenceTarget(t, tripleFirst(t, n)); return jreferenceTarget(t, tripleFirst(t, n));
} else { } else {
PROTECT(t, s);
hashMapInsert(t, t->vm->stringMap, s, 0, stringHash); hashMapInsert(t, t->vm->stringMap, s, 0, stringHash);
addFinalizer(t, s, removeString); addFinalizer(t, s, removeString);
return s; return s;

View File

@ -51,11 +51,6 @@ enum StackTag {
ObjectTag ObjectTag
}; };
enum MapType {
NormalMap,
WeakMap
};
const int NativeLine = -1; const int NativeLine = -1;
const int UnknownLine = -2; const int UnknownLine = -2;

View File

@ -95,10 +95,12 @@
(void* next)) (void* next))
(type hashMap (type hashMap
(uint32_t type)
(uint32_t size) (uint32_t size)
(object array)) (object array))
(type weakHashMap
(extends hashMap))
(type hashMapIterator (type hashMapIterator
(object map) (object map)
(object node) (object node)