mirror of
https://github.com/corda/corda.git
synced 2025-02-15 07:02:24 +00:00
Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip
This commit is contained in:
commit
77990b9489
@ -90,8 +90,8 @@ import java.util.concurrent.Callable;
|
|||||||
* <h3>Winding, Unwinding, and Rewinding</h3>
|
* <h3>Winding, Unwinding, and Rewinding</h3>
|
||||||
*
|
*
|
||||||
* <p>Traditionally, Java provides one way to wind the execution stack
|
* <p>Traditionally, Java provides one way to wind the execution stack
|
||||||
* (recursive method calls) and two ways to unwind it (normal returns
|
* (method calls) and two ways to unwind it (normal returns and
|
||||||
* and exception unwinding). With continuations, we add a new way to
|
* exception unwinding). With continuations, we add a new way to
|
||||||
* rewind the stack and a new way to unwind it.
|
* rewind the stack and a new way to unwind it.
|
||||||
*
|
*
|
||||||
* <p>The call stack of a continuation may share frames with other
|
* <p>The call stack of a continuation may share frames with other
|
||||||
@ -149,7 +149,7 @@ public class Continuations {
|
|||||||
*
|
*
|
||||||
* <p>If <code>thunk.call()</code> calls a continuation (directly or
|
* <p>If <code>thunk.call()</code> calls a continuation (directly or
|
||||||
* via a subroutine) which does not include the current call to
|
* via a subroutine) which does not include the current call to
|
||||||
* <code>dynamicWind<code>, <code>after.run()</code> will be called
|
* <code>dynamicWind</code>, <code>after.run()</code> will be called
|
||||||
* before control passes to that continuation. If this call throws
|
* before control passes to that continuation. If this call throws
|
||||||
* an exception, the exception will propagate to the current caller
|
* an exception, the exception will propagate to the current caller
|
||||||
* of <code>dynamicWind</code>.
|
* of <code>dynamicWind</code>.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2009, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -29,7 +29,7 @@ public class SystemClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
protected native Class findClass(String name) throws ClassNotFoundException;
|
protected native Class findClass(String name) throws ClassNotFoundException;
|
||||||
|
|
||||||
protected native Class findLoadedClass(String name);
|
protected native Class reallyFindLoadedClass(String name);
|
||||||
|
|
||||||
private native boolean resourceExists(String name);
|
private native boolean resourceExists(String name);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -170,7 +170,7 @@ map(JNIEnv* e, const char* path)
|
|||||||
void* data = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
|
void* data = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
|
||||||
if (data) {
|
if (data) {
|
||||||
void* p = allocate(e, sizeof(Mapping));
|
void* p = allocate(e, sizeof(Mapping));
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
result = new (p)
|
result = new (p)
|
||||||
Mapping(static_cast<uint8_t*>(data), size, file, mapping);
|
Mapping(static_cast<uint8_t*>(data), size, file, mapping);
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ map(JNIEnv* e, const char* path)
|
|||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result == 0 and not e->ExceptionOccurred()) {
|
if (result == 0 and not e->ExceptionCheck()) {
|
||||||
throwNew(e, "java/io/IOException", "%d", GetLastError());
|
throwNew(e, "java/io/IOException", "%d", GetLastError());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -256,14 +256,14 @@ map(JNIEnv* e, const char* path)
|
|||||||
void* data = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
void* data = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
if (data) {
|
if (data) {
|
||||||
void* p = allocate(e, sizeof(Mapping));
|
void* p = allocate(e, sizeof(Mapping));
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
result = new (p) Mapping(static_cast<uint8_t*>(data), s.st_size);
|
result = new (p) Mapping(static_cast<uint8_t*>(data), s.st_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
if (result == 0 and not e->ExceptionOccurred()) {
|
if (result == 0 and not e->ExceptionCheck()) {
|
||||||
throwNewErrno(e, "java/io/IOException");
|
throwNewErrno(e, "java/io/IOException");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -167,17 +167,17 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
|||||||
makePipe(e, in);
|
makePipe(e, in);
|
||||||
SetHandleInformation(in[0], HANDLE_FLAG_INHERIT, 0);
|
SetHandleInformation(in[0], HANDLE_FLAG_INHERIT, 0);
|
||||||
jlong inDescriptor = static_cast<jlong>(descriptor(e, in[0]));
|
jlong inDescriptor = static_cast<jlong>(descriptor(e, in[0]));
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
e->SetLongArrayRegion(process, 1, 1, &inDescriptor);
|
e->SetLongArrayRegion(process, 1, 1, &inDescriptor);
|
||||||
makePipe(e, out);
|
makePipe(e, out);
|
||||||
SetHandleInformation(out[1], HANDLE_FLAG_INHERIT, 0);
|
SetHandleInformation(out[1], HANDLE_FLAG_INHERIT, 0);
|
||||||
jlong outDescriptor = static_cast<jlong>(descriptor(e, out[1]));
|
jlong outDescriptor = static_cast<jlong>(descriptor(e, out[1]));
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
e->SetLongArrayRegion(process, 2, 1, &outDescriptor);
|
e->SetLongArrayRegion(process, 2, 1, &outDescriptor);
|
||||||
makePipe(e, err);
|
makePipe(e, err);
|
||||||
SetHandleInformation(err[0], HANDLE_FLAG_INHERIT, 0);
|
SetHandleInformation(err[0], HANDLE_FLAG_INHERIT, 0);
|
||||||
jlong errDescriptor = static_cast<jlong>(descriptor(e, err[0]));
|
jlong errDescriptor = static_cast<jlong>(descriptor(e, err[0]));
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
e->SetLongArrayRegion(process, 3, 1, &errDescriptor);
|
e->SetLongArrayRegion(process, 3, 1, &errDescriptor);
|
||||||
|
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
@ -249,19 +249,19 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
|||||||
int msg[] = { -1, -1 };
|
int msg[] = { -1, -1 };
|
||||||
|
|
||||||
makePipe(e, in);
|
makePipe(e, in);
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
jlong inDescriptor = static_cast<jlong>(in[0]);
|
jlong inDescriptor = static_cast<jlong>(in[0]);
|
||||||
e->SetLongArrayRegion(process, 1, 1, &inDescriptor);
|
e->SetLongArrayRegion(process, 1, 1, &inDescriptor);
|
||||||
makePipe(e, out);
|
makePipe(e, out);
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
jlong outDescriptor = static_cast<jlong>(out[1]);
|
jlong outDescriptor = static_cast<jlong>(out[1]);
|
||||||
e->SetLongArrayRegion(process, 1, 1, &outDescriptor);
|
e->SetLongArrayRegion(process, 1, 1, &outDescriptor);
|
||||||
makePipe(e, err);
|
makePipe(e, err);
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
jlong errDescriptor = static_cast<jlong>(err[0]);
|
jlong errDescriptor = static_cast<jlong>(err[0]);
|
||||||
e->SetLongArrayRegion(process, 1, 1, &errDescriptor);
|
e->SetLongArrayRegion(process, 1, 1, &errDescriptor);
|
||||||
makePipe(e, msg);
|
makePipe(e, msg);
|
||||||
if(e->ExceptionOccurred()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {
|
if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {
|
||||||
throwNewErrno(e, "java/io/IOException");
|
throwNewErrno(e, "java/io/IOException");
|
||||||
return;
|
return;
|
||||||
@ -393,7 +393,8 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
|
|||||||
} else if (strcmp(chars, "user.home") == 0) {
|
} else if (strcmp(chars, "user.home") == 0) {
|
||||||
# ifdef _MSC_VER
|
# ifdef _MSC_VER
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
if (_wgetenv_s(0, buffer, MAX_PATH, L"USERPROFILE") == 0) {
|
size_t needed;
|
||||||
|
if (_wgetenv_s(&needed, buffer, MAX_PATH, L"USERPROFILE") == 0) {
|
||||||
r = e->NewString(reinterpret_cast<jchar*>(buffer), lstrlenW(buffer));
|
r = e->NewString(reinterpret_cast<jchar*>(buffer), lstrlenW(buffer));
|
||||||
} else {
|
} else {
|
||||||
r = 0;
|
r = 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -332,11 +332,11 @@ Java_java_nio_channels_ServerSocketChannel_natDoListen(JNIEnv *e,
|
|||||||
{
|
{
|
||||||
int s = makeSocket(e);
|
int s = makeSocket(e);
|
||||||
if (s < 0) return s;
|
if (s < 0) return s;
|
||||||
if (e->ExceptionOccurred()) return 0;
|
if (e->ExceptionCheck()) return 0;
|
||||||
|
|
||||||
sockaddr_in address;
|
sockaddr_in address;
|
||||||
init(e, &address, host, port);
|
init(e, &address, host, port);
|
||||||
if (e->ExceptionOccurred()) return 0;
|
if (e->ExceptionCheck()) return 0;
|
||||||
|
|
||||||
::doListen(e, s, &address);
|
::doListen(e, s, &address);
|
||||||
return s;
|
return s;
|
||||||
@ -369,13 +369,13 @@ Java_java_nio_channels_SocketChannel_natDoConnect(JNIEnv *e,
|
|||||||
jbooleanArray retVal)
|
jbooleanArray retVal)
|
||||||
{
|
{
|
||||||
int s = makeSocket(e);
|
int s = makeSocket(e);
|
||||||
if (e->ExceptionOccurred()) return 0;
|
if (e->ExceptionCheck()) return 0;
|
||||||
|
|
||||||
setBlocking(e, s, blocking);
|
setBlocking(e, s, blocking);
|
||||||
|
|
||||||
sockaddr_in address;
|
sockaddr_in address;
|
||||||
init(e, &address, host, port);
|
init(e, &address, host, port);
|
||||||
if (e->ExceptionOccurred()) return 0;
|
if (e->ExceptionCheck()) return 0;
|
||||||
|
|
||||||
jboolean connected = ::doConnect(e, s, &address);
|
jboolean connected = ::doConnect(e, s, &address);
|
||||||
e->SetBooleanArrayRegion(retVal, 0, 1, &connected);
|
e->SetBooleanArrayRegion(retVal, 0, 1, &connected);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -20,6 +20,11 @@ Java_java_util_zip_Inflater_make
|
|||||||
(JNIEnv* e, jclass, jboolean nowrap)
|
(JNIEnv* e, jclass, jboolean nowrap)
|
||||||
{
|
{
|
||||||
z_stream* s = static_cast<z_stream*>(malloc(sizeof(z_stream)));
|
z_stream* s = static_cast<z_stream*>(malloc(sizeof(z_stream)));
|
||||||
|
if (s == 0) {
|
||||||
|
throwNew(e, "java/lang/OutOfMemoryError", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
memset(s, 0, sizeof(z_stream));
|
memset(s, 0, sizeof(z_stream));
|
||||||
|
|
||||||
int r = inflateInit2(s, (nowrap ? -15 : 15));
|
int r = inflateInit2(s, (nowrap ? -15 : 15));
|
||||||
@ -80,3 +85,74 @@ Java_java_util_zip_Inflater_inflate
|
|||||||
|
|
||||||
e->SetIntArrayRegion(results, 0, 3, resultArray);
|
e->SetIntArrayRegion(results, 0, 3, resultArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jlong JNICALL
|
||||||
|
Java_java_util_zip_Deflater_make
|
||||||
|
(JNIEnv* e, jclass, jboolean nowrap, jint level)
|
||||||
|
{
|
||||||
|
z_stream* s = static_cast<z_stream*>(malloc(sizeof(z_stream)));
|
||||||
|
if (s == 0) {
|
||||||
|
throwNew(e, "java/lang/OutOfMemoryError", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(s, 0, sizeof(z_stream));
|
||||||
|
|
||||||
|
int r = deflateInit2(s, level, (nowrap ? -15 : 15));
|
||||||
|
if (r != Z_OK) {
|
||||||
|
free(s);
|
||||||
|
throwNew(e, "java/lang/RuntimeException", zError(r));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<jlong>(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
Java_java_util_zip_Deflater_dispose(JNIEnv*, jclass, jlong peer)
|
||||||
|
{
|
||||||
|
z_stream* s = reinterpret_cast<z_stream*>(peer);
|
||||||
|
deflateEnd(s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
Java_java_util_zip_Deflater_deflate
|
||||||
|
(JNIEnv* e, jclass, jlong peer,
|
||||||
|
jbyteArray input, jint inputOffset, jint inputLength,
|
||||||
|
jbyteArray output, jint outputOffset, jint outputLength,
|
||||||
|
jintArray results)
|
||||||
|
{
|
||||||
|
z_stream* s = reinterpret_cast<z_stream*>(peer);
|
||||||
|
|
||||||
|
jbyte* in = static_cast<jbyte*>(malloc(inputLength));
|
||||||
|
if (in == 0) {
|
||||||
|
throwNew(e, "java/lang/OutOfMemoryError", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jbyte* out = static_cast<jbyte*>(malloc(outputLength));
|
||||||
|
if (out == 0) {
|
||||||
|
free(in);
|
||||||
|
throwNew(e, "java/lang/OutOfMemoryError", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->GetByteArrayRegion(input, inputOffset, inputLength, in);
|
||||||
|
|
||||||
|
s->next_in = reinterpret_cast<Bytef*>(in);
|
||||||
|
s->avail_in = inputLength;
|
||||||
|
s->next_out = reinterpret_cast<Bytef*>(out);
|
||||||
|
s->avail_out = outputLength;
|
||||||
|
|
||||||
|
int r = deflate(s, Z_SYNC_FLUSH);
|
||||||
|
jint resultArray[3]
|
||||||
|
= { r, inputLength - s->avail_in, outputLength - s->avail_out };
|
||||||
|
|
||||||
|
free(in);
|
||||||
|
|
||||||
|
e->SetByteArrayRegion(output, outputOffset, resultArray[2], out);
|
||||||
|
free(out);
|
||||||
|
|
||||||
|
e->SetIntArrayRegion(results, 0, 3, resultArray);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -49,8 +49,10 @@ public abstract class ClassLoader {
|
|||||||
throw new ClassNotFoundException();
|
throw new ClassNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class findLoadedClass(String name) {
|
protected abstract Class reallyFindLoadedClass(String name);
|
||||||
return null;
|
|
||||||
|
protected final Class findLoadedClass(String name) {
|
||||||
|
return reallyFindLoadedClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class loadClass(String name) throws ClassNotFoundException {
|
public Class loadClass(String name) throws ClassNotFoundException {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -185,7 +185,7 @@ public final class String
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Object decodeUTF8(byte[] s8, int offset, int length) {
|
private static Object decodeUTF8(byte[] s8, int offset, int length) {
|
||||||
Object buf = new byte[s8.length];
|
Object buf = new byte[length];
|
||||||
boolean isMultiByte = false;
|
boolean isMultiByte = false;
|
||||||
int i=offset, j=0;
|
int i=offset, j=0;
|
||||||
while(i < offset+length) {
|
while(i < offset+length) {
|
||||||
@ -195,14 +195,14 @@ public final class String
|
|||||||
decodeUTF8_insert(buf, j++, x);
|
decodeUTF8_insert(buf, j++, x);
|
||||||
} else if((x & 0x0e0) == 0x0c0) { // 2 byte char
|
} else if((x & 0x0e0) == 0x0c0) { // 2 byte char
|
||||||
if(!isMultiByte) {
|
if(!isMultiByte) {
|
||||||
buf = decodeUTF8_widen(buf, j, s8.length-1);
|
buf = decodeUTF8_widen(buf, j, length-1);
|
||||||
isMultiByte = true;
|
isMultiByte = true;
|
||||||
}
|
}
|
||||||
int y = s8[i++];
|
int y = s8[i++];
|
||||||
decodeUTF8_insert(buf, j++, ((x & 0x1f) << 6) | (y & 0x3f));
|
decodeUTF8_insert(buf, j++, ((x & 0x1f) << 6) | (y & 0x3f));
|
||||||
} else if((x & 0x0f0) == 0x0e0) { // 3 byte char
|
} else if((x & 0x0f0) == 0x0e0) { // 3 byte char
|
||||||
if(!isMultiByte) {
|
if(!isMultiByte) {
|
||||||
buf = decodeUTF8_widen(buf, j, s8.length-2);
|
buf = decodeUTF8_widen(buf, j, length-2);
|
||||||
isMultiByte = true;
|
isMultiByte = true;
|
||||||
}
|
}
|
||||||
int y = s8[i++]; int z = s8[i++];
|
int y = s8[i++]; int z = s8[i++];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -10,13 +10,20 @@
|
|||||||
|
|
||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
|
import avian.Cell;
|
||||||
|
|
||||||
public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
||||||
private final ThreadGroup parent;
|
final ThreadGroup parent; // package private for GNU Classpath compatibility
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private Cell<ThreadGroup> subgroups;
|
||||||
|
|
||||||
public ThreadGroup(ThreadGroup parent, String name) {
|
public ThreadGroup(ThreadGroup parent, String name) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
synchronized (parent) {
|
||||||
|
parent.subgroups = new Cell(this, subgroups);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThreadGroup(String name) {
|
public ThreadGroup(String name) {
|
||||||
@ -36,4 +43,75 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ThreadGroup getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int activeCount() {
|
||||||
|
int allCount = Thread.activeCount();
|
||||||
|
Thread[] all = new Thread[allCount];
|
||||||
|
allCount = Thread.enumerate(all);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < allCount; ++i) {
|
||||||
|
if (parentOf(all[i].getThreadGroup())) {
|
||||||
|
++ count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(Thread[] threads) {
|
||||||
|
return enumerate(threads, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(Thread[] threads, boolean recurse) {
|
||||||
|
int allCount = Thread.activeCount();
|
||||||
|
Thread[] all = new Thread[allCount];
|
||||||
|
allCount = Thread.enumerate(all);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < allCount && count < threads.length; ++i) {
|
||||||
|
Thread t = all[i];
|
||||||
|
ThreadGroup g = t.getThreadGroup();
|
||||||
|
if (g == this || (recurse && parentOf(g))) {
|
||||||
|
threads[count++] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean parentOf(ThreadGroup g) {
|
||||||
|
for (; g != null; g = g.parent) {
|
||||||
|
if (g == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(ThreadGroup[] groups, boolean recurse) {
|
||||||
|
return enumerate(groups, recurse, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int enumerate(ThreadGroup[] groups, boolean recurse, int count) {
|
||||||
|
for (Cell<ThreadGroup> c = subgroups; c != null && count < groups.length;
|
||||||
|
c = c.next)
|
||||||
|
{
|
||||||
|
ThreadGroup g = c.value;
|
||||||
|
groups[count++] = g;
|
||||||
|
if (recurse) {
|
||||||
|
count = g.enumerate(groups, true, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -42,6 +42,10 @@ public class Constructor<T> extends AccessibleObject
|
|||||||
return method.getParameterTypes();
|
return method.getParameterTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class[] getExceptionTypes() {
|
||||||
|
return method.getExceptionTypes();
|
||||||
|
}
|
||||||
|
|
||||||
public int getModifiers() {
|
public int getModifiers() {
|
||||||
return method.getModifiers();
|
return method.getModifiers();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -82,6 +82,14 @@ public class Proxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isProxyClass(Class c) {
|
||||||
|
return c.getName().startsWith("Proxy-");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InvocationHandler getInvocationHandler(Object proxy) {
|
||||||
|
return ((Proxy) proxy).h;
|
||||||
|
}
|
||||||
|
|
||||||
private static void set4(byte[] array, int offset, int v) {
|
private static void set4(byte[] array, int offset, int v) {
|
||||||
array[offset ] = (byte) ((v >>> 24) & 0xFF);
|
array[offset ] = (byte) ((v >>> 24) & 0xFF);
|
||||||
array[offset + 1] = (byte) ((v >>> 16) & 0xFF);
|
array[offset + 1] = (byte) ((v >>> 16) & 0xFF);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
149
classpath/java/util/zip/Deflater.java
Normal file
149
classpath/java/util/zip/Deflater.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/* Copyright (c) 2009, 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. */
|
||||||
|
|
||||||
|
package java.util.zip;
|
||||||
|
|
||||||
|
public class Deflater {
|
||||||
|
private static final int DEFAULT_LEVEL = 6; // default compression level (6 is default for gzip)
|
||||||
|
private static final int Z_OK = 0;
|
||||||
|
private static final int Z_STREAM_END = 1;
|
||||||
|
private static final int Z_NEED_DICT = 2;
|
||||||
|
|
||||||
|
// static {
|
||||||
|
// System.loadLibrary("natives");
|
||||||
|
// }
|
||||||
|
|
||||||
|
private long peer;
|
||||||
|
private byte[] input;
|
||||||
|
private int offset;
|
||||||
|
private int length;
|
||||||
|
private boolean needDictionary;
|
||||||
|
private boolean finished;
|
||||||
|
private final boolean nowrap;
|
||||||
|
|
||||||
|
public Deflater(boolean nowrap) {
|
||||||
|
this.nowrap = nowrap;
|
||||||
|
peer = make(nowrap, DEFAULT_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Deflater() {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check() {
|
||||||
|
if (peer == 0) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native long make(boolean nowrap, int level);
|
||||||
|
|
||||||
|
public boolean finished() {
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean needsDictionary() {
|
||||||
|
return needDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean needsInput() {
|
||||||
|
return getRemaining() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemaining() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) throws IllegalArgumentException {
|
||||||
|
if (level < 0 || level > 9) {
|
||||||
|
throw new IllegalArgumentException("Valid compression levels are 0-9");
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose(peer);
|
||||||
|
peer = make(nowrap, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(byte[] input) {
|
||||||
|
setInput(input, 0, input.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(byte[] input, int offset, int length) {
|
||||||
|
this.input = input;
|
||||||
|
this.offset = offset;
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
dispose();
|
||||||
|
peer = make(nowrap, DEFAULT_LEVEL);
|
||||||
|
input = null;
|
||||||
|
offset = length = 0;
|
||||||
|
needDictionary = finished = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deflate(byte[] output) throws DataFormatException {
|
||||||
|
return deflate(output, 0, output.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deflate(byte[] output, int offset, int length)
|
||||||
|
throws DataFormatException
|
||||||
|
{
|
||||||
|
final int zlibResult = 0;
|
||||||
|
final int inputCount = 1;
|
||||||
|
final int outputCount = 2;
|
||||||
|
|
||||||
|
if (peer == 0) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input == null || output == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] results = new int[3];
|
||||||
|
deflate(peer,
|
||||||
|
input, this.offset, this.length,
|
||||||
|
output, offset, length, results);
|
||||||
|
|
||||||
|
if (results[zlibResult] < 0) {
|
||||||
|
throw new DataFormatException();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (results[zlibResult]) {
|
||||||
|
case Z_NEED_DICT:
|
||||||
|
needDictionary = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Z_STREAM_END:
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.offset += results[inputCount];
|
||||||
|
this.length -= results[inputCount];
|
||||||
|
|
||||||
|
return results[outputCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void deflate
|
||||||
|
(long peer,
|
||||||
|
byte[] input, int inputOffset, int inputLength,
|
||||||
|
byte[] output, int outputOffset, int outputLength,
|
||||||
|
int[] results);
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
if (peer != 0) {
|
||||||
|
dispose(peer);
|
||||||
|
peer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void dispose(long peer);
|
||||||
|
}
|
75
classpath/java/util/zip/DeflaterOutputStream.java
Normal file
75
classpath/java/util/zip/DeflaterOutputStream.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* Copyright (c) 2009, 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. */
|
||||||
|
|
||||||
|
package java.util.zip;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DeflaterOutputStream extends OutputStream {
|
||||||
|
private final OutputStream out;
|
||||||
|
private final Deflater deflater;
|
||||||
|
private final byte[] buffer;
|
||||||
|
|
||||||
|
public DeflaterOutputStream(OutputStream out, Deflater deflater, int bufferSize)
|
||||||
|
{
|
||||||
|
this.out = out;
|
||||||
|
this.deflater = deflater;
|
||||||
|
this.buffer = new byte[bufferSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeflaterOutputStream(OutputStream out, Deflater deflater) {
|
||||||
|
this(out, deflater, 4 * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeflaterOutputStream(OutputStream out) {
|
||||||
|
this(out, new Deflater());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
byte[] buffer = new byte[1];
|
||||||
|
buffer[0] = (byte)(b & 0xff);
|
||||||
|
write(buffer, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] b, int offset, int length) throws IOException {
|
||||||
|
// error condition checking
|
||||||
|
if (deflater.finished()) {
|
||||||
|
throw new IOException("Already at end of stream");
|
||||||
|
} else if (offset < 0) {
|
||||||
|
throw new IndexOutOfBoundsException("Offset can't be less than zero");
|
||||||
|
} else if (length < 0) {
|
||||||
|
throw new IndexOutOfBoundsException("Length can't be less than zero");
|
||||||
|
} else if (b.length - (offset + length) < 0) {
|
||||||
|
throw new IndexOutOfBoundsException("Offset + Length is larger than the input byte array");
|
||||||
|
} else if (length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i+= buffer.length) {
|
||||||
|
deflater.setInput(b, offset + i, Math.min(buffer.length, length - i));
|
||||||
|
while (deflater.getRemaining() > 0) {
|
||||||
|
try {
|
||||||
|
int len = deflater.deflate(buffer, 0, buffer.length);
|
||||||
|
if (len > 0) {
|
||||||
|
out.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} catch (DataFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException {
|
||||||
|
out.close();
|
||||||
|
deflater.dispose();
|
||||||
|
}
|
||||||
|
}
|
@ -60,6 +60,10 @@ public class Inflater {
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInput(byte[] input) {
|
||||||
|
setInput(input, 0, input.length);
|
||||||
|
}
|
||||||
|
|
||||||
public void setInput(byte[] input, int offset, int length) {
|
public void setInput(byte[] input, int offset, int length) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
29
makefile
29
makefile
@ -1,7 +1,7 @@
|
|||||||
MAKEFLAGS = -s
|
MAKEFLAGS = -s
|
||||||
|
|
||||||
name = avian
|
name = avian
|
||||||
version = 0.2
|
version = 0.3
|
||||||
|
|
||||||
build-arch := $(shell uname -m | sed 's/^i.86$$/i386/')
|
build-arch := $(shell uname -m | sed 's/^i.86$$/i386/')
|
||||||
ifeq (Power,$(filter Power,$(build-arch)))
|
ifeq (Power,$(filter Power,$(build-arch)))
|
||||||
@ -54,7 +54,7 @@ ifdef gnu
|
|||||||
gnu-object-dep = $(build)/gnu-object.dep
|
gnu-object-dep = $(build)/gnu-object.dep
|
||||||
gnu-cflags = -DBOOT_BUILTINS=\"javaio,javalang,javalangreflect,javamath,javanet,javanio,javautil\" -DAVIAN_GNU
|
gnu-cflags = -DBOOT_BUILTINS=\"javaio,javalang,javalangreflect,javamath,javanet,javanio,javautil\" -DAVIAN_GNU
|
||||||
gnu-lflags = -lgmp
|
gnu-lflags = -lgmp
|
||||||
gnu-objects := $(shell find $(build)/gnu-objects -name "*.o")
|
gnu-objects = $(shell find $(build)/gnu-objects -name "*.o")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
root := $(shell (cd .. && pwd))
|
root := $(shell (cd .. && pwd))
|
||||||
@ -171,6 +171,12 @@ ifeq ($(platform),darwin)
|
|||||||
asmflags += -arch i386
|
asmflags += -arch i386
|
||||||
lflags += -arch i386
|
lflags += -arch i386
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(arch),x86_64)
|
||||||
|
cflags += -arch x86_64
|
||||||
|
asmflags += -arch x86_64
|
||||||
|
lflags += -arch x86_64
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
@ -265,19 +271,17 @@ ifdef msvc
|
|||||||
-I"$(windows-java-home)/include/win32"
|
-I"$(windows-java-home)/include/win32"
|
||||||
shared = -dll
|
shared = -dll
|
||||||
lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
|
lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
|
||||||
-DEFAULTLIB:zlib -MANIFEST
|
-DEFAULTLIB:zlib -MANIFEST -debug
|
||||||
output = -Fo$(1)
|
output = -Fo$(1)
|
||||||
|
|
||||||
ifeq ($(mode),debug)
|
ifeq ($(mode),debug)
|
||||||
cflags += -Od -Zi -MDd
|
cflags += -Od -Zi -MDd
|
||||||
lflags += -debug
|
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),debug-fast)
|
ifeq ($(mode),debug-fast)
|
||||||
cflags += -Od -Zi -DNDEBUG
|
cflags += -Od -Zi -DNDEBUG
|
||||||
lflags += -debug
|
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),fast)
|
ifeq ($(mode),fast)
|
||||||
cflags += -Ob2it -GL -Zi -DNDEBUG
|
cflags += -O2 -GL -Zi -DNDEBUG
|
||||||
lflags += -LTCG
|
lflags += -LTCG
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),small)
|
ifeq ($(mode),small)
|
||||||
@ -383,7 +387,13 @@ bootimage-object = $(native-build)/bootimage-bin.o
|
|||||||
|
|
||||||
ifeq ($(bootimage),true)
|
ifeq ($(bootimage),true)
|
||||||
ifneq ($(build-arch),$(arch))
|
ifneq ($(build-arch),$(arch))
|
||||||
error "can't cross-build a bootimage"
|
$(error "bootimage cross-builds not yet supported")
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(arch),x86_64)
|
||||||
|
ifneq ($(build-platform),$(platform))
|
||||||
|
$(error "bootimage cross-builds not yet supported")
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
vm-classpath-object = $(bootimage-object)
|
vm-classpath-object = $(bootimage-object)
|
||||||
@ -434,7 +444,6 @@ gnu-overrides = \
|
|||||||
avian/*.class \
|
avian/*.class \
|
||||||
avian/resource/*.class \
|
avian/resource/*.class \
|
||||||
java/lang/Class.class \
|
java/lang/Class.class \
|
||||||
java/lang/Class\$$*.class \
|
|
||||||
java/lang/Enum.class \
|
java/lang/Enum.class \
|
||||||
java/lang/InheritableThreadLocal.class \
|
java/lang/InheritableThreadLocal.class \
|
||||||
java/lang/Object.class \
|
java/lang/Object.class \
|
||||||
@ -457,7 +466,9 @@ gnu-overrides = \
|
|||||||
java/lang/reflect/AccessibleObject.class \
|
java/lang/reflect/AccessibleObject.class \
|
||||||
java/lang/reflect/Constructor.class \
|
java/lang/reflect/Constructor.class \
|
||||||
java/lang/reflect/Field.class \
|
java/lang/reflect/Field.class \
|
||||||
java/lang/reflect/Method.class
|
java/lang/reflect/Method.class \
|
||||||
|
java/lang/reflect/Proxy.class \
|
||||||
|
java/lang/reflect/Proxy\$$*.class
|
||||||
|
|
||||||
test-sources = $(wildcard $(test)/*.java)
|
test-sources = $(wildcard $(test)/*.java)
|
||||||
test-classes = $(call java-classes,$(test-sources),$(test),$(test-build))
|
test-classes = $(call java-classes,$(test-sources),$(test),$(test-build))
|
||||||
|
85
readme.txt
85
readme.txt
@ -12,13 +12,13 @@ on Mac OS X:
|
|||||||
$ build/darwin-i386/avian -cp build/test Hello
|
$ build/darwin-i386/avian -cp build/test Hello
|
||||||
|
|
||||||
on Windows (MSYS):
|
on Windows (MSYS):
|
||||||
|
$ git clone git://oss.readytalk.com/win32.git ../win32
|
||||||
$ export JAVA_HOME="C:/Program Files/Java/jdk1.6.0_07"
|
$ export JAVA_HOME="C:/Program Files/Java/jdk1.6.0_07"
|
||||||
$ make
|
$ make
|
||||||
$ build/windows-i386/avian -cp build/test Hello
|
$ build/windows-i386/avian -cp build/test Hello
|
||||||
|
|
||||||
on Windows (Cygwin):
|
on Windows (Cygwin):
|
||||||
|
$ git clone git://oss.readytalk.com/win32.git ../win32
|
||||||
$ export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.6.0_07"
|
$ export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.6.0_07"
|
||||||
$ make
|
$ make
|
||||||
$ build/windows-i386/avian -cp build/test Hello
|
$ build/windows-i386/avian -cp build/test Hello
|
||||||
@ -96,7 +96,9 @@ certain flags described below, all of which are optional.
|
|||||||
|
|
||||||
* bootimage - if true, create a boot image containing the pre-parsed
|
* bootimage - if true, create a boot image containing the pre-parsed
|
||||||
class library and ahead-of-time compiled methods. This option is
|
class library and ahead-of-time compiled methods. This option is
|
||||||
only valid for process=compile builds.
|
only valid for process=compile builds. Note that you may need to
|
||||||
|
specify both build-arch=x86_64 and arch=x86_64 on 64-bit systems
|
||||||
|
where "uname -m" prints "i386".
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
* heapdump - if true, implement avian.Machine.dumpHeap(String),
|
* heapdump - if true, implement avian.Machine.dumpHeap(String),
|
||||||
@ -151,6 +153,63 @@ directory containing the avian directory)
|
|||||||
|
|
||||||
This gives you the Windows JNI headers, zlib headers and library, and
|
This gives you the Windows JNI headers, zlib headers and library, and
|
||||||
a few other useful libraries like OpenSSL, libjpeg, and libpng.
|
a few other useful libraries like OpenSSL, libjpeg, and libpng.
|
||||||
|
There's also a win64 repository for 64-bit builds:
|
||||||
|
|
||||||
|
$ git clone git://oss.readytalk.com/win64.git
|
||||||
|
|
||||||
|
|
||||||
|
Building with Microsoft the Visual C++ Compiler
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
You can also build using the MSVC compiler, which makes debugging with
|
||||||
|
tools like WinDbg and Visual Studio much easier. Note that you will
|
||||||
|
still need to have GCC installed - MSVC is only used to compile the
|
||||||
|
C++ portions of the VM, while the assembly code and helper tools are
|
||||||
|
built using GCC.
|
||||||
|
|
||||||
|
The MSVC build has been tested with Visual Studio Express Edition
|
||||||
|
versions 8 and 9. Other versions may also work.
|
||||||
|
|
||||||
|
To build with MSVC, install Cygwin as described above and set the
|
||||||
|
following environment variables:
|
||||||
|
|
||||||
|
$ export PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/BIN:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/Tools:/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5:/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v2.0.50727:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.0A/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem"
|
||||||
|
|
||||||
|
$ export LIBPATH="C:\WINDOWS\Microsoft.NET\Framework\v3.5;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;"
|
||||||
|
|
||||||
|
$ export VCINSTALLDIR="C:\Program Files\Microsoft Visual Studio 9.0\VC"
|
||||||
|
|
||||||
|
$ export LIB="C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;"
|
||||||
|
|
||||||
|
$ export INCLUDE="C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v6.0A\include;"
|
||||||
|
|
||||||
|
Adjust these definitions as necessary according to your MSVC
|
||||||
|
installation.
|
||||||
|
|
||||||
|
Finally, build with the msvc flag set to the MSVC tool directory:
|
||||||
|
|
||||||
|
$ make msvc="/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC"
|
||||||
|
|
||||||
|
|
||||||
|
Building with GNU Classpath
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
** Please note that this feature is still under development and is
|
||||||
|
neither complete nor well-tested. **
|
||||||
|
|
||||||
|
By default, Avian uses its own lightweight class library. However,
|
||||||
|
that library only contains a relatively small subset of the classes
|
||||||
|
and methods included in the JRE. If your application requires
|
||||||
|
features beyond that subset, you may want to tell Avian to use GNU
|
||||||
|
Classpath instead. To do so, specify the directory where Classpath is
|
||||||
|
installed, e.g.:
|
||||||
|
|
||||||
|
$ make clean
|
||||||
|
$ make gnu=/usr/local/classpath-0.98
|
||||||
|
|
||||||
|
This build will use the classes and native code from Classpath, except
|
||||||
|
that certain core classes are replaced with implementations from the
|
||||||
|
Avian class library for compatibility with the VM.
|
||||||
|
|
||||||
|
|
||||||
Installing
|
Installing
|
||||||
@ -247,13 +306,13 @@ main(int ac, const char** av)
|
|||||||
JNIEnv* e = static_cast<JNIEnv*>(env);
|
JNIEnv* e = static_cast<JNIEnv*>(env);
|
||||||
|
|
||||||
jclass c = e->FindClass("Hello");
|
jclass c = e->FindClass("Hello");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jclass stringClass = e->FindClass("java/lang/String");
|
jclass stringClass = e->FindClass("java/lang/String");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
|
jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
for (int i = 1; i < ac; ++i) {
|
for (int i = 1; i < ac; ++i) {
|
||||||
e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
|
e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
|
||||||
}
|
}
|
||||||
@ -265,7 +324,7 @@ main(int ac, const char** av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
if (e->ExceptionOccurred()) {
|
if (e->ExceptionCheck()) {
|
||||||
exitCode = -1;
|
exitCode = -1;
|
||||||
e->ExceptionDescribe();
|
e->ExceptionDescribe();
|
||||||
}
|
}
|
||||||
@ -449,13 +508,13 @@ main(int ac, const char** av)
|
|||||||
JNIEnv* e = static_cast<JNIEnv*>(env);
|
JNIEnv* e = static_cast<JNIEnv*>(env);
|
||||||
|
|
||||||
jclass c = e->FindClass("Hello");
|
jclass c = e->FindClass("Hello");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jclass stringClass = e->FindClass("java/lang/String");
|
jclass stringClass = e->FindClass("java/lang/String");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
|
jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
for (int i = 1; i < ac; ++i) {
|
for (int i = 1; i < ac; ++i) {
|
||||||
e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
|
e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
|
||||||
}
|
}
|
||||||
@ -467,7 +526,7 @@ main(int ac, const char** av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
if (e->ExceptionOccurred()) {
|
if (e->ExceptionCheck()) {
|
||||||
exitCode = -1;
|
exitCode = -1;
|
||||||
e->ExceptionDescribe();
|
e->ExceptionDescribe();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -64,12 +64,12 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
|
|||||||
object method = arrayBody(t, classMethodTable(t, c), i);
|
object method = arrayBody(t, classMethodTable(t, c), i);
|
||||||
if ((methodCode(t, method) or (methodFlags(t, method) & ACC_NATIVE))
|
if ((methodCode(t, method) or (methodFlags(t, method) & ACC_NATIVE))
|
||||||
and ((methodName == 0
|
and ((methodName == 0
|
||||||
or strcmp
|
or ::strcmp
|
||||||
(reinterpret_cast<char*>
|
(reinterpret_cast<char*>
|
||||||
(&byteArrayBody
|
(&byteArrayBody
|
||||||
(t, vm::methodName(t, method), 0)), methodName) == 0)
|
(t, vm::methodName(t, method), 0)), methodName) == 0)
|
||||||
and (methodSpec == 0
|
and (methodSpec == 0
|
||||||
or strcmp
|
or ::strcmp
|
||||||
(reinterpret_cast<char*>
|
(reinterpret_cast<char*>
|
||||||
(&byteArrayBody
|
(&byteArrayBody
|
||||||
(t, vm::methodSpec(t, method), 0)), methodSpec)
|
(t, vm::methodSpec(t, method), 0)), methodSpec)
|
||||||
|
@ -200,8 +200,8 @@ Avian_avian_SystemClassLoader_defineClass
|
|||||||
t->m->heap->free(buffer, length);
|
t->m->heap->free(buffer, length);
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
if (getClassLoaderMap(t, loader) == 0) {
|
|
||||||
PROTECT(t, c);
|
PROTECT(t, c);
|
||||||
|
if (getClassLoaderMap(t, loader) == 0) {
|
||||||
object map = makeHashMap(t, 0, 0);
|
object map = makeHashMap(t, 0, 0);
|
||||||
set(t, loader, ClassLoaderMap, map);
|
set(t, loader, ClassLoaderMap, map);
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ Avian_avian_SystemClassLoader_defineClass
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT int64_t JNICALL
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
Avian_avian_SystemClassLoader_findLoadedClass
|
Avian_avian_SystemClassLoader_reallyFindLoadedClass
|
||||||
(Thread* t, object, uintptr_t* arguments)
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
{
|
{
|
||||||
object name = reinterpret_cast<object>(arguments[1]);
|
object name = reinterpret_cast<object>(arguments[1]);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined __MINGW32__ || defined __CYGWIN32__
|
||||||
|
|
||||||
#define CALLEE_SAVED_REGISTER_FOOTPRINT 64
|
#define CALLEE_SAVED_REGISTER_FOOTPRINT 64
|
||||||
|
|
||||||
@ -107,9 +107,9 @@ GLOBAL(vmJumpAndInvoke):
|
|||||||
// %rdx: address
|
// %rdx: address
|
||||||
// %r8 : base
|
// %r8 : base
|
||||||
// %r9 : (unused)
|
// %r9 : (unused)
|
||||||
// 8(%rsp): argumentFootprint
|
// 40(%rsp): argumentFootprint
|
||||||
// 16(%rsp): arguments
|
// 48(%rsp): arguments
|
||||||
// 24(%rsp): frameSize
|
// 56(%rsp): frameSize
|
||||||
|
|
||||||
movq %r8,%rbp
|
movq %r8,%rbp
|
||||||
|
|
||||||
@ -118,20 +118,20 @@ GLOBAL(vmJumpAndInvoke):
|
|||||||
movq %rbp,%r9
|
movq %rbp,%r9
|
||||||
|
|
||||||
// allocate new frame, adding room for callee-saved registers
|
// allocate new frame, adding room for callee-saved registers
|
||||||
movl 24(%rsp),%eax
|
movl 56(%rsp),%eax
|
||||||
subq %rax,%r9
|
subq %rax,%r9
|
||||||
subq $CALLEE_SAVED_REGISTER_FOOTPRINT,%r9
|
subq $CALLEE_SAVED_REGISTER_FOOTPRINT,%r9
|
||||||
|
|
||||||
movq %rcx,%rbx
|
movq %rcx,%rbx
|
||||||
|
|
||||||
// set return address
|
// set return address
|
||||||
movq vmInvoke_returnAddress@GOTPCREL(%rip),%r10
|
leaq GLOBAL(vmInvoke_returnAddress)(%rip),%r10
|
||||||
movq %r10,(%r9)
|
movq %r10,(%r9)
|
||||||
|
|
||||||
// copy arguments into place
|
// copy arguments into place
|
||||||
movq $0,%r11
|
movq $0,%r11
|
||||||
movq 16(%rsp),%r8
|
movl 48(%rsp),%r8d
|
||||||
movq 8(%rsp),%rax
|
movl 40(%rsp),%eax
|
||||||
jmp LOCAL(vmJumpAndInvoke_argumentTest)
|
jmp LOCAL(vmJumpAndInvoke_argumentTest)
|
||||||
|
|
||||||
LOCAL(vmJumpAndInvoke_argumentLoop):
|
LOCAL(vmJumpAndInvoke_argumentLoop):
|
||||||
@ -154,7 +154,7 @@ LOCAL(vmJumpAndInvoke_argumentTest):
|
|||||||
int3
|
int3
|
||||||
#endif // not AVIAN_CONTINUATIONS
|
#endif // not AVIAN_CONTINUATIONS
|
||||||
|
|
||||||
#else // not __MINGW32__
|
#else // not __MINGW32__ || __CYGWIN32__
|
||||||
|
|
||||||
#define CALLEE_SAVED_REGISTER_FOOTPRINT 48
|
#define CALLEE_SAVED_REGISTER_FOOTPRINT 48
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ GLOBAL(vmJumpAndInvoke):
|
|||||||
movq %rdi,%rbx
|
movq %rdi,%rbx
|
||||||
|
|
||||||
// set return address
|
// set return address
|
||||||
movq vmInvoke_returnAddress@GOTPCREL(%rip),%r10
|
movq GLOBAL(vmInvoke_returnAddress)@GOTPCREL(%rip),%r10
|
||||||
movq %r10,(%rcx)
|
movq %r10,(%rcx)
|
||||||
|
|
||||||
// copy arguments into place
|
// copy arguments into place
|
||||||
@ -279,7 +279,7 @@ LOCAL(vmJumpAndInvoke_argumentTest):
|
|||||||
int3
|
int3
|
||||||
#endif // not AVIAN_CONTINUATIONS
|
#endif // not AVIAN_CONTINUATIONS
|
||||||
|
|
||||||
#endif // not __MINGW32__
|
#endif // not __MINGW32__ || __CYGWIN32__
|
||||||
|
|
||||||
#elif defined __i386__
|
#elif defined __i386__
|
||||||
|
|
||||||
@ -396,9 +396,18 @@ GLOBAL(vmJumpAndInvoke):
|
|||||||
movl 4(%esp),%ebx
|
movl 4(%esp),%ebx
|
||||||
|
|
||||||
// set return address
|
// set return address
|
||||||
|
#if defined __MINGW32__ || defined __CYGWIN32__
|
||||||
|
movl $vmInvoke_returnAddress,%esi
|
||||||
|
#else
|
||||||
call LOCAL(getPC)
|
call LOCAL(getPC)
|
||||||
|
# if defined __APPLE__
|
||||||
|
LOCAL(vmJumpAndInvoke_offset):
|
||||||
|
leal vmInvoke_returnAddress-LOCAL(vmJumpAndInvoke_offset)(%esi),%esi
|
||||||
|
# else
|
||||||
addl $_GLOBAL_OFFSET_TABLE_,%esi
|
addl $_GLOBAL_OFFSET_TABLE_,%esi
|
||||||
movl vmInvoke_returnAddress@GOT(%esi),%esi
|
movl vmInvoke_returnAddress@GOT(%esi),%esi
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
movl %esi,(%ecx)
|
movl %esi,(%ecx)
|
||||||
|
|
||||||
// copy arguments into place
|
// copy arguments into place
|
||||||
|
@ -1886,7 +1886,7 @@ makeCurrentContinuation(MyThread* t, void** targetIp, void** targetBase,
|
|||||||
*targetIp = ip;
|
*targetIp = ip;
|
||||||
*targetBase = base;
|
*targetBase = base;
|
||||||
*targetStack = static_cast<void**>(stack)
|
*targetStack = static_cast<void**>(stack)
|
||||||
+ t->arch->frameReturnAddressSize();;
|
+ t->arch->frameReturnAddressSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2955,7 +2955,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
{
|
{
|
||||||
#define MATCH(name, constant) \
|
#define MATCH(name, constant) \
|
||||||
(byteArrayLength(t, name) == sizeof(constant) \
|
(byteArrayLength(t, name) == sizeof(constant) \
|
||||||
and strcmp(reinterpret_cast<char*>(&byteArrayBody(t, name, 0)), \
|
and ::strcmp(reinterpret_cast<char*>(&byteArrayBody(t, name, 0)), \
|
||||||
constant) == 0)
|
constant) == 0)
|
||||||
|
|
||||||
object className = vm::className(t, methodClass(t, target));
|
object className = vm::className(t, methodClass(t, target));
|
||||||
@ -6973,6 +6973,8 @@ class MyProcessor: public Processor {
|
|||||||
nativeThunk(0),
|
nativeThunk(0),
|
||||||
bootNativeThunk(0),
|
bootNativeThunk(0),
|
||||||
aioobThunk(0),
|
aioobThunk(0),
|
||||||
|
thunkTable(0),
|
||||||
|
bootThunkTable(0),
|
||||||
callTable(0),
|
callTable(0),
|
||||||
methodTree(0),
|
methodTree(0),
|
||||||
methodTreeSentinal(0),
|
methodTreeSentinal(0),
|
||||||
@ -6985,6 +6987,7 @@ class MyProcessor: public Processor {
|
|||||||
bootImage(0),
|
bootImage(0),
|
||||||
codeAllocator(s, 0, 0),
|
codeAllocator(s, 0, 0),
|
||||||
thunkSize(0),
|
thunkSize(0),
|
||||||
|
bootThunkSize(0),
|
||||||
callTableSize(0),
|
callTableSize(0),
|
||||||
useNativeFeatures(useNativeFeatures)
|
useNativeFeatures(useNativeFeatures)
|
||||||
{ }
|
{ }
|
||||||
@ -7119,11 +7122,20 @@ class MyProcessor: public Processor {
|
|||||||
{
|
{
|
||||||
if (o) {
|
if (o) {
|
||||||
MyThread* t = static_cast<MyThread*>(vmt);
|
MyThread* t = static_cast<MyThread*>(vmt);
|
||||||
PROTECT(t, o);
|
|
||||||
|
for (Reference* r = t->reference; r; r = r->next) {
|
||||||
|
if (r->target == o) {
|
||||||
|
acquire(t, r);
|
||||||
|
|
||||||
|
return &(r->target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference* r = new (t->m->heap->allocate(sizeof(Reference)))
|
Reference* r = new (t->m->heap->allocate(sizeof(Reference)))
|
||||||
Reference(o, &(t->reference));
|
Reference(o, &(t->reference));
|
||||||
|
|
||||||
|
acquire(t, r);
|
||||||
|
|
||||||
return &(r->target);
|
return &(r->target);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -7134,7 +7146,7 @@ class MyProcessor: public Processor {
|
|||||||
disposeLocalReference(Thread* t, object* r)
|
disposeLocalReference(Thread* t, object* r)
|
||||||
{
|
{
|
||||||
if (r) {
|
if (r) {
|
||||||
vm::dispose(t, reinterpret_cast<Reference*>(r));
|
release(t, reinterpret_cast<Reference*>(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7298,8 +7310,14 @@ class MyProcessor: public Processor {
|
|||||||
uint8_t* thunkStart = p->thunkTable;
|
uint8_t* thunkStart = p->thunkTable;
|
||||||
uint8_t* thunkEnd = thunkStart + (p->thunkSize * ThunkCount);
|
uint8_t* thunkEnd = thunkStart + (p->thunkSize * ThunkCount);
|
||||||
|
|
||||||
if (static_cast<uint8_t*>(ip) >= thunkStart
|
uint8_t* bootThunkStart = p->bootThunkTable;
|
||||||
|
uint8_t* bootThunkEnd = bootThunkStart
|
||||||
|
+ (p->bootThunkSize * ThunkCount);
|
||||||
|
|
||||||
|
if ((static_cast<uint8_t*>(ip) >= thunkStart
|
||||||
and static_cast<uint8_t*>(ip) < thunkEnd)
|
and static_cast<uint8_t*>(ip) < thunkEnd)
|
||||||
|
or (static_cast<uint8_t*>(ip) >= bootThunkStart
|
||||||
|
and static_cast<uint8_t*>(ip) < bootThunkEnd))
|
||||||
{
|
{
|
||||||
target->ip = t->arch->frameIp(stack);
|
target->ip = t->arch->frameIp(stack);
|
||||||
target->base = base;
|
target->base = base;
|
||||||
@ -7462,6 +7480,7 @@ class MyProcessor: public Processor {
|
|||||||
uint8_t* bootNativeThunk;
|
uint8_t* bootNativeThunk;
|
||||||
uint8_t* aioobThunk;
|
uint8_t* aioobThunk;
|
||||||
uint8_t* thunkTable;
|
uint8_t* thunkTable;
|
||||||
|
uint8_t* bootThunkTable;
|
||||||
object callTable;
|
object callTable;
|
||||||
object methodTree;
|
object methodTree;
|
||||||
object methodTreeSentinal;
|
object methodTreeSentinal;
|
||||||
@ -7475,6 +7494,7 @@ class MyProcessor: public Processor {
|
|||||||
SegFaultHandler segFaultHandler;
|
SegFaultHandler segFaultHandler;
|
||||||
FixedAllocator codeAllocator;
|
FixedAllocator codeAllocator;
|
||||||
unsigned thunkSize;
|
unsigned thunkSize;
|
||||||
|
unsigned bootThunkSize;
|
||||||
unsigned callTableSize;
|
unsigned callTableSize;
|
||||||
bool useNativeFeatures;
|
bool useNativeFeatures;
|
||||||
};
|
};
|
||||||
@ -7748,6 +7768,8 @@ fixupThunks(MyThread* t, BootImage* image, uint8_t* code)
|
|||||||
|
|
||||||
p->bootDefaultThunk = code + image->defaultThunk;
|
p->bootDefaultThunk = code + image->defaultThunk;
|
||||||
p->bootNativeThunk = code + image->nativeThunk;
|
p->bootNativeThunk = code + image->nativeThunk;
|
||||||
|
p->bootThunkTable = code + image->thunkTable;
|
||||||
|
p->bootThunkSize = image->thunkSize;
|
||||||
|
|
||||||
updateCall(t, LongCall, code + image->compileMethodCall,
|
updateCall(t, LongCall, code + image->compileMethodCall,
|
||||||
voidPointer(local::compileMethod));
|
voidPointer(local::compileMethod));
|
||||||
|
@ -2156,7 +2156,8 @@ class MemorySite: public Site {
|
|||||||
|
|
||||||
virtual SiteMask mask(Context* c) {
|
virtual SiteMask mask(Context* c) {
|
||||||
return SiteMask(1 << MemoryOperand, 0, (base == c->arch->stack())
|
return SiteMask(1 << MemoryOperand, 0, (base == c->arch->stack())
|
||||||
? offsetToFrameIndex(c, offset) : NoFrameIndex);
|
? static_cast<int>(offsetToFrameIndex(c, offset))
|
||||||
|
: NoFrameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SiteMask nextWordMask(Context* c, unsigned index) {
|
virtual SiteMask nextWordMask(Context* c, unsigned index) {
|
||||||
@ -2439,6 +2440,19 @@ maybeMove(Context* c, Read* read, bool intersectRead, bool includeNextWord,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cost) {
|
if (cost) {
|
||||||
|
if (DebugMoves) {
|
||||||
|
char srcb[256]; src->toString(c, srcb, 256);
|
||||||
|
char dstb[256]; dst->toString(c, dstb, 256);
|
||||||
|
fprintf(stderr, "maybe move %s to %s for %p to %p\n",
|
||||||
|
srcb, dstb, value, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
src->freeze(c, value);
|
||||||
|
|
||||||
|
addSite(c, value, dst);
|
||||||
|
|
||||||
|
src->thaw(c, value);
|
||||||
|
|
||||||
if (not src->match(c, srcMask)) {
|
if (not src->match(c, srcMask)) {
|
||||||
src->freeze(c, value);
|
src->freeze(c, value);
|
||||||
dst->freeze(c, value);
|
dst->freeze(c, value);
|
||||||
@ -2450,6 +2464,8 @@ maybeMove(Context* c, Read* read, bool intersectRead, bool includeNextWord,
|
|||||||
|
|
||||||
Site* tmp = pickTargetSite(c, &tmpRead, true);
|
Site* tmp = pickTargetSite(c, &tmpRead, true);
|
||||||
|
|
||||||
|
addSite(c, value, tmp);
|
||||||
|
|
||||||
move(c, value, src, tmp);
|
move(c, value, src, tmp);
|
||||||
|
|
||||||
dst->thaw(c, value);
|
dst->thaw(c, value);
|
||||||
@ -2851,10 +2867,9 @@ move(Context* c, Value* value, Site* src, Site* dst)
|
|||||||
srcb, dstb, value, value);
|
srcb, dstb, value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(c, findSite(c, value, dst));
|
||||||
|
|
||||||
src->freeze(c, value);
|
src->freeze(c, value);
|
||||||
|
|
||||||
addSite(c, value, dst);
|
|
||||||
|
|
||||||
dst->freeze(c, value);
|
dst->freeze(c, value);
|
||||||
|
|
||||||
unsigned srcSize;
|
unsigned srcSize;
|
||||||
@ -3197,7 +3212,7 @@ class CallEvent: public Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < stackArgumentFootprint; ++i) {
|
for (unsigned i = 0; i < stackArgumentFootprint; ++i) {
|
||||||
Value* v = arguments[i];
|
Value* v = RUNTIME_ARRAY_BODY(arguments)[i];
|
||||||
if (v) {
|
if (v) {
|
||||||
int frameIndex = i + frameOffset;
|
int frameIndex = i + frameOffset;
|
||||||
|
|
||||||
@ -5279,10 +5294,6 @@ resolveSourceSites(Context* c, Event* e, SiteRecordList* frozen, Site** sites)
|
|||||||
|
|
||||||
Site* s = pickSourceSite
|
Site* s = pickSourceSite
|
||||||
(c, r, 0, 0, &mask, true, false, true, acceptForResolve);
|
(c, r, 0, 0, &mask, true, false, true, acceptForResolve);
|
||||||
if (s == 0) {
|
|
||||||
s = pickSourceSite
|
|
||||||
(c, r, 0, 0, &mask, false, false, true, acceptForResolve);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
if (DebugControl) {
|
if (DebugControl) {
|
||||||
@ -5317,13 +5328,10 @@ resolveTargetSites(Context* c, Event* e, SiteRecordList* frozen, Site** sites)
|
|||||||
|
|
||||||
Site* s = pickSourceSite
|
Site* s = pickSourceSite
|
||||||
(c, r, 0, 0, &mask, true, true, true, acceptForResolve);
|
(c, r, 0, 0, &mask, true, true, true, acceptForResolve);
|
||||||
if (s == 0) {
|
|
||||||
s = pickSourceSite
|
|
||||||
(c, r, 0, 0, &mask, false, true, true, acceptForResolve);
|
|
||||||
if (s == 0) {
|
if (s == 0) {
|
||||||
s = maybeMove(c, v, mask, false, true, ResolveRegisterReserveCount);
|
s = maybeMove(c, v, mask, false, true, ResolveRegisterReserveCount);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
freeze(c, frozen, s, v);
|
freeze(c, frozen, s, v);
|
||||||
|
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
/* Copyright (c) 2009, 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. */
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
#define THREAD_CONTINUATION 176
|
#define THREAD_CONTINUATION 176
|
||||||
@ -42,7 +52,11 @@ LOCAL(vmInvoke_continuationTest):
|
|||||||
|
|
||||||
// set the return address to vmInvoke_returnAddress
|
// set the return address to vmInvoke_returnAddress
|
||||||
movq CONTINUATION_RETURN_ADDRESS_OFFSET(%rcx),%rdi
|
movq CONTINUATION_RETURN_ADDRESS_OFFSET(%rcx),%rdi
|
||||||
movq vmInvoke_returnAddress@GOTPCREL(%rip),%r10
|
#if defined __MINGW32__ || defined __CYGWIN32__
|
||||||
|
leaq GLOBAL(vmInvoke_returnAddress)(%rip),%r10
|
||||||
|
#else
|
||||||
|
movq GLOBAL(vmInvoke_returnAddress)@GOTPCREL(%rip),%r10
|
||||||
|
#endif
|
||||||
movq %r10,(%rsp,%rdi,1)
|
movq %r10,(%rsp,%rdi,1)
|
||||||
|
|
||||||
// save the current base pointer in the frame and update it
|
// save the current base pointer in the frame and update it
|
||||||
@ -93,9 +107,11 @@ LOCAL(vmInvoke_exit):
|
|||||||
cmpl $0,%ecx
|
cmpl $0,%ecx
|
||||||
je LOCAL(vmInvoke_exit)
|
je LOCAL(vmInvoke_exit)
|
||||||
|
|
||||||
// allocate a frame of size (continuation.length * BYTES_PER_WORD)
|
// allocate a frame of size (continuation.length * BYTES_PER_WORD),
|
||||||
|
// plus stack alignment padding
|
||||||
movl CONTINUATION_LENGTH(%ecx),%esi
|
movl CONTINUATION_LENGTH(%ecx),%esi
|
||||||
shll $2,%esi
|
shll $2,%esi
|
||||||
|
leal 8(%esi),%esi
|
||||||
subl %esi,%esp
|
subl %esi,%esp
|
||||||
|
|
||||||
// copy the continuation body into the frame
|
// copy the continuation body into the frame
|
||||||
@ -121,9 +137,18 @@ LOCAL(vmInvoke_continuationTest):
|
|||||||
|
|
||||||
// set the return address to vmInvoke_returnAddress
|
// set the return address to vmInvoke_returnAddress
|
||||||
movl CONTINUATION_RETURN_ADDRESS_OFFSET(%ecx),%edi
|
movl CONTINUATION_RETURN_ADDRESS_OFFSET(%ecx),%edi
|
||||||
|
#if defined __MINGW32__ || defined __CYGWIN32__
|
||||||
|
movl $vmInvoke_returnAddress,%esi
|
||||||
|
#else
|
||||||
call LOCAL(getPC)
|
call LOCAL(getPC)
|
||||||
|
# if defined __APPLE__
|
||||||
|
LOCAL(vmInvoke_offset):
|
||||||
|
leal vmInvoke_returnAddress-LOCAL(vmInvoke_offset)(%esi),%esi
|
||||||
|
# else
|
||||||
addl $_GLOBAL_OFFSET_TABLE_,%esi
|
addl $_GLOBAL_OFFSET_TABLE_,%esi
|
||||||
movl vmInvoke_returnAddress@GOT(%esi),%esi
|
movl vmInvoke_returnAddress@GOT(%esi),%esi
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
movl %esi,(%esp,%edi,1)
|
movl %esi,(%esp,%edi,1)
|
||||||
|
|
||||||
// save the current base pointer in the frame and update it
|
// save the current base pointer in the frame and update it
|
||||||
|
@ -351,7 +351,7 @@ Avian_java_lang_VMClassLoader_getPrimitiveClass
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT int64_t JNICALL
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
Avian_java_lang_ClassLoader_defineClass
|
Avian_avian_SystemClassLoader_defineClass
|
||||||
(Thread*, object, uintptr_t*);
|
(Thread*, object, uintptr_t*);
|
||||||
|
|
||||||
extern "C" JNIEXPORT int64_t JNICALL
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
@ -367,7 +367,7 @@ Avian_java_lang_VMClassLoader_defineClass
|
|||||||
// fprintf(stderr, "define class %s in %p\n", n,
|
// fprintf(stderr, "define class %s in %p\n", n,
|
||||||
// reinterpret_cast<void*>(arguments[0]));
|
// reinterpret_cast<void*>(arguments[0]));
|
||||||
|
|
||||||
return Avian_java_lang_ClassLoader_defineClass(t, 0, args);
|
return Avian_avian_SystemClassLoader_defineClass(t, 0, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT int64_t JNICALL
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -15,6 +15,8 @@ using namespace vm;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
namespace local {
|
||||||
|
|
||||||
const uintptr_t PointerShift = log(BytesPerWord);
|
const uintptr_t PointerShift = log(BytesPerWord);
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
@ -157,7 +159,7 @@ find(Context* c, object p)
|
|||||||
int
|
int
|
||||||
Set::find(object value)
|
Set::find(object value)
|
||||||
{
|
{
|
||||||
Set::Entry* e = ::find(context, value);
|
Set::Entry* e = local::find(context, value);
|
||||||
if (e) {
|
if (e) {
|
||||||
return e->number;
|
return e->number;
|
||||||
} else {
|
} else {
|
||||||
@ -328,6 +330,8 @@ class MyHeapWalker: public HeapWalker {
|
|||||||
HeapVisitor* visitor;
|
HeapVisitor* visitor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace local
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
@ -335,7 +339,8 @@ namespace vm {
|
|||||||
HeapWalker*
|
HeapWalker*
|
||||||
makeHeapWalker(Thread* t, HeapVisitor* v)
|
makeHeapWalker(Thread* t, HeapVisitor* v)
|
||||||
{
|
{
|
||||||
return new (t->m->heap->allocate(sizeof(MyHeapWalker))) MyHeapWalker(t, v);
|
return new (t->m->heap->allocate(sizeof(local::MyHeapWalker)))
|
||||||
|
local::MyHeapWalker(t, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
|
@ -506,7 +506,7 @@ resolveNativeMethodData(Thread* t, object method)
|
|||||||
// ensure other threads see updated methodVmFlags before
|
// ensure other threads see updated methodVmFlags before
|
||||||
// methodCode, and that the native method data is initialized
|
// methodCode, and that the native method data is initialized
|
||||||
// before it is visible to those threads:
|
// before it is visible to those threads:
|
||||||
memoryBarrier();
|
storeStoreMemoryBarrier();
|
||||||
|
|
||||||
set(t, method, MethodCode, data);
|
set(t, method, MethodCode, data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1186,9 +1186,19 @@ NewGlobalRef(Thread* t, jobject o)
|
|||||||
ACQUIRE(t, t->m->referenceLock);
|
ACQUIRE(t, t->m->referenceLock);
|
||||||
|
|
||||||
if (o) {
|
if (o) {
|
||||||
|
for (Reference* r = t->m->jniReferences; r; r = r->next) {
|
||||||
|
if (r->target == *o) {
|
||||||
|
acquire(t, r);
|
||||||
|
|
||||||
|
return &(r->target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference* r = new (t->m->heap->allocate(sizeof(Reference)))
|
Reference* r = new (t->m->heap->allocate(sizeof(Reference)))
|
||||||
Reference(*o, &(t->m->jniReferences));
|
Reference(*o, &(t->m->jniReferences));
|
||||||
|
|
||||||
|
acquire(t, r);
|
||||||
|
|
||||||
return &(r->target);
|
return &(r->target);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1203,7 +1213,7 @@ DeleteGlobalRef(Thread* t, jobject r)
|
|||||||
ACQUIRE(t, t->m->referenceLock);
|
ACQUIRE(t, t->m->referenceLock);
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
dispose(t, reinterpret_cast<Reference*>(r));
|
release(t, reinterpret_cast<Reference*>(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,8 +173,10 @@ turnOffTheLights(Thread* t)
|
|||||||
|
|
||||||
void (*function)(Thread*, object);
|
void (*function)(Thread*, object);
|
||||||
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
||||||
|
if (function) {
|
||||||
function(t, finalizerTarget(t, f));
|
function(t, finalizerTarget(t, f));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (object* p = &(t->m->tenuredFinalizers); *p;) {
|
for (object* p = &(t->m->tenuredFinalizers); *p;) {
|
||||||
object f = *p;
|
object f = *p;
|
||||||
@ -182,8 +184,10 @@ turnOffTheLights(Thread* t)
|
|||||||
|
|
||||||
void (*function)(Thread*, object);
|
void (*function)(Thread*, object);
|
||||||
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
||||||
|
if (function) {
|
||||||
function(t, finalizerTarget(t, f));
|
function(t, finalizerTarget(t, f));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Machine* m = t->m;
|
Machine* m = t->m;
|
||||||
|
|
||||||
@ -230,7 +234,7 @@ makeJavaThread(Thread* t, Thread* parent)
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
group = threadGroup(t, parent->javaThread);
|
group = threadGroup(t, parent->javaThread);
|
||||||
} else {
|
} else {
|
||||||
group = makeThreadGroup(t, 0, 0);
|
group = makeThreadGroup(t, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned NewState = 0;
|
const unsigned NewState = 0;
|
||||||
@ -1848,8 +1852,9 @@ bootClass(Thread* t, Machine::Type type, int superType, uint32_t objectMask,
|
|||||||
super = (superType >= 0 ? arrayBody(t, t->m->types, superType) : 0);
|
super = (superType >= 0 ? arrayBody(t, t->m->types, superType) : 0);
|
||||||
|
|
||||||
object class_ = t->m->processor->makeClass
|
object class_ = t->m->processor->makeClass
|
||||||
(t, 0, BootstrapFlag, fixedSize, arrayElementSize, 0, mask, 0, 0, super, 0,
|
(t, 0, BootstrapFlag, fixedSize, arrayElementSize,
|
||||||
0, 0, 0, 0, 0, t->m->loader, vtableLength);
|
arrayElementSize ? 1 : 0, mask, 0, 0, super, 0, 0, 0, 0, 0, 0,
|
||||||
|
t->m->loader, vtableLength);
|
||||||
|
|
||||||
set(t, t->m->types, ArrayBody + (type * BytesPerWord), class_);
|
set(t, t->m->types, ArrayBody + (type * BytesPerWord), class_);
|
||||||
}
|
}
|
||||||
@ -1951,6 +1956,23 @@ boot(Thread* t)
|
|||||||
classVmFlags(t, arrayBody(t, m->types, Machine::JvoidType))
|
classVmFlags(t, arrayBody(t, m->types, Machine::JvoidType))
|
||||||
|= PrimitiveFlag;
|
|= PrimitiveFlag;
|
||||||
|
|
||||||
|
set(t, arrayBody(t, m->types, Machine::BooleanArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JbooleanType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::ByteArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JbyteType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::CharArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JcharType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::ShortArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JshortType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::IntArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JintType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::LongArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JlongType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::FloatArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JfloatType));
|
||||||
|
set(t, arrayBody(t, m->types, Machine::DoubleArrayType), ClassStaticTable,
|
||||||
|
arrayBody(t, m->types, Machine::JdoubleType));
|
||||||
|
|
||||||
m->classMap = makeHashMap(t, 0, 0);
|
m->classMap = makeHashMap(t, 0, 0);
|
||||||
|
|
||||||
m->bootstrapClassMap = makeHashMap(t, 0, 0);
|
m->bootstrapClassMap = makeHashMap(t, 0, 0);
|
||||||
|
@ -1131,7 +1131,8 @@ class Reference {
|
|||||||
Reference(object target, Reference** handle):
|
Reference(object target, Reference** handle):
|
||||||
target(target),
|
target(target),
|
||||||
next(*handle),
|
next(*handle),
|
||||||
handle(handle)
|
handle(handle),
|
||||||
|
count(0)
|
||||||
{
|
{
|
||||||
if (next) {
|
if (next) {
|
||||||
next->handle = &next;
|
next->handle = &next;
|
||||||
@ -1142,6 +1143,7 @@ class Reference {
|
|||||||
object target;
|
object target;
|
||||||
Reference* next;
|
Reference* next;
|
||||||
Reference** handle;
|
Reference** handle;
|
||||||
|
unsigned count;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Machine {
|
class Machine {
|
||||||
@ -1404,6 +1406,20 @@ dispose(Thread* t, Reference* r)
|
|||||||
t->m->heap->free(r, sizeof(*r));
|
t->m->heap->free(r, sizeof(*r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
acquire(Thread*, Reference* r)
|
||||||
|
{
|
||||||
|
++ r->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
release(Thread* t, Reference* r)
|
||||||
|
{
|
||||||
|
if ((-- r->count) == 0) {
|
||||||
|
dispose(t, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
collect(Thread* t, Heap::CollectionType type);
|
collect(Thread* t, Heap::CollectionType type);
|
||||||
|
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -178,13 +178,13 @@ main(int ac, const char** av)
|
|||||||
JNIEnv* e = static_cast<JNIEnv*>(env);
|
JNIEnv* e = static_cast<JNIEnv*>(env);
|
||||||
|
|
||||||
jclass c = e->FindClass(class_);
|
jclass c = e->FindClass(class_);
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jclass stringClass = e->FindClass("java/lang/String");
|
jclass stringClass = e->FindClass("java/lang/String");
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
jobjectArray a = e->NewObjectArray(argc, stringClass, 0);
|
jobjectArray a = e->NewObjectArray(argc, stringClass, 0);
|
||||||
if (not e->ExceptionOccurred()) {
|
if (not e->ExceptionCheck()) {
|
||||||
for (int i = 0; i < argc; ++i) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
e->SetObjectArrayElement(a, i, e->NewStringUTF(argv[i]));
|
e->SetObjectArrayElement(a, i, e->NewStringUTF(argv[i]));
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ main(int ac, const char** av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
if (e->ExceptionOccurred()) {
|
if (e->ExceptionCheck()) {
|
||||||
exitCode = -1;
|
exitCode = -1;
|
||||||
e->ExceptionDescribe();
|
e->ExceptionDescribe();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2008, Avian Contributors
|
/* Copyright (c) 2008-2009, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
There is NO WARRANTY for this software. See license.txt for
|
There is NO WARRANTY for this software. See license.txt for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define LOCAL(x) .L##x
|
#define LOCAL(x) .L##x
|
||||||
@ -168,8 +167,8 @@ LOCAL(exit):
|
|||||||
.globl GLOBAL(vmJump)
|
.globl GLOBAL(vmJump)
|
||||||
GLOBAL(vmJump):
|
GLOBAL(vmJump):
|
||||||
movq %rdx,%rbp
|
movq %rdx,%rbp
|
||||||
movq 8(%rsp),%rax
|
movq 40(%rsp),%rax
|
||||||
movq 16(%rsp),%rdx
|
movq 48(%rsp),%rdx
|
||||||
movq %r8,%rsp
|
movq %r8,%rsp
|
||||||
movq %r9,%rbx
|
movq %r9,%rbx
|
||||||
jmp *%rcx
|
jmp *%rcx
|
||||||
|
@ -981,7 +981,7 @@ sseMoveRR(Context* c, unsigned aSize, Assembler::Register* a,
|
|||||||
modrm(c, 0xc0, a, b);
|
modrm(c, 0xc0, a, b);
|
||||||
} else {
|
} else {
|
||||||
opcode(c, 0xf2);
|
opcode(c, 0xf2);
|
||||||
maybeRex(c, 8, a, b);
|
maybeRex(c, 4, a, b);
|
||||||
opcode(c, 0x0f, 0x10);
|
opcode(c, 0x0f, 0x10);
|
||||||
modrm(c, 0xc0, a, b);
|
modrm(c, 0xc0, a, b);
|
||||||
}
|
}
|
||||||
|
38
src/x86.h
38
src/x86.h
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# include "windows.h"
|
# include "windows.h"
|
||||||
|
# pragma push_macro("assert")
|
||||||
|
# include "intrin.h"
|
||||||
|
# pragma pop_macro("assert")
|
||||||
|
# undef interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_x86_32
|
#ifdef ARCH_x86_32
|
||||||
@ -155,7 +159,23 @@ trap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
memoryBarrier()
|
programOrderMemoryBarrier()
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_ReadWriteBarrier();
|
||||||
|
#else
|
||||||
|
__asm__ __volatile__("": : :"memory");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
storeStoreMemoryBarrier()
|
||||||
|
{
|
||||||
|
programOrderMemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
storeLoadMemoryBarrier()
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
MemoryBarrier();
|
MemoryBarrier();
|
||||||
@ -166,28 +186,16 @@ memoryBarrier()
|
|||||||
#endif // ARCH_x86_64
|
#endif // ARCH_x86_64
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
storeStoreMemoryBarrier()
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("": : :"memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
storeLoadMemoryBarrier()
|
|
||||||
{
|
|
||||||
memoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
loadMemoryBarrier()
|
loadMemoryBarrier()
|
||||||
{
|
{
|
||||||
__asm__ __volatile__("": : :"memory");
|
programOrderMemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
syncInstructionCache(const void*, unsigned)
|
syncInstructionCache(const void*, unsigned)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__("": : :"memory");
|
programOrderMemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_ATOMIC_OPERATIONS
|
#ifdef USE_ATOMIC_OPERATIONS
|
||||||
|
@ -15,3 +15,9 @@
|
|||||||
#define inflateInit2(strm, windowBits) \
|
#define inflateInit2(strm, windowBits) \
|
||||||
inflateInit2_((strm), (windowBits), ZLIB_VERSION, static_cast<int>(sizeof(z_stream)))
|
inflateInit2_((strm), (windowBits), ZLIB_VERSION, static_cast<int>(sizeof(z_stream)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef deflateInit2
|
||||||
|
#undef deflateInit2
|
||||||
|
#define deflateInit2(strm, level, windowBits) \
|
||||||
|
deflateInit2_((strm), (level), Z_DEFLATED, (windowBits), 8, Z_DEFAULT_STRATEGY, ZLIB_VERSION, static_cast<int>(sizeof(z_stream)))
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user