mirror of
https://github.com/corda/corda.git
synced 2025-02-05 02:29:20 +00:00
support object arrays of various element types and dimensions; clean up weak hash map support
This commit is contained in:
parent
0099aa396b
commit
2df8a60a78
@ -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;
|
||||
|
@ -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_)
|
||||
{
|
||||
|
1234
src/machine.cpp
1234
src/machine.cpp
File diff suppressed because it is too large
Load Diff
@ -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));
|
||||
|
||||
|
1049
src/run.cpp
1049
src/run.cpp
File diff suppressed because it is too large
Load Diff
@ -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));
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user