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