support object arrays of various element types and dimensions; clean up weak hash map support

This commit is contained in:
Joel Dice 2007-07-14 11:31:01 -06:00
parent 0099aa396b
commit 2df8a60a78
7 changed files with 1274 additions and 1128 deletions

View File

@ -2,7 +2,8 @@ package java.lang;
public final class Class <T> { public final class Class <T> {
private short flags; private short flags;
private short vmFlags; private byte vmFlags;
private byte arrayDimensions;
private short fixedSize; private short fixedSize;
private short arrayElementSize; private short arrayElementSize;
private int[] objectMask; private int[] objectMask;

View File

@ -84,28 +84,13 @@ arraycopy(Thread* t, jobject src, jint srcOffset, jobject dst, jint dstOffset,
unsigned elementSize = classArrayElementSize(t, objectClass(t, s)); unsigned elementSize = classArrayElementSize(t, objectClass(t, s));
if (LIKELY(elementSize)) { if (LIKELY(elementSize)) {
unsigned offset = 1; intptr_t sl = cast<uintptr_t>(s, BytesPerWord);
intptr_t dl = cast<uintptr_t>(d, BytesPerWord);
if (objectClass(t, s)
== arrayBody(t, t->vm->types, Machine::ObjectArrayType))
{
if (LIKELY(objectArrayElementClass(t, s)
== objectArrayElementClass(t, d)))
{
offset = 2;
} else {
t->exception = makeArrayStoreException(t);
return;
}
}
intptr_t sl = cast<uintptr_t>(s, offset * BytesPerWord);
intptr_t dl = cast<uintptr_t>(d, offset * BytesPerWord);
if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and
dstOffset >= 0 and dstOffset + length <= dl)) dstOffset >= 0 and dstOffset + length <= dl))
{ {
uint8_t* sbody = &cast<uint8_t>(s, (offset + 1) * BytesPerWord); uint8_t* sbody = &cast<uint8_t>(s, 2 * BytesPerWord);
uint8_t* dbody = &cast<uint8_t>(d, (offset + 1) * BytesPerWord); uint8_t* dbody = &cast<uint8_t>(d, 2 * BytesPerWord);
memcpy(dbody + (dstOffset * elementSize), memcpy(dbody + (dstOffset * elementSize),
sbody + (srcOffset * elementSize), sbody + (srcOffset * elementSize),
length * elementSize); length * elementSize);
@ -121,7 +106,7 @@ arraycopy(Thread* t, jobject src, jint srcOffset, jobject dst, jint dstOffset,
t->exception = makeArrayStoreException(t); t->exception = makeArrayStoreException(t);
} }
jarray jobject
trace(Thread* t, jint skipCount) trace(Thread* t, jint skipCount)
{ {
int frame = t->frame; int frame = t->frame;
@ -144,6 +129,12 @@ trace(Thread* t, jint skipCount)
return pushReference(t, makeTrace(t, frame)); return pushReference(t, makeTrace(t, frame));
} }
jarray
resolveTrace(Thread* t, object trace)
{
// todo
}
void void
start(Thread* t, jobject this_) start(Thread* t, jobject this_)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,11 @@ enum StackTag {
ObjectTag ObjectTag
}; };
enum MapType {
NormalMap,
WeakMap
};
const int NativeLine = -1; const int NativeLine = -1;
const int UnknownLine = -2; const int UnknownLine = -2;
@ -1289,6 +1294,15 @@ set(Thread* t, object& target, object value)
} }
} }
inline void
setObjectClass(Thread* t, object o, object value)
{
set(t, cast<object>(o, 0),
reinterpret_cast<object>
(reinterpret_cast<uintptr_t>(value)
| reinterpret_cast<uintptr_t>(cast<object>(o, 0)) & (~PointerMask)));
}
object& object&
arrayBodyUnsafe(Thread*, object, unsigned); arrayBodyUnsafe(Thread*, object, unsigned);
@ -1705,18 +1719,6 @@ objectEqual(Thread*, object a, object b)
return a == b; return a == b;
} }
inline uint32_t
referenceHash(Thread* t, object o)
{
return objectHash(t, jreferenceTarget(t, o));
}
inline bool
referenceEqual(Thread* t, object a, object b)
{
return a == jreferenceTarget(t, b);
}
inline uint32_t inline uint32_t
byteArrayHash(Thread* t, object array) byteArrayHash(Thread* t, object array)
{ {
@ -1821,6 +1823,54 @@ hashMapIteratorNext(Thread* t, object it);
void void
listAppend(Thread* t, object list, object value); listAppend(Thread* t, object list, object value);
unsigned
fieldCode(Thread* t, unsigned javaCode);
unsigned
fieldType(Thread* t, unsigned code);
unsigned
primitiveSize(Thread* t, unsigned code);
inline unsigned
fieldSize(Thread* t, object field)
{
unsigned code = fieldCode(t, field);
if (code == ObjectField) {
return BytesPerWord;
} else {
return primitiveSize(t, code);
}
}
object
resolveClass(Thread* t, object spec);
object
resolveObjectArrayClass(Thread* t, object elementSpec);
object
makeObjectArray(Thread* t, object elementClass, unsigned count, bool clear);
inline unsigned
objectArrayLength(Thread* t, object array)
{
assert(t, classFixedSize(t, objectClass(t, array)) == BytesPerWord * 2);
assert(t, classArrayElementSize(t, objectClass(t, array)) == BytesPerWord);
return cast<uintptr_t>(array, BytesPerWord);
}
inline object&
objectArrayBody(Thread* t, object array, unsigned index)
{
assert(t, classFixedSize(t, objectClass(t, array)) == BytesPerWord * 2);
assert(t, classArrayElementSize(t, objectClass(t, array)) == BytesPerWord);
assert(t, classObjectMask(t, objectClass(t, array))
== classObjectMask(t, arrayBody
(t, t->vm->types, Machine::ArrayType)));
return cast<object>(array, (1 + index) * BytesPerWord);
}
void void
addFinalizer(Thread* t, object target, void (*finalize)(Thread*, object)); addFinalizer(Thread* t, object target, void (*finalize)(Thread*, object));

File diff suppressed because it is too large Load Diff

View File

@ -1484,7 +1484,7 @@ writeInitialization(Output* out, Object* type)
} }
out->write(" object class_ = makeClass"); out->write(" object class_ = makeClass");
out->write("(t, 0, 0, "); out->write("(t, 0, 0, 0, ");
out->write(typeFixedSize(type)); out->write(typeFixedSize(type));
out->write(", "); out->write(", ");
out->write(typeArrayElementSize(type)); out->write(typeArrayElementSize(type));

View File

@ -3,7 +3,8 @@
(type class java/lang/Class (type class java/lang/Class
(extends jobject) (extends jobject)
(uint16_t flags) (uint16_t flags)
(uint16_t vmFlags) (uint8_t vmFlags)
(uint8_t arrayDimensions)
(uint16_t fixedSize) (uint16_t fixedSize)
(uint16_t arrayElementSize) (uint16_t arrayElementSize)
(object objectMask) (object objectMask)
@ -88,6 +89,7 @@
(void* next)) (void* next))
(type hashMap (type hashMap
(uint32_t type)
(uint32_t size) (uint32_t size)
(object array)) (object array))
@ -215,11 +217,6 @@
(type weakReference java/lang/ref/WeakReference (type weakReference java/lang/ref/WeakReference
(extends jreference)) (extends jreference))
(type objectArray [
(extends jobject)
(object elementClass)
(array object body))
(type byteArray [B (type byteArray [B
(extends jobject) (extends jobject)
(array int8_t body)) (array int8_t body))