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> {
private short flags;
private short vmFlags;
private byte vmFlags;
private byte arrayDimensions;
private short fixedSize;
private short arrayElementSize;
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));
if (LIKELY(elementSize)) {
unsigned offset = 1;
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);
intptr_t sl = cast<uintptr_t>(s, BytesPerWord);
intptr_t dl = cast<uintptr_t>(d, BytesPerWord);
if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and
dstOffset >= 0 and dstOffset + length <= dl))
{
uint8_t* sbody = &cast<uint8_t>(s, (offset + 1) * BytesPerWord);
uint8_t* dbody = &cast<uint8_t>(d, (offset + 1) * BytesPerWord);
uint8_t* sbody = &cast<uint8_t>(s, 2 * BytesPerWord);
uint8_t* dbody = &cast<uint8_t>(d, 2 * BytesPerWord);
memcpy(dbody + (dstOffset * elementSize),
sbody + (srcOffset * elementSize),
length * elementSize);
@ -121,7 +106,7 @@ arraycopy(Thread* t, jobject src, jint srcOffset, jobject dst, jint dstOffset,
t->exception = makeArrayStoreException(t);
}
jarray
jobject
trace(Thread* t, jint skipCount)
{
int frame = t->frame;
@ -144,6 +129,12 @@ trace(Thread* t, jint skipCount)
return pushReference(t, makeTrace(t, frame));
}
jarray
resolveTrace(Thread* t, object trace)
{
// todo
}
void
start(Thread* t, jobject this_)
{

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,11 @@ enum StackTag {
ObjectTag
};
enum MapType {
NormalMap,
WeakMap
};
const int NativeLine = -1;
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&
arrayBodyUnsafe(Thread*, object, unsigned);
@ -1705,18 +1719,6 @@ objectEqual(Thread*, object a, object 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
byteArrayHash(Thread* t, object array)
{
@ -1821,6 +1823,54 @@ hashMapIteratorNext(Thread* t, object it);
void
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
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("(t, 0, 0, ");
out->write("(t, 0, 0, 0, ");
out->write(typeFixedSize(type));
out->write(", ");
out->write(typeArrayElementSize(type));

View File

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