mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
add process and classpath-avian changes
This commit is contained in:
parent
86d9249f29
commit
9f0327bb9e
@ -61,18 +61,18 @@ class MyClasspath : public Classpath {
|
||||
{
|
||||
PROTECT(t, vmMethod);
|
||||
|
||||
object jmethod = reinterpret_cast<object>(makeJmethod(t, vmMethod, false));
|
||||
GcJmethod* jmethod = makeJmethod(t, vmMethod, false);
|
||||
|
||||
return vmMethod->name()->body()[0] == '<'
|
||||
? reinterpret_cast<object>(makeJconstructor(t, cast<GcJmethod>(t, jmethod))) : jmethod;
|
||||
? reinterpret_cast<object>(makeJconstructor(t, jmethod)) : reinterpret_cast<object>(jmethod);
|
||||
}
|
||||
|
||||
virtual GcMethod*
|
||||
getVMMethod(Thread* t, object jmethod)
|
||||
{
|
||||
return objectClass(t, jmethod) == type(t, GcJmethod::Type)
|
||||
? cast<GcMethod>(t, jmethodVmMethod(t, jmethod))
|
||||
: cast<GcMethod>(t, jmethodVmMethod(t, jconstructorMethod(t, jmethod)));
|
||||
? cast<GcJmethod>(t, jmethod)->vmMethod()
|
||||
: cast<GcJconstructor>(t, jmethod)->method()->vmMethod();
|
||||
}
|
||||
|
||||
virtual object
|
||||
@ -84,7 +84,7 @@ class MyClasspath : public Classpath {
|
||||
virtual GcField*
|
||||
getVMField(Thread* t, object jfield)
|
||||
{
|
||||
return cast<GcField>(t, jfieldVmField(t, jfield));
|
||||
return cast<GcJfield>(t, jfield)->vmField();
|
||||
}
|
||||
|
||||
virtual void
|
||||
@ -492,11 +492,11 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_reflect_Array_makeObjectArray
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object elementType = reinterpret_cast<object>(arguments[0]);
|
||||
GcJclass* elementType = cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]));
|
||||
int length = arguments[1];
|
||||
|
||||
return reinterpret_cast<int64_t>
|
||||
(makeObjectArray(t, cast<GcClass>(t, jclassVmClass(t, elementType)), length));
|
||||
(makeObjectArray(t, elementType->vmClass(), length));
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -587,7 +587,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_java_lang_ClassLoader_load(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object name = reinterpret_cast<object>(arguments[0]);
|
||||
GcString* name = cast<GcString>(t, reinterpret_cast<object>(arguments[0]));
|
||||
|
||||
Thread::LibraryLoadStack stack(
|
||||
t,
|
||||
@ -595,9 +595,9 @@ extern "C" AVIAN_EXPORT void JNICALL
|
||||
|
||||
bool mapName = arguments[2];
|
||||
|
||||
unsigned length = stringLength(t, name);
|
||||
unsigned length = name->length(t);
|
||||
THREAD_RUNTIME_ARRAY(t, char, n, length + 1);
|
||||
stringChars(t, cast<GcString>(t, name), RUNTIME_ARRAY_BODY(n));
|
||||
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
||||
|
||||
loadLibrary(t, "", RUNTIME_ARRAY_BODY(n), mapName, true);
|
||||
}
|
||||
@ -708,13 +708,13 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_java_lang_Thread_enumerate
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object array = reinterpret_cast<object>(*arguments);
|
||||
GcArray* array = cast<GcArray>(t, reinterpret_cast<object>(*arguments));
|
||||
|
||||
ACQUIRE_RAW(t, t->m->stateLock);
|
||||
|
||||
unsigned count = min(t->m->liveCount, objectArrayLength(t, array));
|
||||
unsigned count = min(t->m->liveCount, objectArrayLength(t, reinterpret_cast<object>(array)));
|
||||
unsigned index = 0;
|
||||
local::enumerateThreads(t, t->m->rootThread, array, &index, count);
|
||||
local::enumerateThreads(t, t->m->rootThread, reinterpret_cast<object>(array), &index, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -729,16 +729,14 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_avian_Atomic_getOffset
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
return fieldOffset
|
||||
(t, jfieldVmField(t, reinterpret_cast<object>(arguments[0])));
|
||||
return cast<GcJfield>(t, reinterpret_cast<object>(arguments[0]))->vmField()->offset();
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_objectFieldOffset
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
return fieldOffset
|
||||
(t, jfieldVmField(t, reinterpret_cast<object>(arguments[1])));
|
||||
return cast<GcJfield>(t, reinterpret_cast<object>(arguments[1]))->vmField()->offset();
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
@ -786,10 +784,12 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_avian_Classes_makeMethod
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object method = arrayBody
|
||||
(t, classMethodTable
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0]))),
|
||||
arguments[1]);
|
||||
GcMethod* method = cast<GcMethod>(
|
||||
t,
|
||||
cast<GcArray>(t,
|
||||
cast<GcJclass>(t, reinterpret_cast<object>(arguments[0]))
|
||||
->vmClass()
|
||||
->methodTable())->body()[arguments[1]]);
|
||||
PROTECT(t, method);
|
||||
|
||||
GcClass* c = resolveClass
|
||||
@ -803,8 +803,8 @@ Avian_avian_Classes_makeMethod
|
||||
|
||||
t->m->processor->invoke(t, constructor, instance, method);
|
||||
|
||||
if (byteArrayBody(t, methodName(t, method), 0) == '<') {
|
||||
method = instance;
|
||||
if (method->name()->body()[0] == '<') {
|
||||
object oldInstance = instance;
|
||||
|
||||
c = resolveClass
|
||||
(t, cast<GcClassLoader>(t, root(t, Machine::BootLoader)), "java/lang/reflect/Constructor");
|
||||
@ -814,7 +814,7 @@ Avian_avian_Classes_makeMethod
|
||||
GcMethod* constructor = resolveMethod
|
||||
(t, c, "<init>", "(Ljava/lang/Method;)V");
|
||||
|
||||
t->m->processor->invoke(t, constructor, instance, method);
|
||||
t->m->processor->invoke(t, constructor, instance, oldInstance);
|
||||
}
|
||||
|
||||
return reinterpret_cast<uintptr_t>(instance);
|
||||
|
@ -61,36 +61,36 @@ mangle(int8_t c, char* dst)
|
||||
return 6;
|
||||
|
||||
default:
|
||||
dst[0] = c;
|
||||
dst[0] = c;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
jniNameLength(Thread* t, GcMethod* method, bool decorate)
|
||||
jniNameLength(Thread* t UNUSED, GcMethod* method, bool decorate)
|
||||
{
|
||||
unsigned size = 0;
|
||||
|
||||
object className = reinterpret_cast<object>(method->class_()->name());
|
||||
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
|
||||
size += mangledSize(byteArrayBody(t, className, i));
|
||||
GcByteArray* className = method->class_()->name();
|
||||
for (unsigned i = 0; i < className->length() - 1; ++i) {
|
||||
size += mangledSize(className->body()[i]);
|
||||
}
|
||||
|
||||
++ size;
|
||||
|
||||
object methodName = reinterpret_cast<object>(method->name());
|
||||
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
|
||||
size += mangledSize(byteArrayBody(t, methodName, i));
|
||||
GcByteArray* methodName = method->name();
|
||||
for (unsigned i = 0; i < methodName->length() - 1; ++i) {
|
||||
size += mangledSize(methodName->body()[i]);
|
||||
}
|
||||
|
||||
if (decorate) {
|
||||
size += 2;
|
||||
|
||||
object methodSpec = reinterpret_cast<object>(method->spec());
|
||||
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
|
||||
and byteArrayBody(t, methodSpec, i) != ')'; ++i)
|
||||
GcByteArray* methodSpec = method->spec();
|
||||
for (unsigned i = 1; i < methodSpec->length() - 1
|
||||
and methodSpec->body()[i] != ')'; ++i)
|
||||
{
|
||||
size += mangledSize(byteArrayBody(t, methodSpec, i));
|
||||
size += mangledSize(methodSpec->body()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,33 +98,33 @@ jniNameLength(Thread* t, GcMethod* method, bool decorate)
|
||||
}
|
||||
|
||||
void
|
||||
makeJNIName(Thread* t, const char* prefix, unsigned prefixLength, char* name,
|
||||
makeJNIName(Thread* t UNUSED, const char* prefix, unsigned prefixLength, char* name,
|
||||
GcMethod* method, bool decorate)
|
||||
{
|
||||
memcpy(name, prefix, prefixLength);
|
||||
name += prefixLength;
|
||||
|
||||
object className = reinterpret_cast<object>(method->class_()->name());
|
||||
for (unsigned i = 0; i < byteArrayLength(t, className) - 1; ++i) {
|
||||
name += mangle(byteArrayBody(t, className, i), name);
|
||||
GcByteArray* className = method->class_()->name();
|
||||
for (unsigned i = 0; i < className->length() - 1; ++i) {
|
||||
name += mangle(className->body()[i], name);
|
||||
}
|
||||
|
||||
*(name++) = '_';
|
||||
|
||||
object methodName = reinterpret_cast<object>(method->name());
|
||||
for (unsigned i = 0; i < byteArrayLength(t, methodName) - 1; ++i) {
|
||||
name += mangle(byteArrayBody(t, methodName, i), name);
|
||||
GcByteArray* methodName = method->name();
|
||||
for (unsigned i = 0; i < methodName->length() - 1; ++i) {
|
||||
name += mangle(methodName->body()[i], name);
|
||||
}
|
||||
|
||||
if (decorate) {
|
||||
*(name++) = '_';
|
||||
*(name++) = '_';
|
||||
|
||||
object methodSpec = reinterpret_cast<object>(method->spec());
|
||||
for (unsigned i = 1; i < byteArrayLength(t, methodSpec) - 1
|
||||
and byteArrayBody(t, methodSpec, i) != ')'; ++i)
|
||||
GcByteArray* methodSpec = method->spec();
|
||||
for (unsigned i = 1; i < methodSpec->length() - 1
|
||||
and methodSpec->body()[i] != ')'; ++i)
|
||||
{
|
||||
name += mangle(byteArrayBody(t, methodSpec, i), name);
|
||||
name += mangle(methodSpec->body()[i], name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,18 +245,18 @@ resolveNative(Thread* t, GcMethod* method)
|
||||
|
||||
PROTECT(t, native);
|
||||
|
||||
object runtimeData = reinterpret_cast<object>(getMethodRuntimeData(t, method));
|
||||
GcMethodRuntimeData* runtimeData = getMethodRuntimeData(t, method);
|
||||
|
||||
// ensure other threads only see the methodRuntimeDataNative field
|
||||
// populated once the object it points to has been populated:
|
||||
storeStoreMemoryBarrier();
|
||||
|
||||
set(t, runtimeData, MethodRuntimeDataNative, native);
|
||||
set(t, reinterpret_cast<object>(runtimeData), MethodRuntimeDataNative, native);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
findLineNumber(Thread* t, GcMethod* method, unsigned ip)
|
||||
findLineNumber(Thread* t UNUSED, GcMethod* method, unsigned ip)
|
||||
{
|
||||
if (method->flags() & ACC_NATIVE) {
|
||||
return NativeLine;
|
||||
@ -266,18 +266,17 @@ findLineNumber(Thread* t, GcMethod* method, unsigned ip)
|
||||
// about, so we back up first:
|
||||
-- ip;
|
||||
|
||||
object code = reinterpret_cast<object>(method->code());
|
||||
object lnt = reinterpret_cast<object>(codeLineNumberTable(t, code));
|
||||
GcLineNumberTable* lnt = method->code()->lineNumberTable();
|
||||
if (lnt) {
|
||||
unsigned bottom = 0;
|
||||
unsigned top = lineNumberTableLength(t, lnt);
|
||||
unsigned top = lnt->length();
|
||||
for (unsigned span = top - bottom; span; span = top - bottom) {
|
||||
unsigned middle = bottom + (span / 2);
|
||||
uint64_t ln = lineNumberTableBody(t, lnt, middle);
|
||||
uint64_t ln = lnt->body()[middle];
|
||||
|
||||
if (ip >= lineNumberIp(ln)
|
||||
and (middle + 1 == lineNumberTableLength(t, lnt)
|
||||
or ip < lineNumberIp(lineNumberTableBody(t, lnt, middle + 1))))
|
||||
and (middle + 1 == lnt->length()
|
||||
or ip < lineNumberIp(lnt->body()[middle + 1])))
|
||||
{
|
||||
return lineNumberLine(ln);
|
||||
} else if (ip < lineNumberIp(ln)) {
|
||||
@ -287,8 +286,8 @@ findLineNumber(Thread* t, GcMethod* method, unsigned ip)
|
||||
}
|
||||
}
|
||||
|
||||
if (top < lineNumberTableLength(t, lnt)) {
|
||||
return lineNumberLine(lineNumberTableBody(t, lnt, top));
|
||||
if (top < lnt->length()) {
|
||||
return lineNumberLine(lnt->body()[top]);
|
||||
} else {
|
||||
return UnknownLine;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user