mirror of
https://github.com/corda/corda.git
synced 2025-03-03 12:57:29 +00:00
revise signatures of mark() and set() to take a target object and offset instead of a target object reference, paving the way for immovable objects
This commit is contained in:
parent
f4dfc889fd
commit
3e84d4438a
@ -304,7 +304,7 @@ Java_java_lang_reflect_Field_setObject
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
set(t, cast<object>(*instance, offset), (value ? *value : 0));
|
||||
set(t, *instance, offset, (value ? *value : 0));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL
|
||||
@ -442,8 +442,8 @@ Java_java_lang_System_arraycopy
|
||||
if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and
|
||||
dstOffset >= 0 and dstOffset + length <= dl))
|
||||
{
|
||||
uint8_t* sbody = &cast<uint8_t>(s, 2 * BytesPerWord);
|
||||
uint8_t* dbody = &cast<uint8_t>(d, 2 * BytesPerWord);
|
||||
uint8_t* sbody = &cast<uint8_t>(s, ArrayBody);
|
||||
uint8_t* dbody = &cast<uint8_t>(d, ArrayBody);
|
||||
if (s == d) {
|
||||
memmove(dbody + (dstOffset * elementSize),
|
||||
sbody + (srcOffset * elementSize),
|
||||
@ -455,7 +455,7 @@ Java_java_lang_System_arraycopy
|
||||
}
|
||||
|
||||
if (classObjectMask(t, objectClass(t, d))) {
|
||||
mark(t, reinterpret_cast<object*>(dbody) + dstOffset, length);
|
||||
mark(t, d, ArrayBody + (dstOffset * BytesPerWord), length);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -595,7 +595,7 @@ Java_java_lang_Throwable_resolveTrace(Thread* t, jclass, jobject trace)
|
||||
(t, traceElementMethod(t, e), traceElementIp(t, e));
|
||||
|
||||
object ste = makeStackTraceElement(t, class_, method, 0, line);
|
||||
set(t, objectArrayBody(t, array, i), ste);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), ste);
|
||||
}
|
||||
|
||||
return makeLocalReference(t, array);
|
||||
|
@ -993,7 +993,7 @@ throwNew(MyThread* t, object class_)
|
||||
{
|
||||
t->exception = makeNew(t, class_);
|
||||
object trace = makeTrace(t);
|
||||
set(t, cast<object>(t->exception, ThrowableTrace), trace);
|
||||
set(t, t->exception, ThrowableTrace, trace);
|
||||
unwind(t);
|
||||
}
|
||||
|
||||
@ -1338,7 +1338,7 @@ invokeNative2(MyThread* t, object method)
|
||||
}
|
||||
|
||||
object p = makePointer(t, function);
|
||||
set(t, methodCode(t, method), p);
|
||||
set(t, method, MethodCode, p);
|
||||
}
|
||||
|
||||
object class_ = methodClass(t, method);
|
||||
@ -2771,23 +2771,40 @@ class JavaCompiler: public Compiler {
|
||||
cmp(rsi, rcx);
|
||||
jge(outOfBounds);
|
||||
|
||||
add(BytesPerWord * 2, rax);
|
||||
|
||||
switch (instruction) {
|
||||
case aastore:
|
||||
shl(log(BytesPerWord), rcx);
|
||||
add(rcx, rax);
|
||||
compileCall(true, reinterpret_cast<void*>(set), rax, rbx);
|
||||
add(ArrayBody, rcx);
|
||||
|
||||
if (BytesPerWord == 8) {
|
||||
mov(rcx, rdx);
|
||||
mov(rbx, rcx);
|
||||
mov(rax, rsi);
|
||||
mov(rbp, FrameThread, rdi);
|
||||
} else {
|
||||
push(rbx);
|
||||
push(rcx);
|
||||
push(rax);
|
||||
push(rbp, FrameThread);
|
||||
}
|
||||
|
||||
directCall(reinterpret_cast<void*>(set));
|
||||
|
||||
if (BytesPerWord == 4) {
|
||||
add(BytesPerWord * 4, rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case fastore:
|
||||
case iastore:
|
||||
shl(log(BytesPerWord), rcx);
|
||||
add(ArrayBody, rcx);
|
||||
add(rcx, rax);
|
||||
mov(rbx, rax, 0);
|
||||
break;
|
||||
|
||||
case bastore:
|
||||
add(ArrayBody, rcx);
|
||||
add(rcx, rax);
|
||||
mov1(rbx, rax, 0);
|
||||
break;
|
||||
@ -2795,6 +2812,7 @@ class JavaCompiler: public Compiler {
|
||||
case castore:
|
||||
case sastore:
|
||||
shl(1, rcx);
|
||||
add(ArrayBody, rcx);
|
||||
add(rcx, rax);
|
||||
mov2(rbx, rax, 0);
|
||||
break;
|
||||
@ -2802,6 +2820,7 @@ class JavaCompiler: public Compiler {
|
||||
case dastore:
|
||||
case lastore:
|
||||
shl(3, rcx);
|
||||
add(ArrayBody, rcx);
|
||||
add(rcx, rax);
|
||||
mov4(rbx, rax, 0);
|
||||
mov4(rdx, rax, 4);
|
||||
@ -2843,7 +2862,7 @@ class JavaCompiler: public Compiler {
|
||||
case anewarray: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
Label nonnegative(this);
|
||||
@ -2914,7 +2933,7 @@ class JavaCompiler: public Compiler {
|
||||
case checkcast: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
Label next(this);
|
||||
@ -3627,7 +3646,7 @@ class JavaCompiler: public Compiler {
|
||||
case instanceof: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
Label call(this);
|
||||
@ -3872,7 +3891,7 @@ class JavaCompiler: public Compiler {
|
||||
{
|
||||
pushObject(poolRegister(), poolReference(v));
|
||||
} else {
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
|
||||
pushObject(poolRegister(), poolReference(class_));
|
||||
}
|
||||
@ -4145,7 +4164,7 @@ class JavaCompiler: public Compiler {
|
||||
case new_: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
PROTECT(t, class_);
|
||||
|
||||
@ -4273,15 +4292,15 @@ class JavaCompiler: public Compiler {
|
||||
|
||||
case ObjectField: {
|
||||
if (BytesPerWord == 8) {
|
||||
popObject(rdx);
|
||||
popObject(rcx);
|
||||
mov(fieldOffset(t, field), rdx);
|
||||
popObject(rsi);
|
||||
add(fieldOffset(t, field), rsi);
|
||||
mov(rbp, FrameThread, rdi);
|
||||
} else {
|
||||
popObject(rdx);
|
||||
popObject(rcx);
|
||||
popObject(rsi);
|
||||
add(fieldOffset(t, field), rsi);
|
||||
push(rdx);
|
||||
push(rcx);
|
||||
push(fieldOffset(t, field));
|
||||
push(rsi);
|
||||
push(rbp, FrameThread);
|
||||
}
|
||||
@ -4335,15 +4354,14 @@ class JavaCompiler: public Compiler {
|
||||
popInt4(rax, IntValue);
|
||||
|
||||
if (BytesPerWord == 8) {
|
||||
mov(rax, rdx);
|
||||
mov(rax, rcx);
|
||||
mov(offset, rdx);
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
mov(rbp, FrameThread, rdi);
|
||||
} else {
|
||||
push(rax);
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
push(rsi);
|
||||
push(offset);
|
||||
push(poolRegister(), poolReference(table));
|
||||
push(rbp, FrameThread);
|
||||
}
|
||||
|
||||
@ -4377,15 +4395,14 @@ class JavaCompiler: public Compiler {
|
||||
}
|
||||
|
||||
if (BytesPerWord == 8) {
|
||||
mov(rax, rdx);
|
||||
mov(rax, rcx);
|
||||
mov(offset, rdx);
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
mov(rbp, FrameThread, rdi);
|
||||
} else {
|
||||
push(rax);
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
push(rsi);
|
||||
push(offset);
|
||||
push(poolRegister(), poolReference(table));
|
||||
push(rbp, FrameThread);
|
||||
}
|
||||
|
||||
@ -4398,14 +4415,13 @@ class JavaCompiler: public Compiler {
|
||||
|
||||
case ObjectField:
|
||||
if (BytesPerWord == 8) {
|
||||
popObject(rdx);
|
||||
popObject(rcx);
|
||||
mov(offset, rdx);
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
mov(rbp, FrameThread, rdi);
|
||||
} else {
|
||||
mov(poolRegister(), poolReference(table), rsi);
|
||||
add(offset, rsi);
|
||||
push(rsi);
|
||||
push(offset);
|
||||
push(poolRegister(), poolReference(table));
|
||||
push(rbp, FrameThread);
|
||||
}
|
||||
|
||||
@ -4502,7 +4518,7 @@ class JavaCompiler: public Compiler {
|
||||
unsigned ct = exceptionHandlerCatchType(eh);
|
||||
object catchType;
|
||||
if (ct) {
|
||||
catchType = resolveClass
|
||||
catchType = resolveClassInPool
|
||||
(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1);
|
||||
} else {
|
||||
catchType = 0;
|
||||
@ -4611,7 +4627,7 @@ compileMethod2(MyThread* t, object method)
|
||||
}
|
||||
|
||||
object pool = c.makePool();
|
||||
set(t, methodCode(t, method), pool);
|
||||
set(t, method, MethodCode, pool);
|
||||
|
||||
methodCompiled(t, method) = reinterpret_cast<uint64_t>(code);
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ resolveNativeMethodData(Thread* t, object method)
|
||||
if (LIKELY(p)) {
|
||||
PROTECT(t, method);
|
||||
object data = makeNativeMethodData(t, method, p);
|
||||
set(t, methodCode(t, method), data);
|
||||
set(t, method, MethodCode, data);
|
||||
return data;
|
||||
} else {
|
||||
object message = makeString
|
||||
@ -656,7 +656,7 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
|
||||
for (int32_t i = 0; i < counts[index]; ++i) {
|
||||
object a = makeArray(t, counts[index + 1], true);
|
||||
setObjectClass(t, a, class_);
|
||||
set(t, objectArrayBody(t, array, i), a);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), a);
|
||||
|
||||
populateMultiArray(t, a, counts, index + 1, dimensions);
|
||||
}
|
||||
@ -682,7 +682,7 @@ findExceptionHandler(Thread* t, int frame)
|
||||
PROTECT(t, e);
|
||||
|
||||
PROTECT(t, eht);
|
||||
catchType = resolveClass
|
||||
catchType = resolveClassInPool
|
||||
(t, codePool(t, t->code), exceptionHandlerCatchType(eh) - 1);
|
||||
|
||||
if (catchType) {
|
||||
@ -781,7 +781,7 @@ interpret(Thread* t)
|
||||
if (LIKELY(index >= 0 and
|
||||
static_cast<uintptr_t>(index) < objectArrayLength(t, array)))
|
||||
{
|
||||
set(t, objectArrayBody(t, array, index), value);
|
||||
set(t, array, ArrayBody + (index * BytesPerWord), value);
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
objectArrayLength(t, array));
|
||||
@ -824,7 +824,7 @@ interpret(Thread* t)
|
||||
if (LIKELY(count >= 0)) {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
|
||||
pushObject(t, makeObjectArray(t, class_, count, true));
|
||||
@ -1010,7 +1010,7 @@ interpret(Thread* t)
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
if (peekObject(t, sp - 1)) {
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
|
||||
if (not instanceOf(t, class_, peekObject(t, sp - 1))) {
|
||||
@ -1766,7 +1766,7 @@ interpret(Thread* t)
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
if (peekObject(t, sp - 1)) {
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
|
||||
if (instanceOf(t, class_, popObject(t))) {
|
||||
@ -2054,7 +2054,7 @@ interpret(Thread* t)
|
||||
{
|
||||
pushObject(t, v);
|
||||
} else {
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
|
||||
pushObject(t, class_);
|
||||
@ -2262,7 +2262,7 @@ interpret(Thread* t)
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
uint8_t dimensions = codeBody(t, code, ip++);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
PROTECT(t, class_);
|
||||
|
||||
@ -2288,7 +2288,7 @@ interpret(Thread* t)
|
||||
case new_: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object class_ = resolveClass(t, codePool(t, code), index - 1);
|
||||
object class_ = resolveClassInPool(t, codePool(t, code), index - 1);
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
PROTECT(t, class_);
|
||||
|
||||
@ -2413,7 +2413,7 @@ interpret(Thread* t)
|
||||
object value = popObject(t);
|
||||
object o = popObject(t);
|
||||
if (LIKELY(o)) {
|
||||
set(t, cast<object>(o, fieldOffset(t, field)), value);
|
||||
set(t, o, fieldOffset(t, field), value);
|
||||
} else {
|
||||
exception = makeNullPointerException(t);
|
||||
goto throw_;
|
||||
@ -2457,8 +2457,8 @@ interpret(Thread* t)
|
||||
default: abort(t);
|
||||
}
|
||||
|
||||
set(t, arrayBody(t, classStaticTable(t, fieldClass(t, field)),
|
||||
fieldOffset(t, field)), v);
|
||||
set(t, classStaticTable(t, fieldClass(t, field)),
|
||||
ArrayBody + (fieldOffset(t, field) * BytesPerWord), v);
|
||||
} goto loop;
|
||||
|
||||
case ret: {
|
||||
|
@ -115,8 +115,8 @@ ThrowNew(Thread* t, jclass c, const char* message)
|
||||
PROTECT(t, trace);
|
||||
|
||||
t->exception = make(t, *c);
|
||||
set(t, throwableMessageUnsafe(t, t->exception), m);
|
||||
set(t, throwableTraceUnsafe(t, t->exception), trace);
|
||||
set(t, t->exception, ThrowableMessage, m);
|
||||
set(t, t->exception, ThrowableTrace, trace);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -775,7 +775,7 @@ SetObjectField(Thread* t, jobject o, jfieldID field, jobject v)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
set(t, cast<object>(*o, field), (v ? *v : 0));
|
||||
set(t, *o, field, (v ? *v : 0));
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -931,7 +931,8 @@ SetStaticObjectField(Thread* t, jclass c, jfieldID field, jobject v)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), (v ? *v : 0));
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord),
|
||||
(v ? *v : 0));
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -940,7 +941,7 @@ SetStaticBooleanField(Thread* t, jclass c, jfieldID field, jboolean v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeInt(t, v ? 1 : 0);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -949,7 +950,7 @@ SetStaticByteField(Thread* t, jclass c, jfieldID field, jbyte v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeInt(t, v);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -958,7 +959,7 @@ SetStaticCharField(Thread* t, jclass c, jfieldID field, jchar v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeInt(t, v);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -967,7 +968,7 @@ SetStaticShortField(Thread* t, jclass c, jfieldID field, jshort v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeInt(t, v);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -976,7 +977,7 @@ SetStaticIntField(Thread* t, jclass c, jfieldID field, jint v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeInt(t, v);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -985,7 +986,7 @@ SetStaticLongField(Thread* t, jclass c, jfieldID field, jlong v)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object o = makeLong(t, v);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -995,7 +996,7 @@ SetStaticFloatField(Thread* t, jclass c, jfieldID field, jfloat v)
|
||||
|
||||
jint i; memcpy(&i, &v, 4);
|
||||
object o = makeInt(t, i);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -1005,7 +1006,7 @@ SetStaticDoubleField(Thread* t, jclass c, jfieldID field, jdouble v)
|
||||
|
||||
jlong i; memcpy(&i, &v, 8);
|
||||
object o = makeLong(t, i);
|
||||
set(t, arrayBody(t, classStaticTable(t, *c), field), o);
|
||||
set(t, classStaticTable(t, *c), ArrayBody + (field * BytesPerWord), o);
|
||||
}
|
||||
|
||||
jobject JNICALL
|
||||
|
155
src/machine.cpp
155
src/machine.cpp
@ -177,13 +177,13 @@ referenceTargetUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
||||
|
||||
object q = jreferenceQueue(t, *p);
|
||||
|
||||
set(t, jreferenceJnext(t, *p), *p);
|
||||
set(t, *p, JreferenceJnext, *p);
|
||||
if (referenceQueueFront(t, q)) {
|
||||
set(t, jreferenceJnext(t, referenceQueueRear(t, q)), *p);
|
||||
set(t, referenceQueueRear(t, q), JreferenceJnext, *p);
|
||||
} else {
|
||||
set(t, referenceQueueFront(t, q), *p);
|
||||
set(t, q, ReferenceQueueFront, *p);
|
||||
}
|
||||
set(t, referenceQueueRear(t, q), *p);
|
||||
set(t, q, ReferenceQueueRear, *p);
|
||||
|
||||
jreferenceQueue(t, *p) = 0;
|
||||
}
|
||||
@ -516,23 +516,23 @@ parsePool(Thread* t, Stream& s)
|
||||
switch (c) {
|
||||
case CONSTANT_Integer: {
|
||||
object value = makeInt(t, s.read4());
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_Float: {
|
||||
object value = makeFloat(t, s.readFloat());
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_Long: {
|
||||
object value = makeLong(t, s.read8());
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
++i;
|
||||
} break;
|
||||
|
||||
case CONSTANT_Double: {
|
||||
object value = makeDouble(t, s.readDouble());
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
++i;
|
||||
} break;
|
||||
|
||||
@ -541,21 +541,21 @@ parsePool(Thread* t, Stream& s)
|
||||
object value = makeByteArray(t, length + 1, false);
|
||||
s.read(reinterpret_cast<uint8_t*>(&byteArrayBody(t, value, 0)), length);
|
||||
byteArrayBody(t, value, length) = 0;
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_Class: {
|
||||
object value = makeIntArray(t, 2, false);
|
||||
intArrayBody(t, value, 0) = c;
|
||||
intArrayBody(t, value, 1) = s.read2();
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_String: {
|
||||
object value = makeIntArray(t, 2, false);
|
||||
intArrayBody(t, value, 0) = c;
|
||||
intArrayBody(t, value, 1) = s.read2();
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_NameAndType: {
|
||||
@ -563,7 +563,7 @@ parsePool(Thread* t, Stream& s)
|
||||
intArrayBody(t, value, 0) = c;
|
||||
intArrayBody(t, value, 1) = s.read2();
|
||||
intArrayBody(t, value, 2) = s.read2();
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_Fieldref:
|
||||
@ -573,7 +573,7 @@ parsePool(Thread* t, Stream& s)
|
||||
intArrayBody(t, value, 0) = c;
|
||||
intArrayBody(t, value, 1) = s.read2();
|
||||
intArrayBody(t, value, 2) = s.read2();
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
default: abort(t);
|
||||
@ -587,7 +587,7 @@ parsePool(Thread* t, Stream& s)
|
||||
{
|
||||
switch (intArrayBody(t, o, 0)) {
|
||||
case CONSTANT_Class: {
|
||||
set(t, arrayBody(t, pool, i),
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord),
|
||||
arrayBody(t, pool, intArrayBody(t, o, 1) - 1));
|
||||
} break;
|
||||
|
||||
@ -596,14 +596,14 @@ parsePool(Thread* t, Stream& s)
|
||||
object value = makeString
|
||||
(t, bytes, 0, byteArrayLength(t, bytes) - 1, 0);
|
||||
value = intern(t, value);
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
|
||||
case CONSTANT_NameAndType: {
|
||||
object name = arrayBody(t, pool, intArrayBody(t, o, 1) - 1);
|
||||
object type = arrayBody(t, pool, intArrayBody(t, o, 2) - 1);
|
||||
object value = makePair(t, name, type);
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@ -622,7 +622,7 @@ parsePool(Thread* t, Stream& s)
|
||||
object nameAndType = arrayBody(t, pool, intArrayBody(t, o, 2) - 1);
|
||||
object value = makeReference
|
||||
(t, c, pairFirst(t, nameAndType), pairSecond(t, nameAndType));
|
||||
set(t, arrayBody(t, pool, i), value);
|
||||
set(t, pool, ArrayBody + (i * BytesPerWord), value);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@ -697,7 +697,8 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
|
||||
(t, tripleFirst(t, hashMapIteratorNode(t, it)));
|
||||
if (UNLIKELY(t->exception)) return;
|
||||
|
||||
set(t, arrayBody(t, interfaceTable, i++), interface);
|
||||
set(t, interfaceTable, ArrayBody + (i * BytesPerWord), interface);
|
||||
++ i;
|
||||
|
||||
if ((classFlags(t, class_) & ACC_INTERFACE) == 0) {
|
||||
if (classVirtualTable(t, interface)) {
|
||||
@ -705,7 +706,7 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
|
||||
object vtable = makeArray
|
||||
(t, arrayLength(t, classVirtualTable(t, interface)), true);
|
||||
|
||||
set(t, arrayBody(t, interfaceTable, i), vtable);
|
||||
set(t, interfaceTable, ArrayBody + (i * BytesPerWord), vtable);
|
||||
}
|
||||
|
||||
++i;
|
||||
@ -713,7 +714,7 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
|
||||
}
|
||||
}
|
||||
|
||||
set(t, classInterfaceTable(t, class_), interfaceTable);
|
||||
set(t, class_, ClassInterfaceTable, interfaceTable);
|
||||
}
|
||||
|
||||
void
|
||||
@ -767,15 +768,15 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
||||
memberOffset += fieldSize(t, field);
|
||||
}
|
||||
|
||||
set(t, arrayBody(t, fieldTable, i), field);
|
||||
set(t, fieldTable, ArrayBody + (i * BytesPerWord), field);
|
||||
}
|
||||
|
||||
set(t, classFieldTable(t, class_), fieldTable);
|
||||
set(t, class_, ClassFieldTable, fieldTable);
|
||||
|
||||
if (staticOffset) {
|
||||
object staticTable = makeArray(t, staticOffset, true);
|
||||
|
||||
set(t, classStaticTable(t, class_), staticTable);
|
||||
set(t, class_, ClassStaticTable, staticTable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -784,7 +785,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
||||
if (classSuper(t, class_)
|
||||
and memberOffset == classFixedSize(t, classSuper(t, class_)))
|
||||
{
|
||||
set(t, classObjectMask(t, class_),
|
||||
set(t, class_, ClassObjectMask,
|
||||
classObjectMask(t, classSuper(t, class_)));
|
||||
} else {
|
||||
object mask = makeIntArray
|
||||
@ -819,7 +820,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
||||
}
|
||||
|
||||
if (superMask or sawReferenceField) {
|
||||
set(t, classObjectMask(t, class_), mask);
|
||||
set(t, class_, ClassObjectMask, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -848,7 +849,7 @@ parseCode(Thread* t, Stream& s, object pool)
|
||||
exceptionHandlerCatchType(eh) = s.read2();
|
||||
}
|
||||
|
||||
set(t, codeExceptionHandlerTable(t, code), eht);
|
||||
set(t, code, CodeExceptionHandlerTable, eht);
|
||||
}
|
||||
|
||||
unsigned attributeCount = s.read2();
|
||||
@ -867,7 +868,7 @@ parseCode(Thread* t, Stream& s, object pool)
|
||||
lineNumberLine(ln) = s.read2();
|
||||
}
|
||||
|
||||
set(t, codeLineNumberTable(t, code), lnt);
|
||||
set(t, code, CodeLineNumberTable, lnt);
|
||||
} else {
|
||||
s.skip(length);
|
||||
}
|
||||
@ -1031,7 +1032,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
if (p) {
|
||||
methodOffset(t, method) = methodOffset(t, tripleFirst(t, p));
|
||||
|
||||
set(t, tripleSecond(t, p), method);
|
||||
set(t, p, TripleSecond, method);
|
||||
} else {
|
||||
methodOffset(t, method) = virtualCount++;
|
||||
|
||||
@ -1046,13 +1047,13 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
(t, nativeMap, methodName(t, method), byteArrayHash, byteArrayEqual);
|
||||
|
||||
if (p) {
|
||||
set(t, tripleSecond(t, p), method);
|
||||
set(t, p, TripleSecond, method);
|
||||
} else {
|
||||
hashMapInsert(t, nativeMap, methodName(t, method), 0, byteArrayHash);
|
||||
}
|
||||
}
|
||||
|
||||
set(t, arrayBody(t, methodTable, i), method);
|
||||
set(t, methodTable, ArrayBody + (i * BytesPerWord), method);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
@ -1065,11 +1066,11 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
(t, nativeMap, methodName(t, method), byteArrayHash, byteArrayEqual);
|
||||
|
||||
object jniName = makeJNIName(t, method, overloaded);
|
||||
set(t, methodCode(t, method), jniName);
|
||||
set(t, method, MethodCode, jniName);
|
||||
}
|
||||
}
|
||||
|
||||
set(t, classMethodTable(t, class_), methodTable);
|
||||
set(t, class_, ClassMethodTable, methodTable);
|
||||
}
|
||||
|
||||
if (declaredVirtualCount == 0
|
||||
@ -1077,10 +1078,10 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
{
|
||||
// inherit interface table and virtual table from superclass
|
||||
|
||||
set(t, classInterfaceTable(t, class_),
|
||||
set(t, class_, ClassInterfaceTable,
|
||||
classInterfaceTable(t, classSuper(t, class_)));
|
||||
|
||||
set(t, classVirtualTable(t, class_), superVirtualTable);
|
||||
set(t, class_, ClassVirtualTable, superVirtualTable);
|
||||
} else if (virtualCount) {
|
||||
// generate class vtable
|
||||
|
||||
@ -1095,7 +1096,8 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
{
|
||||
object method = tripleFirst(t, hashMapIteratorNode(t, it));
|
||||
assert(t, arrayBody(t, vtable, methodOffset(t, method)) == 0);
|
||||
set(t, arrayBody(t, vtable, methodOffset(t, method)), method);
|
||||
set(t, vtable, ArrayBody + (methodOffset(t, method) * BytesPerWord),
|
||||
method);
|
||||
++ i;
|
||||
}
|
||||
} else {
|
||||
@ -1104,18 +1106,19 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
object method = arrayBody(t, superVirtualTable, i);
|
||||
method = hashMapFind(t, virtualMap, method, methodHash, methodEqual);
|
||||
|
||||
set(t, arrayBody(t, vtable, i), method);
|
||||
set(t, vtable, ArrayBody + (i * BytesPerWord), method);
|
||||
}
|
||||
}
|
||||
|
||||
for (object p = listFront(t, newVirtuals); p; p = pairSecond(t, p)) {
|
||||
set(t, arrayBody(t, vtable, i++), pairFirst(t, p));
|
||||
set(t, vtable, ArrayBody + (i * BytesPerWord), pairFirst(t, p));
|
||||
++ i;
|
||||
}
|
||||
}
|
||||
|
||||
assert(t, arrayLength(t, vtable) == i);
|
||||
|
||||
set(t, classVirtualTable(t, class_), vtable);
|
||||
set(t, class_, ClassVirtualTable, vtable);
|
||||
|
||||
if ((classFlags(t, class_) & ACC_INTERFACE) == 0) {
|
||||
// generate interface vtables
|
||||
@ -1135,7 +1138,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
||||
(t, virtualMap, method, methodHash, methodEqual);
|
||||
assert(t, method);
|
||||
|
||||
set(t, arrayBody(t, vtable, j), method);
|
||||
set(t, vtable, ArrayBody + (j * BytesPerWord), method);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1167,25 +1170,24 @@ updateBootstrapClass(Thread* t, object bootstrapClass, object class_)
|
||||
classFlags(t, bootstrapClass) = classFlags(t, class_);
|
||||
classVmFlags(t, bootstrapClass) |= classVmFlags(t, class_);
|
||||
|
||||
set(t, classSuper(t, bootstrapClass), classSuper(t, class_));
|
||||
set(t, classInterfaceTable(t, bootstrapClass),
|
||||
classInterfaceTable(t, class_));
|
||||
set(t, classVirtualTable(t, bootstrapClass), classVirtualTable(t, class_));
|
||||
set(t, classFieldTable(t, bootstrapClass), classFieldTable(t, class_));
|
||||
set(t, classMethodTable(t, bootstrapClass), classMethodTable(t, class_));
|
||||
set(t, classStaticTable(t, bootstrapClass), classStaticTable(t, class_));
|
||||
set(t, bootstrapClass, ClassSuper, classSuper(t, class_));
|
||||
set(t, bootstrapClass, ClassInterfaceTable, classInterfaceTable(t, class_));
|
||||
set(t, bootstrapClass, ClassVirtualTable, classVirtualTable(t, class_));
|
||||
set(t, bootstrapClass, ClassFieldTable, classFieldTable(t, class_));
|
||||
set(t, bootstrapClass, ClassMethodTable, classMethodTable(t, class_));
|
||||
set(t, bootstrapClass, ClassStaticTable, classStaticTable(t, class_));
|
||||
|
||||
object fieldTable = classFieldTable(t, class_);
|
||||
if (fieldTable) {
|
||||
for (unsigned i = 0; i < arrayLength(t, fieldTable); ++i) {
|
||||
set(t, fieldClass(t, arrayBody(t, fieldTable, i)), bootstrapClass);
|
||||
set(t, arrayBody(t, fieldTable, i), FieldClass, bootstrapClass);
|
||||
}
|
||||
}
|
||||
|
||||
object methodTable = classMethodTable(t, class_);
|
||||
if (methodTable) {
|
||||
for (unsigned i = 0; i < arrayLength(t, methodTable); ++i) {
|
||||
set(t, methodClass(t, arrayBody(t, methodTable, i)), bootstrapClass);
|
||||
set(t, arrayBody(t, methodTable, i), MethodClass, bootstrapClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1295,7 +1297,7 @@ invoke(Thread* t, const char* className, int argc, const char** argv)
|
||||
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
object arg = makeString(t, "%s", argv[i]);
|
||||
set(t, objectArrayBody(t, args, i), arg);
|
||||
set(t, args, ArrayBody + (i * BytesPerWord), arg);
|
||||
}
|
||||
|
||||
t->m->processor->invoke
|
||||
@ -1414,21 +1416,21 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
|
||||
#include "type-initializations.cpp"
|
||||
|
||||
object arrayClass = arrayBody(t, t->m->types, Machine::ArrayType);
|
||||
set(t, cast<object>(t->m->types, 0), arrayClass);
|
||||
set(t, t->m->types, 0, arrayClass);
|
||||
|
||||
object loaderClass = arrayBody
|
||||
(t, t->m->types, Machine::SystemClassLoaderType);
|
||||
set(t, cast<object>(t->m->loader, 0), loaderClass);
|
||||
set(t, t->m->loader, 0, loaderClass);
|
||||
|
||||
object objectClass = arrayBody(t, m->types, Machine::JobjectType);
|
||||
|
||||
object classClass = arrayBody(t, m->types, Machine::ClassType);
|
||||
set(t, cast<object>(classClass, 0), classClass);
|
||||
set(t, classSuper(t, classClass), objectClass);
|
||||
set(t, classClass, 0, classClass);
|
||||
set(t, classClass, ClassSuper, objectClass);
|
||||
|
||||
object intArrayClass = arrayBody(t, m->types, Machine::IntArrayType);
|
||||
set(t, cast<object>(intArrayClass, 0), classClass);
|
||||
set(t, classSuper(t, intArrayClass), objectClass);
|
||||
set(t, intArrayClass, 0, classClass);
|
||||
set(t, intArrayClass, ClassSuper, objectClass);
|
||||
|
||||
m->unsafe = false;
|
||||
|
||||
@ -1461,7 +1463,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
|
||||
m->bootstrapClassMap = makeHashMap(this, 0, 0);
|
||||
|
||||
object loaderMap = makeHashMap(this, 0, 0);
|
||||
set(t, systemClassLoaderMap(t, m->loader), loaderMap);
|
||||
set(t, m->loader, SystemClassLoaderMap, loaderMap);
|
||||
|
||||
m->monitorMap = makeWeakHashMap(this, 0, 0);
|
||||
m->stringMap = makeWeakHashMap(this, 0, 0);
|
||||
@ -1872,14 +1874,14 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
|
||||
|
||||
unsigned index = hash(t, k) & (newLength - 1);
|
||||
|
||||
set(t, tripleThird(t, p), arrayBody(t, newArray, index));
|
||||
set(t, arrayBody(t, newArray, index), p);
|
||||
set(t, p, TripleThird, arrayBody(t, newArray, index));
|
||||
set(t, newArray, ArrayBody + (index * BytesPerWord), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set(t, hashMapArray(t, map), newArray);
|
||||
set(t, map, HashMapArray, newArray);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1917,7 +1919,7 @@ hashMapInsert(Thread* t, object map, object key, object value,
|
||||
|
||||
object n = makeTriple(t, key, value, arrayBody(t, array, index));
|
||||
|
||||
set(t, arrayBody(t, array, index), n);
|
||||
set(t, array, ArrayBody + (index * BytesPerWord), n);
|
||||
}
|
||||
|
||||
object
|
||||
@ -1932,19 +1934,26 @@ hashMapRemove(Thread* t, object map, object key,
|
||||
object o = 0;
|
||||
if (array) {
|
||||
unsigned index = hash(t, key) & (arrayLength(t, array) - 1);
|
||||
for (object* n = &arrayBody(t, array, index); *n;) {
|
||||
object k = tripleFirst(t, *n);
|
||||
object p = 0;
|
||||
for (object n = arrayBody(t, array, index); n;) {
|
||||
object k = tripleFirst(t, n);
|
||||
if (weak) {
|
||||
k = jreferenceTarget(t, k);
|
||||
}
|
||||
|
||||
if (equal(t, key, k)) {
|
||||
o = tripleSecond(t, *n);
|
||||
set(t, *n, tripleThird(t, *n));
|
||||
o = tripleSecond(t, n);
|
||||
if (p) {
|
||||
set(t, p, TripleThird, tripleThird(t, n));
|
||||
} else {
|
||||
set(t, array, ArrayBody + (index * BytesPerWord),
|
||||
tripleThird(t, n));
|
||||
}
|
||||
-- hashMapSize(t, map);
|
||||
break;
|
||||
} else {
|
||||
n = &tripleThird(t, *n);
|
||||
p = n;
|
||||
n = tripleThird(t, n);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2000,11 +2009,11 @@ listAppend(Thread* t, object list, object value)
|
||||
|
||||
object p = makePair(t, value, 0);
|
||||
if (listFront(t, list)) {
|
||||
set(t, pairSecond(t, listRear(t, list)), p);
|
||||
set(t, listRear(t, list), PairSecond, p);
|
||||
} else {
|
||||
set(t, listFront(t, list), p);
|
||||
set(t, list, ListFront, p);
|
||||
}
|
||||
set(t, listRear(t, list), p);
|
||||
set(t, list, ListRear, p);
|
||||
}
|
||||
|
||||
object
|
||||
@ -2031,7 +2040,8 @@ vectorAppend(Thread* t, object vector, object value)
|
||||
vector = newVector;
|
||||
}
|
||||
|
||||
set(t, vectorBody(t, vector, vectorSize(t, vector)++), value);
|
||||
set(t, vector, VectorBody + (vectorSize(t, vector) * BytesPerWord), value);
|
||||
++ vectorSize(t, vector);
|
||||
return vector;
|
||||
}
|
||||
|
||||
@ -2175,7 +2185,7 @@ parseClass(Thread* t, const uint8_t* data, unsigned size)
|
||||
object sc = resolveClass(t, arrayBody(t, pool, super - 1));
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
set(t, classSuper(t, class_), sc);
|
||||
set(t, class_, ClassSuper, sc);
|
||||
|
||||
classVmFlags(t, class_)
|
||||
|= (classVmFlags(t, sc) & (ReferenceFlag | WeakReferenceFlag));
|
||||
@ -2207,7 +2217,7 @@ resolveClass(Thread* t, object spec)
|
||||
(t, t->m->bootstrapClassMap, spec, byteArrayHash, byteArrayEqual);
|
||||
|
||||
if (class_) {
|
||||
set(t, classVirtualTable(t, class_),
|
||||
set(t, class_, ClassVirtualTable,
|
||||
classVirtualTable
|
||||
(t, arrayBody(t, t->m->types, Machine::JobjectType)));
|
||||
} else {
|
||||
@ -2700,7 +2710,8 @@ makeTrace(Thread* t, uintptr_t start)
|
||||
{
|
||||
object e = makeTraceElement
|
||||
(t, p->frameMethod(t, frame), p->frameIp(t, frame));
|
||||
set(t, arrayBody(t, trace, index++), e);
|
||||
set(t, trace, ArrayBody + (index * BytesPerWord), e);
|
||||
++ index;
|
||||
}
|
||||
|
||||
return trace;
|
||||
|
122
src/machine.h
122
src/machine.h
@ -28,6 +28,7 @@ const bool DebugReferences = false;
|
||||
|
||||
const uintptr_t HashTakenMark = 1;
|
||||
const uintptr_t ExtendedMark = 2;
|
||||
const uintptr_t FixedMark = 3;
|
||||
|
||||
enum FieldCode {
|
||||
VoidField,
|
||||
@ -1421,37 +1422,20 @@ allocate(Thread* t, unsigned sizeInBytes)
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
mark(Thread* t, object* targets, unsigned count)
|
||||
{
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
if (t->m->heap->needsMark(reinterpret_cast<void**>(targets + i))) {
|
||||
t->m->heap->mark(reinterpret_cast<void**>(targets + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
mark(Thread* t, object target, unsigned offset);
|
||||
|
||||
inline void
|
||||
mark(Thread* t, object& target)
|
||||
set(Thread* t, object target, unsigned offset, object value)
|
||||
{
|
||||
if (t->m->heap->needsMark(reinterpret_cast<void**>(&target))) {
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
t->m->heap->mark(reinterpret_cast<void**>(&target));
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
set(Thread* t, object& target, object value)
|
||||
{
|
||||
target = value;
|
||||
mark(t, target);
|
||||
cast<object>(target, offset) = value;
|
||||
mark(t, target, offset);
|
||||
}
|
||||
|
||||
inline void
|
||||
setObjectClass(Thread* t, object o, object value)
|
||||
{
|
||||
set(t, cast<object>(o, 0),
|
||||
set(t, o, 0,
|
||||
reinterpret_cast<object>
|
||||
(reinterpret_cast<uintptr_t>(value)
|
||||
| reinterpret_cast<uintptr_t>(cast<object>(o, 0)) & (~PointerMask)));
|
||||
@ -1462,6 +1446,70 @@ arrayBodyUnsafe(Thread*, object, unsigned);
|
||||
|
||||
#include "type-declarations.cpp"
|
||||
|
||||
inline bool
|
||||
objectFixed(Thread*, object o)
|
||||
{
|
||||
return (cast<uintptr_t>(o, 0) & (~PointerMask)) == FixedMark;
|
||||
}
|
||||
|
||||
inline bool
|
||||
objectExtended(Thread*, object o)
|
||||
{
|
||||
return (cast<uintptr_t>(o, 0) & (~PointerMask)) == ExtendedMark;
|
||||
}
|
||||
|
||||
inline bool
|
||||
hashTaken(Thread*, object o)
|
||||
{
|
||||
return (cast<uintptr_t>(o, 0) & (~PointerMask)) == HashTakenMark;
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
baseSize(Thread* t, object o, object class_)
|
||||
{
|
||||
return ceiling(classFixedSize(t, class_), BytesPerWord)
|
||||
+ ceiling(classArrayElementSize(t, class_)
|
||||
* cast<uintptr_t>(o, classFixedSize(t, class_) - BytesPerWord),
|
||||
BytesPerWord);
|
||||
}
|
||||
|
||||
inline void
|
||||
mark(Thread* t, object target, unsigned offset, unsigned count)
|
||||
{
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
if (objectFixed(t, target)) {
|
||||
unsigned size = baseSize(t, target, objectClass(t, target))
|
||||
* BytesPerWord;
|
||||
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
markBit(&cast<uintptr_t>(target, size), offset + (i * BytesPerWord));
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
unsigned j = offset + (i * BytesPerWord);
|
||||
if (t->m->heap->needsMark(&cast<void*>(target, j))) {
|
||||
t->m->heap->mark(&cast<void*>(target, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
mark(Thread* t, object target, unsigned offset)
|
||||
{
|
||||
if (objectFixed(t, target)) {
|
||||
unsigned size = baseSize(t, target, objectClass(t, target)) * BytesPerWord;
|
||||
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
|
||||
markBit(&cast<uintptr_t>(target, size), offset);
|
||||
} else if (t->m->heap->needsMark(&cast<void*>(target, offset))) {
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
|
||||
t->m->heap->mark(&cast<void*>(target, offset));
|
||||
}
|
||||
}
|
||||
|
||||
object
|
||||
makeTrace(Thread* t, uintptr_t start);
|
||||
|
||||
@ -1656,21 +1704,6 @@ classInitializer(Thread* t, object class_);
|
||||
object
|
||||
frameMethod(Thread* t, int frame);
|
||||
|
||||
inline unsigned
|
||||
baseSize(Thread* t, object o, object class_)
|
||||
{
|
||||
return ceiling(classFixedSize(t, class_), BytesPerWord)
|
||||
+ ceiling(classArrayElementSize(t, class_)
|
||||
* cast<uintptr_t>(o, classFixedSize(t, class_) - BytesPerWord),
|
||||
BytesPerWord);
|
||||
}
|
||||
|
||||
inline bool
|
||||
objectExtended(Thread*, object o)
|
||||
{
|
||||
return (cast<uintptr_t>(o, 0) & (~PointerMask)) == ExtendedMark;
|
||||
}
|
||||
|
||||
inline uintptr_t&
|
||||
extendedWord(Thread* t UNUSED, object o, unsigned baseSize)
|
||||
{
|
||||
@ -1684,16 +1717,11 @@ extendedSize(Thread* t, object o, unsigned baseSize)
|
||||
return baseSize + objectExtended(t, o);
|
||||
}
|
||||
|
||||
inline bool
|
||||
hashTaken(Thread*, object o)
|
||||
{
|
||||
return (cast<uintptr_t>(o, 0) & (~PointerMask)) == HashTakenMark;
|
||||
}
|
||||
|
||||
inline void
|
||||
markHashTaken(Thread* t, object o)
|
||||
{
|
||||
assert(t, not objectExtended(t, o));
|
||||
assert(t, not objectFixed(t, o));
|
||||
cast<uintptr_t>(o, 0) |= HashTakenMark;
|
||||
|
||||
ACQUIRE_RAW(t, t->m->heapLock);
|
||||
@ -1712,7 +1740,9 @@ objectHash(Thread* t, object o)
|
||||
if (objectExtended(t, o)) {
|
||||
return extendedWord(t, o, baseSize(t, o, objectClass(t, o)));
|
||||
} else {
|
||||
markHashTaken(t, o);
|
||||
if (not objectFixed(t, o)) {
|
||||
markHashTaken(t, o);
|
||||
}
|
||||
return takeHash(t, o);
|
||||
}
|
||||
}
|
||||
@ -1848,7 +1878,7 @@ hashMapInsertOrReplace(Thread* t, object map, object key, object value,
|
||||
hashMapInsert(t, map, key, value, hash);
|
||||
return true;
|
||||
} else {
|
||||
set(t, tripleSecond(t, n), value);
|
||||
set(t, n, TripleSecond, value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,9 @@ codeReadInt32(Thread* t, object code, unsigned& ip)
|
||||
}
|
||||
|
||||
inline object
|
||||
resolveClass(Thread* t, object container,
|
||||
object& (*class_)(vm::Thread*, object))
|
||||
resolveClassInObject(Thread* t, object container, unsigned classOffset)
|
||||
{
|
||||
object o = class_(t, container);
|
||||
object o = cast<object>(container, classOffset);
|
||||
if (objectClass(t, o) == arrayBody(t, t->m->types, Machine::ByteArrayType))
|
||||
{
|
||||
PROTECT(t, container);
|
||||
@ -38,13 +37,13 @@ resolveClass(Thread* t, object container,
|
||||
o = resolveClass(t, o);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
set(t, class_(t, container), o);
|
||||
set(t, container, classOffset, o);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
inline object
|
||||
resolveClass(Thread* t, object pool, unsigned index)
|
||||
resolveClassInPool(Thread* t, object pool, unsigned index)
|
||||
{
|
||||
object o = arrayBody(t, pool, index);
|
||||
if (objectClass(t, o) == arrayBody(t, t->m->types, Machine::ByteArrayType))
|
||||
@ -54,7 +53,7 @@ resolveClass(Thread* t, object pool, unsigned index)
|
||||
o = resolveClass(t, o);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
set(t, arrayBody(t, pool, index), o);
|
||||
set(t, pool, ArrayBody + (index * BytesPerWord), o);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
@ -72,7 +71,7 @@ resolve(Thread* t, object pool, unsigned index,
|
||||
object reference = o;
|
||||
PROTECT(t, reference);
|
||||
|
||||
object class_ = resolveClass(t, o, referenceClass);
|
||||
object class_ = resolveClassInObject(t, o, ReferenceClass);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
o = findInHierarchy
|
||||
@ -80,7 +79,7 @@ resolve(Thread* t, object pool, unsigned index,
|
||||
find, makeError);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
set(t, arrayBody(t, pool, index), o);
|
||||
set(t, pool, ArrayBody + (index * BytesPerWord), o);
|
||||
}
|
||||
|
||||
return o;
|
||||
|
@ -1605,9 +1605,9 @@ writeInitialization(Output* out, Object* type)
|
||||
out->write(typeArrayElementSize(type));
|
||||
out->write(", mask, 0, super, 0, 0, 0, 0, 0, t->m->loader);\n");
|
||||
|
||||
out->write(" set(t, arrayBody(t, t->m->types, Machine::");
|
||||
out->write(" set(t, t->m->types, ArrayBody + (Machine::");
|
||||
out->write(capitalize(typeName(type)));
|
||||
out->write("Type), class_);\n");
|
||||
out->write("Type * BytesPerWord), class_);\n");
|
||||
|
||||
out->write("}\n\n");
|
||||
}
|
||||
@ -1689,7 +1689,7 @@ writeJavaInitialization(Output* out, Object* type)
|
||||
out->write(capitalize(typeName(type)));
|
||||
out->write("Type);\n");
|
||||
|
||||
out->write(" set(t, className(t, class_), name);\n");
|
||||
out->write(" set(t, class_, ClassName, name);\n");
|
||||
|
||||
out->write(" hashMapInsert(t, t->m->bootstrapClassMap, ");
|
||||
out->write("name, class_, byteArrayHash);\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user