mirror of
https://github.com/corda/corda.git
synced 2025-01-19 03:06:36 +00:00
apply machine.h changes
This commit is contained in:
parent
9ffbd7e9fe
commit
00e2307c39
57
include/avian/util/hash.h
Normal file
57
include/avian/util/hash.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* Copyright (c) 2008-2014, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
#ifndef AVIAN_UTIL_HASH_H
|
||||
#define AVIAN_UTIL_HASH_H
|
||||
|
||||
#include "slice.h"
|
||||
|
||||
namespace avian {
|
||||
namespace util {
|
||||
|
||||
inline uint32_t hash(const char* s)
|
||||
{
|
||||
uint32_t h = 0;
|
||||
for (unsigned i = 0; s[i]; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
inline uint32_t hash(Slice<const uint8_t> data)
|
||||
{
|
||||
const uint8_t* s = data.begin();
|
||||
uint32_t h = 0;
|
||||
for (size_t i = 0; i < data.count; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
inline uint32_t hash(Slice<const int8_t> data)
|
||||
{
|
||||
return hash(
|
||||
Slice<const uint8_t>(reinterpret_cast<const uint8_t*>(data.begin()), data.count));
|
||||
}
|
||||
|
||||
inline uint32_t hash(Slice<const uint16_t> data)
|
||||
{
|
||||
const uint16_t* s = data.begin();
|
||||
uint32_t h = 0;
|
||||
for (size_t i = 0; i < data.count; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace avian
|
||||
|
||||
#endif // AVIAN_UTIL_HASH_H
|
@ -18,6 +18,20 @@
|
||||
namespace avian {
|
||||
namespace util {
|
||||
|
||||
template <class T>
|
||||
struct NonConst;
|
||||
|
||||
|
||||
template <class T>
|
||||
struct NonConst<const T> {
|
||||
typedef T Type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct NonConst {
|
||||
typedef T Type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Slice {
|
||||
public:
|
||||
@ -28,7 +42,7 @@ class Slice {
|
||||
{
|
||||
}
|
||||
|
||||
inline Slice(const Slice<T>& copy) : items(copy.items), count(copy.count)
|
||||
inline Slice(const Slice<typename NonConst<T>::Type>& copy) : items(copy.items), count(copy.count)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,6 +62,13 @@ class Slice {
|
||||
return items + count;
|
||||
}
|
||||
|
||||
inline Slice<T> subslice(size_t begin, size_t count)
|
||||
{
|
||||
ASSERT(begin <= this->count);
|
||||
ASSERT(begin + count <= this->count);
|
||||
return Slice<T>(this->begin() + begin, count);
|
||||
}
|
||||
|
||||
static Slice<T> alloc(Allocator* a, size_t count)
|
||||
{
|
||||
return Slice<T>((T*)a->allocate(sizeof(T) * count), count);
|
||||
|
@ -291,20 +291,20 @@ makeStackTraceElement(Thread* t, object e)
|
||||
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_name));
|
||||
replace('/', '.', RUNTIME_ARRAY_BODY(s),
|
||||
reinterpret_cast<char*>(&byteArrayBody(t, class_name, 0)));
|
||||
class_name = makeString(t, "%s", RUNTIME_ARRAY_BODY(s));
|
||||
class_name = reinterpret_cast<object>(makeString(t, "%s", RUNTIME_ARRAY_BODY(s)));
|
||||
|
||||
object method_name = reinterpret_cast<object>(method->name());
|
||||
PROTECT(t, method_name);
|
||||
|
||||
method_name = t->m->classpath->makeString
|
||||
(t, method_name, 0, byteArrayLength(t, method_name) - 1);
|
||||
method_name = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, method_name, 0, byteArrayLength(t, method_name) - 1));
|
||||
|
||||
unsigned line = t->m->processor->lineNumber
|
||||
(t, method, traceElementIp(t, e));
|
||||
|
||||
object file = reinterpret_cast<object>(method->class_()->sourceFile());
|
||||
file = file ? t->m->classpath->makeString
|
||||
(t, file, 0, byteArrayLength(t, file) - 1) : 0;
|
||||
file = file ? reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, file, 0, byteArrayLength(t, file) - 1)) : 0;
|
||||
|
||||
return reinterpret_cast<object>(makeStackTraceElement(t, cast<GcString>(t, class_name), cast<GcString>(t, method_name), cast<GcString>(t, file), line));
|
||||
}
|
||||
@ -484,7 +484,7 @@ resolveExceptionJTypes(Thread* t, GcClassLoader* loader, GcMethodAddendum* adden
|
||||
object o = singletonObject(t, addendum->pool(), index);
|
||||
|
||||
if (objectClass(t, o) == type(t, GcReference::Type)) {
|
||||
o = reinterpret_cast<object>(resolveClass(t, loader, referenceName(t, o)));
|
||||
o = reinterpret_cast<object>(resolveClass(t, loader, cast<GcByteArray>(t, referenceName(t, o))));
|
||||
|
||||
set(t, reinterpret_cast<object>(addendum->pool()), SingletonBody + (index * BytesPerWord),
|
||||
o);
|
||||
@ -578,7 +578,7 @@ invoke(Thread* t, GcMethod* method, object instance, object args)
|
||||
(t, GcInvocationTargetException::Type, 0, 0, t->exception);
|
||||
|
||||
set(t, t->exception, InvocationTargetExceptionTarget,
|
||||
throwableCause(t, t->exception));
|
||||
t->exception->cause());
|
||||
}
|
||||
});
|
||||
|
||||
@ -616,7 +616,7 @@ intercept(Thread* t, GcClass* c, const char* name, const char* spec,
|
||||
|
||||
PROTECT(t, native);
|
||||
|
||||
object runtimeData = getMethodRuntimeData(t, m);
|
||||
object runtimeData = reinterpret_cast<object>(getMethodRuntimeData(t, m));
|
||||
|
||||
set(t, runtimeData, MethodRuntimeDataNative, native);
|
||||
}
|
||||
@ -711,7 +711,7 @@ getDeclaredClasses(Thread* t, object c, bool publicOnly)
|
||||
resolveClass(
|
||||
t,
|
||||
cast<GcClassLoader>(t, classLoader(t, c)),
|
||||
innerClassReferenceInner(t, arrayBody(t, table, i)))));
|
||||
cast<GcByteArray>(t, innerClassReferenceInner(t, arrayBody(t, table, i))))));
|
||||
|
||||
-- count;
|
||||
set(t, result, ArrayBody + (count * BytesPerWord), inner);
|
||||
@ -742,7 +742,7 @@ getDeclaringClass(Thread* t, object c)
|
||||
t,
|
||||
resolveClass(t,
|
||||
cast<GcClassLoader>(t, classLoader(t, c)),
|
||||
innerClassReferenceOuter(t, reference)));
|
||||
cast<GcByteArray>(t, innerClassReferenceOuter(t, reference))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,42 +427,6 @@ maskAlignedPointer(T* p)
|
||||
return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) & PointerMask);
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
hash(const char* s)
|
||||
{
|
||||
uint32_t h = 0;
|
||||
for (unsigned i = 0; s[i]; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
hash(const uint8_t* s, unsigned length)
|
||||
{
|
||||
uint32_t h = 0;
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
hash(const int8_t* s, unsigned length)
|
||||
{
|
||||
return hash(reinterpret_cast<const uint8_t*>(s), length);
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
hash(const uint16_t* s, unsigned length)
|
||||
{
|
||||
uint32_t h = 0;
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
h = (h * 31) + s[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
inline void
|
||||
write4(uint8_t* dst, uint32_t v)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,14 +20,14 @@ using namespace vm;
|
||||
namespace {
|
||||
|
||||
int64_t
|
||||
search(Thread* t, GcClassLoader* loader, object name,
|
||||
GcClass* (*op)(Thread*, GcClassLoader*, object), bool replaceDots)
|
||||
search(Thread* t, GcClassLoader* loader, GcString* name,
|
||||
GcClass* (*op)(Thread*, GcClassLoader*, GcByteArray*), bool replaceDots)
|
||||
{
|
||||
if (LIKELY(name)) {
|
||||
PROTECT(t, loader);
|
||||
PROTECT(t, name);
|
||||
|
||||
GcByteArray* n = makeByteArray(t, stringLength(t, name) + 1);
|
||||
GcByteArray* n = makeByteArray(t, name->length(t) + 1);
|
||||
char* s = reinterpret_cast<char*>(n->body().begin());
|
||||
stringChars(t, name, s);
|
||||
|
||||
@ -35,14 +35,14 @@ search(Thread* t, GcClassLoader* loader, object name,
|
||||
replace('.', '/', s);
|
||||
}
|
||||
|
||||
return reinterpret_cast<int64_t>(op(t, loader, reinterpret_cast<object>(n)));
|
||||
return reinterpret_cast<int64_t>(op(t, loader, n));
|
||||
} else {
|
||||
throwNew(t, GcNullPointerException::Type);
|
||||
}
|
||||
}
|
||||
|
||||
GcClass*
|
||||
resolveSystemClassThrow(Thread* t, GcClassLoader* loader, object spec)
|
||||
resolveSystemClassThrow(Thread* t, GcClassLoader* loader, GcByteArray* spec)
|
||||
{
|
||||
return resolveSystemClass
|
||||
(t, loader, spec, true, GcClassNotFoundException::Type);
|
||||
@ -135,7 +135,7 @@ Avian_avian_Classes_resolveVMClass
|
||||
object spec = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
return reinterpret_cast<int64_t>
|
||||
(resolveClass(t, loader, spec, true, GcClassNotFoundException::Type));
|
||||
(resolveClass(t, loader, cast<GcByteArray>(t, spec), true, GcClassNotFoundException::Type));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -165,7 +165,7 @@ Avian_avian_SystemClassLoader_findLoadedVMClass
|
||||
GcClassLoader* loader = cast<GcClassLoader>(t, reinterpret_cast<object>(arguments[0]));
|
||||
object name = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
return search(t, loader, name, findLoadedClass, true);
|
||||
return search(t, loader, cast<GcString>(t, name), findLoadedClass, true);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -183,7 +183,7 @@ Avian_avian_SystemClassLoader_findVMClass
|
||||
GcClassLoader* loader = cast<GcClassLoader>(t, reinterpret_cast<object>(arguments[0]));
|
||||
object name = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
return search(t, loader, name, resolveSystemClassThrow, true);
|
||||
return search(t, loader, cast<GcString>(t, name), resolveSystemClassThrow, true);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -194,8 +194,8 @@ Avian_avian_SystemClassLoader_resourceURLPrefix
|
||||
object name = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
if (LIKELY(name)) {
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, stringLength(t, name) + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, cast<GcString>(t, name)->length(t) + 1);
|
||||
stringChars(t, cast<GcString>(t, name), RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
const char* name = static_cast<Finder*>
|
||||
(loader->as<GcSystemClassLoader>(t)->finder())->urlPrefix(RUNTIME_ARRAY_BODY(n));
|
||||
@ -215,8 +215,8 @@ Avian_avian_SystemClassLoader_00024ResourceEnumeration_nextResourceURLPrefix
|
||||
object finderElementPtrPtr = reinterpret_cast<object>(arguments[3]);
|
||||
|
||||
if (LIKELY(name) && LIKELY(finderElementPtrPtr)) {
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, stringLength(t, name) + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, cast<GcString>(t, name)->length(t) + 1);
|
||||
stringChars(t, cast<GcString>(t, name), RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
void *&finderElementPtr = reinterpret_cast<void *&>(longArrayBody(t,
|
||||
finderElementPtrPtr, 0));
|
||||
@ -247,13 +247,13 @@ Avian_avian_SystemClassLoader_getPackageSource
|
||||
|
||||
ACQUIRE(t, t->m->classLock);
|
||||
|
||||
THREAD_RUNTIME_ARRAY(t, char, chars, stringLength(t, name) + 2);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(chars));
|
||||
THREAD_RUNTIME_ARRAY(t, char, chars, cast<GcString>(t, name)->length(t) + 2);
|
||||
stringChars(t, cast<GcString>(t, name), RUNTIME_ARRAY_BODY(chars));
|
||||
replace('.', '/', RUNTIME_ARRAY_BODY(chars));
|
||||
RUNTIME_ARRAY_BODY(chars)[stringLength(t, name)] = '/';
|
||||
RUNTIME_ARRAY_BODY(chars)[stringLength(t, name) + 1] = 0;
|
||||
RUNTIME_ARRAY_BODY(chars)[cast<GcString>(t, name)->length(t)] = '/';
|
||||
RUNTIME_ARRAY_BODY(chars)[cast<GcString>(t, name)->length(t) + 1] = 0;
|
||||
|
||||
object key = makeByteArray(t, RUNTIME_ARRAY_BODY(chars));
|
||||
object key = reinterpret_cast<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars)));
|
||||
|
||||
object array = hashMapFind
|
||||
(t, cast<GcHashMap>(t, root(t, Machine::PackageMap)), key, byteArrayHash, byteArrayEqual);
|
||||
@ -261,8 +261,8 @@ Avian_avian_SystemClassLoader_getPackageSource
|
||||
if (array) {
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeString
|
||||
(t, array, 0, byteArrayLength(t, array))));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, array, 0, byteArrayLength(t, array)))));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -323,8 +323,8 @@ Avian_avian_avianvmresource_Handler_00024ResourceInputStream_getContentLength
|
||||
object path = reinterpret_cast<object>(*arguments);
|
||||
|
||||
if (LIKELY(path)) {
|
||||
THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
|
||||
stringChars(t, path, RUNTIME_ARRAY_BODY(p));
|
||||
THREAD_RUNTIME_ARRAY(t, char, p, cast<GcString>(t, path)->length(t) + 1);
|
||||
stringChars(t, cast<GcString>(t, path), RUNTIME_ARRAY_BODY(p));
|
||||
|
||||
System::Region* r = t->m->bootFinder->find(RUNTIME_ARRAY_BODY(p));
|
||||
if (r == 0) {
|
||||
@ -347,8 +347,8 @@ Avian_avian_avianvmresource_Handler_00024ResourceInputStream_open
|
||||
object path = reinterpret_cast<object>(*arguments);
|
||||
|
||||
if (LIKELY(path)) {
|
||||
THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
|
||||
stringChars(t, path, RUNTIME_ARRAY_BODY(p));
|
||||
THREAD_RUNTIME_ARRAY(t, char, p, cast<GcString>(t, path)->length(t) + 1);
|
||||
stringChars(t, cast<GcString>(t, path), RUNTIME_ARRAY_BODY(p));
|
||||
|
||||
System::Region* r = t->m->bootFinder->find(RUNTIME_ARRAY_BODY(p));
|
||||
if (r == 0) {
|
||||
@ -933,12 +933,12 @@ extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_unpark
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object thread = reinterpret_cast<object>(arguments[1]);
|
||||
GcThread* thread = cast<GcThread>(t, reinterpret_cast<object>(arguments[1]));
|
||||
|
||||
monitorAcquire(t, interruptLock(t, thread));
|
||||
threadUnparked(t, thread) = true;
|
||||
monitorNotify(t, interruptLock(t, thread));
|
||||
monitorRelease(t, interruptLock(t, thread));
|
||||
monitorAcquire(t, cast<GcMonitor>(t, interruptLock(t, thread)));
|
||||
thread->unparked() = true;
|
||||
monitorNotify(t, cast<GcMonitor>(t, interruptLock(t, thread)));
|
||||
monitorRelease(t, cast<GcMonitor>(t, interruptLock(t, thread)));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
@ -962,13 +962,13 @@ Avian_sun_misc_Unsafe_park
|
||||
time = (time / (1000 * 1000)) + 1;
|
||||
}
|
||||
|
||||
monitorAcquire(t, interruptLock(t, t->javaThread));
|
||||
monitorAcquire(t, cast<GcMonitor>(t, interruptLock(t, t->javaThread)));
|
||||
bool interrupted = false;
|
||||
while (time >= 0
|
||||
and (not (threadUnparked(t, t->javaThread)
|
||||
or threadInterrupted(t, t->javaThread)
|
||||
and (not (t->javaThread->unparked()
|
||||
or t->javaThread->interrupted()
|
||||
or (interrupted = monitorWait
|
||||
(t, interruptLock(t, t->javaThread), time)))))
|
||||
(t, cast<GcMonitor>(t, interruptLock(t, t->javaThread)), time)))))
|
||||
{
|
||||
int64_t now = t->m->system->now();
|
||||
time -= now - then;
|
||||
@ -979,10 +979,10 @@ Avian_sun_misc_Unsafe_park
|
||||
}
|
||||
}
|
||||
if (interrupted) {
|
||||
threadInterrupted(t, t->javaThread) = true;
|
||||
t->javaThread->interrupted() = true;
|
||||
}
|
||||
threadUnparked(t, t->javaThread) = false;
|
||||
monitorRelease(t, interruptLock(t, t->javaThread));
|
||||
t->javaThread->unparked() = false;
|
||||
monitorRelease(t, cast<GcMonitor>(t, interruptLock(t, t->javaThread)));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
@ -1127,7 +1127,7 @@ extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_throwException
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
vm::throw_(t, reinterpret_cast<object>(arguments[1]));
|
||||
vm::throw_(t, cast<GcThrowable>(t, reinterpret_cast<object>(arguments[1])));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
|
@ -43,8 +43,8 @@ getDirectBufferAddress(Thread* t, object b)
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField
|
||||
(t, objectClass(t, b), "effectiveDirectAddress", "J"));
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, b), "effectiveDirectAddress", "J");
|
||||
|
||||
return reinterpret_cast<void*>
|
||||
(fieldAtOffset<int64_t>(b, field->offset()));
|
||||
@ -53,12 +53,12 @@ getDirectBufferAddress(Thread* t, object b)
|
||||
void JNICALL
|
||||
loadLibrary(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object name = reinterpret_cast<object>(arguments[1]);
|
||||
GcString* name = cast<GcString>(t, reinterpret_cast<object>(arguments[1]));
|
||||
|
||||
Thread::LibraryLoadStack stack(
|
||||
t, cast<GcClassLoader>(t, reinterpret_cast<object>(arguments[2])));
|
||||
|
||||
unsigned length = stringLength(t, name);
|
||||
unsigned length = name->length(t);
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
@ -137,9 +137,9 @@ makeMethodOrConstructor(Thread* t, GcJclass* c, unsigned index)
|
||||
} else {
|
||||
PROTECT(t, exceptionTypes);
|
||||
|
||||
GcString* name = cast<GcString>(t, t->m->classpath->makeString
|
||||
GcString* name = t->m->classpath->makeString
|
||||
(t, reinterpret_cast<object>(method->name()), 0,
|
||||
method->name()->length() - 1));
|
||||
method->name()->length() - 1);
|
||||
|
||||
return reinterpret_cast<object>(makeJmethod
|
||||
(t, 0, index, c, name, parameterTypes, exceptionTypes, returnType, 0, 0,
|
||||
@ -165,9 +165,9 @@ makeField(Thread* t, GcJclass* c, unsigned index)
|
||||
field->spec()->length() - 1));
|
||||
PROTECT(t, type);
|
||||
|
||||
GcString* name = cast<GcString>(t, t->m->classpath->makeString
|
||||
GcString* name = t->m->classpath->makeString
|
||||
(t, reinterpret_cast<object>(field->name()), 0,
|
||||
field->name()->length() - 1));
|
||||
field->name()->length() - 1);
|
||||
|
||||
return reinterpret_cast<object>(makeJfield(t, 0, c, type, 0, 0, name, index));
|
||||
}
|
||||
@ -193,7 +193,7 @@ void initVmThread(Thread* t, GcThread* thread, unsigned offset)
|
||||
}
|
||||
|
||||
if (thread->group() == 0) {
|
||||
set(t, reinterpret_cast<object>(thread), ThreadGroup, threadGroup(t, t->javaThread));
|
||||
set(t, thread, ThreadGroup, t->javaThread->group());
|
||||
expect(t, thread->group());
|
||||
}
|
||||
}
|
||||
@ -203,10 +203,8 @@ void initVmThread(Thread* t, GcThread* thread)
|
||||
initVmThread(
|
||||
t,
|
||||
thread,
|
||||
fieldOffset(
|
||||
t,
|
||||
resolveField(
|
||||
t, objectClass(t, thread), "vmThread", "Ljava/lang/VMThread;")));
|
||||
resolveField(
|
||||
t, objectClass(t, thread), "vmThread", "Ljava/lang/VMThread;")->offset());
|
||||
}
|
||||
|
||||
object
|
||||
@ -247,7 +245,7 @@ class MyClasspath : public Classpath {
|
||||
return c;
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcString*
|
||||
makeString(Thread* t, object array, int32_t offset, int32_t length)
|
||||
{
|
||||
if (objectClass(t, array) == type(t, GcByteArray::Type)) {
|
||||
@ -265,34 +263,34 @@ class MyClasspath : public Classpath {
|
||||
expect(t, objectClass(t, array) == type(t, GcCharArray::Type));
|
||||
}
|
||||
|
||||
return reinterpret_cast<object>(vm::makeString(t, array, offset, length, 0));
|
||||
return vm::makeString(t, array, offset, length, 0);
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcThread*
|
||||
makeThread(Thread* t, Thread* parent)
|
||||
{
|
||||
const unsigned NormalPriority = 5;
|
||||
|
||||
object group = 0;
|
||||
GcThreadGroup* group = 0;
|
||||
PROTECT(t, group);
|
||||
if (parent) {
|
||||
group = threadGroup(t, parent->javaThread);
|
||||
group = parent->javaThread->group();
|
||||
} else {
|
||||
resolveSystemClass
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)),
|
||||
reinterpret_cast<object>(type(t, GcThreadGroup::Type)->name()), false);
|
||||
type(t, GcThreadGroup::Type)->name(), false);
|
||||
|
||||
group = makeNew(t, type(t, GcThreadGroup::Type));
|
||||
group = cast<GcThreadGroup>(t, makeNew(t, type(t, GcThreadGroup::Type)));
|
||||
|
||||
GcMethod* constructor = resolveMethod
|
||||
(t, type(t, GcThreadGroup::Type), "<init>", "()V");
|
||||
|
||||
t->m->processor->invoke(t, constructor, group);
|
||||
t->m->processor->invoke(t, constructor, reinterpret_cast<object>(group));
|
||||
}
|
||||
|
||||
resolveSystemClass
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)),
|
||||
reinterpret_cast<object>(type(t, GcThread::Type)->name()), false);
|
||||
type(t, GcThread::Type)->name(), false);
|
||||
|
||||
GcThread* thread = cast<GcThread>(t, makeNew(t, type(t, GcThread::Type)));
|
||||
PROTECT(t, thread);
|
||||
@ -308,7 +306,7 @@ class MyClasspath : public Classpath {
|
||||
|
||||
initVmThread(t, thread);
|
||||
|
||||
return reinterpret_cast<object>(thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
virtual object
|
||||
@ -324,10 +322,10 @@ class MyClasspath : public Classpath {
|
||||
abort(t);
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcMethod*
|
||||
getVMMethod(Thread* t, object jmethod)
|
||||
{
|
||||
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
return cast<GcMethod>(t, objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
? arrayBody
|
||||
(t, classMethodTable
|
||||
(t, jclassVmClass(t, jmethodDeclaringClass(t, jmethod))),
|
||||
@ -335,28 +333,28 @@ class MyClasspath : public Classpath {
|
||||
: arrayBody
|
||||
(t, classMethodTable
|
||||
(t, jclassVmClass(t, jconstructorDeclaringClass(t, jmethod))),
|
||||
jconstructorSlot(t, jmethod));
|
||||
jconstructorSlot(t, jmethod)));
|
||||
}
|
||||
|
||||
virtual object
|
||||
makeJField(Thread* t, object vmField)
|
||||
makeJField(Thread* t, GcField* vmField)
|
||||
{
|
||||
object table = classFieldTable(t, fieldClass(t, vmField));
|
||||
object table = vmField->class_()->fieldTable();
|
||||
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
|
||||
if (vmField == arrayBody(t, table, i)) {
|
||||
return makeField(t, getJClass(t, cast<GcClass>(t, fieldClass(t, vmField))), i);
|
||||
if (reinterpret_cast<object>(vmField) == arrayBody(t, table, i)) {
|
||||
return makeField(t, getJClass(t, vmField->class_()), i);
|
||||
}
|
||||
}
|
||||
abort(t);
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcField*
|
||||
getVMField(Thread* t, object jfield)
|
||||
{
|
||||
return arrayBody
|
||||
return cast<GcField>(t, arrayBody
|
||||
(t, classFieldTable
|
||||
(t, jclassVmClass(t, jfieldDeclaringClass(t, jfield))),
|
||||
jfieldSlot(t, jfield));
|
||||
jfieldSlot(t, jfield)));
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -370,10 +368,10 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
// force monitor creation so we don't get an OutOfMemory error
|
||||
// later when we try to acquire it:
|
||||
objectMonitor(t, t->javaThread, true);
|
||||
objectMonitor(t, reinterpret_cast<object>(t->javaThread), true);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField(
|
||||
t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;"));
|
||||
GcField* field = resolveField(
|
||||
t, objectClass(t, t->javaThread), "vmThread", "Ljava/lang/VMThread;");
|
||||
|
||||
unsigned offset = field->offset();
|
||||
|
||||
@ -387,18 +385,18 @@ class MyClasspath : public Classpath {
|
||||
vm::release(t, vmt);
|
||||
}
|
||||
|
||||
vm::acquire(t, t->javaThread);
|
||||
vm::acquire(t, reinterpret_cast<object>(t->javaThread));
|
||||
t->flags &= ~Thread::ActiveFlag;
|
||||
vm::notifyAll(t, t->javaThread);
|
||||
vm::release(t, t->javaThread);
|
||||
vm::notifyAll(t, reinterpret_cast<object>(t->javaThread));
|
||||
vm::release(t, reinterpret_cast<object>(t->javaThread));
|
||||
});
|
||||
|
||||
initVmThread(t, cast<GcThread>(t, t->javaThread), offset);
|
||||
initVmThread(t, t->javaThread, offset);
|
||||
|
||||
GcMethod* method = resolveMethod
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V");
|
||||
|
||||
t->m->processor->invoke(t, method, t->javaThread);
|
||||
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread));
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -559,14 +557,14 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField
|
||||
(t, objectClass(t, b), "capacity", "I"));
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, b), "capacity", "I");
|
||||
|
||||
return fieldAtOffset<int32_t>(b, field->offset());
|
||||
}
|
||||
|
||||
virtual bool
|
||||
canTailCall(Thread*, GcMethod*, object, object, object)
|
||||
canTailCall(Thread*, GcMethod*, GcByteArray*, GcByteArray*, GcByteArray*)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -645,7 +643,7 @@ closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments)
|
||||
MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
|
||||
|
||||
if (cp->tzdata) {
|
||||
GcField* field = cast<GcField>(t, resolveField(t, objectClass(t, file), "address", "J"));
|
||||
GcField* field = resolveField(t, objectClass(t, file), "address", "J");
|
||||
|
||||
if (fieldAtOffset<int64_t>(file, field->offset())
|
||||
== reinterpret_cast<int64_t>(cp->tzdata->start()))
|
||||
@ -660,7 +658,7 @@ closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments)
|
||||
|
||||
t->m->processor->invoke
|
||||
(t, cast<GcMethod>(t, nativeInterceptOriginal
|
||||
(t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method)))),
|
||||
(t, getMethodRuntimeData(t, method)->native())),
|
||||
file);
|
||||
}
|
||||
|
||||
@ -712,7 +710,7 @@ matchType(Thread* t, GcField* field, object o)
|
||||
}
|
||||
|
||||
return instanceOf
|
||||
(t, resolveClass(t, field->class_()->loader(), reinterpret_cast<object>(spec)), o);
|
||||
(t, resolveClass(t, field->class_()->loader(), spec), o);
|
||||
}
|
||||
|
||||
default: abort(t);
|
||||
@ -1011,12 +1009,12 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_String_compareTo
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object a = reinterpret_cast<object>(arguments[0]);
|
||||
object b = reinterpret_cast<object>(arguments[1]);
|
||||
GcString* a = cast<GcString>(t, reinterpret_cast<object>(arguments[0]));
|
||||
GcString* b = cast<GcString>(t, reinterpret_cast<object>(arguments[1]));
|
||||
|
||||
unsigned length = stringLength(t, a);
|
||||
if (length > stringLength(t, b)) {
|
||||
length = stringLength(t, b);
|
||||
unsigned length = a->length(t);
|
||||
if (length > b->length(t)) {
|
||||
length = b->length(t);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
@ -1026,7 +1024,7 @@ Avian_java_lang_String_compareTo
|
||||
}
|
||||
}
|
||||
|
||||
return stringLength(t, a) - stringLength(t, b);
|
||||
return a->length(t) - b->length(t);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -1055,7 +1053,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_String_charAt
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
return stringCharAt(t, reinterpret_cast<object>(arguments[0]), arguments[1]);
|
||||
return stringCharAt(t, cast<GcString>(t, reinterpret_cast<object>(arguments[0])), arguments[1]);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -1071,11 +1069,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_String_fastIndexOf
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object s = reinterpret_cast<object>(arguments[0]);
|
||||
GcString* s = cast<GcString>(t, reinterpret_cast<object>(arguments[0]));
|
||||
unsigned c = arguments[1];
|
||||
unsigned start = arguments[2];
|
||||
|
||||
for (unsigned i = start; i < stringLength(t, s); ++i) {
|
||||
for (unsigned i = start; i < s->length(t); ++i) {
|
||||
if (stringCharAt(t, s, i) == c) {
|
||||
return i;
|
||||
}
|
||||
@ -1352,13 +1350,13 @@ Avian_dalvik_system_VMRuntime_properties
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < t->m->propertyCount; ++i) {
|
||||
object s = makeString(t, "%s", t->m->properties[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), s);
|
||||
GcString* s = makeString(t, "%s", t->m->properties[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(s));
|
||||
}
|
||||
|
||||
{
|
||||
object s = makeString(t, "%s", "java.protocol.handler.pkgs=avian");
|
||||
set(t, array, ArrayBody + (i++ * BytesPerWord), s);
|
||||
GcString* s = makeString(t, "%s", "java.protocol.handler.pkgs=avian");
|
||||
set(t, array, ArrayBody + (i++ * BytesPerWord), reinterpret_cast<object>(s));
|
||||
}
|
||||
|
||||
return reinterpret_cast<uintptr_t>(array);
|
||||
@ -1375,10 +1373,10 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_Runtime_nativeLoad
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object name = reinterpret_cast<object>(arguments[0]);
|
||||
GcString* name = cast<GcString>(t, reinterpret_cast<object>(arguments[0]));
|
||||
PROTECT(t, name);
|
||||
|
||||
unsigned length = stringLength(t, name);
|
||||
unsigned length = name->length(t);
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
@ -1419,8 +1417,8 @@ Avian_java_lang_VMThread_interrupt
|
||||
object vmThread = reinterpret_cast<object>(arguments[0]);
|
||||
PROTECT(t, vmThread);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField
|
||||
(t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;"));
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;");
|
||||
|
||||
interrupt
|
||||
(t, reinterpret_cast<Thread*>
|
||||
@ -1441,8 +1439,8 @@ Avian_java_lang_VMThread_isInterrupted
|
||||
object vmThread = reinterpret_cast<object>(arguments[0]);
|
||||
PROTECT(t, vmThread);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField
|
||||
(t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;"));
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, vmThread), "thread", "Ljava/lang/Thread;");
|
||||
|
||||
return threadInterrupted
|
||||
(t, fieldAtOffset<object>(vmThread, field->offset()));
|
||||
@ -1482,14 +1480,14 @@ Avian_java_lang_VMThread_sleep
|
||||
if (arguments[2] > 0) ++ milliseconds;
|
||||
if (milliseconds <= 0) milliseconds = 1;
|
||||
|
||||
if (threadSleepLock(t, t->javaThread) == 0) {
|
||||
if (t->javaThread->sleepLock() == 0) {
|
||||
object lock = reinterpret_cast<object>(makeJobject(t));
|
||||
set(t, t->javaThread, ThreadSleepLock, lock);
|
||||
set(t, reinterpret_cast<object>(t->javaThread), ThreadSleepLock, lock);
|
||||
}
|
||||
|
||||
acquire(t, threadSleepLock(t, t->javaThread));
|
||||
vm::wait(t, threadSleepLock(t, t->javaThread), milliseconds);
|
||||
release(t, threadSleepLock(t, t->javaThread));
|
||||
acquire(t, t->javaThread->sleepLock());
|
||||
vm::wait(t, t->javaThread->sleepLock(), milliseconds);
|
||||
release(t, t->javaThread->sleepLock());
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -2249,10 +2247,10 @@ Avian_java_lang_reflect_Field_getSignatureAnnotation
|
||||
object array = makeObjectArray(t, 1);
|
||||
PROTECT(t, array);
|
||||
|
||||
object string = t->m->classpath->makeString
|
||||
GcString* string = t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1);
|
||||
|
||||
set(t, array, ArrayBody, string);
|
||||
set(t, array, ArrayBody, reinterpret_cast<object>(string));
|
||||
|
||||
return reinterpret_cast<uintptr_t>(array);
|
||||
}
|
||||
@ -2459,7 +2457,7 @@ Avian_libcore_io_OsConstants_initConstants
|
||||
object table = classStaticTable(t, c);
|
||||
PROTECT(t, table);
|
||||
|
||||
GcField* field = cast<GcField>(t, resolveField(t, c, "STDIN_FILENO", "I");
|
||||
GcField* field = resolveField(t, c, "STDIN_FILENO", "I");
|
||||
fieldAtOffset<jint>(table, field->offset()) = 0;
|
||||
|
||||
field = resolveField(t, c, "STDOUT_FILENO", "I");
|
||||
@ -2474,7 +2472,7 @@ Avian_libcore_io_Posix_getenv(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object name = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
THREAD_RUNTIME_ARRAY(t, uint16_t, chars, stringLength(t, name) + 1);
|
||||
THREAD_RUNTIME_ARRAY(t, uint16_t, chars, name->length(t) + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(chars));
|
||||
|
||||
wchar_t* value = _wgetenv
|
||||
|
@ -32,28 +32,28 @@ class MyClasspath : public Classpath {
|
||||
return reinterpret_cast<object>(vm::makeJclass(t, class_));
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcString*
|
||||
makeString(Thread* t, object array, int32_t offset, int32_t length)
|
||||
{
|
||||
return reinterpret_cast<object>(vm::makeString(t, array, offset, length, 0));
|
||||
return vm::makeString(t, array, offset, length, 0);
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcThread*
|
||||
makeThread(Thread* t, Thread* parent)
|
||||
{
|
||||
object group;
|
||||
GcThreadGroup* group;
|
||||
if (parent) {
|
||||
group = threadGroup(t, parent->javaThread);
|
||||
group = parent->javaThread->group();
|
||||
} else {
|
||||
group = reinterpret_cast<object>(makeThreadGroup(t, 0, 0, 0));
|
||||
group = makeThreadGroup(t, 0, 0, 0);
|
||||
}
|
||||
|
||||
const unsigned NewState = 0;
|
||||
const unsigned NormalPriority = 5;
|
||||
|
||||
return reinterpret_cast<object>(vm::makeThread
|
||||
return vm::makeThread
|
||||
(t, 0, 0, 0, 0, 0, NewState, NormalPriority, 0, 0, 0,
|
||||
cast<GcClassLoader>(t, root(t, Machine::AppLoader)), 0, 0, cast<GcThreadGroup>(t, group), 0));
|
||||
cast<GcClassLoader>(t, root(t, Machine::AppLoader)), 0, 0, group, 0);
|
||||
}
|
||||
|
||||
virtual object
|
||||
@ -67,24 +67,24 @@ class MyClasspath : public Classpath {
|
||||
? reinterpret_cast<object>(makeJconstructor(t, cast<GcJmethod>(t, jmethod))) : jmethod;
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcMethod*
|
||||
getVMMethod(Thread* t, object jmethod)
|
||||
{
|
||||
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
? jmethodVmMethod(t, jmethod)
|
||||
: jmethodVmMethod(t, jconstructorMethod(t, jmethod));
|
||||
? cast<GcMethod>(t, jmethodVmMethod(t, jmethod))
|
||||
: cast<GcMethod>(t, jmethodVmMethod(t, jconstructorMethod(t, jmethod)));
|
||||
}
|
||||
|
||||
virtual object
|
||||
makeJField(Thread* t, object vmField)
|
||||
makeJField(Thread* t, GcField* vmField)
|
||||
{
|
||||
return reinterpret_cast<object>(makeJfield(t, cast<GcField>(t, vmField), false));
|
||||
return reinterpret_cast<object>(makeJfield(t, vmField, false));
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcField*
|
||||
getVMField(Thread* t, object jfield)
|
||||
{
|
||||
return jfieldVmField(t, jfield);
|
||||
return cast<GcField>(t, jfieldVmField(t, jfield));
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -162,10 +162,10 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
object field = resolveField(t, objectClass(t, b), "address", "J");
|
||||
GcField* field = resolveField(t, objectClass(t, b), "address", "J");
|
||||
|
||||
return reinterpret_cast<void*>
|
||||
(fieldAtOffset<int64_t>(b, fieldOffset(t, field)));
|
||||
(fieldAtOffset<int64_t>(b, field->offset()));
|
||||
}
|
||||
|
||||
virtual int64_t
|
||||
@ -173,17 +173,17 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
object field = resolveField
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, b), "capacity", "I");
|
||||
|
||||
return fieldAtOffset<int32_t>(b, fieldOffset(t, field));
|
||||
return fieldAtOffset<int32_t>(b, field->offset());
|
||||
}
|
||||
|
||||
virtual bool canTailCall(Thread* t,
|
||||
virtual bool canTailCall(Thread* t UNUSED,
|
||||
GcMethod*,
|
||||
object calleeClassName,
|
||||
object calleeMethodName,
|
||||
object)
|
||||
GcByteArray* calleeClassName,
|
||||
GcByteArray* calleeMethodName,
|
||||
GcByteArray*)
|
||||
{
|
||||
// we can't tail call System.load[Library] or
|
||||
// Runtime.load[Library] due to their use of
|
||||
@ -192,16 +192,16 @@ class MyClasspath : public Classpath {
|
||||
|
||||
return (
|
||||
(strcmp("loadLibrary",
|
||||
reinterpret_cast<char*>(&byteArrayBody(t, calleeMethodName, 0)))
|
||||
reinterpret_cast<char*>(calleeMethodName->body().begin()))
|
||||
and strcmp("load",
|
||||
reinterpret_cast<char*>(
|
||||
&byteArrayBody(t, calleeMethodName, 0))))
|
||||
calleeMethodName->body().begin())))
|
||||
or (strcmp(
|
||||
"java/lang/System",
|
||||
reinterpret_cast<char*>(&byteArrayBody(t, calleeClassName, 0)))
|
||||
reinterpret_cast<char*>(calleeClassName->body().begin()))
|
||||
and strcmp("java/lang/Runtime",
|
||||
reinterpret_cast<char*>(
|
||||
&byteArrayBody(t, calleeClassName, 0)))));
|
||||
calleeClassName->body().begin()))));
|
||||
}
|
||||
|
||||
virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller)
|
||||
@ -232,7 +232,7 @@ enumerateThreads(Thread* t, Thread* x, object array, unsigned* index,
|
||||
unsigned limit)
|
||||
{
|
||||
if (*index < limit) {
|
||||
set(t, array, ArrayBody + (*index * BytesPerWord), x->javaThread);
|
||||
set(t, array, ArrayBody + (*index * BytesPerWord), reinterpret_cast<object>(x->javaThread));
|
||||
++ (*index);
|
||||
|
||||
if (x->peer) enumerateThreads(t, x->peer, array, index, limit);
|
||||
@ -263,7 +263,7 @@ Avian_java_lang_Object_toString
|
||||
object this_ = reinterpret_cast<object>(arguments[0]);
|
||||
|
||||
unsigned hash = objectHash(t, this_);
|
||||
object s = makeString
|
||||
GcString* s = makeString
|
||||
(t, "%s@0x%x",
|
||||
objectClass(t, this_)->name()->body().begin(),
|
||||
hash);
|
||||
@ -456,7 +456,7 @@ Avian_java_lang_reflect_Method_invoke
|
||||
|
||||
THREAD_RESOURCE0(t, {
|
||||
if (t->exception) {
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = makeThrowable
|
||||
(t, GcInvocationTargetException::Type, 0, 0, exception);
|
||||
}
|
||||
@ -546,8 +546,8 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
PROTECT(t, array);
|
||||
|
||||
for (unsigned i = 0; i < t->m->propertyCount; ++i) {
|
||||
object s = makeString(t, "%s", t->m->properties[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), s);
|
||||
GcString* s = makeString(t, "%s", t->m->properties[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(s));
|
||||
}
|
||||
|
||||
return reinterpret_cast<int64_t>(array);
|
||||
@ -597,7 +597,7 @@ extern "C" AVIAN_EXPORT void JNICALL
|
||||
|
||||
unsigned length = stringLength(t, name);
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
stringChars(t, cast<GcString>(t, name), RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), mapName, true);
|
||||
}
|
||||
|
@ -323,9 +323,9 @@ getClassName(Thread* t, GcClass* c)
|
||||
if (c->vmFlags() & PrimitiveFlag) {
|
||||
PROTECT(t, c);
|
||||
|
||||
object name = makeByteArray(t, primitiveName(t, c));
|
||||
GcByteArray* name = makeByteArray(t, primitiveName(t, c));
|
||||
|
||||
set(t, reinterpret_cast<object>(c), ClassName, name);
|
||||
set(t, c, ClassName, name);
|
||||
} else {
|
||||
abort(t);
|
||||
}
|
||||
@ -334,7 +334,7 @@ getClassName(Thread* t, GcClass* c)
|
||||
return reinterpret_cast<object>(c->name());
|
||||
}
|
||||
|
||||
object
|
||||
GcString*
|
||||
makeClassNameString(Thread* t, object name)
|
||||
{
|
||||
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, name));
|
||||
@ -486,18 +486,18 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, class_);
|
||||
|
||||
object name = makeClassNameString(t, getClassName(t, class_));
|
||||
GcString* name = makeClassNameString(t, getClassName(t, class_));
|
||||
PROTECT(t, name);
|
||||
|
||||
object c = allocate(t, GcJclass::FixedSize, true);
|
||||
setObjectClass(t, c, type(t, GcJclass::Type));
|
||||
set(t, c, JclassName, name);
|
||||
set(t, c, JclassName, reinterpret_cast<object>(name));
|
||||
set(t, c, JclassVmClass, reinterpret_cast<object>(class_));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcString*
|
||||
makeString(Thread* t, object array, int32_t offset, int32_t length)
|
||||
{
|
||||
if (objectClass(t, array) == type(t, GcByteArray::Type)) {
|
||||
@ -511,7 +511,7 @@ class MyClasspath : public Classpath {
|
||||
"([BIILjava/lang/String;)V");
|
||||
PROTECT(t, constructor);
|
||||
|
||||
object utf8 = vm::makeString(t, "UTF8");
|
||||
GcString* utf8 = vm::makeString(t, "UTF8");
|
||||
PROTECT(t, utf8);
|
||||
|
||||
object s = makeNew(t, type(t, GcString::Type));
|
||||
@ -520,7 +520,7 @@ class MyClasspath : public Classpath {
|
||||
t->m->processor->invoke
|
||||
(t, constructor, s, array, offset, length, utf8);
|
||||
|
||||
return s;
|
||||
return cast<GcString>(t, s);
|
||||
}
|
||||
|
||||
charArrayBody(t, reinterpret_cast<object>(charArray), i) = byteArrayBody(t, array, offset + i);
|
||||
@ -534,40 +534,44 @@ class MyClasspath : public Classpath {
|
||||
return vm::makeString(t, array, offset, length, 0);
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcThread*
|
||||
makeThread(Thread* t, Thread* parent)
|
||||
{
|
||||
const unsigned MaxPriority = 10;
|
||||
const unsigned NormalPriority = 5;
|
||||
|
||||
object group;
|
||||
GcThreadGroup* group;
|
||||
if (parent) {
|
||||
group = threadGroup(t, parent->javaThread);
|
||||
group = parent->javaThread->group();
|
||||
} else {
|
||||
group = allocate(t, GcThreadGroup::FixedSize, true);
|
||||
setObjectClass(t, group, type(t, GcThreadGroup::Type));
|
||||
threadGroupMaxPriority(t, group) = MaxPriority;
|
||||
group = reinterpret_cast<GcThreadGroup*>(allocate(t, GcThreadGroup::FixedSize, true));
|
||||
setObjectClass(t, reinterpret_cast<object>(group), type(t, GcThreadGroup::Type));
|
||||
group->maxPriority() = MaxPriority;
|
||||
}
|
||||
|
||||
PROTECT(t, group);
|
||||
|
||||
object thread = allocate(t, GcThread::FixedSize, true);
|
||||
setObjectClass(t, thread, type(t, GcThread::Type));
|
||||
threadPriority(t, thread) = NormalPriority;
|
||||
threadGroup(t, thread) = group;
|
||||
threadContextClassLoader(t, thread) = root(t, Machine::AppLoader);
|
||||
|
||||
GcThread* thread = reinterpret_cast<GcThread*>(allocate(t, GcThread::FixedSize, true));
|
||||
setObjectClass(t, reinterpret_cast<object>(thread), type(t, GcThread::Type));
|
||||
thread->priority() = NormalPriority;
|
||||
|
||||
// TODO: use set / write barrier?
|
||||
thread->group() = group;
|
||||
|
||||
// TODO: use set / write barrier?
|
||||
thread->contextClassLoader() = cast<GcClassLoader>(t, root(t, Machine::AppLoader));
|
||||
|
||||
PROTECT(t, thread);
|
||||
|
||||
object blockerLock = reinterpret_cast<object>(makeJobject(t));
|
||||
GcJobject* blockerLock = makeJobject(t);
|
||||
set(t, thread, ThreadBlockerLock, blockerLock);
|
||||
|
||||
const unsigned BufferSize = 256;
|
||||
char buffer[BufferSize];
|
||||
unsigned length = vm::snprintf(buffer, BufferSize, "Thread-%p", thread);
|
||||
object name = reinterpret_cast<object>(makeCharArray(t, length));
|
||||
GcCharArray* name = makeCharArray(t, length);
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
charArrayBody(t, name, i) = buffer[i];
|
||||
name->body()[i] = buffer[i];
|
||||
}
|
||||
set(t, thread, ThreadName, name);
|
||||
|
||||
@ -584,10 +588,10 @@ class MyClasspath : public Classpath {
|
||||
: reinterpret_cast<object>(makeJmethod(t, vmMethod));
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcMethod*
|
||||
getVMMethod(Thread* t, object jmethod)
|
||||
{
|
||||
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
return cast<GcMethod>(t, objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
? arrayBody
|
||||
(t, classMethodTable
|
||||
(t, jclassVmClass(t, jmethodClazz(t, jmethod))),
|
||||
@ -595,21 +599,21 @@ class MyClasspath : public Classpath {
|
||||
: arrayBody
|
||||
(t, classMethodTable
|
||||
(t, jclassVmClass(t, jconstructorClazz(t, jmethod))),
|
||||
jconstructorSlot(t, jmethod));
|
||||
jconstructorSlot(t, jmethod)));
|
||||
}
|
||||
|
||||
virtual object
|
||||
makeJField(Thread* t, object vmField)
|
||||
makeJField(Thread* t, GcField* vmField)
|
||||
{
|
||||
return makeJfield(t, vmField);
|
||||
return reinterpret_cast<object>(makeJfield(t, reinterpret_cast<object>(vmField)));
|
||||
}
|
||||
|
||||
virtual object
|
||||
virtual GcField*
|
||||
getVMField(Thread* t, object jfield)
|
||||
{
|
||||
return arrayBody
|
||||
return cast<GcField>(t, arrayBody
|
||||
(t, classFieldTable
|
||||
(t, jclassVmClass(t, jfieldClazz(t, jfield))), jfieldSlot(t, jfield));
|
||||
(t, jclassVmClass(t, jfieldClazz(t, jfield))), jfieldSlot(t, jfield)));
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -623,22 +627,22 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
// force monitor creation so we don't get an OutOfMemory error
|
||||
// later when we try to acquire it:
|
||||
objectMonitor(t, t->javaThread, true);
|
||||
objectMonitor(t, reinterpret_cast<object>(t->javaThread), true);
|
||||
|
||||
THREAD_RESOURCE0(t, {
|
||||
vm::acquire(t, t->javaThread);
|
||||
vm::acquire(t, reinterpret_cast<object>(t->javaThread));
|
||||
t->flags &= ~Thread::ActiveFlag;
|
||||
vm::notifyAll(t, t->javaThread);
|
||||
vm::release(t, t->javaThread);
|
||||
vm::notifyAll(t, reinterpret_cast<object>(t->javaThread));
|
||||
vm::release(t, reinterpret_cast<object>(t->javaThread));
|
||||
|
||||
object e = t->exception;
|
||||
GcThrowable* e = t->exception;
|
||||
PROTECT(t, e);
|
||||
|
||||
t->exception = 0;
|
||||
|
||||
t->m->processor->invoke
|
||||
(t, cast<GcMethod>(t, root(t, Machine::ThreadTerminated)),
|
||||
threadGroup(t, t->javaThread), t->javaThread);
|
||||
reinterpret_cast<object>(t->javaThread->group()), t->javaThread);
|
||||
|
||||
t->exception = e;
|
||||
});
|
||||
@ -646,7 +650,7 @@ class MyClasspath : public Classpath {
|
||||
GcMethod* method = resolveMethod
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/Thread", "run", "()V");
|
||||
|
||||
t->m->processor->invoke(t, method, t->javaThread);
|
||||
t->m->processor->invoke(t, method, reinterpret_cast<object>(t->javaThread));
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -692,7 +696,7 @@ class MyClasspath : public Classpath {
|
||||
globalMachine = t->m;
|
||||
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)),
|
||||
reinterpret_cast<object>(type(t, GcClassLoader::Type)->name()));
|
||||
type(t, GcClassLoader::Type)->name());
|
||||
|
||||
setRoot(t, Machine::ThreadTerminated, reinterpret_cast<object>(resolveMethod
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/ThreadGroup",
|
||||
@ -705,11 +709,11 @@ class MyClasspath : public Classpath {
|
||||
expect(t, loadLibrary(t, libraryPath, "java", true, true));
|
||||
#endif // not AVIAN_OPENJDK_SRC
|
||||
|
||||
{ object assertionLock = resolveField
|
||||
{ GcField* assertionLock = resolveField
|
||||
(t, type(t, GcClassLoader::Type), "assertionLock",
|
||||
"Ljava/lang/Object;");
|
||||
|
||||
set(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), fieldOffset(t, assertionLock),
|
||||
set(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), assertionLock->offset(),
|
||||
cast<GcClassLoader>(t, root(t, Machine::BootLoader)));
|
||||
}
|
||||
|
||||
@ -745,20 +749,20 @@ class MyClasspath : public Classpath {
|
||||
cast<GcClassLoader>(t, root(t, Machine::BootLoader)));
|
||||
}
|
||||
|
||||
{ object scl = resolveField
|
||||
{ GcField* scl = resolveField
|
||||
(t, type(t, GcClassLoader::Type), "scl",
|
||||
"Ljava/lang/ClassLoader;");
|
||||
|
||||
PROTECT(t, scl);
|
||||
|
||||
object sclSet = resolveField
|
||||
GcField* sclSet = resolveField
|
||||
(t, type(t, GcClassLoader::Type), "sclSet", "Z");
|
||||
|
||||
set(t, reinterpret_cast<object>(type(t, GcClassLoader::Type)->staticTable()),
|
||||
fieldOffset(t, scl), root(t, Machine::AppLoader));
|
||||
scl->offset(), root(t, Machine::AppLoader));
|
||||
|
||||
fieldAtOffset<uint8_t>(type(t, GcClassLoader::Type)->staticTable(),
|
||||
fieldOffset(t, sclSet)) = true;
|
||||
sclSet->offset()) = true;
|
||||
}
|
||||
|
||||
t->m->processor->invoke
|
||||
@ -769,7 +773,7 @@ class MyClasspath : public Classpath {
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "sun/misc/Launcher",
|
||||
"getLauncher", "()Lsun/misc/Launcher;", 0);
|
||||
|
||||
set(t, t->javaThread, ThreadContextClassLoader,
|
||||
set(t, reinterpret_cast<object>(t->javaThread), ThreadContextClassLoader,
|
||||
root(t, Machine::AppLoader));
|
||||
}
|
||||
|
||||
@ -803,10 +807,10 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
object field = resolveField(t, objectClass(t, b), "address", "J");
|
||||
GcField* field = resolveField(t, objectClass(t, b), "address", "J");
|
||||
|
||||
return reinterpret_cast<void*>
|
||||
(fieldAtOffset<int64_t>(b, fieldOffset(t, field)));
|
||||
(fieldAtOffset<int64_t>(b, field->offset()));
|
||||
}
|
||||
|
||||
virtual int64_t
|
||||
@ -814,34 +818,34 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, b);
|
||||
|
||||
object field = resolveField
|
||||
GcField* field = resolveField
|
||||
(t, objectClass(t, b), "capacity", "I");
|
||||
|
||||
return fieldAtOffset<int32_t>(b, fieldOffset(t, field));
|
||||
return fieldAtOffset<int32_t>(b, field->offset());
|
||||
}
|
||||
|
||||
virtual bool
|
||||
canTailCall(Thread* t, GcMethod*, object calleeClassName,
|
||||
object calleeMethodName, object)
|
||||
canTailCall(Thread* t UNUSED, GcMethod*, GcByteArray* calleeClassName,
|
||||
GcByteArray* calleeMethodName, GcByteArray*)
|
||||
{
|
||||
// we can't tail call System.loadLibrary or Runtime.loadLibrary
|
||||
// due to their use of System.getCallerClass, which gets confused
|
||||
// if we elide stack frames.
|
||||
|
||||
return (strcmp("loadLibrary", reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, calleeMethodName, 0)))
|
||||
(calleeMethodName->body().begin()))
|
||||
or (strcmp("java/lang/System", reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, calleeClassName, 0)))
|
||||
(calleeClassName->body().begin()))
|
||||
and strcmp("java/lang/Runtime", reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, calleeClassName, 0)))))
|
||||
(calleeClassName->body().begin()))))
|
||||
|
||||
// and we can't tail call Reflection.getCallerClass because the
|
||||
// number of stack frames will be wrong
|
||||
|
||||
and (strcmp("getCallerClass", reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, calleeMethodName, 0)))
|
||||
(calleeMethodName->body().begin()))
|
||||
or strcmp("sun/reflect/Reflection", reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, calleeClassName, 0))));
|
||||
(calleeClassName->body().begin())));
|
||||
}
|
||||
|
||||
virtual GcClassLoader* libraryClassLoader(Thread* t, GcMethod* caller)
|
||||
@ -2222,8 +2226,8 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
|
||||
PROTECT(t, vmMethod);
|
||||
|
||||
object name = intern
|
||||
(t, t->m->classpath->makeString
|
||||
(t, reinterpret_cast<object>(vmMethod->name()), 0, vmMethod->name()->length() - 1));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, reinterpret_cast<object>(vmMethod->name()), 0, vmMethod->name()->length() - 1)));
|
||||
PROTECT(t, name);
|
||||
|
||||
unsigned parameterCount;
|
||||
@ -2254,8 +2258,8 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
|
||||
if (signature) {
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1);
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
}
|
||||
|
||||
annotationTable = addendumAnnotationTable(t, addendum);
|
||||
@ -2277,10 +2281,10 @@ makeJmethod(Thread* t, GcMethod* vmMethod, int index)
|
||||
PROTECT(t, annotationDefault);
|
||||
|
||||
if (annotationTable or parameterAnnotationTable or annotationDefault) {
|
||||
object runtimeData = getClassRuntimeData(t, vmMethod->class_());
|
||||
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_());
|
||||
|
||||
set(t, runtimeData, ClassRuntimeDataPool,
|
||||
reinterpret_cast<object>(vmMethod->addendum()->pool()));
|
||||
vmMethod->addendum()->pool());
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
@ -2329,8 +2333,8 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
|
||||
if (signature) {
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1);
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
}
|
||||
|
||||
annotationTable = addendumAnnotationTable(t, addendum);
|
||||
@ -2347,10 +2351,10 @@ makeJconstructor(Thread* t, GcMethod* vmMethod, int index)
|
||||
PROTECT(t, parameterAnnotationTable);
|
||||
|
||||
if (annotationTable or parameterAnnotationTable) {
|
||||
object runtimeData = getClassRuntimeData(t, vmMethod->class_());
|
||||
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, vmMethod->class_());
|
||||
|
||||
set(t, runtimeData, ClassRuntimeDataPool,
|
||||
reinterpret_cast<object>(vmMethod->addendum()->pool()));
|
||||
vmMethod->addendum()->pool());
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
@ -2391,9 +2395,9 @@ makeJfield(Thread* t, object vmField, int index)
|
||||
PROTECT(t, vmField);
|
||||
|
||||
object name = intern
|
||||
(t, t->m->classpath->makeString
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, fieldName(t, vmField), 0, byteArrayLength
|
||||
(t, fieldName(t, vmField)) - 1));
|
||||
(t, fieldName(t, vmField)) - 1)));
|
||||
PROTECT(t, name);
|
||||
|
||||
GcClass* type = resolveClassBySpec
|
||||
@ -2413,8 +2417,8 @@ makeJfield(Thread* t, object vmField, int index)
|
||||
if (signature) {
|
||||
PROTECT(t, addendum);
|
||||
|
||||
signature = t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1);
|
||||
signature = reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1));
|
||||
}
|
||||
|
||||
annotationTable = addendumAnnotationTable(t, addendum);
|
||||
@ -2427,9 +2431,9 @@ makeJfield(Thread* t, object vmField, int index)
|
||||
PROTECT(t, annotationTable);
|
||||
|
||||
if (annotationTable) {
|
||||
object runtimeData = getClassRuntimeData(t, cast<GcClass>(t, fieldClass(t, vmField)));
|
||||
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, cast<GcClass>(t, fieldClass(t, vmField)));
|
||||
|
||||
set(t, runtimeData, ClassRuntimeDataPool,
|
||||
set(t, reinterpret_cast<object>(runtimeData), ClassRuntimeDataPool,
|
||||
addendumPool(t, fieldAddendum(t, vmField)));
|
||||
}
|
||||
|
||||
@ -2459,10 +2463,10 @@ setProperty(Thread* t, GcMethod* method, object properties,
|
||||
PROTECT(t, method);
|
||||
PROTECT(t, properties);
|
||||
|
||||
object n = makeString(t, "%s", name);
|
||||
GcString* n = makeString(t, "%s", name);
|
||||
PROTECT(t, n);
|
||||
|
||||
object v = makeString(t, format, value);
|
||||
GcString* v = makeString(t, format, value);
|
||||
|
||||
t->m->processor->invoke(t, method, properties, n, v);
|
||||
}
|
||||
@ -3329,14 +3333,14 @@ jvmSleep(Thread* t, uintptr_t* arguments)
|
||||
milliseconds = 1;
|
||||
}
|
||||
|
||||
if (threadSleepLock(t, t->javaThread) == 0) {
|
||||
object lock = reinterpret_cast<object>(makeJobject(t));
|
||||
if (t->javaThread->sleepLock() == 0) {
|
||||
GcJobject* lock = makeJobject(t);
|
||||
set(t, t->javaThread, ThreadSleepLock, lock);
|
||||
}
|
||||
|
||||
acquire(t, threadSleepLock(t, t->javaThread));
|
||||
vm::wait(t, threadSleepLock(t, t->javaThread), milliseconds);
|
||||
release(t, threadSleepLock(t, t->javaThread));
|
||||
acquire(t, t->javaThread->sleepLock());
|
||||
vm::wait(t, t->javaThread->sleepLock(), milliseconds);
|
||||
release(t, t->javaThread->sleepLock());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3355,7 +3359,7 @@ EXPORT(JVM_CurrentThread)(Thread* t, jclass)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
return makeLocalReference(t, t->javaThread);
|
||||
return makeLocalReference(t, reinterpret_cast<object>(t->javaThread));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jint JNICALL
|
||||
@ -3364,7 +3368,7 @@ EXPORT(JVM_CountStackFrames)(Thread*, jobject) { abort(); }
|
||||
uint64_t
|
||||
jvmInterrupt(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
threadInterrupt(t, *reinterpret_cast<jobject>(arguments[0]));
|
||||
threadInterrupt(t, cast<GcThread>(t, *reinterpret_cast<jobject>(arguments[0])));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3383,7 +3387,7 @@ jvmIsInterrupted(Thread* t, uintptr_t* arguments)
|
||||
jobject thread = reinterpret_cast<jobject>(arguments[0]);
|
||||
jboolean clear = arguments[1];
|
||||
|
||||
return threadIsInterrupted(t, *thread, clear);
|
||||
return threadIsInterrupted(t, cast<GcThread>(t, *thread), clear);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jboolean JNICALL
|
||||
@ -3397,9 +3401,9 @@ EXPORT(JVM_IsInterrupted)(Thread* t, jobject thread, jboolean clear)
|
||||
uint64_t
|
||||
jvmHoldsLock(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
object m = objectMonitor(t, *reinterpret_cast<jobject>(arguments[0]), false);
|
||||
GcMonitor* m = objectMonitor(t, *reinterpret_cast<jobject>(arguments[0]), false);
|
||||
|
||||
return m and monitorOwner(t, m) == t;
|
||||
return m and m->owner() == t;
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jboolean JNICALL
|
||||
@ -3424,7 +3428,7 @@ jvmDumpThreads(Thread* t, uintptr_t* arguments)
|
||||
unsigned threadsLength = objectArrayLength(t, *threads);
|
||||
GcClass* arrayClass = resolveObjectArrayClass
|
||||
(t, type(t, GcStackTraceElement::Type)->loader(),
|
||||
reinterpret_cast<object>(type(t, GcStackTraceElement::Type)));
|
||||
type(t, GcStackTraceElement::Type));
|
||||
object result = makeObjectArray(t, arrayClass, threadsLength);
|
||||
PROTECT(t, result);
|
||||
|
||||
@ -3519,8 +3523,8 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments)
|
||||
|
||||
ACQUIRE(t, t->m->classLock);
|
||||
|
||||
THREAD_RUNTIME_ARRAY(t, char, chars, stringLength(t, *s) + 1);
|
||||
stringChars(t, *s, RUNTIME_ARRAY_BODY(chars));
|
||||
THREAD_RUNTIME_ARRAY(t, char, chars, cast<GcString>(t, *s)->length(t) + 1);
|
||||
stringChars(t, cast<GcString>(t, *s), RUNTIME_ARRAY_BODY(chars));
|
||||
|
||||
object key = reinterpret_cast<object>(makeByteArray(t, RUNTIME_ARRAY_BODY(chars)));
|
||||
|
||||
@ -3530,8 +3534,8 @@ jvmGetSystemPackage(Thread* t, uintptr_t* arguments)
|
||||
if (array) {
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeString
|
||||
(t, array, 0, byteArrayLength(t, array))));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, array, 0, byteArrayLength(t, array)))));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -3932,15 +3936,15 @@ jvmFindLoadedClass(Thread* t, uintptr_t* arguments)
|
||||
jobject loader = reinterpret_cast<jobject>(arguments[0]);
|
||||
jstring name = reinterpret_cast<jstring>(arguments[1]);
|
||||
|
||||
object spec = reinterpret_cast<object>(makeByteArray(t, stringLength(t, *name) + 1));
|
||||
GcByteArray* spec = makeByteArray(t, cast<GcString>(t, *name)->length(t) + 1);
|
||||
|
||||
{ char* s = reinterpret_cast<char*>(&byteArrayBody(t, spec, 0));
|
||||
stringChars(t, *name, s);
|
||||
{ char* s = reinterpret_cast<char*>(spec->body().begin());
|
||||
stringChars(t, cast<GcString>(t, *name), s);
|
||||
replace('.', '/', s);
|
||||
}
|
||||
|
||||
GcClass* c = findLoadedClass(t, cast<GcClassLoader>(t, *loader), spec);
|
||||
|
||||
|
||||
return reinterpret_cast<uint64_t>
|
||||
(c ? makeLocalReference(t, reinterpret_cast<object>(getJClass(t, c))) : 0);
|
||||
}
|
||||
@ -4077,7 +4081,7 @@ EXPORT(JVM_GetClassSigners)(Thread* t, jclass c)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object runtimeData = getClassRuntimeDataIfExists(t, jclassVmClass(t, *c));
|
||||
object runtimeData = getClassRuntimeDataIfExists(t, cast<GcClass>(t, jclassVmClass(t, *c)));
|
||||
|
||||
return runtimeData ? makeLocalReference
|
||||
(t, classRuntimeDataSigners(t, runtimeData)) : 0;
|
||||
@ -4106,9 +4110,9 @@ EXPORT(JVM_SetClassSigners)(Thread* t, jclass c, jobjectArray signers)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object runtimeData = getClassRuntimeData(t, cast<GcClass>(t, jclassVmClass(t, *c)));
|
||||
GcClassRuntimeData* runtimeData = getClassRuntimeData(t, cast<GcClass>(t, jclassVmClass(t, *c)));
|
||||
|
||||
set(t, runtimeData, ClassRuntimeDataSigners, *signers);
|
||||
set(t, reinterpret_cast<object>(runtimeData), ClassRuntimeDataSigners, *signers);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -4240,8 +4244,8 @@ jvmGetClassSignature(Thread* t, uintptr_t* arguments)
|
||||
if (signature) {
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1)));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, signature, 0, byteArrayLength(t, signature) - 1))));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -4505,7 +4509,7 @@ EXPORT(JVM_GetClassConstantPool)(Thread* t, jclass c)
|
||||
}
|
||||
|
||||
if (pool == 0) {
|
||||
pool = classRuntimeDataPool(t, getClassRuntimeData(t, cast<GcClass>(t, vmClass)));
|
||||
pool = getClassRuntimeData(t, cast<GcClass>(t, vmClass))->pool();
|
||||
}
|
||||
|
||||
return makeLocalReference(t, reinterpret_cast<object>(makeConstantPool(t, pool)));
|
||||
@ -4599,12 +4603,12 @@ jvmConstantPoolGetUTF8At(Thread* t, uintptr_t* arguments)
|
||||
jobject pool = reinterpret_cast<jobject>(arguments[0]);
|
||||
jint index = arguments[1];
|
||||
|
||||
object array = parseUtf8(t, singletonObject(t, cast<GcSingleton>(t, *pool), index - 1));
|
||||
object array = parseUtf8(t, cast<GcByteArray>(t, singletonObject(t, cast<GcSingleton>(t, *pool), index - 1)));
|
||||
|
||||
return reinterpret_cast<uint64_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeString
|
||||
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1))));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT jstring JNICALL
|
||||
@ -4622,11 +4626,11 @@ maybeWrap(Thread* t, bool wrapException)
|
||||
{
|
||||
if (t->exception
|
||||
and wrapException
|
||||
and not (instanceOf(t, type(t, GcError::Type), t->exception)
|
||||
and not (instanceOf(t, type(t, GcError::Type), reinterpret_cast<object>(t->exception))
|
||||
or instanceOf
|
||||
(t, type(t, GcRuntimeException::Type), t->exception)))
|
||||
(t, type(t, GcRuntimeException::Type), reinterpret_cast<object>(t->exception))))
|
||||
{
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
|
||||
PROTECT(t, exception);
|
||||
@ -4640,10 +4644,10 @@ maybeWrap(Thread* t, bool wrapException)
|
||||
(t, paeClass, "<init>", "(Ljava/lang/Exception;)V");
|
||||
PROTECT(t, paeConstructor);
|
||||
|
||||
object result = make(t, paeClass);
|
||||
GcThrowable* result = cast<GcThrowable>(t, make(t, paeClass));
|
||||
PROTECT(t, result);
|
||||
|
||||
t->m->processor->invoke(t, paeConstructor, result, exception);
|
||||
t->m->processor->invoke(t, paeConstructor, reinterpret_cast<object>(result), exception);
|
||||
|
||||
t->exception = result;
|
||||
}
|
||||
@ -5140,8 +5144,8 @@ getInputArgumentArray(Thread* t, uintptr_t*)
|
||||
PROTECT(t, array);
|
||||
|
||||
for (unsigned i = 0; i < t->m->argumentCount; ++i) {
|
||||
object argument = makeString(t, t->m->arguments[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), argument);
|
||||
GcString* argument = makeString(t, t->m->arguments[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(argument));
|
||||
}
|
||||
|
||||
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
|
||||
@ -5270,7 +5274,7 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments)
|
||||
PROTECT(t, array);
|
||||
|
||||
enclosingClass = reinterpret_cast<object>(getJClass
|
||||
(t, resolveClass(t, cast<GcClassLoader>(t, classLoader(t, class_)), enclosingClass)));
|
||||
(t, resolveClass(t, cast<GcClassLoader>(t, classLoader(t, class_)), cast<GcByteArray>(t, enclosingClass))));
|
||||
|
||||
set(t, array, ArrayBody, enclosingClass);
|
||||
|
||||
@ -5279,17 +5283,17 @@ getEnclosingMethodInfo(Thread* t, uintptr_t* arguments)
|
||||
if (enclosingMethod) {
|
||||
PROTECT(t, enclosingMethod);
|
||||
|
||||
object name = t->m->classpath->makeString
|
||||
GcString* name = t->m->classpath->makeString
|
||||
(t, pairFirst(t, enclosingMethod), 0,
|
||||
byteArrayLength(t, pairFirst(t, enclosingMethod)) - 1);
|
||||
|
||||
set(t, array, ArrayBody + BytesPerWord, name);
|
||||
set(t, array, ArrayBody + BytesPerWord, reinterpret_cast<object>(name));
|
||||
|
||||
object spec = t->m->classpath->makeString
|
||||
GcString* spec = t->m->classpath->makeString
|
||||
(t, pairSecond(t, enclosingMethod), 0,
|
||||
byteArrayLength(t, pairSecond(t, enclosingMethod)) - 1);
|
||||
|
||||
set(t, array, ArrayBody + (2 * BytesPerWord), spec);
|
||||
set(t, array, ArrayBody + (2 * BytesPerWord), reinterpret_cast<object>(spec));
|
||||
}
|
||||
|
||||
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
|
||||
|
114
src/compile.cpp
114
src/compile.cpp
@ -247,7 +247,7 @@ class MyThread: public Thread {
|
||||
|
||||
MyThread(Machine* m, GcThread* javaThread, MyThread* parent,
|
||||
bool useNativeFeatures):
|
||||
Thread(m, reinterpret_cast<object>(javaThread), parent),
|
||||
Thread(m, javaThread, parent),
|
||||
ip(0),
|
||||
stack(0),
|
||||
newStack(0),
|
||||
@ -336,7 +336,7 @@ resolveTarget(MyThread* t, void* stack, GcMethod* method)
|
||||
PROTECT(t, method);
|
||||
PROTECT(t, class_);
|
||||
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), reinterpret_cast<object>(class_->name()));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name());
|
||||
}
|
||||
|
||||
if (method->class_()->flags() & ACC_INTERFACE) {
|
||||
@ -352,7 +352,7 @@ resolveTarget(MyThread* t, GcClass* class_, unsigned index)
|
||||
if (class_->vmFlags() & BootstrapFlag) {
|
||||
PROTECT(t, class_);
|
||||
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), reinterpret_cast<object>(class_->name()));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name());
|
||||
}
|
||||
|
||||
return cast<GcMethod>(t, arrayBody(t, class_->virtualTable(), index));
|
||||
@ -2285,7 +2285,7 @@ resolveMethod(Thread* t, object pair)
|
||||
ReferenceClass);
|
||||
|
||||
return cast<GcMethod>(t, findInHierarchy
|
||||
(t, class_, referenceName(t, reference), referenceSpec(t, reference),
|
||||
(t, class_, cast<GcByteArray>(t, referenceName(t, reference)), cast<GcByteArray>(t, referenceSpec(t, reference)),
|
||||
findMethodInClass, GcNoSuchMethodError::Type));
|
||||
}
|
||||
|
||||
@ -2420,7 +2420,7 @@ getJClassFromReference(MyThread* t, object pair)
|
||||
t,
|
||||
resolveClass(t,
|
||||
cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair)))));
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair))))));
|
||||
}
|
||||
|
||||
unsigned
|
||||
@ -2455,7 +2455,7 @@ throwArithmetic(MyThread* t)
|
||||
} else {
|
||||
// not enough memory available for a new exception and stack trace
|
||||
// -- use a preallocated instance instead
|
||||
throw_(t, root(t, Machine::ArithmeticException));
|
||||
throw_(t, cast<GcThrowable>(t, root(t, Machine::ArithmeticException)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2513,7 +2513,7 @@ makeBlankObjectArrayFromReference(MyThread* t, object pair,
|
||||
t,
|
||||
resolveClass(t,
|
||||
cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair))),
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair)))),
|
||||
length);
|
||||
}
|
||||
|
||||
@ -2652,7 +2652,7 @@ makeMultidimensionalArrayFromReference(MyThread* t, object pair,
|
||||
return makeMultidimensionalArray
|
||||
(t, resolveClass
|
||||
(t, cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair))), dimensions, offset);
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair)))), dimensions, offset);
|
||||
}
|
||||
|
||||
void NO_RETURN
|
||||
@ -2666,7 +2666,7 @@ throwArrayIndexOutOfBounds(MyThread* t)
|
||||
} else {
|
||||
// not enough memory available for a new exception and stack trace
|
||||
// -- use a preallocated instance instead
|
||||
throw_(t, root(t, Machine::ArrayIndexOutOfBoundsException));
|
||||
throw_(t, cast<GcThrowable>(t, root(t, Machine::ArrayIndexOutOfBoundsException)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2677,7 +2677,7 @@ throwStackOverflow(MyThread* t)
|
||||
}
|
||||
|
||||
void NO_RETURN
|
||||
throw_(MyThread* t, object o)
|
||||
throw_(MyThread* t, GcThrowable* o)
|
||||
{
|
||||
if (LIKELY(o)) {
|
||||
vm::throw_(t, o);
|
||||
@ -2691,13 +2691,13 @@ checkCast(MyThread* t, GcClass* class_, object o)
|
||||
{
|
||||
if (UNLIKELY(o and not isAssignableFrom(t, class_, objectClass(t, o)))) {
|
||||
object classNameFrom = reinterpret_cast<object>(objectClass(t, o)->name());
|
||||
object classNameTo = reinterpret_cast<object>(class_->name());
|
||||
GcByteArray* classNameTo = class_->name();
|
||||
THREAD_RUNTIME_ARRAY(t, char, classFrom, byteArrayLength(t, classNameFrom));
|
||||
THREAD_RUNTIME_ARRAY(t, char, classTo, byteArrayLength(t, classNameTo));
|
||||
THREAD_RUNTIME_ARRAY(t, char, classTo, classNameTo->length());
|
||||
replace('/', '.', RUNTIME_ARRAY_BODY(classFrom),
|
||||
reinterpret_cast<char*>(&byteArrayBody(t, classNameFrom, 0)));
|
||||
replace('/', '.', RUNTIME_ARRAY_BODY(classTo),
|
||||
reinterpret_cast<char*>(&byteArrayBody(t, classNameTo, 0)));
|
||||
reinterpret_cast<char*>(classNameTo->body().begin()));
|
||||
throwNew
|
||||
(t, GcClassCastException::Type, "%s cannot be cast to %s",
|
||||
RUNTIME_ARRAY_BODY(classFrom), RUNTIME_ARRAY_BODY(classTo));
|
||||
@ -2711,7 +2711,7 @@ checkCastFromReference(MyThread* t, object pair, object o)
|
||||
|
||||
GcClass* c = resolveClass
|
||||
(t, cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair)));
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair))));
|
||||
|
||||
checkCast(t, c, o);
|
||||
}
|
||||
@ -2727,7 +2727,7 @@ resolveField(Thread* t, object pair)
|
||||
ReferenceClass);
|
||||
|
||||
return findInHierarchy
|
||||
(t, class_, referenceName(t, reference), referenceSpec(t, reference),
|
||||
(t, class_, cast<GcByteArray>(t, referenceName(t, reference)), cast<GcByteArray>(t, referenceSpec(t, reference)),
|
||||
findFieldInClass, GcNoSuchFieldError::Type);
|
||||
}
|
||||
|
||||
@ -2762,12 +2762,12 @@ getFieldValue(Thread* t, object target, object field)
|
||||
uint64_t
|
||||
getStaticFieldValueFromReference(MyThread* t, object pair)
|
||||
{
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return getFieldValue(t, classStaticTable(t, fieldClass(t, field)), field);
|
||||
}
|
||||
@ -2777,10 +2777,10 @@ getFieldValueFromReference(MyThread* t, object pair, object instance)
|
||||
{
|
||||
PROTECT(t, instance);
|
||||
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return getFieldValue(t, instance, field);
|
||||
}
|
||||
@ -2788,12 +2788,12 @@ getFieldValueFromReference(MyThread* t, object pair, object instance)
|
||||
void
|
||||
setStaticLongFieldValueFromReference(MyThread* t, object pair, uint64_t value)
|
||||
{
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<int64_t>
|
||||
(classStaticTable(t, fieldClass(t, field)), fieldOffset(t, field)) = value;
|
||||
@ -2805,10 +2805,10 @@ setLongFieldValueFromReference(MyThread* t, object pair, object instance,
|
||||
{
|
||||
PROTECT(t, instance);
|
||||
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<int64_t>(instance, fieldOffset(t, field)) = value;
|
||||
}
|
||||
@ -2818,12 +2818,12 @@ setStaticObjectFieldValueFromReference(MyThread* t, object pair, object value)
|
||||
{
|
||||
PROTECT(t, value);
|
||||
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
set(t, classStaticTable(t, fieldClass(t, field)), fieldOffset(t, field),
|
||||
value);
|
||||
@ -2836,10 +2836,10 @@ setObjectFieldValueFromReference(MyThread* t, object pair, object instance,
|
||||
PROTECT(t, instance);
|
||||
PROTECT(t, value);
|
||||
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
set(t, instance, fieldOffset(t, field), value);
|
||||
}
|
||||
@ -2871,12 +2871,12 @@ setFieldValue(MyThread* t, object target, object field, uint32_t value)
|
||||
void
|
||||
setStaticFieldValueFromReference(MyThread* t, object pair, uint32_t value)
|
||||
{
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
setFieldValue(t, classStaticTable(t, fieldClass(t, field)), field, value);
|
||||
}
|
||||
@ -2886,10 +2886,10 @@ setFieldValueFromReference(MyThread* t, object pair, object instance,
|
||||
uint32_t value)
|
||||
{
|
||||
PROTECT(t, instance);
|
||||
object field = resolveField(t, pair);
|
||||
object field = reinterpret_cast<object>(resolveField(t, pair));
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
setFieldValue(t, instance, field, value);
|
||||
}
|
||||
@ -2907,7 +2907,7 @@ instanceOfFromReference(Thread* t, object pair, object o)
|
||||
|
||||
GcClass* c = resolveClass
|
||||
(t, cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair)));
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair))));
|
||||
|
||||
return instanceOf64(t, c, o);
|
||||
}
|
||||
@ -2937,7 +2937,7 @@ makeNewFromReference(Thread* t, object pair)
|
||||
{
|
||||
GcClass* class_ = resolveClass
|
||||
(t, cast<GcMethod>(t, cast<GcPair>(t, pair)->first())->class_()->loader(),
|
||||
referenceName(t, pairSecond(t, pair)));
|
||||
cast<GcByteArray>(t, referenceName(t, pairSecond(t, pair))));
|
||||
|
||||
PROTECT(t, class_);
|
||||
|
||||
@ -3335,8 +3335,8 @@ returnsNext(MyThread* t, object code, unsigned ip)
|
||||
|
||||
bool
|
||||
isTailCall(MyThread* t, object code, unsigned ip, GcMethod* caller,
|
||||
int calleeReturnCode, object calleeClassName,
|
||||
object calleeMethodName, object calleeMethodSpec)
|
||||
int calleeReturnCode, GcByteArray* calleeClassName,
|
||||
GcByteArray* calleeMethodName, GcByteArray* calleeMethodSpec)
|
||||
{
|
||||
return avian::codegen::TailCalls
|
||||
and ((caller->flags() & ACC_SYNCHRONIZED) == 0)
|
||||
@ -3354,8 +3354,8 @@ isTailCall(MyThread* t, object code, unsigned ip, GcMethod* caller, GcMethod* ca
|
||||
{
|
||||
return isTailCall
|
||||
(t, code, ip, caller, callee->returnCode(),
|
||||
reinterpret_cast<object>(callee->class_()->name()), reinterpret_cast<object>(callee->name()),
|
||||
reinterpret_cast<object>(callee->spec()));
|
||||
callee->class_()->name(), callee->name(),
|
||||
callee->spec());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3369,7 +3369,7 @@ isReferenceTailCall(MyThread* t, object code, unsigned ip, GcMethod* caller,
|
||||
|
||||
return isTailCall
|
||||
(t, code, ip, caller, methodReferenceReturnCode(t, calleeReference),
|
||||
c, referenceName(t, calleeReference), referenceSpec(t, calleeReference));
|
||||
cast<GcByteArray>(t, c), cast<GcByteArray>(t, referenceName(t, calleeReference)), cast<GcByteArray>(t, referenceSpec(t, calleeReference)));
|
||||
}
|
||||
|
||||
lir::TernaryOperation toCompilerJumpOp(MyThread* t, unsigned instruction) {
|
||||
@ -4426,7 +4426,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
|
||||
PROTECT(t, reference);
|
||||
|
||||
object field = resolveField(t, context->method, index - 1, false);
|
||||
object field = reinterpret_cast<object>(resolveField(t, context->method, index - 1, false));
|
||||
|
||||
if (LIKELY(field)) {
|
||||
if ((fieldFlags(t, field) & ACC_VOLATILE)
|
||||
@ -5628,7 +5628,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
|
||||
PROTECT(t, reference);
|
||||
|
||||
object field = resolveField(t, context->method, index - 1, false);
|
||||
object field = reinterpret_cast<object>(resolveField(t, context->method, index - 1, false));
|
||||
|
||||
if (LIKELY(field)) {
|
||||
int fieldCode = vm::fieldCode(t, field);
|
||||
@ -7244,7 +7244,7 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
|
||||
}
|
||||
|
||||
if (UNLIKELY(t->exception)) {
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
vm::throw_(t, exception);
|
||||
}
|
||||
@ -7294,7 +7294,7 @@ invokeNativeSlow(MyThread* t, GcMethod* method, void* function)
|
||||
uint64_t
|
||||
invokeNative2(MyThread* t, GcMethod* method)
|
||||
{
|
||||
object native = methodRuntimeDataNative(t, getMethodRuntimeData(t, method));
|
||||
object native = reinterpret_cast<object>(getMethodRuntimeData(t, method)->native());
|
||||
if (nativeFast(t, native)) {
|
||||
return invokeNativeFast(t, method, nativeFunction(t, native));
|
||||
} else {
|
||||
@ -7543,7 +7543,7 @@ walkContinuationBody(MyThread* t, Heap::Walker* w, object c, int start)
|
||||
|
||||
void
|
||||
callContinuation(MyThread* t, object continuation, object result,
|
||||
object exception, void* ip, void* stack)
|
||||
GcThrowable* exception, void* ip, void* stack)
|
||||
{
|
||||
assertT(t, t->exception == 0);
|
||||
|
||||
@ -7582,15 +7582,15 @@ returnClass(MyThread* t, GcMethod* method)
|
||||
|
||||
int8_t* spec = returnSpec(t, method);
|
||||
unsigned length = strlen(reinterpret_cast<char*>(spec));
|
||||
object name;
|
||||
GcByteArray* name;
|
||||
if (*spec == '[') {
|
||||
name = reinterpret_cast<object>(makeByteArray(t, length + 1));
|
||||
memcpy(&byteArrayBody(t, name, 0), spec, length);
|
||||
name = makeByteArray(t, length + 1);
|
||||
memcpy(name->body().begin(), spec, length);
|
||||
} else {
|
||||
assertT(t, *spec == 'L');
|
||||
assertT(t, spec[length - 1] == ';');
|
||||
name = reinterpret_cast<object>(makeByteArray(t, length - 1));
|
||||
memcpy(&byteArrayBody(t, name, 0), spec + 1, length - 2);
|
||||
name = makeByteArray(t, length - 1);
|
||||
memcpy(name->body().begin(), spec + 1, length - 2);
|
||||
}
|
||||
|
||||
return resolveClass(t, method->class_()->loader(), name);
|
||||
@ -7745,7 +7745,7 @@ callContinuation(MyThread* t, object continuation, object result,
|
||||
|
||||
switch (action) {
|
||||
case Call: {
|
||||
callContinuation(t, continuation, result, exception, ip, stack);
|
||||
callContinuation(t, continuation, result, cast<GcThrowable>(t, exception), ip, stack);
|
||||
} break;
|
||||
|
||||
case Unwind: {
|
||||
@ -7783,12 +7783,12 @@ callWithCurrentContinuation(MyThread* t, object receiver)
|
||||
if (m) {
|
||||
setRoot(t, ReceiveMethod, reinterpret_cast<object>(m));
|
||||
|
||||
object continuationClass = reinterpret_cast<object>(type(t, GcContinuation::Type));
|
||||
GcClass* continuationClass = type(t, GcContinuation::Type);
|
||||
|
||||
if (classVmFlags(t, continuationClass) & BootstrapFlag) {
|
||||
if (continuationClass->vmFlags() & BootstrapFlag) {
|
||||
resolveSystemClass
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)),
|
||||
vm::className(t, continuationClass));
|
||||
continuationClass->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8067,7 +8067,7 @@ invoke(Thread* thread, GcMethod* method, ArgumentList* arguments)
|
||||
collect(t, Heap::MinorCollection);
|
||||
}
|
||||
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
vm::throw_(t, exception);
|
||||
}
|
||||
@ -8129,7 +8129,7 @@ class SignalHandler: public SignalRegistrar::Handler {
|
||||
} else {
|
||||
// not enough memory available for a new exception and stack
|
||||
// trace -- use a preallocated instance instead
|
||||
t->exception = vm::root(t, root);
|
||||
t->exception = cast<GcThrowable>(t, vm::root(t, root));
|
||||
}
|
||||
|
||||
// printTrace(t, t->exception);
|
||||
@ -9511,9 +9511,9 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
|
||||
|
||||
t->m->heap->setImmortalHeap(heap, image->heapSize / BytesPerWord);
|
||||
|
||||
t->m->types = bootObject(heap, image->types);
|
||||
t->m->types = reinterpret_cast<GcArray*>(bootObject(heap, image->types));
|
||||
|
||||
t->m->roots = reinterpret_cast<object>(makeArray(t, Machine::RootCount));
|
||||
t->m->roots = makeArray(t, Machine::RootCount);
|
||||
|
||||
setRoot(t, Machine::BootLoader, bootObject(heap, image->bootLoader));
|
||||
setRoot(t, Machine::AppLoader, bootObject(heap, image->appLoader));
|
||||
@ -9561,7 +9561,7 @@ boot(MyThread* t, BootImage* image, uint8_t* code)
|
||||
(t, cast<GcHashMap>(t, classLoaderMap(t, root(t, Machine::AppLoader))), heap,
|
||||
image->heapSize);
|
||||
|
||||
for (unsigned i = 0; i < arrayLength(t, t->m->types); ++i) {
|
||||
for (unsigned i = 0; i < t->m->types->length(); ++i) {
|
||||
resetClassRuntimeState
|
||||
(t, reinterpret_cast<object>(type(t, static_cast<Gc::Type>(i))), heap, image->heapSize);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <avian/util/string.h>
|
||||
#include <avian/util/runtime-array.h>
|
||||
#include <avian/util/list.h>
|
||||
#include <avian/util/slice.h>
|
||||
#include <avian/util/hash.h>
|
||||
|
||||
#include "avian/zlib-custom.h"
|
||||
#include "avian/finder.h"
|
||||
@ -283,7 +285,7 @@ class JarIndex {
|
||||
|
||||
while (p < end) {
|
||||
if (signature(p) == EntrySignature) {
|
||||
index = index->add(Entry(hash(fileName(p), fileNameLength(p)), p));
|
||||
index = index->add(Entry(hash(avian::util::Slice<const uint8_t>(reinterpret_cast<const uint8_t*>(fileName(p)), fileNameLength(p))), p));
|
||||
|
||||
p = endOfEntry(p);
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ class Thread: public vm::Thread {
|
||||
public:
|
||||
|
||||
Thread(Machine* m, GcThread* javaThread, vm::Thread* parent):
|
||||
vm::Thread(m, reinterpret_cast<object>(javaThread), parent),
|
||||
vm::Thread(m, javaThread, parent),
|
||||
ip(0),
|
||||
sp(0),
|
||||
frame(-1),
|
||||
@ -615,7 +615,7 @@ invokeNativeSlow(Thread* t, GcMethod* method, void* function)
|
||||
popFrame(t);
|
||||
|
||||
if (UNLIKELY(t->exception)) {
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
throw_(t, exception);
|
||||
}
|
||||
@ -632,7 +632,7 @@ invokeNative(Thread* t, GcMethod* method)
|
||||
|
||||
resolveNative(t, method);
|
||||
|
||||
object native = methodRuntimeDataNative(t, getMethodRuntimeData(t, method));
|
||||
object native = reinterpret_cast<object>(getMethodRuntimeData(t, method)->native());
|
||||
if (nativeFast(t, native)) {
|
||||
pushFrame(t, method);
|
||||
|
||||
@ -699,7 +699,7 @@ findExceptionHandler(Thread* t, GcMethod* method, unsigned ip)
|
||||
{
|
||||
GcClass* catchType = 0;
|
||||
if (exceptionHandlerCatchType(eh)) {
|
||||
object e = t->exception;
|
||||
GcThrowable* e = t->exception;
|
||||
t->exception = 0;
|
||||
PROTECT(t, e);
|
||||
|
||||
@ -779,7 +779,7 @@ interpret3(Thread* t, const int base)
|
||||
unsigned& sp = t->sp;
|
||||
int& frame = t->frame;
|
||||
object& code = t->code;
|
||||
object& exception = t->exception;
|
||||
GcThrowable*& exception = t->exception;
|
||||
uintptr_t* stack = t->stack;
|
||||
|
||||
code = reinterpret_cast<object>(frameMethod(t, frame)->code());
|
||||
@ -937,7 +937,7 @@ interpret3(Thread* t, const int base)
|
||||
} goto loop;
|
||||
|
||||
case athrow: {
|
||||
exception = popObject(t);
|
||||
exception = cast<GcThrowable>(t, popObject(t));
|
||||
if (UNLIKELY(exception == 0)) {
|
||||
exception = makeThrowable(t, GcNullPointerException::Type);
|
||||
}
|
||||
@ -1458,13 +1458,13 @@ interpret3(Thread* t, const int base)
|
||||
if (LIKELY(peekObject(t, sp - 1))) {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object field = resolveField(t, frameMethod(t, frame), index - 1);
|
||||
object field = reinterpret_cast<object>(resolveField(t, frameMethod(t, frame), index - 1));
|
||||
|
||||
assertT(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
pushField(t, popObject(t), field);
|
||||
} else {
|
||||
@ -1476,7 +1476,7 @@ interpret3(Thread* t, const int base)
|
||||
case getstatic: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object field = resolveField(t, frameMethod(t, frame), index - 1);
|
||||
object field = reinterpret_cast<object>(resolveField(t, frameMethod(t, frame), index - 1));
|
||||
|
||||
assertT(t, fieldFlags(t, field) & ACC_STATIC);
|
||||
|
||||
@ -1484,7 +1484,7 @@ interpret3(Thread* t, const int base)
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
pushField(t, classStaticTable(t, fieldClass(t, field)), field);
|
||||
} goto loop;
|
||||
@ -2429,12 +2429,12 @@ interpret3(Thread* t, const int base)
|
||||
case putfield: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object field = resolveField(t, frameMethod(t, frame), index - 1);
|
||||
object field = reinterpret_cast<object>(resolveField(t, frameMethod(t, frame), index - 1));
|
||||
|
||||
assertT(t, (fieldFlags(t, field) & ACC_STATIC) == 0);
|
||||
PROTECT(t, field);
|
||||
|
||||
{ ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
{ ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
switch (fieldCode(t, field)) {
|
||||
case ByteField:
|
||||
@ -2500,13 +2500,13 @@ interpret3(Thread* t, const int base)
|
||||
case putstatic: {
|
||||
uint16_t index = codeReadInt16(t, code, ip);
|
||||
|
||||
object field = resolveField(t, frameMethod(t, frame), index - 1);
|
||||
object field = reinterpret_cast<object>(resolveField(t, frameMethod(t, frame), index - 1));
|
||||
|
||||
assertT(t, fieldFlags(t, field) & ACC_STATIC);
|
||||
|
||||
PROTECT(t, field);
|
||||
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
initClass(t, cast<GcClass>(t, fieldClass(t, field)));
|
||||
|
||||
@ -2666,7 +2666,7 @@ interpret3(Thread* t, const int base)
|
||||
assertT(t, class_->vmFlags() & BootstrapFlag);
|
||||
|
||||
resolveClass(t, frameMethod(t, frame)->class_()->loader(),
|
||||
reinterpret_cast<object>(class_->name()));
|
||||
class_->name());
|
||||
|
||||
ip -= 3;
|
||||
} goto loop;
|
||||
@ -2738,7 +2738,7 @@ interpret3(Thread* t, const int base)
|
||||
if (eh) {
|
||||
sp = frame + FrameFootprint;
|
||||
ip = exceptionHandlerIp(eh);
|
||||
pushObject(t, exception);
|
||||
pushObject(t, reinterpret_cast<object>(exception));
|
||||
exception = 0;
|
||||
goto loop;
|
||||
}
|
||||
@ -2771,7 +2771,7 @@ interpret(Thread* t)
|
||||
uint64_t r = run(t, interpret2, arguments);
|
||||
if (success) {
|
||||
if (t->exception) {
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
throw_(t, exception);
|
||||
} else {
|
||||
@ -2891,7 +2891,7 @@ invoke(Thread* t, GcMethod* method)
|
||||
class_ = objectClass(t, peekObject(t, t->sp - parameterFootprint));
|
||||
|
||||
if (class_->vmFlags() & BootstrapFlag) {
|
||||
resolveClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), reinterpret_cast<object>(class_->name()));
|
||||
resolveClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), class_->name());
|
||||
}
|
||||
|
||||
if (method->class_()->flags() & ACC_INTERFACE) {
|
||||
@ -2947,7 +2947,7 @@ invoke(Thread* t, GcMethod* method)
|
||||
if (LIKELY(t->exception == 0)) {
|
||||
popFrame(t);
|
||||
} else {
|
||||
object exception = t->exception;
|
||||
GcThrowable* exception = t->exception;
|
||||
t->exception = 0;
|
||||
throw_(t, exception);
|
||||
}
|
||||
|
158
src/jnienv.cpp
158
src/jnienv.cpp
@ -58,7 +58,7 @@ DetachCurrentThread(Machine* m)
|
||||
|
||||
enter(t, Thread::ActiveState);
|
||||
|
||||
threadPeer(t, t->javaThread) = 0;
|
||||
t->javaThread->peer() = 0;
|
||||
|
||||
enter(t, Thread::ZombieState);
|
||||
|
||||
@ -142,7 +142,7 @@ GetStringLength(Thread* t, jstring s)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
return stringLength(t, *s);
|
||||
return cast<GcString>(t, *s)->length(t);
|
||||
}
|
||||
|
||||
const jchar* JNICALL
|
||||
@ -151,8 +151,8 @@ GetStringChars(Thread* t, jstring s, jboolean* isCopy)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
jchar* chars = static_cast<jchar*>
|
||||
(t->m->heap->allocate((stringLength(t, *s) + 1) * sizeof(jchar)));
|
||||
stringChars(t, *s, chars);
|
||||
(t->m->heap->allocate((cast<GcString>(t, *s)->length(t) + 1) * sizeof(jchar)));
|
||||
stringChars(t, cast<GcString>(t, *s), chars);
|
||||
|
||||
if (isCopy) *isCopy = true;
|
||||
return chars;
|
||||
@ -163,7 +163,7 @@ ReleaseStringChars(Thread* t, jstring s, const jchar* chars)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
t->m->heap->free(chars, (stringLength(t, *s) + 1) * sizeof(jchar));
|
||||
t->m->heap->free(chars, (cast<GcString>(t, *s)->length(t) + 1) * sizeof(jchar));
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -171,7 +171,7 @@ GetStringRegion(Thread* t, jstring s, jsize start, jsize length, jchar* dst)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
stringChars(t, *s, start, length, dst);
|
||||
stringChars(t, cast<GcString>(t, *s), start, length, dst);
|
||||
}
|
||||
|
||||
const jchar* JNICALL
|
||||
@ -191,7 +191,7 @@ GetStringCritical(Thread* t, jstring s, jboolean* isCopy)
|
||||
if (objectClass(t, data) == type(t, GcByteArray::Type)) {
|
||||
return GetStringChars(t, s, isCopy);
|
||||
} else {
|
||||
return &charArrayBody(t, data, stringOffset(t, *s));
|
||||
return &charArrayBody(t, data, cast<GcString>(t, *s)->offset(t));
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ GetStringUTFLength(Thread* t, jstring s)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
return stringUTFLength(t, *s);
|
||||
return stringUTFLength(t, cast<GcString>(t, *s));
|
||||
}
|
||||
|
||||
const char* JNICALL
|
||||
@ -220,10 +220,10 @@ GetStringUTFChars(Thread* t, jstring s, jboolean* isCopy)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
int length = stringUTFLength(t, *s);
|
||||
int length = stringUTFLength(t, cast<GcString>(t, *s));
|
||||
char* chars = static_cast<char*>
|
||||
(t->m->heap->allocate(length + 1));
|
||||
stringUTFChars(t, *s, chars, length);
|
||||
stringUTFChars(t, cast<GcString>(t, *s), chars, length);
|
||||
|
||||
if (isCopy) *isCopy = true;
|
||||
return chars;
|
||||
@ -234,7 +234,7 @@ ReleaseStringUTFChars(Thread* t, jstring s, const char* chars)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
t->m->heap->free(chars, stringUTFLength(t, *s) + 1);
|
||||
t->m->heap->free(chars, stringUTFLength(t, cast<GcString>(t, *s)) + 1);
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -243,7 +243,7 @@ GetStringUTFRegion(Thread* t, jstring s, jsize start, jsize length, char* dst)
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
stringUTFChars
|
||||
(t, *s, start, length, dst, stringUTFLength(t, *s, start, length));
|
||||
(t, cast<GcString>(t, *s), start, length, dst, stringUTFLength(t, cast<GcString>(t, *s), start, length));
|
||||
}
|
||||
|
||||
jsize JNICALL
|
||||
@ -266,7 +266,7 @@ newString(Thread* t, uintptr_t* arguments)
|
||||
}
|
||||
|
||||
return reinterpret_cast<uint64_t>
|
||||
(makeLocalReference(t, t->m->classpath->makeString(t, a, 0, size)));
|
||||
(makeLocalReference(t, reinterpret_cast<object>(t->m->classpath->makeString(t, a, 0, size))));
|
||||
}
|
||||
|
||||
jstring JNICALL
|
||||
@ -289,8 +289,8 @@ newStringUTF(Thread* t, uintptr_t* arguments)
|
||||
|
||||
return reinterpret_cast<uint64_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeString
|
||||
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1)));
|
||||
(t, reinterpret_cast<object>(t->m->classpath->makeString
|
||||
(t, array, 0, fieldAtOffset<uintptr_t>(array, BytesPerWord) - 1))));
|
||||
}
|
||||
|
||||
jstring JNICALL
|
||||
@ -355,7 +355,7 @@ findClass(Thread* t, uintptr_t* arguments)
|
||||
t,
|
||||
caller ? t->m->classpath->libraryClassLoader(t, caller) : cast
|
||||
<GcClassLoader>(t, root(t, Machine::AppLoader)),
|
||||
n);
|
||||
cast<GcByteArray>(t, n));
|
||||
|
||||
if (t->m->classpath->mayInitClasses()) {
|
||||
PROTECT(t, c);
|
||||
@ -384,15 +384,15 @@ throwNew(Thread* t, uintptr_t* arguments)
|
||||
PROTECT(t, m);
|
||||
|
||||
if (message) {
|
||||
m = makeString(t, "%s", message);
|
||||
m = reinterpret_cast<object>(makeString(t, "%s", message));
|
||||
}
|
||||
|
||||
object trace = makeTrace(t);
|
||||
PROTECT(t, trace);
|
||||
|
||||
t->exception = make(t, cast<GcClass>(t, jclassVmClass(t, *c)));
|
||||
set(t, t->exception, ThrowableMessage, m);
|
||||
set(t, t->exception, ThrowableTrace, trace);
|
||||
t->exception = cast<GcThrowable>(t, make(t, cast<GcClass>(t, jclassVmClass(t, *c))));
|
||||
set(t, reinterpret_cast<object>(t->exception), ThrowableMessage, m);
|
||||
set(t, reinterpret_cast<object>(t->exception), ThrowableTrace, trace);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -419,7 +419,7 @@ Throw(Thread* t, jthrowable throwable)
|
||||
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
t->exception = *throwable;
|
||||
t->exception = cast<GcThrowable>(t, *throwable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -523,10 +523,10 @@ IsAssignableFrom(Thread* t, jclass b, jclass a)
|
||||
GcMethod*
|
||||
findMethod(Thread* t, jclass c, const char* name, const char* spec)
|
||||
{
|
||||
object n = makeByteArray(t, "%s", name);
|
||||
GcByteArray* n = makeByteArray(t, "%s", name);
|
||||
PROTECT(t, n);
|
||||
|
||||
object s = makeByteArray(t, "%s", spec);
|
||||
GcByteArray* s = makeByteArray(t, "%s", spec);
|
||||
return vm::findMethod(t, cast<GcClass>(t, jclassVmClass(t, *c)), n, s);
|
||||
}
|
||||
|
||||
@ -1484,9 +1484,9 @@ CallStaticVoidMethodA(Thread* t, jclass, jmethodID m, const jvalue* a)
|
||||
}
|
||||
|
||||
jint
|
||||
fieldID(Thread* t, object field)
|
||||
fieldID(Thread* t, GcField* field)
|
||||
{
|
||||
int id = fieldNativeID(t, field);
|
||||
int id = field->nativeID();
|
||||
|
||||
loadMemoryBarrier();
|
||||
|
||||
@ -1495,17 +1495,17 @@ fieldID(Thread* t, object field)
|
||||
|
||||
ACQUIRE(t, t->m->referenceLock);
|
||||
|
||||
if (fieldNativeID(t, field) == 0) {
|
||||
if (field->nativeID() == 0) {
|
||||
setRoot(t, Machine::JNIFieldTable, reinterpret_cast<object>(vectorAppend
|
||||
(t, cast<GcVector>(t, root(t, Machine::JNIFieldTable)), field)));
|
||||
(t, cast<GcVector>(t, root(t, Machine::JNIFieldTable)), reinterpret_cast<object>(field))));
|
||||
|
||||
storeStoreMemoryBarrier();
|
||||
|
||||
fieldNativeID(t, field) = vectorSize(t, root(t, Machine::JNIFieldTable));
|
||||
field->nativeID() = vectorSize(t, root(t, Machine::JNIFieldTable));
|
||||
}
|
||||
}
|
||||
|
||||
return fieldNativeID(t, field);
|
||||
return field->nativeID();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -1557,7 +1557,7 @@ getObjectField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference(t, fieldAtOffset<object>(*o, fieldOffset(t, field))));
|
||||
@ -1579,7 +1579,7 @@ getBooleanField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jboolean>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1600,7 +1600,7 @@ getByteField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jbyte>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1621,7 +1621,7 @@ getCharField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jchar>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1642,7 +1642,7 @@ getShortField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jshort>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1663,7 +1663,7 @@ getIntField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jint>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1684,7 +1684,7 @@ getLongField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jlong>(*o, fieldOffset(t, field));
|
||||
}
|
||||
@ -1705,7 +1705,7 @@ getFloatField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return floatToBits(fieldAtOffset<jfloat>(*o, fieldOffset(t, field)));
|
||||
}
|
||||
@ -1726,7 +1726,7 @@ getDoubleField(Thread* t, uintptr_t* arguments)
|
||||
object field = getField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return doubleToBits(fieldAtOffset<jdouble>(*o, fieldOffset(t, field)));
|
||||
}
|
||||
@ -1748,7 +1748,7 @@ setObjectField(Thread* t, uintptr_t* arguments)
|
||||
jobject v = reinterpret_cast<jobject>(arguments[2]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
set(t, *o, fieldOffset(t, field), (v ? *v : 0));
|
||||
|
||||
@ -1773,7 +1773,7 @@ setBooleanField(Thread* t, uintptr_t* arguments)
|
||||
jboolean v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jboolean>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1798,7 +1798,7 @@ setByteField(Thread* t, uintptr_t* arguments)
|
||||
jbyte v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jbyte>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1823,7 +1823,7 @@ setCharField(Thread* t, uintptr_t* arguments)
|
||||
jchar v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jchar>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1848,7 +1848,7 @@ setShortField(Thread* t, uintptr_t* arguments)
|
||||
jshort v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jshort>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1873,7 +1873,7 @@ setIntField(Thread* t, uintptr_t* arguments)
|
||||
jint v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jint>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1898,7 +1898,7 @@ setLongField(Thread* t, uintptr_t* arguments)
|
||||
jlong v; memcpy(&v, arguments + 2, sizeof(jlong));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jlong>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1924,7 +1924,7 @@ setFloatField(Thread* t, uintptr_t* arguments)
|
||||
jfloat v = bitsToFloat(arguments[2]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jfloat>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1949,7 +1949,7 @@ setDoubleField(Thread* t, uintptr_t* arguments)
|
||||
jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jdouble>(*o, fieldOffset(t, field)) = v;
|
||||
|
||||
@ -1989,7 +1989,7 @@ getStaticObjectField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
@ -2016,7 +2016,7 @@ getStaticBooleanField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jboolean>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2041,7 +2041,7 @@ getStaticByteField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jbyte>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2066,7 +2066,7 @@ getStaticCharField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jchar>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2091,7 +2091,7 @@ getStaticShortField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jshort>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2116,7 +2116,7 @@ getStaticIntField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jint>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2141,7 +2141,7 @@ getStaticLongField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return fieldAtOffset<jlong>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field));
|
||||
@ -2166,7 +2166,7 @@ getStaticFloatField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return floatToBits
|
||||
(fieldAtOffset<jfloat>
|
||||
@ -2192,7 +2192,7 @@ getStaticDoubleField(Thread* t, uintptr_t* arguments)
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, field);
|
||||
ACQUIRE_FIELD_FOR_READ(t, cast<GcField>(t, field));
|
||||
|
||||
return doubleToBits
|
||||
(fieldAtOffset<jdouble>
|
||||
@ -2219,7 +2219,7 @@ setStaticObjectField(Thread* t, uintptr_t* arguments)
|
||||
jobject v = reinterpret_cast<jobject>(arguments[2]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
set(t, classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field),
|
||||
(v ? *v : 0));
|
||||
@ -2248,7 +2248,7 @@ setStaticBooleanField(Thread* t, uintptr_t* arguments)
|
||||
jboolean v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jboolean>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2277,7 +2277,7 @@ setStaticByteField(Thread* t, uintptr_t* arguments)
|
||||
jbyte v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jbyte>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2306,7 +2306,7 @@ setStaticCharField(Thread* t, uintptr_t* arguments)
|
||||
jchar v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jchar>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2335,7 +2335,7 @@ setStaticShortField(Thread* t, uintptr_t* arguments)
|
||||
jshort v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jshort>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2364,7 +2364,7 @@ setStaticIntField(Thread* t, uintptr_t* arguments)
|
||||
jint v = arguments[2];
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jint>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2393,7 +2393,7 @@ setStaticLongField(Thread* t, uintptr_t* arguments)
|
||||
jlong v; memcpy(&v, arguments + 2, sizeof(jlong));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jlong>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2423,7 +2423,7 @@ setStaticFloatField(Thread* t, uintptr_t* arguments)
|
||||
jfloat v = bitsToFloat(arguments[2]);
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jfloat>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2452,7 +2452,7 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments)
|
||||
jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, cast<GcField>(t, field));
|
||||
|
||||
fieldAtOffset<jdouble>
|
||||
(classStaticTable(t, jclassVmClass(t, *c)), fieldOffset(t, field)) = v;
|
||||
@ -2539,7 +2539,7 @@ ExceptionOccurred(Thread* t)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
return makeLocalReference(t, t->exception);
|
||||
return makeLocalReference(t, reinterpret_cast<object>(t->exception));
|
||||
}
|
||||
|
||||
void JNICALL
|
||||
@ -3197,7 +3197,7 @@ fromReflectedMethod(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject m = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
return methodID(t, cast<GcMethod>(t, t->m->classpath->getVMMethod(t, *m)));
|
||||
return methodID(t, t->m->classpath->getVMMethod(t, *m));
|
||||
}
|
||||
|
||||
jmethodID JNICALL
|
||||
@ -3255,7 +3255,7 @@ toReflectedField(Thread* t, uintptr_t* arguments)
|
||||
return reinterpret_cast<uintptr_t>
|
||||
(makeLocalReference
|
||||
(t, t->m->classpath->makeJField
|
||||
(t, isStatic ? getStaticField(t, f) : getField(t, f))));
|
||||
(t, cast<GcField>(t, isStatic ? getStaticField(t, f) : getField(t, f)))));
|
||||
}
|
||||
|
||||
jobject JNICALL
|
||||
@ -3318,7 +3318,7 @@ UnregisterNatives(Thread* t, jclass c)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
unregisterNatives(t, *c);
|
||||
unregisterNatives(t, cast<GcClass>(t, *c));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -3393,7 +3393,7 @@ pushLocalFrame(Thread* t, uintptr_t* arguments)
|
||||
if (t->m->processor->pushLocalFrame(t, arguments[0])) {
|
||||
return 1;
|
||||
} else {
|
||||
throw_(t, root(t, Machine::OutOfMemoryError));
|
||||
throw_(t, cast<GcThrowable>(t, root(t, Machine::OutOfMemoryError)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3531,27 +3531,27 @@ append(char** p, const char* value, unsigned length, char tail)
|
||||
uint64_t
|
||||
boot(Thread* t, uintptr_t*)
|
||||
{
|
||||
setRoot(t, Machine::NullPointerException, makeThrowable
|
||||
(t, GcNullPointerException::Type));
|
||||
setRoot(t, Machine::NullPointerException,
|
||||
reinterpret_cast<object>(makeThrowable(t, GcNullPointerException::Type)));
|
||||
|
||||
setRoot(t, Machine::ArithmeticException,
|
||||
makeThrowable(t, GcArithmeticException::Type));
|
||||
reinterpret_cast<object>(makeThrowable(t, GcArithmeticException::Type)));
|
||||
|
||||
setRoot(t, Machine::ArrayIndexOutOfBoundsException,
|
||||
makeThrowable(t, GcArrayIndexOutOfBoundsException::Type));
|
||||
reinterpret_cast<object>(makeThrowable(t, GcArrayIndexOutOfBoundsException::Type)));
|
||||
|
||||
setRoot(t, Machine::OutOfMemoryError,
|
||||
makeThrowable(t, GcOutOfMemoryError::Type));
|
||||
reinterpret_cast<object>(makeThrowable(t, GcOutOfMemoryError::Type)));
|
||||
|
||||
setRoot(t, Machine::Shutdown, makeThrowable(t, GcThrowable::Type));
|
||||
setRoot(t, Machine::Shutdown, reinterpret_cast<object>(makeThrowable(t, GcThrowable::Type)));
|
||||
|
||||
t->m->classpath->preBoot(t);
|
||||
|
||||
t->javaThread = t->m->classpath->makeThread(t, 0);
|
||||
|
||||
threadPeer(t, t->javaThread) = reinterpret_cast<jlong>(t);
|
||||
t->javaThread->peer() = reinterpret_cast<jlong>(t);
|
||||
|
||||
setRoot(t, Machine::FinalizerThread, t->m->classpath->makeThread(t, t));
|
||||
setRoot(t, Machine::FinalizerThread, reinterpret_cast<object>(t->m->classpath->makeThread(t, t)));
|
||||
|
||||
threadDaemon(t, root(t, Machine::FinalizerThread)) = true;
|
||||
|
||||
@ -3559,7 +3559,7 @@ boot(Thread* t, uintptr_t*)
|
||||
|
||||
const char* port = findProperty(t, "avian.trace.port");
|
||||
if (port) {
|
||||
object host = makeString(t, "0.0.0.0");
|
||||
object host = reinterpret_cast<object>(makeString(t, "0.0.0.0"));
|
||||
PROTECT(t, host);
|
||||
|
||||
GcMethod* method = resolveMethod
|
||||
|
376
src/machine.cpp
376
src/machine.cpp
File diff suppressed because it is too large
Load Diff
@ -234,7 +234,7 @@ resolveNative(Thread* t, GcMethod* method)
|
||||
|
||||
initClass(t, method->class_());
|
||||
|
||||
if (methodRuntimeDataNative(t, getMethodRuntimeData(t, method)) == 0) {
|
||||
if (getMethodRuntimeData(t, method)->native() == 0) {
|
||||
object native = resolveNativeMethod(t, method);
|
||||
if (UNLIKELY(native == 0)) {
|
||||
throwNew(t, GcUnsatisfiedLinkError::Type, "%s.%s%s",
|
||||
@ -245,7 +245,7 @@ resolveNative(Thread* t, GcMethod* method)
|
||||
|
||||
PROTECT(t, native);
|
||||
|
||||
object runtimeData = getMethodRuntimeData(t, method);
|
||||
object runtimeData = reinterpret_cast<object>(getMethodRuntimeData(t, method));
|
||||
|
||||
// ensure other threads only see the methodRuntimeDataNative field
|
||||
// populated once the object it points to has been populated:
|
||||
|
@ -655,7 +655,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
|
||||
|
||||
if (objectClass(t, o) == type(t, GcReference::Type)) {
|
||||
o = reinterpret_cast<object>(resolveClass
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), referenceName(t, o)));
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, referenceName(t, o))));
|
||||
|
||||
set(t, reinterpret_cast<object>(addendum->pool()),
|
||||
SingletonBody + (index * BytesPerWord), o);
|
||||
@ -712,7 +712,7 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, object constants)
|
||||
|
||||
image->bootLoader = w->visitRoot(root(t, Machine::BootLoader));
|
||||
image->appLoader = w->visitRoot(root(t, Machine::AppLoader));
|
||||
image->types = w->visitRoot(m->types);
|
||||
image->types = w->visitRoot(reinterpret_cast<object>(m->types));
|
||||
|
||||
m->processor->visitRoots(t, w);
|
||||
|
||||
@ -1332,7 +1332,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
|
||||
|
||||
#include "type-maps.cpp"
|
||||
|
||||
for (unsigned i = 0; i < arrayLength(t, t->m->types); ++i) {
|
||||
for (unsigned i = 0; i < t->m->types->length(); ++i) {
|
||||
Type* source = types[i];
|
||||
unsigned typeCount = 0;
|
||||
unsigned fieldCount = 1;
|
||||
@ -1523,28 +1523,28 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
|
||||
// resolve primitive array classes in case they are needed at
|
||||
// runtime:
|
||||
{ object name = reinterpret_cast<object>(makeByteArray(t, "[B"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[Z"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[S"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[C"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[I"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[J"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[F"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
|
||||
name = reinterpret_cast<object>(makeByteArray(t, "[D"));
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), name, true);
|
||||
resolveSystemClass(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), cast<GcByteArray>(t, name), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,8 @@ class Field {
|
||||
uintptr_t ownerId;
|
||||
bool noassert;
|
||||
bool nogc;
|
||||
bool polyfill;
|
||||
bool threadParam;
|
||||
|
||||
std::string javaSpec;
|
||||
std::string typeName;
|
||||
@ -69,6 +71,8 @@ class Field {
|
||||
ownerId(reinterpret_cast<uintptr_t>(ownerId)),
|
||||
noassert(false),
|
||||
nogc(false),
|
||||
polyfill(false),
|
||||
threadParam(false),
|
||||
javaSpec(javaSpec),
|
||||
typeName(typeName)
|
||||
{
|
||||
@ -83,6 +87,9 @@ class Field {
|
||||
if(nogc) {
|
||||
ss << " nogc";
|
||||
}
|
||||
if(polyfill) {
|
||||
ss << " polyfill";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
@ -416,6 +423,15 @@ class ClassParser {
|
||||
}
|
||||
|
||||
void add(FieldSpec f) {
|
||||
if(f.field->polyfill) {
|
||||
if(fields.find(f.field->name) == fields.end()) {
|
||||
fields[f.field->name] = f.field;
|
||||
cl->fields.push_back(f.field);
|
||||
} else {
|
||||
fields[f.field->name]->threadParam = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(f.aliasName.size() > 0) {
|
||||
if(fields.find(f.aliasName) == fields.end()) {
|
||||
if(fields.find(f.field->name) != fields.end()) {
|
||||
@ -510,6 +526,9 @@ FieldSpec parseField(Module& module, ClassParser& clparser, Object* p)
|
||||
const char* name = string(car(cdr(p)));
|
||||
f = parseField(module, clparser, cdr(cdr(p)));
|
||||
f.aliasName = name;
|
||||
} else if (equal(spec, "polyfill")) {
|
||||
f = parseField(module, clparser, cdr(p));
|
||||
f.field->polyfill = true;
|
||||
} else {
|
||||
return parseVerbatimField(module, clparser, p);
|
||||
}
|
||||
@ -778,13 +797,15 @@ void layoutClass(Class* cl) {
|
||||
for(std::vector<Field*>::iterator it = cl->fields.begin(); it != cl->fields.end(); it++) {
|
||||
Field& f = **it;
|
||||
|
||||
alignment = f.elementSize;
|
||||
offset = (offset + alignment - 1) & ~(alignment - 1);
|
||||
f.offset = offset;
|
||||
if(!f.polyfill) { // polyfills contribute no size
|
||||
alignment = f.elementSize;
|
||||
offset = (offset + alignment - 1) & ~(alignment - 1);
|
||||
f.offset = offset;
|
||||
|
||||
size = f.elementSize;
|
||||
size = f.elementSize;
|
||||
|
||||
offset += size;
|
||||
offset += size;
|
||||
}
|
||||
}
|
||||
if(cl->arrayField) {
|
||||
Field& f = *cl->arrayField;
|
||||
@ -955,7 +976,9 @@ writeAccessors(Output* out, Module& module)
|
||||
for(std::vector<Field*>::iterator it = cl->fields.begin(); it != cl->fields.end(); ++it) {
|
||||
Field& f = **it;
|
||||
|
||||
writeAccessor(out, module, cl, f, false);
|
||||
if(!f.polyfill) {
|
||||
writeAccessor(out, module, cl, f, false);
|
||||
}
|
||||
}
|
||||
if(cl->arrayField) {
|
||||
writeAccessor(out, module, cl, *cl->arrayField, true);
|
||||
@ -1001,10 +1024,12 @@ writeConstructorParameters(Output* out, Module& module, Class* cl)
|
||||
{
|
||||
for(std::vector<Field*>::iterator it = cl->fields.begin(); it != cl->fields.end(); ++it) {
|
||||
Field& f = **it;
|
||||
out->write(", ");
|
||||
writeFieldType(out, module, f);
|
||||
out->write(" ");
|
||||
out->write(obfuscate(f.name));
|
||||
if(!f.polyfill) {
|
||||
out->write(", ");
|
||||
writeFieldType(out, module, f);
|
||||
out->write(" ");
|
||||
out->write(obfuscate(f.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1013,8 +1038,10 @@ writeConstructorArguments(Output* out, Class* cl)
|
||||
{
|
||||
for(std::vector<Field*>::iterator it = cl->fields.begin(); it != cl->fields.end(); ++it) {
|
||||
Field& f = **it;
|
||||
out->write(", ");
|
||||
out->write(obfuscate(f.name));
|
||||
if(!f.polyfill) {
|
||||
out->write(", ");
|
||||
out->write(obfuscate(f.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1023,11 +1050,17 @@ writeConstructorInitializations(Output* out, Class* cl)
|
||||
{
|
||||
for(std::vector<Field*>::iterator it = cl->fields.begin(); it != cl->fields.end(); ++it) {
|
||||
Field& f = **it;
|
||||
out->write(" o->");
|
||||
out->write(obfuscate(f.name));
|
||||
out->write("() = ");
|
||||
out->write(obfuscate(f.name));
|
||||
out->write(";\n");
|
||||
if(!f.polyfill) {
|
||||
out->write(" o->");
|
||||
out->write(obfuscate(f.name));
|
||||
out->write("(");
|
||||
if(f.threadParam) {
|
||||
out->write("t");
|
||||
}
|
||||
out->write(") = ");
|
||||
out->write(obfuscate(f.name));
|
||||
out->write(";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1050,14 +1083,26 @@ void writeClassAccessors(Output* out, Module& module, Class* cl)
|
||||
Field& f = **it;
|
||||
out->write(" ");
|
||||
writeFieldType(out, module, f);
|
||||
out->write("& ");
|
||||
if(!f.polyfill) {
|
||||
out->write("&");
|
||||
}
|
||||
out->write(" ");
|
||||
out->write(obfuscate(f.name));
|
||||
out->write("() { return field_at<");
|
||||
writeFieldType(out, module, f);
|
||||
out->write(">(");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write(capitalize(f.name));
|
||||
out->write("); }\n");
|
||||
if(f.threadParam || f.polyfill) {
|
||||
out->write("(Thread*");
|
||||
} else {
|
||||
out->write("(");
|
||||
}
|
||||
if(f.polyfill) {
|
||||
out->write("); // polyfill, assumed to be implemented elsewhere\n");
|
||||
} else {
|
||||
out->write(") { return field_at<");
|
||||
writeFieldType(out, module, f);
|
||||
out->write(">(");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write(capitalize(f.name));
|
||||
out->write("); }\n");
|
||||
}
|
||||
}
|
||||
if(cl->arrayField) {
|
||||
Field& f = *cl->arrayField;
|
||||
|
@ -181,7 +181,9 @@
|
||||
(type string java/lang/String
|
||||
(alias data object value)
|
||||
(alias length uint32_t count)
|
||||
(alias hashCode uint32_t hash))
|
||||
(alias hashCode uint32_t hash)
|
||||
(polyfill uint32_t offset)
|
||||
(polyfill uint32_t length))
|
||||
|
||||
(type thread java/lang/Thread
|
||||
(require object sleepLock)
|
||||
@ -196,7 +198,7 @@
|
||||
(type stackTraceElement java/lang/StackTraceElement)
|
||||
|
||||
(type throwable java/lang/Throwable
|
||||
(alias message object detailMessage)
|
||||
(alias message string detailMessage)
|
||||
(alias trace object backtrace)
|
||||
(alias trace object stackState))
|
||||
|
||||
|
@ -428,8 +428,8 @@ hashMapInsert(Thread* t, GcHashMap* map, object key, object value,
|
||||
|
||||
GcWeakReference* r = makeWeakReference(t, 0, 0, 0, 0);
|
||||
r->target() = key;
|
||||
r->vmNext() = t->m->weakReferences;
|
||||
t->m->weakReferences = reinterpret_cast<object>(r);
|
||||
r->vmNext() = reinterpret_cast<object>(t->m->weakReferences);
|
||||
t->m->weakReferences = r->as<GcJreference>(t);
|
||||
k = reinterpret_cast<object>(r);
|
||||
|
||||
array = map->array();
|
||||
|
Loading…
Reference in New Issue
Block a user