2009-03-15 18:02:36 +00:00
|
|
|
/* Copyright (c) 2008-2009, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2007-07-06 23:50:26 +00:00
|
|
|
#include "machine.h"
|
2007-07-24 01:44:20 +00:00
|
|
|
#include "constants.h"
|
2007-09-24 01:39:03 +00:00
|
|
|
#include "processor.h"
|
2009-08-10 13:56:16 +00:00
|
|
|
#include "util.h"
|
2007-07-06 15:24:06 +00:00
|
|
|
|
2007-07-24 01:44:20 +00:00
|
|
|
using namespace vm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t
|
|
|
|
search(Thread* t, object name, object (*op)(Thread*, object),
|
2007-09-18 23:30:09 +00:00
|
|
|
bool replaceDots)
|
2007-07-07 23:47:35 +00:00
|
|
|
{
|
2007-09-18 23:30:09 +00:00
|
|
|
if (LIKELY(name)) {
|
2009-06-11 23:13:25 +00:00
|
|
|
PROTECT(t, name);
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
object n = makeByteArray(t, stringLength(t, name) + 1);
|
2007-09-18 23:30:09 +00:00
|
|
|
char* s = reinterpret_cast<char*>(&byteArrayBody(t, n, 0));
|
2009-05-26 02:02:25 +00:00
|
|
|
stringChars(t, name, s);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
|
|
|
if (replaceDots) {
|
|
|
|
replace('.', '/', s);
|
|
|
|
}
|
|
|
|
|
|
|
|
object r = op(t, n);
|
|
|
|
if (t->exception) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(r);
|
2007-09-18 23:30:09 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-11 22:48:39 +00:00
|
|
|
void
|
|
|
|
enumerateThreads(Thread* t, Thread* x, object array, unsigned* index,
|
|
|
|
unsigned limit)
|
|
|
|
{
|
|
|
|
if (*index < limit) {
|
|
|
|
set(t, array, ArrayBody + (*index * BytesPerWord), x->javaThread);
|
2008-04-21 22:36:13 +00:00
|
|
|
++ (*index);
|
2008-04-11 22:48:39 +00:00
|
|
|
|
|
|
|
if (x->peer) enumerateThreads(t, x->peer, array, index, limit);
|
|
|
|
|
|
|
|
if (x->child) enumerateThreads(t, x->child, array, index, limit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-04 23:19:48 +00:00
|
|
|
bool
|
|
|
|
compatibleArrayTypes(Thread* t, object a, object b)
|
|
|
|
{
|
|
|
|
return classArrayElementSize(t, a)
|
|
|
|
and classArrayElementSize(t, b)
|
|
|
|
and (a == b
|
|
|
|
or (not ((classVmFlags(t, a) & PrimitiveFlag)
|
|
|
|
or (classVmFlags(t, b) & PrimitiveFlag))));
|
|
|
|
}
|
|
|
|
|
2009-06-11 00:15:00 +00:00
|
|
|
void
|
|
|
|
runOnLoadIfFound(Thread* t, System::Library* library)
|
|
|
|
{
|
|
|
|
void* p = library->resolve("JNI_OnLoad");
|
|
|
|
if (p) {
|
2009-08-03 16:56:43 +00:00
|
|
|
jint (JNICALL * JNI_OnLoad)(Machine*, void*);
|
|
|
|
memcpy(&JNI_OnLoad, &p, sizeof(void*));
|
|
|
|
JNI_OnLoad(t->m, 0);
|
2009-06-11 00:15:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
} // namespace
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Object_toString
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-09-18 23:30:09 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned hash = objectHash(t, this_);
|
2007-07-07 23:47:35 +00:00
|
|
|
object s = makeString
|
2007-08-22 04:02:17 +00:00
|
|
|
(t, "%s@0x%x",
|
2009-05-26 02:02:25 +00:00
|
|
|
&byteArrayBody(t, className(t, objectClass(t, this_)), 0),
|
2007-08-22 04:02:17 +00:00
|
|
|
hash);
|
2007-07-07 23:47:35 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(s);
|
2007-07-07 23:47:35 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Object_getClass
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-12 23:46:08 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(objectClass(t, this_));
|
2007-07-12 23:46:08 +00:00
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Object_wait
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-07 23:47:35 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int64_t milliseconds; memcpy(&milliseconds, arguments + 1, 8);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
vm::wait(t, this_, milliseconds);
|
2007-07-07 23:47:35 +00:00
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Object_notify
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-07 23:47:35 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
notify(t, this_);
|
2007-07-07 23:47:35 +00:00
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Object_notifyAll
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-07 23:47:35 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
notifyAll(t, this_);
|
2007-08-13 00:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 23:19:18 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Object_hashCode
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-13 00:50:25 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return objectHash(t, this_);
|
2007-07-07 23:47:35 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Object_clone
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-15 01:14:55 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object o = reinterpret_cast<object>(arguments[0]);
|
|
|
|
PROTECT(t, o);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
object class_ = objectClass(t, o);
|
|
|
|
unsigned size = baseSize(t, o, class_) * BytesPerWord;
|
2007-09-26 19:45:52 +00:00
|
|
|
object clone;
|
|
|
|
|
|
|
|
if (classArrayElementSize(t, class_)) {
|
2007-10-28 01:54:30 +00:00
|
|
|
clone = static_cast<object>(allocate(t, size, classObjectMask(t, class_)));
|
2009-05-26 02:02:25 +00:00
|
|
|
memcpy(clone, o, size);
|
2007-09-27 22:10:29 +00:00
|
|
|
// clear any object header flags:
|
2009-05-26 02:02:25 +00:00
|
|
|
setObjectClass(t, o, objectClass(t, o));
|
2007-09-26 19:45:52 +00:00
|
|
|
} else {
|
2007-11-27 01:40:47 +00:00
|
|
|
clone = make(t, class_);
|
2007-09-26 19:45:52 +00:00
|
|
|
memcpy(reinterpret_cast<void**>(clone) + 1,
|
2009-05-26 02:02:25 +00:00
|
|
|
reinterpret_cast<void**>(o) + 1,
|
2007-09-26 19:45:52 +00:00
|
|
|
size - BytesPerWord);
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(clone);
|
2007-08-15 01:14:55 +00:00
|
|
|
}
|
|
|
|
|
2009-09-19 22:21:15 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
Avian_avian_SystemClassLoader_acquireClassLock
|
2009-10-14 00:42:49 +00:00
|
|
|
(Thread* t, object, uintptr_t*)
|
2009-09-19 22:21:15 +00:00
|
|
|
{
|
|
|
|
acquire(t, t->m->classLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
Avian_avian_SystemClassLoader_releaseClassLock
|
2009-10-14 00:42:49 +00:00
|
|
|
(Thread* t, object, uintptr_t*)
|
2009-09-19 22:21:15 +00:00
|
|
|
{
|
|
|
|
release(t, t->m->classLock);
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-09-19 22:21:15 +00:00
|
|
|
Avian_avian_SystemClassLoader_defineClass
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-10 23:45:47 +00:00
|
|
|
{
|
2009-08-10 13:56:16 +00:00
|
|
|
object loader = reinterpret_cast<object>(arguments[0]);
|
|
|
|
PROTECT(t, loader);
|
|
|
|
|
|
|
|
object b = reinterpret_cast<object>(arguments[1]);
|
|
|
|
int offset = arguments[2];
|
|
|
|
int length = arguments[3];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2008-01-13 22:05:08 +00:00
|
|
|
uint8_t* buffer = static_cast<uint8_t*>
|
2008-04-13 18:15:04 +00:00
|
|
|
(t->m->heap->allocate(length));
|
2009-05-26 02:02:25 +00:00
|
|
|
memcpy(buffer, &byteArrayBody(t, b, offset), length);
|
2009-08-10 13:56:16 +00:00
|
|
|
object c = parseClass(t, loader, buffer, length);
|
2008-04-13 18:15:04 +00:00
|
|
|
t->m->heap->free(buffer, length);
|
2009-08-10 13:56:16 +00:00
|
|
|
|
|
|
|
if (c) {
|
2009-09-03 15:06:04 +00:00
|
|
|
if (getClassLoaderMap(t, loader) == 0) {
|
2009-08-11 15:25:35 +00:00
|
|
|
PROTECT(t, c);
|
|
|
|
object map = makeHashMap(t, 0, 0);
|
|
|
|
set(t, loader, ClassLoaderMap, map);
|
|
|
|
}
|
|
|
|
|
2009-09-03 15:06:04 +00:00
|
|
|
hashMapInsert(t, getClassLoaderMap(t, loader), className(t, c), c,
|
2009-08-10 13:56:16 +00:00
|
|
|
byteArrayHash);
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(c);
|
2007-08-10 23:45:47 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-05-26 03:36:29 +00:00
|
|
|
Avian_avian_SystemClassLoader_findLoadedClass
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-24 01:44:20 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object name = reinterpret_cast<object>(arguments[1]);
|
2007-07-24 01:44:20 +00:00
|
|
|
|
2009-08-10 13:56:16 +00:00
|
|
|
return search(t, name, findLoadedSystemClass, true);
|
2007-07-30 23:19:05 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-05-26 03:36:29 +00:00
|
|
|
Avian_avian_SystemClassLoader_findClass
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-30 23:19:05 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object name = reinterpret_cast<object>(arguments[1]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-08-10 13:56:16 +00:00
|
|
|
return search(t, name, resolveSystemClass, true);
|
2007-07-30 23:19:05 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-05-26 03:36:29 +00:00
|
|
|
Avian_avian_SystemClassLoader_resourceExists
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-30 23:19:05 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object name = reinterpret_cast<object>(arguments[1]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-08-10 23:45:47 +00:00
|
|
|
if (LIKELY(name)) {
|
2009-08-27 00:26:44 +00:00
|
|
|
RUNTIME_ARRAY(char, n, stringLength(t, name) + 1);
|
|
|
|
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
|
|
|
return t->m->finder->exists(RUNTIME_ARRAY_BODY(n));
|
2007-08-10 23:45:47 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-07-30 23:19:05 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_io_ObjectInputStream_makeInstance
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-13 00:50:25 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object c = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(make(t, c));
|
2007-08-13 00:50:25 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Class_primitiveClass
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-28 16:55:24 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
char name = arguments[0];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-07-28 16:55:24 +00:00
|
|
|
switch (name) {
|
|
|
|
case 'B':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JbyteType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'C':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JcharType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'D':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JdoubleType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'F':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JfloatType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'I':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JintType));
|
2007-07-29 23:32:23 +00:00
|
|
|
case 'J':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JlongType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'S':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JshortType));
|
2007-07-28 16:55:24 +00:00
|
|
|
case 'V':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JvoidType));
|
2007-07-29 23:32:23 +00:00
|
|
|
case 'Z':
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(arrayBody(t, t->m->types, Machine::JbooleanType));
|
2007-07-28 16:55:24 +00:00
|
|
|
default:
|
|
|
|
t->exception = makeIllegalArgumentException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Class_initialize
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-01 23:48:36 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
initClass(t, this_);
|
2007-08-01 23:48:36 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Class_isAssignableFrom
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-24 01:44:20 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
|
|
|
object that = reinterpret_cast<object>(arguments[1]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-07-24 01:44:20 +00:00
|
|
|
if (LIKELY(that)) {
|
2009-05-26 02:02:25 +00:00
|
|
|
return vm::isAssignableFrom(t, this_, that);
|
2007-07-24 01:44:20 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Field_getPrimitive
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object instance = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int code = arguments[1];
|
|
|
|
int offset = arguments[2];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-08-18 17:15:03 +00:00
|
|
|
switch (code) {
|
|
|
|
case ByteField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<int8_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case BooleanField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<uint8_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case CharField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<uint16_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case ShortField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<int16_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case IntField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<int32_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case LongField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<int64_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case FloatField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<uint32_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
case DoubleField:
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<uint64_t>(instance, offset);
|
2007-08-18 17:15:03 +00:00
|
|
|
default:
|
|
|
|
abort(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Field_getObject
|
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-07-24 01:44:20 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object instance = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int offset = arguments[1];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(cast<object>(instance, offset));
|
2007-08-18 17:15:03 +00:00
|
|
|
}
|
2007-07-24 01:44:20 +00:00
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_reflect_Field_setPrimitive
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object instance = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int code = arguments[1];
|
|
|
|
int offset = arguments[2];
|
|
|
|
int64_t value; memcpy(&value, arguments + 3, 8);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-08-18 17:15:03 +00:00
|
|
|
switch (code) {
|
|
|
|
case ByteField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<int8_t>(instance, offset) = static_cast<int8_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case BooleanField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<uint8_t>(instance, offset) = static_cast<uint8_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case CharField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<uint16_t>(instance, offset) = static_cast<uint16_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case ShortField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<int16_t>(instance, offset) = static_cast<int16_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case IntField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<int32_t>(instance, offset) = static_cast<int32_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case LongField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<int64_t>(instance, offset) = static_cast<int64_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case FloatField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<uint32_t>(instance, offset) = static_cast<uint32_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
case DoubleField:
|
2009-05-26 02:02:25 +00:00
|
|
|
cast<uint64_t>(instance, offset) = static_cast<uint64_t>(value);
|
2007-08-18 17:15:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort(t);
|
2007-07-27 23:56:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_reflect_Field_setObject
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-27 23:56:19 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object instance = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int offset = arguments[1];
|
|
|
|
object value = reinterpret_cast<object>(arguments[2]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
set(t, instance, offset, value);
|
2007-07-24 01:44:20 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Constructor_make
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-27 02:39:53 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object c = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(make(t, c));
|
2007-07-27 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Method_getCaller
|
|
|
|
(Thread* t, object, uintptr_t*)
|
2007-07-30 23:19:05 +00:00
|
|
|
{
|
2007-11-25 23:00:55 +00:00
|
|
|
class Visitor: public Processor::StackVisitor {
|
|
|
|
public:
|
|
|
|
Visitor(Thread* t): t(t), method(0), count(0) { }
|
|
|
|
|
|
|
|
virtual bool visit(Processor::StackWalker* walker) {
|
|
|
|
if (count == 2) {
|
|
|
|
method = walker->method();
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
++ count;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread* t;
|
|
|
|
object method;
|
|
|
|
unsigned count;
|
|
|
|
} v(t);
|
2007-09-24 01:39:03 +00:00
|
|
|
|
2007-11-25 23:00:55 +00:00
|
|
|
t->m->processor->walkStack(t, &v);
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(v.method);
|
2007-07-30 23:19:05 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Method_invoke
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-24 01:44:20 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object method = reinterpret_cast<object>(arguments[0]);
|
|
|
|
object instance = reinterpret_cast<object>(arguments[1]);
|
|
|
|
object args = reinterpret_cast<object>(arguments[2]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
object v = t->m->processor->invokeArray(t, method, instance, args);
|
2007-08-18 17:53:30 +00:00
|
|
|
if (t->exception) {
|
|
|
|
t->exception = makeInvocationTargetException(t, t->exception);
|
2007-07-24 01:44:20 +00:00
|
|
|
}
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(v);
|
2007-07-24 01:44:20 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Array_getLength
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-27 02:39:53 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object array = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-07-27 02:39:53 +00:00
|
|
|
if (LIKELY(array)) {
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned elementSize = classArrayElementSize(t, objectClass(t, array));
|
2007-07-27 02:39:53 +00:00
|
|
|
|
|
|
|
if (LIKELY(elementSize)) {
|
2009-05-26 02:02:25 +00:00
|
|
|
return cast<uintptr_t>(array, BytesPerWord);
|
2007-07-27 02:39:53 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeIllegalArgumentException(t);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_reflect_Array_makeObjectArray
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-27 02:39:53 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object elementType = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int length = arguments[1];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-08-10 13:56:16 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(makeObjectArray(t, classLoader(t, elementType), elementType, length));
|
2007-07-27 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Float_floatToRawIntBits
|
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
return static_cast<int32_t>(*arguments);
|
2007-08-18 17:15:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Float_intBitsToFloat
|
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
return static_cast<int32_t>(*arguments);
|
2007-08-18 17:15:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Double_doubleToRawLongBits
|
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t v; memcpy(&v, arguments, 8);
|
|
|
|
return v;
|
2007-08-18 17:15:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Double_longBitsToDouble
|
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-18 17:15:03 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t v; memcpy(&v, arguments, 8);
|
|
|
|
return v;
|
2007-08-18 17:15:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_String_intern
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-29 00:02:32 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object this_ = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(intern(t, this_));
|
2007-07-29 00:02:32 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_System_getVMProperty
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-27 13:46:17 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object name = reinterpret_cast<object>(arguments[0]);
|
|
|
|
object found = reinterpret_cast<object>(arguments[1]);
|
|
|
|
PROTECT(t, found);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned length = stringLength(t, name);
|
2009-08-27 00:26:44 +00:00
|
|
|
RUNTIME_ARRAY(char, n, length + 1);
|
|
|
|
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
2007-08-27 13:46:17 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t r = 0;
|
2009-08-27 00:26:44 +00:00
|
|
|
if (::strcmp(RUNTIME_ARRAY_BODY(n), "java.lang.classpath") == 0) {
|
2009-05-26 02:02:25 +00:00
|
|
|
r = reinterpret_cast<int64_t>(makeString(t, "%s", t->m->finder->path()));
|
2009-08-27 00:26:44 +00:00
|
|
|
} else if (::strcmp(RUNTIME_ARRAY_BODY(n), "avian.version") == 0) {
|
2009-05-26 02:02:25 +00:00
|
|
|
r = reinterpret_cast<int64_t>(makeString(t, AVIAN_VERSION));
|
2009-08-27 00:26:44 +00:00
|
|
|
} else if (::strcmp(RUNTIME_ARRAY_BODY(n), "file.encoding") == 0) {
|
2009-05-26 02:02:25 +00:00
|
|
|
r = reinterpret_cast<int64_t>(makeString(t, "ASCII"));
|
2008-11-11 15:20:49 +00:00
|
|
|
} else {
|
2009-08-27 00:26:44 +00:00
|
|
|
const char* v = findProperty(t, RUNTIME_ARRAY_BODY(n));
|
2008-11-11 15:20:49 +00:00
|
|
|
if (v) {
|
2009-05-26 02:02:25 +00:00
|
|
|
r = reinterpret_cast<int64_t>(makeString(t, v));
|
2008-11-11 15:20:49 +00:00
|
|
|
}
|
2007-10-26 18:13:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (r) {
|
2009-05-26 02:02:25 +00:00
|
|
|
booleanArrayBody(t, found, 0) = true;
|
2007-08-27 13:46:17 +00:00
|
|
|
}
|
2007-10-26 18:13:21 +00:00
|
|
|
|
|
|
|
return r;
|
2007-08-27 13:46:17 +00:00
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_System_arraycopy
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-06 15:24:06 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object src = reinterpret_cast<object>(arguments[0]);
|
|
|
|
int32_t srcOffset = arguments[1];
|
|
|
|
object dst = reinterpret_cast<object>(arguments[2]);
|
|
|
|
int32_t dstOffset = arguments[3];
|
|
|
|
int32_t length = arguments[4];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-07-07 23:47:35 +00:00
|
|
|
if (LIKELY(src and dst)) {
|
2009-06-04 23:19:48 +00:00
|
|
|
if (LIKELY(compatibleArrayTypes
|
|
|
|
(t, objectClass(t, src), objectClass(t, dst))))
|
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned elementSize = classArrayElementSize(t, objectClass(t, src));
|
2007-07-07 23:47:35 +00:00
|
|
|
|
|
|
|
if (LIKELY(elementSize)) {
|
2009-05-26 02:02:25 +00:00
|
|
|
intptr_t sl = cast<uintptr_t>(src, BytesPerWord);
|
|
|
|
intptr_t dl = cast<uintptr_t>(dst, BytesPerWord);
|
2007-07-07 23:47:35 +00:00
|
|
|
if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl and
|
2007-07-11 01:38:06 +00:00
|
|
|
dstOffset >= 0 and dstOffset + length <= dl))
|
2007-07-07 23:47:35 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
uint8_t* sbody = &cast<uint8_t>(src, ArrayBody);
|
|
|
|
uint8_t* dbody = &cast<uint8_t>(dst, ArrayBody);
|
|
|
|
if (src == dst) {
|
2007-07-22 03:47:08 +00:00
|
|
|
memmove(dbody + (dstOffset * elementSize),
|
|
|
|
sbody + (srcOffset * elementSize),
|
|
|
|
length * elementSize);
|
|
|
|
} else {
|
|
|
|
memcpy(dbody + (dstOffset * elementSize),
|
|
|
|
sbody + (srcOffset * elementSize),
|
|
|
|
length * elementSize);
|
|
|
|
}
|
2007-10-13 21:47:45 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
if (classObjectMask(t, objectClass(t, dst))) {
|
|
|
|
mark(t, dst, ArrayBody + (dstOffset * BytesPerWord), length);
|
2007-10-13 21:47:45 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 23:47:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return;
|
|
|
|
}
|
2007-07-06 15:24:06 +00:00
|
|
|
|
2007-07-07 23:47:35 +00:00
|
|
|
t->exception = makeArrayStoreException(t);
|
2007-07-06 15:24:06 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_System_identityHashCode
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-13 00:50:25 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object o = reinterpret_cast<object>(arguments[0]);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-08-13 00:50:25 +00:00
|
|
|
if (LIKELY(o)) {
|
2009-05-26 02:02:25 +00:00
|
|
|
return objectHash(t, o);
|
2007-08-13 00:50:25 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Runtime_load
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-21 17:50:26 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object name = reinterpret_cast<object>(arguments[0]);
|
|
|
|
bool mapName = arguments[1];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned length = stringLength(t, name);
|
2009-08-27 00:26:44 +00:00
|
|
|
RUNTIME_ARRAY(char, n, length + 1);
|
|
|
|
stringChars(t, name, RUNTIME_ARRAY_BODY(n));
|
2009-05-26 02:02:25 +00:00
|
|
|
|
|
|
|
ACQUIRE(t, t->m->classLock);
|
2007-07-21 17:50:26 +00:00
|
|
|
|
2008-11-11 15:20:49 +00:00
|
|
|
const char* builtins = findProperty(t, "avian.builtins");
|
|
|
|
if (mapName and builtins) {
|
|
|
|
const char* s = builtins;
|
2007-10-23 20:05:59 +00:00
|
|
|
while (*s) {
|
2009-08-27 00:26:44 +00:00
|
|
|
if (::strncmp(s, RUNTIME_ARRAY_BODY(n), length) == 0
|
2007-10-23 20:05:59 +00:00
|
|
|
and (s[length] == ',' or s[length] == 0))
|
|
|
|
{
|
|
|
|
// library is built in to this executable
|
2009-06-11 00:15:00 +00:00
|
|
|
if (not t->m->triedBuiltinOnLoad) {
|
|
|
|
t->m->triedBuiltinOnLoad = true;
|
|
|
|
runOnLoadIfFound(t, t->m->libraries);
|
|
|
|
}
|
2007-10-23 20:05:59 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
while (*s and *s != ',') ++ s;
|
|
|
|
if (*s) ++ s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-29 17:02:58 +00:00
|
|
|
System::Library* last = t->m->libraries;
|
2008-01-29 15:19:15 +00:00
|
|
|
for (System::Library* lib = t->m->libraries; lib; lib = lib->next()) {
|
2007-09-18 23:30:09 +00:00
|
|
|
if (lib->name()
|
2009-08-27 00:26:44 +00:00
|
|
|
and ::strcmp(lib->name(), RUNTIME_ARRAY_BODY(n)) == 0
|
2007-09-18 23:30:09 +00:00
|
|
|
and lib->mapName() == mapName)
|
|
|
|
{
|
2007-09-12 01:13:05 +00:00
|
|
|
// already loaded
|
|
|
|
return;
|
2007-07-21 17:50:26 +00:00
|
|
|
}
|
2008-01-29 15:19:15 +00:00
|
|
|
last = lib;
|
2007-09-12 01:13:05 +00:00
|
|
|
}
|
2007-07-21 17:50:26 +00:00
|
|
|
|
2008-01-25 23:38:26 +00:00
|
|
|
System::Library* lib;
|
2009-08-27 00:26:44 +00:00
|
|
|
if (LIKELY(t->m->system->success
|
|
|
|
(t->m->system->load(&lib, RUNTIME_ARRAY_BODY(n), mapName))))
|
|
|
|
{
|
2008-01-29 15:19:15 +00:00
|
|
|
last->setNext(lib);
|
2009-06-11 00:15:00 +00:00
|
|
|
runOnLoadIfFound(t, lib);
|
2008-01-25 23:38:26 +00:00
|
|
|
} else {
|
2009-08-27 00:26:44 +00:00
|
|
|
object message = makeString
|
|
|
|
(t, "library not found: %s", RUNTIME_ARRAY_BODY(n));
|
2007-09-13 00:21:37 +00:00
|
|
|
t->exception = makeUnsatisfiedLinkError(t, message);
|
2007-07-21 17:50:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Runtime_gc
|
|
|
|
(Thread* t, object, uintptr_t*)
|
2007-07-20 03:18:25 +00:00
|
|
|
{
|
|
|
|
collect(t, Heap::MajorCollection);
|
|
|
|
}
|
|
|
|
|
2008-11-11 15:20:49 +00:00
|
|
|
#ifdef AVIAN_HEAPDUMP
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 03:36:29 +00:00
|
|
|
Avian_avian_Machine_dumpHeap
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2008-11-11 15:20:49 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object outputFile = reinterpret_cast<object>(*arguments);
|
2008-11-11 15:20:49 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned length = stringLength(t, outputFile);
|
2008-11-11 15:20:49 +00:00
|
|
|
char n[length + 1];
|
2009-05-26 02:02:25 +00:00
|
|
|
stringChars(t, outputFile, n);
|
2009-09-01 18:15:33 +00:00
|
|
|
FILE* out = vm::fopen(n, "wb");
|
2008-11-11 15:20:49 +00:00
|
|
|
if (out) {
|
|
|
|
{ ENTER(t, Thread::ExclusiveState);
|
|
|
|
dumpHeap(t, out);
|
|
|
|
}
|
|
|
|
fclose(out);
|
|
|
|
} else {
|
|
|
|
object message = makeString(t, "file not found: %s", n);
|
|
|
|
t->exception = makeRuntimeException(t, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif//AVIAN_HEAPDUMP
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Runtime_exit
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-21 17:50:26 +00:00
|
|
|
{
|
2009-08-19 20:27:03 +00:00
|
|
|
shutDown(t);
|
|
|
|
|
2009-09-18 00:28:42 +00:00
|
|
|
t->m->system->exit(arguments[1]);
|
2007-07-21 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Runtime_freeMemory
|
|
|
|
(Thread*, object, uintptr_t*)
|
2007-07-27 02:39:53 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Runtime_totalMemory
|
|
|
|
(Thread*, object, uintptr_t*)
|
2007-10-29 20:57:33 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:27:03 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
Avian_java_lang_Runtime_addShutdownHook
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
object hook = reinterpret_cast<object>(arguments[1]);
|
|
|
|
PROTECT(t, hook);
|
|
|
|
|
|
|
|
ACQUIRE(t, t->m->shutdownLock);
|
|
|
|
|
|
|
|
t->m->shutdownHooks = makePair(t, hook, t->m->shutdownHooks);
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Throwable_trace
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-06 15:24:06 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int32_t skipCount = arguments[0];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-11-25 23:00:55 +00:00
|
|
|
class Visitor: public Processor::StackVisitor {
|
|
|
|
public:
|
|
|
|
Visitor(Thread* t, int skipCount):
|
|
|
|
t(t), trace(0), skipCount(skipCount)
|
|
|
|
{ }
|
2007-09-24 01:39:03 +00:00
|
|
|
|
2007-11-25 23:00:55 +00:00
|
|
|
virtual bool visit(Processor::StackWalker* walker) {
|
|
|
|
if (skipCount == 0) {
|
|
|
|
object method = walker->method();
|
|
|
|
if (isAssignableFrom
|
|
|
|
(t, arrayBody(t, t->m->types, Machine::ThrowableType),
|
|
|
|
methodClass(t, method))
|
2009-08-27 00:26:44 +00:00
|
|
|
and vm::strcmp(reinterpret_cast<const int8_t*>("<init>"),
|
|
|
|
&byteArrayBody(t, methodName(t, method), 0))
|
2007-11-25 23:00:55 +00:00
|
|
|
== 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
trace = makeTrace(t, walker);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
-- skipCount;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread* t;
|
|
|
|
object trace;
|
|
|
|
unsigned skipCount;
|
|
|
|
} v(t, skipCount);
|
|
|
|
|
|
|
|
t->m->processor->walkStack(t, &v);
|
2007-07-06 15:24:06 +00:00
|
|
|
|
2009-03-04 03:05:48 +00:00
|
|
|
if (v.trace == 0) v.trace = makeArray(t, 0);
|
2007-12-16 00:24:15 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(v.trace);
|
2007-07-06 15:24:06 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Throwable_resolveTrace
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-14 17:31:01 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object trace = reinterpret_cast<object>(*arguments);
|
|
|
|
PROTECT(t, trace);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned length = arrayLength(t, trace);
|
2009-08-10 13:56:16 +00:00
|
|
|
object elementType = arrayBody
|
|
|
|
(t, t->m->types, Machine::StackTraceElementType);
|
2007-07-14 18:37:04 +00:00
|
|
|
object array = makeObjectArray
|
2009-08-10 13:56:16 +00:00
|
|
|
(t, classLoader(t, elementType), elementType, length);
|
2007-07-14 18:37:04 +00:00
|
|
|
PROTECT(t, array);
|
|
|
|
|
|
|
|
object e = 0;
|
|
|
|
PROTECT(t, e);
|
|
|
|
|
|
|
|
object class_ = 0;
|
|
|
|
PROTECT(t, class_);
|
|
|
|
|
2009-08-27 22:26:25 +00:00
|
|
|
object method = 0;
|
|
|
|
PROTECT(t, method);
|
|
|
|
|
2007-07-14 18:37:04 +00:00
|
|
|
for (unsigned i = 0; i < length; ++i) {
|
2009-05-26 02:02:25 +00:00
|
|
|
e = arrayBody(t, trace, i);
|
2007-07-14 18:37:04 +00:00
|
|
|
|
|
|
|
class_ = className(t, methodClass(t, traceElementMethod(t, e)));
|
|
|
|
class_ = makeString(t, class_, 0, byteArrayLength(t, class_) - 1, 0);
|
|
|
|
|
2009-08-27 22:26:25 +00:00
|
|
|
method = methodName(t, traceElementMethod(t, e));
|
2007-07-14 18:37:04 +00:00
|
|
|
method = makeString(t, method, 0, byteArrayLength(t, method) - 1, 0);
|
|
|
|
|
2007-10-04 22:41:19 +00:00
|
|
|
unsigned line = t->m->processor->lineNumber
|
2007-07-14 18:37:04 +00:00
|
|
|
(t, traceElementMethod(t, e), traceElementIp(t, e));
|
|
|
|
|
2009-08-27 22:26:25 +00:00
|
|
|
object file = classSourceFile(t, methodClass(t, traceElementMethod(t, e)));
|
|
|
|
file = file ? makeString(t, file, 0, byteArrayLength(t, file) - 1, 0) : 0;
|
|
|
|
|
|
|
|
object ste = makeStackTraceElement(t, class_, method, file, line);
|
2007-10-22 17:22:30 +00:00
|
|
|
set(t, array, ArrayBody + (i * BytesPerWord), ste);
|
2007-07-14 18:37:04 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(array);
|
2007-07-14 17:31:01 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Thread_currentThread
|
|
|
|
(Thread* t, object, uintptr_t*)
|
2007-07-27 00:06:05 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(t->javaThread);
|
2007-07-27 00:06:05 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Thread_doStart
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-07 18:09:16 +00:00
|
|
|
{
|
2009-08-19 20:27:03 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(startThread(t, reinterpret_cast<object>(*arguments)));
|
2007-07-07 18:09:16 +00:00
|
|
|
}
|
2007-07-16 23:58:37 +00:00
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-26 02:02:25 +00:00
|
|
|
Avian_java_lang_Thread_interrupt
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-07-28 21:28:25 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t peer; memcpy(&peer, arguments, 8);
|
|
|
|
|
2007-07-28 21:28:25 +00:00
|
|
|
interrupt(t, reinterpret_cast<Thread*>(peer));
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Thread_getStackTrace
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2008-04-11 22:48:39 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t peer; memcpy(&peer, arguments, 8);
|
2008-04-16 05:27:42 +00:00
|
|
|
|
2008-04-11 22:48:39 +00:00
|
|
|
if (reinterpret_cast<Thread*>(peer) == t) {
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>(makeTrace(t));
|
2008-04-11 22:48:39 +00:00
|
|
|
} else {
|
2009-05-26 02:02:25 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(t->m->processor->getStackTrace(t, reinterpret_cast<Thread*>(peer)));
|
2008-04-11 22:48:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Thread_activeCount
|
|
|
|
(Thread* t, object, uintptr_t*)
|
2008-04-11 22:48:39 +00:00
|
|
|
{
|
|
|
|
return t->m->liveCount;
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_java_lang_Thread_enumerate
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2008-04-11 22:48:39 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object array = reinterpret_cast<object>(*arguments);
|
2008-04-11 22:48:39 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
ACQUIRE_RAW(t, t->m->stateLock);
|
2008-04-11 22:48:39 +00:00
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
unsigned count = min(t->m->liveCount, objectArrayLength(t, array));
|
2008-04-11 22:48:39 +00:00
|
|
|
unsigned index = 0;
|
2009-05-26 02:02:25 +00:00
|
|
|
enumerateThreads(t, t->m->rootThread, array, &index, count);
|
2008-04-11 22:48:39 +00:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:27:03 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
Avian_java_lang_Thread_setDaemon
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
object thread = reinterpret_cast<object>(arguments[0]);
|
|
|
|
bool daemon = arguments[1] != 0;
|
|
|
|
|
2009-08-24 23:51:31 +00:00
|
|
|
setDaemon(t, thread, daemon);
|
2009-08-19 20:27:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-06-07 02:32:44 +00:00
|
|
|
Avian_avian_resource_Handler_00024ResourceInputStream_getContentLength
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2008-07-15 15:36:52 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object path = reinterpret_cast<object>(*arguments);
|
2008-07-15 15:36:52 +00:00
|
|
|
|
|
|
|
if (LIKELY(path)) {
|
2009-08-27 00:26:44 +00:00
|
|
|
RUNTIME_ARRAY(char, p, stringLength(t, path) + 1);
|
|
|
|
stringChars(t, path, RUNTIME_ARRAY_BODY(p));
|
2008-07-15 15:36:52 +00:00
|
|
|
|
2009-08-27 00:26:44 +00:00
|
|
|
System::Region* r = t->m->finder->find(RUNTIME_ARRAY_BODY(p));
|
2008-07-15 15:36:52 +00:00
|
|
|
if (r) {
|
|
|
|
jint rSize = r->length();
|
|
|
|
r->dispose();
|
|
|
|
return rSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-06-07 02:32:44 +00:00
|
|
|
Avian_avian_resource_Handler_00024ResourceInputStream_open
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-10 23:45:47 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
object path = reinterpret_cast<object>(*arguments);
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-08-10 23:45:47 +00:00
|
|
|
if (LIKELY(path)) {
|
2009-08-27 00:26:44 +00:00
|
|
|
RUNTIME_ARRAY(char, p, stringLength(t, path) + 1);
|
|
|
|
stringChars(t, path, RUNTIME_ARRAY_BODY(p));
|
2007-08-10 23:45:47 +00:00
|
|
|
|
2009-08-27 00:26:44 +00:00
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(t->m->finder->find(RUNTIME_ARRAY_BODY(p)));
|
2007-08-10 23:45:47 +00:00
|
|
|
} else {
|
|
|
|
t->exception = makeNullPointerException(t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-06-07 02:32:44 +00:00
|
|
|
Avian_avian_resource_Handler_00024ResourceInputStream_read__JI
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-10 23:45:47 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t peer; memcpy(&peer, arguments, 8);
|
|
|
|
int32_t position = arguments[2];
|
|
|
|
|
2007-09-17 00:13:36 +00:00
|
|
|
System::Region* region = reinterpret_cast<System::Region*>(peer);
|
|
|
|
if (position >= static_cast<jint>(region->length())) {
|
2007-08-10 23:45:47 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
2007-09-17 00:13:36 +00:00
|
|
|
return region->start()[position];
|
2007-08-10 23:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 02:02:25 +00:00
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
2009-06-07 02:32:44 +00:00
|
|
|
Avian_avian_resource_Handler_00024ResourceInputStream_read__JI_3BII
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2007-08-10 23:45:47 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t peer; memcpy(&peer, arguments, 8);
|
|
|
|
int32_t position = arguments[2];
|
|
|
|
object buffer = reinterpret_cast<object>(arguments[3]);
|
|
|
|
int32_t offset = arguments[4];
|
|
|
|
int32_t length = arguments[5];
|
2007-09-18 23:30:09 +00:00
|
|
|
|
2007-09-13 00:21:37 +00:00
|
|
|
if (length == 0) return 0;
|
|
|
|
|
2007-09-17 00:13:36 +00:00
|
|
|
System::Region* region = reinterpret_cast<System::Region*>(peer);
|
|
|
|
if (length > static_cast<jint>(region->length()) - position) {
|
|
|
|
length = static_cast<jint>(region->length()) - position;
|
2007-08-10 23:45:47 +00:00
|
|
|
}
|
2007-09-13 00:21:37 +00:00
|
|
|
if (length <= 0) {
|
2007-08-10 23:45:47 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
2009-05-26 02:02:25 +00:00
|
|
|
memcpy(&byteArrayBody(t, buffer, offset), region->start() + position,
|
|
|
|
length);
|
2007-08-10 23:45:47 +00:00
|
|
|
return length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:30:09 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-06-07 02:32:44 +00:00
|
|
|
Avian_avian_resource_Handler_00024ResourceInputStream_close
|
2009-05-26 02:02:25 +00:00
|
|
|
(Thread*, object, uintptr_t* arguments)
|
2007-08-10 23:45:47 +00:00
|
|
|
{
|
2009-05-26 02:02:25 +00:00
|
|
|
int64_t peer; memcpy(&peer, arguments, 8);
|
2007-09-17 00:13:36 +00:00
|
|
|
reinterpret_cast<System::Region*>(peer)->dispose();
|
2007-08-10 23:45:47 +00:00
|
|
|
}
|
2009-05-06 00:29:05 +00:00
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-23 22:15:06 +00:00
|
|
|
Avian_avian_Continuations_callWithCurrentContinuation
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2009-05-06 00:29:05 +00:00
|
|
|
{
|
|
|
|
t->m->processor->callWithCurrentContinuation
|
|
|
|
(t, reinterpret_cast<object>(*arguments));
|
|
|
|
|
|
|
|
abort(t);
|
|
|
|
}
|
|
|
|
|
2009-05-23 22:15:06 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
|
|
|
Avian_avian_Continuations_dynamicWind2
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
t->m->processor->dynamicWind
|
|
|
|
(t, reinterpret_cast<object>(arguments[0]),
|
|
|
|
reinterpret_cast<object>(arguments[1]),
|
|
|
|
reinterpret_cast<object>(arguments[2]));
|
|
|
|
|
|
|
|
abort(t);
|
|
|
|
}
|
|
|
|
|
2009-05-06 00:29:05 +00:00
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-16 08:03:03 +00:00
|
|
|
Avian_avian_Continuations_00024Continuation_handleResult
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2009-05-06 00:29:05 +00:00
|
|
|
{
|
|
|
|
t->m->processor->feedResultToContinuation
|
|
|
|
(t, reinterpret_cast<object>(arguments[0]),
|
|
|
|
reinterpret_cast<object>(arguments[1]));
|
|
|
|
|
|
|
|
abort(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT void JNICALL
|
2009-05-16 08:03:03 +00:00
|
|
|
Avian_avian_Continuations_00024Continuation_handleException
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
2009-05-06 00:29:05 +00:00
|
|
|
{
|
|
|
|
t->m->processor->feedExceptionToContinuation
|
|
|
|
(t, reinterpret_cast<object>(arguments[0]),
|
|
|
|
reinterpret_cast<object>(arguments[1]));
|
|
|
|
|
|
|
|
abort(t);
|
|
|
|
}
|
2009-09-19 22:21:15 +00:00
|
|
|
|
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_avian_Singleton_getObject
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<int64_t>
|
|
|
|
(singletonObject(t, reinterpret_cast<object>(arguments[0]), arguments[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_avian_Singleton_getInt
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
return singletonValue
|
|
|
|
(t, reinterpret_cast<object>(arguments[0]), arguments[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT int64_t JNICALL
|
|
|
|
Avian_avian_Singleton_getLong
|
|
|
|
(Thread* t, object, uintptr_t* arguments)
|
|
|
|
{
|
|
|
|
int64_t v;
|
2009-10-20 19:38:05 +00:00
|
|
|
memcpy(&v, &singletonValue
|
|
|
|
(t, reinterpret_cast<object>(arguments[0]), arguments[1]), 8);
|
2009-09-19 22:21:15 +00:00
|
|
|
return v;
|
|
|
|
}
|