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 bool Verbose = true;
const bool Debug = false;
const bool Debug = true;
class Context;

View File

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

View File

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

View File

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