Merge remote branch 'oss/master'

This commit is contained in:
Joel Dice 2011-08-18 09:45:37 -06:00
commit 3793174bb0
68 changed files with 572 additions and 186 deletions

View File

@ -50,7 +50,7 @@ import java.util.concurrent.Callable;
* frames from within that context.
*
* <p>Calling a continuation (i.e. feeding it a result or exception)
* causes the current continuation to be replaced with the calling
* causes the current continuation to be replaced with the called
* continuation. When the last method in this new continuation
* returns, it returns to the native frame which created the current
* context, which may or may not be the same as the context in which

View File

@ -0,0 +1,26 @@
/* Copyright (c) 2011, 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 avian;
import java.io.ByteArrayOutputStream;
public class Iso88591 {
public static byte[] encode(char[] s16, int offset, int length) {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
for (int i = offset; i < offset+length; ++i) {
// ISO-88591-1/Latin-1 is the same as UTF-16 under 0x100
buf.write(s16[i]);
}
return buf.toByteArray();
}
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -314,10 +314,29 @@ Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path)
}
extern "C" JNIEXPORT jstring JNICALL
Java_java_io_File_toAbsolutePath(JNIEnv* /*e*/, jclass, jstring path)
Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path)
{
#ifdef PLATFORM_WINDOWS
// todo
return path;
#else
jstring result = path;
string_t chars = getChars(e, path);
if (chars) {
if (chars[0] != '/') {
char* cwd = getcwd(NULL, 0);
if (cwd) {
unsigned size = strlen(cwd) + strlen(chars) + 2;
RUNTIME_ARRAY(char, buffer, size);
snprintf(RUNTIME_ARRAY_BODY(buffer), size, "%s/%s", cwd, chars);
result = e->NewStringUTF(RUNTIME_ARRAY_BODY(buffer));
free(cwd);
}
}
releaseChars(e, path, chars);
}
return result;
#endif
}
extern "C" JNIEXPORT jlong JNICALL

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -48,6 +48,7 @@
# define SO_SUFFIX ".so"
# endif
# include "unistd.h"
# include "limits.h"
# include "sys/time.h"
# include "sys/sysctl.h"
# include "sys/utsname.h"
@ -410,8 +411,8 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
execvp(argv[0], argv);
// Error if here
char c = errno;
ssize_t rv UNUSED = write(msg[1], &c, 1);
int val = errno;
ssize_t rv UNUSED = write(msg[1], &val, sizeof(val));
exit(127);
} break;
@ -424,12 +425,13 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
safeClose(err[1]);
safeClose(msg[1]);
char c;
int r = read(msg[0], &c, 1);
int val;
int r = read(msg[0], &val, sizeof(val));
if(r == -1) {
throwNewErrno(e, "java/io/IOException");
return;
} else if(r) {
errno = val;
throwNewErrno(e, "java/io/IOException");
return;
}
@ -590,7 +592,8 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
r = e->NewStringUTF("/tmp");
} else if (strcmp(chars, "user.dir") == 0) {
r = e->NewStringUTF(getenv("PWD"));
char buffer[PATH_MAX];
r = e->NewStringUTF(getcwd(buffer, PATH_MAX));
} else if (strcmp(chars, "user.home") == 0) {
r = e->NewStringUTF(getenv("HOME"));
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -120,6 +120,10 @@ public class File implements Serializable {
return toAbsolutePath(path);
}
public File getAbsoluteFile() {
return new File(getAbsolutePath());
}
private static native long length(String path);
public long length() {

View File

@ -161,7 +161,7 @@ public class ObjectInputStream extends InputStream {
case 'n':
return null;
case 'z':
return (readLongToken() == 0);
return (readLongToken() != 0);
case 'b':
return (byte) readLongToken();
case 'c':

View File

@ -0,0 +1,21 @@
/* Copyright (c) 2011, 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.lang;
public class AbstractMethodError extends IncompatibleClassChangeError {
public AbstractMethodError() {
super();
}
public AbstractMethodError(String message) {
super(message);
}
}

View File

@ -103,7 +103,8 @@ public class Runtime {
if (exception[0] != null) {
if (exception[0] instanceof IOException) {
throw new IOException(exception[0]);
String message = "Failed to run \"" + command[0] + "\": " + exception[0].getMessage();
throw new IOException(message);
} else {
throw new RuntimeException(exception[0]);
}

View File

@ -16,10 +16,16 @@ import java.util.Comparator;
import java.util.Locale;
import java.io.Serializable;
import avian.Utf8;
import avian.Iso88591;
public final class String
implements Comparable<String>, CharSequence, Serializable
{
private static final String UTF_8_ENCODING = "UTF-8";
private static final String ISO_8859_1_ENCODING = "ISO-8859-1";
private static final String LATIN_1_ENCODING = "LATIN-1";
private static final String DEFAULT_ENCODING = UTF_8_ENCODING;
public static Comparator<String> CASE_INSENSITIVE_ORDER
= new Comparator<String>() {
public int compare(String a, String b) {
@ -52,8 +58,8 @@ public final class String
throws UnsupportedEncodingException
{
this(bytes, offset, length);
if (! (charsetName.equalsIgnoreCase("UTF-8")
|| charsetName.equalsIgnoreCase("ISO-8859-1")))
if (! (charsetName.equalsIgnoreCase(UTF_8_ENCODING)
|| charsetName.equalsIgnoreCase(ISO_8859_1_ENCODING)))
{
throw new UnsupportedEncodingException(charsetName);
}
@ -421,18 +427,31 @@ public final class String
}
public byte[] getBytes() {
if(data instanceof byte[]) {
byte[] b = new byte[length];
getBytes(0, length, b, 0);
return b;
try {
return getBytes(DEFAULT_ENCODING);
} catch (java.io.UnsupportedEncodingException ex) {
throw new RuntimeException(
"Default '" + DEFAULT_ENCODING + "' encoding not handled", ex);
}
return Utf8.encode((char[])data, offset, length);
}
public byte[] getBytes(String format)
throws java.io.UnsupportedEncodingException
{
return getBytes();
if(data instanceof byte[]) {
byte[] b = new byte[length];
getBytes(0, length, b, 0);
return b;
}
String fmt = format.trim().toUpperCase();
if (DEFAULT_ENCODING.equals(fmt)) {
return Utf8.encode((char[])data, offset, length);
} else if (ISO_8859_1_ENCODING.equals(fmt) || LATIN_1_ENCODING.equals(fmt)) {
return Iso88591.encode((char[])data, offset, length);
} else {
throw new java.io.UnsupportedEncodingException(
"Encoding " + format + " not supported");
}
}
public void getChars(int srcOffset, int srcEnd,

View File

@ -12,4 +12,14 @@ package java.util;
public abstract class AbstractList<T> extends AbstractCollection<T>
implements List<T>
{ }
{
protected int modCount;
public Iterator<T> iterator() {
return listIterator();
}
public ListIterator<T> listIterator() {
return new Collections.ArrayListIterator(this);
}
}

View File

@ -0,0 +1,13 @@
/* Copyright (c) 2008-2011, 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;
public abstract class AbstractMap<K,V> extends Object implements Map<K,V> { }

View File

@ -74,6 +74,9 @@ public class ZipFile {
}
protected ZipEntry getEntry(EntryFactory factory, String name) {
while (name.startsWith("/")) {
name = name.substring(1);
}
Integer pointer = index.get(name);
return (pointer == null ? null : factory.makeEntry(window, pointer));
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
Copyright (c) 2008-2010, Avian Contributors
Copyright (c) 2008-2011, 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

38
makefile Normal file → Executable file
View File

@ -1,7 +1,7 @@
MAKEFLAGS = -s
name = avian
version = 0.4
version = 0.5
build-arch := $(shell uname -m \
| sed 's/^i.86$$/i386/' \
@ -94,12 +94,12 @@ ifneq ($(openjdk),)
lib/security/java.policy lib/security/cacerts
local-policy = lib/security/local_policy.jar
ifeq ($(shell test -e $(openjdk)/$(local-policy) && echo found),found)
ifeq ($(shell test -e "$(openjdk)/$(local-policy)" && echo found),found)
javahome-files += $(local-policy)
endif
export-policy = lib/security/US_export_policy.jar
ifeq ($(shell test -e $(openjdk)/$(export-policy) && echo found),found)
ifeq ($(shell test -e "$(openjdk)/$(export-policy)" && echo found),found)
javahome-files += $(export-policy)
endif
@ -181,7 +181,8 @@ endif
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject \
-fno-rtti -fno-exceptions
cflags = $(build-cflags)
@ -333,15 +334,20 @@ ifeq ($(platform),windows)
openjdk-extra-cflags =
build-lflags = -L$(lib) $(common-lflags)
ifeq ($(build-platform),cygwin)
build-lflags += -mno-cygwin
build-cflags += -mno-cygwin
openjdk-extra-cflags += -mno-cygwin
lflags += -mno-cygwin
cflags += -mno-cygwin
build-cxx = i686-w64-mingw32-g++
build-cc = i686-w64-mingw32-gcc
dlltool = i686-w64-mingw32-dlltool
ar = i686-w64-mingw32-ar
ranlib = i686-w64-mingw32-ranlib
strip = i686-w64-mingw32-strip
endif
endif
ifeq ($(arch),x86_64)
ifeq ($(build-platform),cygwin)
build-cxx = x86_64-w64-mingw32-g++
build-cc = x86_64-w64-mingw32-gcc
endif
cxx = x86_64-w64-mingw32-g++ $(mflag)
cc = x86_64-w64-mingw32-gcc $(mflag)
dlltool = x86_64-w64-mingw32-dlltool
@ -758,7 +764,7 @@ $(boot-javahome-object): $(src)/boot-javahome.cpp
$(compile-object)
$(build)/binaryToObject-main.o: $(src)/binaryToObject/main.cpp
$(build-cxx) -c $(^) -o $(@)
$(build-cxx) $(converter-cflags) -c $(^) -o $(@)
$(build)/binaryToObject-elf64.o: $(src)/binaryToObject/elf.cpp
$(build-cxx) $(converter-cflags) -DBITS_PER_WORD=64 -c $(^) -o $(@)
@ -776,7 +782,7 @@ $(build)/binaryToObject-pe.o: $(src)/binaryToObject/pe.cpp
$(build-cxx) $(converter-cflags) -c $(^) -o $(@)
$(converter): $(converter-objects)
$(build-cxx) $(^) -o $(@)
$(build-cc) $(^) -o $(@)
$(build)/classpath.jar: $(classpath-dep) $(classpath-jar-dep)
@echo "creating $(@)"
@ -930,8 +936,14 @@ ifeq ($(platform),windows)
sed 's/^#ifdef _WIN64/#if 1/' \
< "$(openjdk-src)/windows/native/java/net/net_util_md.h" \
> $(build)/openjdk/net_util_md.h
cp "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
$(build)/openjdk/NetworkInterface.h
sed \
-e 's/IpPrefix/hide_IpPrefix/' \
-e 's/IpSuffix/hide_IpSuffix/' \
-e 's/IpDad/hide_IpDad/' \
-e 's/ScopeLevel/hide_ScopeLevel/' \
-e 's/SCOPE_LEVEL/hide_SCOPE_LEVEL/' \
< "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
> $(build)/openjdk/NetworkInterface.h
echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h
endif
@touch $(@)

View File

@ -48,6 +48,7 @@ openjdk-sources = \
$(openjdk-src)/share/native/java/util/zip/ZipEntry.c \
$(openjdk-src)/share/native/java/util/zip/ZipFile.c \
$(openjdk-src)/share/native/java/util/zip/zip_util.c \
$(openjdk-src)/share/native/sun/management/VMManagementImpl.c \
$(openjdk-src)/share/native/sun/misc/GC.c \
$(openjdk-src)/share/native/sun/misc/MessageUtils.c \
$(openjdk-src)/share/native/sun/misc/NativeSignalHandler.c \
@ -112,6 +113,7 @@ openjdk-headers-classes = \
java.util.zip.Inflater \
java.util.zip.ZipEntry \
java.util.zip.ZipFile \
sun.management.VMManagementImpl \
sun.misc.GC \
sun.misc.MessageUtils \
sun.misc.NativeSignalHandler \
@ -151,6 +153,7 @@ openjdk-cflags = \
"-I$(openjdk-src)/share/native/java/lang/fdlibm/include" \
"-I$(openjdk-src)/share/native/java/net" \
"-I$(openjdk-src)/share/native/java/util/zip" \
"-I$(openjdk-src)/share/native/sun/management" \
"-I$(openjdk-src)/share/native/sun/nio/ch" \
"-I$(openjdk-src)/share/javavm/include" \
-D_LITTLE_ENDIAN \
@ -184,6 +187,7 @@ ifeq ($(platform),windows)
$(openjdk-src)/windows/native/java/lang/ProcessEnvironment_md.c \
$(openjdk-src)/windows/native/java/lang/ProcessImpl_md.c \
$(openjdk-src)/windows/native/java/net/net_util_md.c \
$(openjdk-src)/windows/native/java/net/DualStackPlainSocketImpl.c \
$(openjdk-src)/windows/native/java/net/InetAddressImplFactory.c \
$(openjdk-src)/windows/native/java/net/Inet4AddressImpl.c \
$(openjdk-src)/windows/native/java/net/Inet6AddressImpl.c \
@ -210,6 +214,7 @@ ifeq ($(platform),windows)
$(openjdk-src)/windows/native/sun/security/provider/WinCAPISeedGenerator.c
openjdk-headers-classes += \
java.net.DualStackPlainSocketImpl \
java.lang.ProcessImpl \
sun.io.Win32ErrorMode \
sun.nio.ch.WindowsSelectorImpl \
@ -225,7 +230,6 @@ ifeq ($(platform),windows)
"-I$(root)/win32/include" \
-D_JNI_IMPLEMENTATION_ \
-D_JAVASOFT_WIN32_TYPEDEF_MD_H_ \
-D_WINSOCK2API_ \
-Ds6_words=_s6_words \
-Ds6_bytes=_s6_bytes
else
@ -290,13 +294,15 @@ else
"-I$(openjdk-src)/solaris/native/java/lang" \
"-I$(openjdk-src)/solaris/native/java/net" \
"-I$(openjdk-src)/solaris/native/java/util" \
"-I$(openjdk-src)/solaris/native/sun/management" \
"-I$(openjdk-src)/solaris/native/sun/nio/ch" \
"-I$(openjdk-src)/solaris/javavm/include" \
"-I$(openjdk-src)/solaris/hpi/include"
endif
openjdk-local-sources = \
$(src)/openjdk/my_net_util.c
$(src)/openjdk/my_net_util.c \
$(src)/openjdk/my_management.c
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))

View File

@ -162,8 +162,8 @@ Installing MSYS:
Installing Cygwin:
1. Download and run setup.exe from cygwin.com, installing the base
system and these packages: make, gcc-mingw-g++, and (optionally)
git.
system and these packages: make, gcc-mingw-g++,
mingw64-i686-gcc-g++, mingw64-x86_64-gcc-g++, and (optionally) git.
You may also find our win32 repository useful: (run this from the
directory containing the avian directory)
@ -308,7 +308,7 @@ it on various OSes:
# http://download.java.net/openjdk/jdk6/promoted/, e.g.:
wget http://download.java.net/openjdk/jdk6/promoted/b21/openjdk-6-src-b21-20_jan_2011.tar.gz
mkdir openjdk
(cd openjdk && tar xzf openjdk-6-src-b21-20_jan_2011.tar.gz)
(cd openjdk && tar xzf ../openjdk-6-src-b21-20_jan_2011.tar.gz)
make openjdk=/cygdrive/c/OpenSCG/openjdk-6.21 \
openjdk-src=$(pwd)/openjdk/jdk/src \
test

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -22,6 +22,39 @@ class Allocator {
virtual void free(const void* p, unsigned size) = 0;
};
inline const char*
append(Allocator* allocator, const char* a, const char* b, const char* c)
{
unsigned al = strlen(a);
unsigned bl = strlen(b);
unsigned cl = strlen(c);
char* p = static_cast<char*>(allocator->allocate((al + bl + cl) + 1));
memcpy(p, a, al);
memcpy(p + al, b, bl);
memcpy(p + al + bl, c, cl + 1);
return p;
}
inline const char*
append(Allocator* allocator, const char* a, const char* b)
{
unsigned al = strlen(a);
unsigned bl = strlen(b);
char* p = static_cast<char*>(allocator->allocate((al + bl) + 1));
memcpy(p, a, al);
memcpy(p + al, b, bl + 1);
return p;
}
inline const char*
copy(Allocator* allocator, const char* a)
{
unsigned al = strlen(a);
char* p = static_cast<char*>(allocator->allocate(al + 1));
memcpy(p, a, al + 1);
return p;
}
} // namespace vm
#endif//ALLOCATOR_H

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,5 +1,5 @@
/* arm.S: JNI gluecode for ARM/Linux
Copyright (c) 2008-2010, Avian Contributors
Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2010, Avian Contributors
/* Copyright (c) 2009-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -23,7 +23,7 @@ using namespace vm;
namespace {
const unsigned HeapCapacity = 128 * 1024 * 1024;
const unsigned HeapCapacity = 256 * 1024 * 1024;
// Notes on immutable references in the heap image:
//
@ -572,7 +572,7 @@ main(int ac, const char** av)
p->initialize(&image, code, CodeCapacity);
Machine* m = new (h->allocate(sizeof(Machine))) Machine
(s, h, f, 0, p, c, 0, 0);
(s, h, f, 0, p, c, 0, 0, 0, 0);
Thread* t = p->makeThread(m, 0, 0);
enter(t, Thread::ActiveState);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -355,7 +355,7 @@ class MyClasspath : public Classpath {
MyClasspath(System* s, Allocator* allocator, const char* javaHome,
const char* embedPrefix):
allocator(allocator), ranNetOnLoad(0)
allocator(allocator), ranNetOnLoad(0), ranManagementOnLoad(0)
{
class StringBuilder {
public:
@ -613,6 +613,7 @@ class MyClasspath : public Classpath {
unsigned zipEntryCsizeField;
unsigned zipEntryMethodField;
bool ranNetOnLoad;
bool ranManagementOnLoad;
char buffer[BufferSize];
JmmInterface jmmInterface;
};
@ -1615,6 +1616,9 @@ getBootstrapResources(Thread* t, object, uintptr_t* arguments)
extern "C" JNIEXPORT jint JNICALL
net_JNI_OnLoad(JavaVM*, void*);
extern "C" JNIEXPORT jint JNICALL
management_JNI_OnLoad(JavaVM*, void*);
void JNICALL
loadLibrary(Thread* t, object, uintptr_t* arguments)
{
@ -1642,6 +1646,23 @@ loadLibrary(Thread* t, object, uintptr_t* arguments)
net_JNI_OnLoad(t->m, 0);
}
return;
} else if (strcmp(n, "management") == 0) {
bool ran;
{ ACQUIRE(t, t->m->classLock);
local::MyClasspath* c = static_cast<local::MyClasspath*>
(t->m->classpath);
ran = c->ranManagementOnLoad;
c->ranManagementOnLoad = true;
}
if (not ran) {
management_JNI_OnLoad(t->m, 0);
}
return;
} else if (strcmp(n, "zip") == 0
or strcmp(n, "nio") == 0)
@ -5118,6 +5139,27 @@ GetVersion(Thread*)
return JMM_VERSION_1_0;
}
uint64_t
getInputArgumentArray(Thread* t, uintptr_t*)
{
object array = makeObjectArray
(t, type(t, Machine::StringType), t->m->argumentCount);
PROTECT(t, array);
for (unsigned i = 0; i < t->m->argumentCount; ++i) {
object argument = makeString(t, t->m->arguments[i]);
set(t, array, ArrayBody + (i * BytesPerWord), argument);
}
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
}
jobjectArray JNICALL
GetInputArgumentArray(Thread* t)
{
return reinterpret_cast<jobjectArray>(run(t, getInputArgumentArray, 0));
}
jint JNICALL
GetOptionalSupport(Thread*, jmmOptionalSupport* support)
{
@ -5203,6 +5245,7 @@ EXPORT(JVM_GetManagement)(jint version)
interface->GetBoolAttribute = GetBoolAttribute;
interface->GetMemoryManagers = GetMemoryManagers;
interface->GetMemoryPools = GetMemoryPools;
interface->GetInputArgumentArray = GetInputArgumentArray;
return interface;
} else {

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2010, Avian Contributors
/* Copyright (c) 2009-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -2190,6 +2190,9 @@ unwind(MyThread* t)
object continuation;
findUnwindTarget(t, &ip, &frame, &stack, &continuation);
t->trace->targetMethod = 0;
t->trace->nativeMethod = 0;
transition(t, ip, stack, continuation, t->trace);
vmJump(ip, frame, stack, t, 0, 0);
@ -2263,9 +2266,22 @@ resolveMethod(Thread* t, object pair)
findMethodInClass, Machine::NoSuchMethodErrorType);
}
bool
methodAbstract(Thread* t, object method)
{
return methodCode(t, method) == 0
and (methodFlags(t, method) & ACC_NATIVE) == 0;
}
int64_t
prepareMethodForCall(MyThread* t, object target)
{
if (methodAbstract(t, target)) {
throwNew(t, Machine::AbstractMethodErrorType, "%s.%s%s",
&byteArrayBody(t, className(t, methodClass(t, target)), 0),
&byteArrayBody(t, methodName(t, target), 0),
&byteArrayBody(t, methodSpec(t, target), 0));
} else {
if (unresolved(t, methodAddress(t, target))) {
PROTECT(t, target);
@ -2275,7 +2291,9 @@ prepareMethodForCall(MyThread* t, object target)
if (methodFlags(t, target) & ACC_NATIVE) {
t->trace->nativeMethod = target;
}
return methodAddress(t, target);
}
}
int64_t
@ -2341,6 +2359,12 @@ findVirtualMethodFromReference(MyThread* t, object pair, object instance)
return prepareMethodForCall(t, target);
}
int64_t
getMethodAddress(MyThread* t, object target)
{
return prepareMethodForCall(t, target);
}
int64_t
getJClassFromReference(MyThread* t, object pair)
{
@ -3437,6 +3461,48 @@ compileDirectReferenceInvoke(MyThread* t, Frame* frame, Thunk thunk,
reference, isStatic, tailCall);
}
void
compileAbstractInvoke(MyThread* t, Frame* frame, Compiler::Operand* method,
object target, bool tailCall)
{
unsigned parameterFootprint = methodParameterFootprint(t, target);
int returnCode = methodReturnCode(t, target);
unsigned rSize = resultSize(t, returnCode);
Compiler::Operand* result = frame->c->stackCall
(method,
tailCall ? Compiler::TailJump : 0,
frame->trace(0, 0),
rSize,
operandTypeForFieldCode(t, returnCode),
parameterFootprint);
frame->pop(parameterFootprint);
if (rSize) {
pushReturnValue(t, frame, returnCode, result);
}
}
void
compileDirectAbstractInvoke(MyThread* t, Frame* frame, Thunk thunk,
object target, bool tailCall)
{
Compiler* c = frame->c;
compileAbstractInvoke
(t, frame, c->call
(c->constant(getThunk(t, thunk), Compiler::AddressType),
0,
frame->trace(0, 0),
BytesPerWord,
Compiler::AddressType,
2, c->register_(t->arch->thread()), frame->append(target)),
target, tailCall);
}
void
handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function)
{
@ -4841,7 +4907,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
bool tailCall = isTailCall(t, code, ip, context->method, target);
if (UNLIKELY(methodAbstract(t, target))) {
compileDirectAbstractInvoke
(t, frame, getMethodAddressThunk, target, tailCall);
} else {
compileDirectInvoke(t, frame, target, tailCall);
}
} else {
compileDirectReferenceInvoke
(t, frame, findSpecialMethodFromReferenceThunk, reference, false,
@ -7329,11 +7400,6 @@ invokeNative(MyThread* t)
t->trace->targetMethod = t->trace->nativeMethod;
THREAD_RESOURCE0(t, {
static_cast<MyThread*>(t)->trace->targetMethod = 0;
static_cast<MyThread*>(t)->trace->nativeMethod = 0;
});
t->m->classpath->resolveNative(t, t->trace->nativeMethod);
result = invokeNative2(t, t->trace->nativeMethod);
@ -7355,6 +7421,9 @@ invokeNative(MyThread* t)
transition(t, getIp(t), stack, t->continuation, t->trace);
t->trace->targetMethod = 0;
t->trace->nativeMethod = 0;
return result;
}

View File

@ -4815,7 +4815,11 @@ class BranchEvent: public Event {
ConstantSite* secondConstant = findConstantSite(c, second);
if (not unreachable(this)) {
if (firstConstant and secondConstant) {
if (firstConstant
and secondConstant
and firstConstant->value->resolved()
and secondConstant->value->resolved())
{
int64_t firstValue = firstConstant->value->value();
int64_t secondValue = secondConstant->value->value();

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2010, Avian Contributors
/* Copyright (c) 2009-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -18,39 +18,7 @@ using namespace vm;
namespace {
const bool DebugFind = false;
const char*
append(Allocator* allocator, const char* a, const char* b, const char* c)
{
unsigned al = strlen(a);
unsigned bl = strlen(b);
unsigned cl = strlen(c);
char* p = static_cast<char*>(allocator->allocate((al + bl + cl) + 1));
memcpy(p, a, al);
memcpy(p + al, b, bl);
memcpy(p + al + bl, c, cl + 1);
return p;
}
const char*
append(Allocator* allocator, const char* a, const char* b)
{
unsigned al = strlen(a);
unsigned bl = strlen(b);
char* p = static_cast<char*>(allocator->allocate((al + bl) + 1));
memcpy(p, a, al);
memcpy(p + al, b, bl + 1);
return p;
}
const char*
copy(Allocator* allocator, const char* a)
{
unsigned al = strlen(a);
char* p = static_cast<char*>(allocator->allocate(al + 1));
memcpy(p, a, al + 1);
return p;
}
const bool DebugStat = false;
class Element {
public:
@ -136,9 +104,12 @@ class DirectoryElement: public Element {
};
DirectoryElement(System* s, Allocator* allocator, const char* name):
s(s), allocator(allocator), name(name),
urlPrefix_(append(allocator, "file:", name, "/")),
sourceUrl_(append(allocator, "file:", name))
s(s),
allocator(allocator),
originalName(name),
name(s->toAbsolutePath(allocator, name)),
urlPrefix_(append(allocator, "file:", this->name, "/")),
sourceUrl_(append(allocator, "file:", this->name))
{ }
virtual Element::Iterator* iterator() {
@ -168,6 +139,9 @@ class DirectoryElement: public Element {
virtual System::FileType stat(const char* name, unsigned* length, bool) {
const char* file = append(allocator, this->name, "/", name);
System::FileType type = s->stat(file, length);
if (DebugStat) {
fprintf(stderr, "stat %s in %s: %d\n", name, this->name, type);
}
allocator->free(file, strlen(file) + 1);
return type;
}
@ -181,6 +155,7 @@ class DirectoryElement: public Element {
}
virtual void dispose() {
allocator->free(originalName, strlen(originalName) + 1);
allocator->free(name, strlen(name) + 1);
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
@ -189,6 +164,7 @@ class DirectoryElement: public Element {
System* s;
Allocator* allocator;
const char* originalName;
const char* name;
const char* urlPrefix_;
const char* sourceUrl_;
@ -454,10 +430,17 @@ class JarElement: public Element {
unsigned position;
};
JarElement(System* s, Allocator* allocator, const char* name):
s(s), allocator(allocator), name(name),
urlPrefix_(name ? append(allocator, "jar:file:", name, "!/") : 0),
sourceUrl_(name ? append(allocator, "file:", name) : 0),
JarElement(System* s, Allocator* allocator, const char* name,
bool canonicalizePath = true):
s(s),
allocator(allocator),
originalName(name),
name(name and canonicalizePath
? s->toAbsolutePath(allocator, name) : name),
urlPrefix_(this->name
? append(allocator, "jar:file:", this->name, "!/") : 0),
sourceUrl_(this->name
? append(allocator, "file:", this->name) : 0),
region(0), index(0)
{ }
@ -513,8 +496,12 @@ class JarElement: public Element {
while (*name == '/') name++;
return (index ? index->stat(name, length, tryDirectory)
System::FileType type = (index ? index->stat(name, length, tryDirectory)
: System::TypeDoesNotExist);
if (DebugStat) {
fprintf(stderr, "stat %s in %s: %d\n", name, this->name, type);
}
return type;
}
virtual const char* urlPrefix() {
@ -530,6 +517,9 @@ class JarElement: public Element {
}
virtual void dispose(unsigned size) {
if (originalName != name) {
allocator->free(originalName, strlen(originalName) + 1);
}
allocator->free(name, strlen(name) + 1);
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
@ -544,6 +534,7 @@ class JarElement: public Element {
System* s;
Allocator* allocator;
const char* originalName;
const char* name;
const char* urlPrefix_;
const char* sourceUrl_;
@ -555,7 +546,7 @@ class BuiltinElement: public JarElement {
public:
BuiltinElement(System* s, Allocator* allocator, const char* name,
const char* libraryName):
JarElement(s, allocator, name),
JarElement(s, allocator, name, false),
libraryName(libraryName ? copy(allocator, libraryName) : 0)
{ }

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010 Avian Contributors
/* Copyright (c) 2008-2011 Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -3337,15 +3337,24 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
const char** properties = static_cast<const char**>
(h->allocate(sizeof(const char*) * propertyCount));
const char** propertyPointer = properties;
const char** arguments = static_cast<const char**>
(h->allocate(sizeof(const char*) * a->nOptions));
const char** argumentPointer = arguments;
for (int i = 0; i < a->nOptions; ++i) {
if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
*(propertyPointer++) = a->options[i].optionString + 2;
}
*(argumentPointer++) = a->options[i].optionString;
}
*m = new (h->allocate(sizeof(Machine)))
Machine(s, h, bf, af, p, c, properties, propertyCount);
Machine
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions);
*t = p->makeThread(*m, 0, 0);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -974,6 +974,8 @@ getClassAddendum(Thread* t, object class_, object pool)
{
object addendum = classAddendum(t, class_);
if (addendum == 0) {
PROTECT(t, class_);
addendum = makeClassAddendum(t, pool, 0, 0, 0, 0, 0);
set(t, class_, ClassAddendum, addendum);
}
@ -1879,6 +1881,8 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec,
loader,
arrayLength(t, vtable));
PROTECT(t, c);
t->m->processor->initVtable(t, c);
return c;
@ -2395,7 +2399,8 @@ namespace vm {
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
Finder* appFinder, Processor* processor, Classpath* classpath,
const char** properties, unsigned propertyCount):
const char** properties, unsigned propertyCount,
const char** arguments, unsigned argumentCount):
vtable(&javaVMVTable),
system(system),
heapClient(new (heap->allocate(sizeof(HeapClient)))
@ -2411,6 +2416,8 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
jniReferences(0),
properties(properties),
propertyCount(propertyCount),
arguments(arguments),
argumentCount(argumentCount),
activeCount(0),
liveCount(0),
daemonCount(0),
@ -2477,6 +2484,8 @@ Machine::dispose()
heap->free(heapPool[i], ThreadHeapSizeInBytes);
}
heap->free(arguments, sizeof(const char*) * argumentCount);
heap->free(properties, sizeof(const char*) * propertyCount);
static_cast<HeapClient*>(heapClient)->dispose();
@ -3016,16 +3025,20 @@ popResources(Thread* t)
object
makeByteArray(Thread* t, const char* format, va_list a)
{
const int Size = 256;
char buffer[Size];
int r = vm::vsnprintf(buffer, Size - 1, format, a);
expect(t, r >= 0 and r < Size - 1);
object s = makeByteArray(t, strlen(buffer) + 1);
memcpy(&byteArrayBody(t, s, 0), buffer, byteArrayLength(t, s));
int size = 256;
while (true) {
THREAD_RUNTIME_ARRAY(t, char, buffer, size);
int r = vm::vsnprintf(RUNTIME_ARRAY_BODY(buffer), size - 1, format, a);
if (r >= 0 and r < size - 1) {
object s = makeByteArray(t, strlen(RUNTIME_ARRAY_BODY(buffer)) + 1);
memcpy(&byteArrayBody(t, s, 0), RUNTIME_ARRAY_BODY(buffer),
byteArrayLength(t, s));
return s;
} else {
size *= 2;
}
}
}
object
@ -3215,7 +3228,9 @@ instanceOf(Thread* t, object class_, object o)
object
classInitializer(Thread* t, object class_)
{
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, class_)); ++i) {
if (classMethodTable(t, class_)) {
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, class_)); ++i)
{
object o = arrayBody(t, classMethodTable(t, class_), i);
if (vm::strcmp(reinterpret_cast<const int8_t*>("<clinit>"),
@ -3224,6 +3239,7 @@ classInitializer(Thread* t, object class_)
return o;
}
}
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -1273,7 +1273,8 @@ class Machine {
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
Processor* processor, Classpath* classpath, const char** properties,
unsigned propertyCount);
unsigned propertyCount, const char** arguments,
unsigned argumentCount);
~Machine() {
dispose();
@ -1295,6 +1296,8 @@ class Machine {
Reference* jniReferences;
const char** properties;
unsigned propertyCount;
const char** arguments;
unsigned argumentCount;
unsigned activeCount;
unsigned liveCount;
unsigned daemonCount;
@ -3036,7 +3039,7 @@ monitorWait(Thread* t, object monitor, int64_t time)
ENTER(t, Thread::IdleState);
interrupted = t->lock->wait(t->systemThread, time);
interrupted = t->lock->waitAndClearInterrupted(t->systemThread, time);
}
monitorAcquire(t, monitor, monitorNode);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -179,6 +179,10 @@ main(int ac, const char** av)
or strncmp(av[i], "-D", 2) == 0)
{
++ vmArgs.nOptions;
} else if (strcmp(av[i], "-client") == 0
or strcmp(av[i], "-server") == 0)
{
// ignore
} else {
if (jar == 0) {
class_ = av[i++];

View File

@ -0,0 +1,2 @@
#define JNI_OnLoad management_JNI_OnLoad
#include "management.c"

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -286,7 +286,16 @@ class MySystem: public System {
}
}
virtual bool wait(System::Thread* context, int64_t time) {
virtual void wait(System::Thread* context, int64_t time) {
wait(context, time, false);
}
virtual bool waitAndClearInterrupted(System::Thread* context, int64_t time)
{
return wait(context, time, true);
}
bool wait(System::Thread* context, int64_t time, bool clearInterrupted) {
Thread* t = static_cast<Thread*>(context);
if (owner_ == t) {
@ -298,7 +307,9 @@ class MySystem: public System {
{ ACQUIRE(t->mutex);
if (t->r->interrupted()) {
if (clearInterrupted) {
t->r->setInterrupted(false);
}
return true;
}
@ -329,7 +340,7 @@ class MySystem: public System {
t->flags = 0;
interrupted = t->r->interrupted();
if (interrupted) {
if (interrupted and clearInterrupted) {
t->r->setInterrupted(false);
}
}
@ -786,6 +797,15 @@ class MySystem: public System {
return SO_SUFFIX;
}
virtual const char* toAbsolutePath(Allocator* allocator, const char* name) {
if (name[0] == '/') {
return copy(allocator, name);
} else {
char buffer[PATH_MAX];
return append(allocator, getcwd(buffer, PATH_MAX), "/", name);
}
}
virtual Status load(System::Library** lib,
const char* name)
{

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2010, Avian Contributors
/* Copyright (c) 2009-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -12,6 +12,7 @@
#define SYSTEM_H
#include "common.h"
#include "allocator.h"
namespace vm {
@ -59,7 +60,8 @@ class System {
virtual bool tryAcquire(Thread* context) = 0;
virtual void acquire(Thread* context) = 0;
virtual void release(Thread* context) = 0;
virtual bool wait(Thread* context, int64_t time) = 0;
virtual void wait(Thread* context, int64_t time) = 0;
virtual bool waitAndClearInterrupted(Thread* context, int64_t time) = 0;
virtual void notify(Thread* context) = 0;
virtual void notifyAll(Thread* context) = 0;
virtual Thread* owner() = 0;
@ -141,6 +143,8 @@ class System {
virtual Status load(Library**, const char* name) = 0;
virtual char pathSeparator() = 0;
virtual char fileSeparator() = 0;
virtual const char* toAbsolutePath(Allocator* allocator,
const char* name) = 0;
virtual int64_t now() = 0;
virtual void yield() = 0;
virtual void exit(int code) = 0;

View File

@ -4,6 +4,7 @@ THUNK(findInterfaceMethodFromInstanceAndReference)
THUNK(findSpecialMethodFromReference)
THUNK(findStaticMethodFromReference)
THUNK(findVirtualMethodFromReference)
THUNK(getMethodAddress)
THUNK(compareDoublesG)
THUNK(compareDoublesL)
THUNK(compareFloatsG)

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, Avian Contributors
/* Copyright (c) 2010-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -1911,7 +1911,7 @@ writeConstructors(Output* out, Object* declarations)
out->write(")\n{\n");
bool hasObjectMask = false;
bool hasObjectMask = strcmp(typeName(o), "singleton") == 0;
for (MemberIterator it(o); it.hasMore();) {
Object* m = it.next();
if (m->type == Object::Scalar

View File

@ -249,6 +249,8 @@
(type incompatibleClassChangeError java/lang/IncompatibleClassChangeError)
(type abstractMethodError java/lang/AbstractMethodError)
(type noSuchFieldError java/lang/NoSuchFieldError)
(type noSuchMethodError java/lang/NoSuchMethodError)

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -247,7 +247,16 @@ class MySystem: public System {
}
}
virtual bool wait(System::Thread* context, int64_t time) {
virtual void wait(System::Thread* context, int64_t time) {
wait(context, time, false);
}
virtual bool waitAndClearInterrupted(System::Thread* context, int64_t time)
{
return wait(context, time, true);
}
bool wait(System::Thread* context, int64_t time, bool clearInterrupted) {
Thread* t = static_cast<Thread*>(context);
assert(s, t);
@ -262,7 +271,9 @@ class MySystem: public System {
{ ACQUIRE(s, t->mutex);
if (t->r->interrupted()) {
if (clearInterrupted) {
t->r->setInterrupted(false);
}
return true;
}
@ -294,7 +305,7 @@ class MySystem: public System {
t->flags = 0;
interrupted = t->r->interrupted();
if (interrupted) {
if (interrupted and clearInterrupted) {
t->r->setInterrupted(false);
}
}
@ -762,6 +773,20 @@ class MySystem: public System {
return SO_SUFFIX;
}
virtual const char* toAbsolutePath(Allocator* allocator, const char* name) {
if (strncmp(name, "//", 2) == 0
or strncmp(name, "\\\\", 2) == 0
or strncmp(name + 1, ":/", 2) == 0
or strncmp(name + 1, ":\\", 2) == 0)
{
return copy(allocator, name);
} else {
TCHAR buffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buffer);
return append(allocator, buffer, "\\", name);
}
}
virtual Status load(System::Library** lib,
const char* name)
{

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2009, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
@ -238,7 +238,7 @@ codePromise(Context* c, unsigned offset)
class Offset: public Promise {
public:
Offset(Context* c, MyBlock* block, unsigned offset, AlignmentPadding* limit):
c(c), block(block), offset(offset), limit(limit)
c(c), block(block), offset(offset), limit(limit), value_(-1)
{ }
virtual bool resolved() {
@ -248,14 +248,19 @@ class Offset: public Promise {
virtual int64_t value() {
assert(c, resolved());
return block->start + (offset - block->offset)
if (value_ == -1) {
value_ = block->start + (offset - block->offset)
+ padding(block->firstPadding, block->start, block->offset, limit);
}
return value_;
}
Context* c;
MyBlock* block;
unsigned offset;
AlignmentPadding* limit;
int value_;
};
Promise*
@ -419,7 +424,8 @@ class AlignmentPadding {
offset(c->code.length()),
instructionOffset(instructionOffset),
alignment(alignment),
next(0)
next(0),
padding(-1)
{
if (c->lastBlock->firstPadding) {
c->lastBlock->lastPadding->next = this;
@ -433,6 +439,7 @@ class AlignmentPadding {
unsigned instructionOffset;
unsigned alignment;
AlignmentPadding* next;
int padding;
};
unsigned
@ -441,14 +448,25 @@ padding(AlignmentPadding* p, unsigned start, unsigned offset,
{
unsigned padding = 0;
if (limit) {
unsigned index = 0;
if (limit->padding == -1) {
for (; p; p = p->next) {
index = p->offset - offset;
while ((start + index + padding + p->instructionOffset) % p->alignment) {
if (p->padding == -1) {
unsigned index = p->offset - offset;
while ((start + index + padding + p->instructionOffset)
% p->alignment)
{
++ padding;
}
p->padding = padding;
if (p == limit) break;
} else {
padding = p->padding;
}
}
} else {
padding = limit->padding;
}
}
return padding;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008-2010, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, Avian Contributors
/* Copyright (c) 2008-2011, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided

View File

@ -49,8 +49,12 @@ public class Logging {
StringBuilder sb = new StringBuilder();
sb.append(r.getLoggerName());
indent(sb, NAME_WIDTH - r.getLoggerName().length());
sb.append(r.getSourceMethodName());
indent(sb, METHOD_WIDTH - r.getSourceMethodName().length());
String methodName = r.getSourceMethodName();
if (methodName == null) {
methodName = "<unknown>";
}
sb.append(methodName);
indent(sb, METHOD_WIDTH - methodName.length());
sb.append(r.getLevel().getName());
indent(sb, LEVEL_WIDTH - r.getLevel().getName().length());
sb.append(r.getMessage());

1
vm.pro
View File

@ -62,6 +62,7 @@
-keep public class java.lang.StackOverflowError
-keep public class java.lang.NoSuchFieldError
-keep public class java.lang.NoSuchMethodError
-keep public class java.lang.AbstractMethodError
-keep public class java.lang.UnsatisfiedLinkError
-keep public class java.lang.ExceptionInInitializerError
-keep public class java.lang.OutOfMemoryError