Commit Graph

2140 Commits

Author SHA1 Message Date
Joel Dice
17c1a552d5 break each Class, Field, and Method into separate classes
In order to facilitate making the VM compatible with multiple class
libraries, it's useful to separate the VM-specific representation of
these classes from the library implementations.  This commit
introduces VMClass, VMField, and VMMethod for that purpose.
2010-09-01 10:13:52 -06:00
Joel Dice
4273ff834c remove uncessary parentheses from Enum.java 2010-09-01 10:10:11 -06:00
Joel Dice
bcf7c0639c clarify GNU Classpath build instructions in readme.txt 2010-08-16 09:37:44 -06:00
Joel Dice
7eabe13921 verify file contents in FileOutput test 2010-08-16 09:30:39 -06:00
Joel Dice
be1ba2ccf8 fix gnu build 2010-08-16 09:24:27 -06:00
Zsombor Gegesy
4169425307 add error classes 2010-08-16 09:23:48 -06:00
Zsombor Gegesy
a50fda1a5e add ClassLoader.getResources calls 2010-08-16 09:23:48 -06:00
Zsombor Gegesy
03b66375f4 add Collections.enumeration(Collection<T> c) 2010-08-16 09:23:48 -06:00
Zsombor Gegesy
4dc05844df add java.util.Properties.propertyNames() method 2010-08-16 09:23:48 -06:00
Zsombor Gegesy
1daa93d3c4 add ability to append to files 2010-08-16 09:23:48 -06:00
Joel Dice
f0f35a920f return a useful value from InflaterInputStream.available
Note the following excerpt from PNGFileFormat.java in SWT:

     /*
     * InflaterInputStream does not consume all bytes in the stream
     * when it is closed. This may leave unread IDAT chunks. The fix
     * is to read all available bytes before closing it.
     */
     while (stream.available() > 0) stream.read();
     stream.close();

This code relies on the documented behavior of
InflaterInputStream.available, which must return "0 after EOF has been
reached, otherwise always return 1".  This is unlike
InputStream.available, which is documented to return "the number of
bytes that can be read (or skipped over) from this input stream
without blocking by the next caller of a method for this input
stream", and says nothing about how many bytes are left until the end
of stream.

This commit modifies InflaterInputStream.available to behave according
to Sun's documentation.
2010-08-04 18:54:47 -06:00
Joel Dice
fca98df55b fix process=interpret class initialization regression
A long time ago, I refactored the class initialization code in the VM,
but did not notice until today that it had caused the
process=interpret build to break on certain recursive initializations.
In particular, we were not always detecting when a thread recursively
tried to initialize a class it was already in the process of
initializing, leading to the mistaken assumption that another thread
was initializing it and that we should wait until it was done, in
which case we would wait forever.

This commit ensures that we always detect recursive initialization and
short-circuit it.
2010-08-04 18:27:54 -06:00
Joel Dice
064c3b7c33 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-07-30 12:28:30 -06:00
Joel Dice
f0129665c6 fix corruption of old revisioins in PersistentSet
In PersistentSet.remove, we were modifying the child node in place
instead of making a copy to update, which would corrupt older
revisions.  This commit ensures that we always create a copy if
necessary.
2010-07-30 12:23:41 -06:00
Joel Dice
ddc90ef76e fix 64-bit left shifts with constant shifts greater than or equal to 32
The shiftLeftC function in powerpc.cpp was miscompiling such shifts,
leading to crashes due to illegal instructions and other weirdness due
to instructions that meant something completely different.  This
commit fixes that and adds a test to Longs.java to make sure it stays
fixed.
2010-07-23 10:52:58 -06:00
Joel Dice
4034a219d0 do nothing in System.arraycopy if length <= 0
Previously, we risked segfaults by passing negative numbers to memcpy.

This commit also makes arraycopy throw an IndexOutOfBounds exception
instead of an ArrayStoreException if the specified offsets and lengths
would take us outside the bounds of one or both of the arrays, per the
Sun documentation.
2010-07-13 18:40:29 -06:00
Joel Dice
71972fd1b5 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-07-13 18:03:30 -06:00
Joel Dice
b3da635b63 add java.nio.channels.Channels implementation 2010-07-13 18:03:25 -06:00
Joel Dice
1f8130f566 handle virtual thunk case in MyProcessor::getStackTrace
If we catch the target thread in a virtual thunk when getting its
stack trace, we must assume its Thread::stack field is garbage and use
the register values instead.  Previously, we treated these thunks as
any other native code, leading to crashes when we tried to use the
garbage pointer.
2010-07-06 16:13:11 -06:00
Joel Dice
0817f4e0da Merge branch 'master' into thread-getstacktrace 2010-07-02 12:51:39 -06:00
Joel Dice
a3daeee1f6 Merge branch 'dns' 2010-07-02 12:39:41 -06:00
Joel Dice
5e7e539c2a fix non-windows java-net.cpp build 2010-07-02 09:36:55 -06:00
Joel Dice
bf8eb52611 reduce CodeCapacity value to 16MB in bootimage.cpp
32MB was just slightly too large for PowerPC immediate call instructions
to span, and 16MB matches the JIT executable memory area we use in
compile.cpp.
2010-06-25 21:54:01 -06:00
Joel Dice
6d887ef34f comment-out debug logging in powerpc.cpp 2010-06-25 21:51:32 -06:00
Joel Dice
d308ba93c7 fix tails=true bootimage=true build
compileDirectInvoke does some magic to optimize tail calls to native
methods which involves storing the return address (which we'll never
actually return to, since it's a tail call) in a thread-local field so
the thunk function can figure out which native method to look up at
runtime.  Since this address will change when the boot image is
loaded, the boot image creation code needs to know about it.
2010-06-25 21:13:59 -06:00
Joel Dice
98b82a9bc1 fix callContinuation regression
callContinuation failed to call the correct continuation when feeding
it an exception due to a regression introduced with the
Thread.getStackTrace changes.
2010-06-25 09:51:35 -06:00
Joel Dice
74930d75e7 update PowerPC assembly Thread field offsets
The new Thread::defaultHeap declaration has increased the offset of all
the fields following it.

This commit also makes vmInvoke_returnAddress global so it can be refered
to from compile.cpp.
2010-06-24 19:35:07 -06:00
Joel Dice
2d6a179bf2 update assembly code field offsets to reflect new Thread field declaration
Thread::defaultHeap is now an inline array, which means the offsets of
all the fields following have increased.
2010-06-24 19:12:15 -06:00
Joel Dice
3e304521d0 initialize MyProcessor::callTableSize in constructor
This field was being used uninitialized, which could lead to an out of
memory condition when we tried to grow the call table to a ridiculous
size.
2010-06-24 19:09:50 -06:00
Joel Dice
3018290238 pre-allocate Thread::backupHeap for signal safety
It's not safe to use malloc from a signal handler, so we can't
allocate new memory when handling segfaults or Thread.getStackTrace
signals.  Instead, we allocate a fixed-size backup heap for each
thread ahead of time and use it if there's no space left in the normal
heap pool.  In the rare case that the backup heap isn't large enough,
we fall back to using a preallocated exception without a stack trace
as a last resort.
2010-06-19 16:40:21 -06:00
Joel Dice
7ea6036842 fix isThunkUnsafeStack
This function was broken in two different ways:

 1. It only checked MyProcessor::thunks, not MyProcessor::bootThunks.
    It needs to check both.

 2. When checking MyProcessor::thunks, it used fields from
    MyProcessor::bootThunks instead of from the same thunk collection.

This fixes both problems.
2010-06-16 20:29:41 -06:00
Joel Dice
ea797fd03c fix windows build 2010-06-16 18:37:22 -06:00
Joel Dice
39a82a4006 update bootimage.cpp to reflect BootImage restructuring 2010-06-15 19:49:48 -06:00
Joel Dice
18d1c54956 fix typo in compile-x86.S 2010-06-15 19:47:06 -06:00
Joel Dice
9559aca825 fix Thread.getStackTrace race conditions
Implementing Thread.getStackTrace is tricky.  A thread may interrupt
another thread at any time to grab a stack trace, including while the
latter is executing Java code, JNI code, helper thunks, VM code, or
while transitioning between any of these.

To create a stack trace we use several context fields associated with
the target thread, including snapshots of the instruction pointer,
stack pointer, and frame pointer.  These fields must be current,
accurate, and consistent with each other in order to get a reliable
trace.  Otherwise, we risk crashing the VM by trying to walk garbage
stack frames or by misinterpreting the size and/or content of
legitimate frames.

This commit addresses sensitive transition points such as entering the
helper thunks which bridge the transitions from Java to native code
(where we must save the stack and frame registers for use from native
code) and stack unwinding (where we must atomically update the thread
context fields to indicate which frame we are unwinding to).  When
grabbing a trace for another thread, we determine what kind of code we
caught the thread executing in and use that information to choose the
thread context values with which to begin the trace.  See
MyProcessor::getStackTrace::Visitor::visit for details.

In order to atomically update the thread context fields, we do the
following:

 1. Create a temporary "transition" object to serve as a staging area
    and populate it with the new field values.

 2. Update a transition pointer in the thread object to point to the
    object created above.  As long as this pointer is non-null,
    interrupting threads will use the context values in the staging
    object instead of those in the thread object.

 3. Update the fields in the thread object.

 4. Clear the transition pointer in the thread object.

We use a memory barrier between each of these steps to ensure they are
made visible to other threads in program order.  See
MyThread::doTransition for details.
2010-06-15 19:10:48 -06:00
Joel Dice
cdc48da493 grammar tweaks to Continuations.java JavaDoc 2010-06-15 18:40:12 -06:00
Joel Dice
1b31fb67e1 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-06-15 18:27:51 -06:00
Joel Dice
47d9039b69 switch from gethostbyname to getaddrinfo on POSIX systems
gethostbyname may return any combination of IPv4 and IPv6 addresses,
and it's not safe to assume the first address is IPv4, which is all
our code is currently prepared to handle.  In contrast, getaddrinfo
allows us to specify whether we want IPv4, IPv6, or both.

We should eventually make this switch on Windows as well, but the
status of getaddrinfo in Windows 2000 is not clear, and MinGW's
ws2tcpip.h only declares it for XP and above.

This commit also adds InetAddress.getByName for explicit DNS lookups.
2010-06-14 16:09:56 -06:00
Matt Klich
686f1ba983 Revert "win32 i386 build should use mingw64 if available"
This reverts commit 74e282a3d3.
2010-06-09 16:03:48 -06:00
Joel Dice
f3a1c3253e use closesocket instead of close on Windows
MinGW's close apparently does nothing, and MSVC's headers don't even
declare it, so closesocket is the way to go.
2010-06-04 18:45:13 -06:00
Joel Dice
8c8f41b5e8 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-06-04 18:04:39 -06:00
Joel Dice
b908f575d5 fix several blocking SocketChannel bugs
In java-nio.cpp, we can't use GetPrimitiveArrayCritical when reading
from or writing to blocking sockets since it may block the rest of the
VM indefinitely.

In SelectableChannel.java, we can't use a null test on
SelectableChannel.key to determine whether the channel is open since
it might never be registered with a Selector.  According to the Sun
documentation, a SelectableChannel is open as soon as it's created, so
that's what we now implement.
2010-06-04 15:37:22 -06:00
Joel Dice
9f1f1840b6 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-05-26 08:55:31 -06:00
Matt Klich
74e282a3d3 win32 i386 build should use mingw64 if available 2010-05-17 12:36:39 -06:00
Matt Klich
62c741d969 Specify -m flag on windows x86_64 gcc/g++ compilers. 2010-05-13 17:01:55 -06:00
Matt Klich
83c51f4801 Fix signed vs. unsigned comparison for 32bit build with mingw64 2010-05-13 16:59:08 -06:00
mjensen
a6998238d5 Additional of several interfaces which can be used in serialization 2010-05-10 10:17:06 -06:00
mjensen
3e111f87c3 Added files to be ignored that are used in eclipse 2010-05-10 10:16:36 -06:00
Joel Dice
a035c6892f Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2010-05-04 08:25:53 -06:00
Joel Dice
a31ae24005 Merge branch 'wip' 2010-05-03 16:32:40 -06:00