Commit Graph

2357 Commits

Author SHA1 Message Date
Joel Dice
35ae3dc391 fix mode=debug build 2011-01-28 08:43:11 -07:00
Joel Dice
740fa7ad9d fix unused parameter warnings 2011-01-27 21:10:06 -07:00
Joel Dice
f980ceb13e enable use-frame-pointer=true build
Also, include Continuations, Coroutines, and DynamicWind tests in test
suite for continuations=true build.
2011-01-27 21:06:01 -07:00
Joel Dice
b47dfdf5bd remove debug logging 2011-01-27 21:05:22 -07:00
Joel Dice
e4e0015005 fix GC safety issue in bootimage.cpp 2011-01-27 21:03:39 -07:00
Joel Dice
b7157c802a fix continuations=true build 2011-01-27 11:54:41 -07:00
Joel Dice
5cedcf7833 remove unnecessary exception checks from bootimage.cpp 2011-01-27 11:53:53 -07:00
Joel Dice
e16d5f83af Merge remote branch 'origin/master' into r0.5 2011-01-25 17:30:21 -07:00
Joel Dice
c1a0d8b6fc more work on frame-pointer-less unwinding
This fixes the tails=true build (at least for x86_64) and eliminates
the need for a frame table in the tails=false build.  In the
tails=true build, we still need a frame table on x86(_64) to help
determine whether we've caught a thread executing code to do a tail
call or pop arguments off the stack.  However, I've not yet written
the code to actually use this table, and it is only needed to handle
asynchronous unwinds via Thread.getStackTrace.
2011-01-25 17:22:43 -07:00
Joel Dice
966650f105 make StackOverflow test useful in tails=true build 2011-01-25 17:13:59 -07:00
Joel Dice
220f7760b7 fix MSVC build regressions 2011-01-21 16:14:21 -07:00
Joel Dice
0cc6156932 remove redundant code from DefineClass and Zip tests 2011-01-21 16:11:36 -07:00
Joel Dice
3aff7dc861 add TreeSet(Collection) constructor 2011-01-20 09:39:16 -07:00
Joel Dice
0ca7ed8c67 add Package.getName 2011-01-20 09:35:34 -07:00
Joel Dice
3a2a46499e add Reader.mark/markSupported/reset 2011-01-20 09:34:46 -07:00
Joel Dice
b57e734ceb implement Character.forDigit 2011-01-20 09:33:50 -07:00
Joel Dice
2dcc1d525a add note about slower floating point code for 32-bit x86 bootimage build 2011-01-20 08:50:53 -07:00
Joel Dice
51c56c1b3c add PrintStream.print[ln] overloads for primitives and char arrays 2011-01-20 08:26:56 -07:00
Joel Dice
9c36105b8f fix misleading pathnames in bootimage build instructions 2011-01-19 16:00:18 -07:00
Joel Dice
c02bfc57a5 resolve primitive array classes when generating boot image
This is necessary to accomodate classes loaded at runtime which refer
to primitive array types.  Otherwise, they won't be included unless
classes in the bootimage refer to them.
2011-01-18 08:35:52 -07:00
Joel Dice
475b286c7f preserve ClassLoader.loadClass from obfuscation/shrinking
This method is called by name in the VM.
2011-01-17 20:23:01 -07:00
Joel Dice
b4941cddbe close FileInputStream before deleting file in FileOutput test
Otherwise, Windows won't let us delete it.
2011-01-17 10:33:43 -07:00
Joel Dice
4a9ff55060 File.length should return 0 for non-existent files 2011-01-17 09:48:34 -07:00
Joel Dice
c855224d14 fix VM abort when ClassLoader.defineClass is used in bootimage build
When loading a class which extends another class that contained a
field of primitive array type using defineClass in a bootimage=true
build, the VM was unable to find the primitive array class, and
makeArrayClass refused to create one since it should already have
existed.

The problem was that the bootimage=true build uses an empty
Machine::BootstrapClassMap, and resolveArrayClass expected to find the
primitive array classes there.  The fix is to check the
Machine::BootLoader map if we can't find it in
Machine::BootstrapClassMap.
2011-01-17 09:36:03 -07:00
Joel Dice
3fe9171766 Merge remote branch 'origin/master' into r0.5 2011-01-16 19:40:01 -07:00
Joel Dice
43cbfd3f3a support stack unwinding without using a frame pointer
Previously, we unwound the stack by following the chain of frame
pointers for normal returns, stack trace creation, and exception
unwinding.  On x86, this required reserving EBP/RBP for frame pointer
duties, making it unavailable for general computation and requiring
that it be explicitly saved and restored on entry and exit,
respectively.

On PowerPC, we use an ABI that makes the stack pointer double as a
frame pointer, so it doesn't cost us anything.  We've been using the
same convention on ARM, but it doesn't match the native calling
convention, which makes it unusable when we want to call native code
from Java and pass arguments on the stack.

So far, the ARM calling convention mismatch hasn't been an issue
because we've never passed more arguments from Java to native code
than would fit in registers.  However, we must now pass an extra
argument (the thread pointer) to e.g. divideLong so it can throw an
exception on divide by zero, which means the last argument must be
passed on the stack.  This will clobber the linkage area we've been
using to hold the frame pointer, so we need to stop using it.

One solution would be to use the same convention on ARM as we do on
x86, but this would introduce the same overhead of making a register
unavailable for general use and extra code at method entry and exit.

Instead, this commit removes the need for a frame pointer.  Unwinding
involves consulting a map of instruction offsets to frame sizes which
is generated at compile time.  This is necessary because stack trace
creation can happen at any time due to Thread.getStackTrace being
called by another thread, and the frame size varies during the
execution of a method.

So far, only x86(_64) is working, and continuations and tail call
optimization are probably broken.  More to come.
2011-01-16 19:05:05 -07:00
Joel Dice
d5ba7412cd update DefineClass to exercise Class.newInstance
This is an attempt to reproduce an issue reported on the discussion
group.  However, the current form of the test is passing, so further
work will be necessary to trigger the bug.
2011-01-15 10:33:56 -07:00
Joel Dice
b6978c6c68 always create file if necessary in Java_java_io_FileOutputStream_open
Previously, we would only create the file if it did not already exist
*and* we weren't appending.  Now we do so whether appending or not.
2011-01-14 11:26:00 -07:00
Joel Dice
d12d33d716 fix memory leak in Java_java_io_File_length 2011-01-14 08:13:49 -07:00
Joel Dice
ff18524906 add DefineClass to test suite
As reported on the discussion group, there is a problem with the
ClassLoader.defineClass implementation sunch that this test is not
currently passing, at least for the mode=debug and bootimage=true
builds.  I plan to address these failures soon, but I wanted to add a
test first to make sure I could reproduce them.
2011-01-13 08:59:55 -07:00
Joel Dice
69dc2026a1 provide default implementation for ClassLoader.reallyFindLoadedClass
This is a non-standard method, so we shouldn't expect subclasses to
implement it.
2011-01-13 08:57:39 -07:00
Joel Dice
0c253c40a2 add ServerSocketChannel.handleReadyOps to fix build 2011-01-13 07:03:28 -07:00
Joel Dice
39018c20e0 check connection readyness in SocketChannel.finishConnect if necessary 2011-01-11 18:39:48 -07:00
Joel Dice
eb3a9f010b fix false positive return from SocketChannel.finishConnect
This fixes a bug in finishConnect such that it would return true even
if the socket had not yet connected successfully.
2011-01-11 18:29:48 -07:00
Joel Dice
4f0dccb53c add Channels.newChannel methods 2011-01-11 18:26:37 -07:00
Joel Dice
dd52908f89 add URLConnection methods 2011-01-11 18:25:34 -07:00
Joel Dice
afabe8e07e rework VM exception handling; throw OOMEs when appropriate
This rather large commit modifies the VM to use non-local returns to
throw exceptions instead of simply setting Thread::exception and
returning frame-by-frame as it used to.  This has several benefits:

 * Functions no longer need to check Thread::exception after each call
   which might throw an exception (which would be especially tedious
   and error-prone now that any function which allocates objects
   directly or indirectly might throw an OutOfMemoryError)

 * There's no need to audit the code for calls to functions which
   previously did not throw exceptions but later do

 * Performance should be improved slightly due to both the reduced
   need for conditionals and because undwinding now occurs in a single
   jump instead of a series of returns

The main disadvantages are:

 * Slightly higher overhead for entering and leaving the VM via the
   JNI and JDK methods

 * Non-local returns can make the code harder to read

 * We must be careful to register destructors for stack-allocated
   resources with the Thread so they can be called prior to a
   non-local return

The non-local return implementation is similar to setjmp/longjmp,
except it uses continuation-passing style to avoid the need for
cooperation from the C/C++ compiler.  Native C++ exceptions would have
also been an option, but that would introduce a dependence on
libstdc++, which we're trying to avoid for portability reasons.

Finally, this commit ensures that the VM throws an OutOfMemoryError
instead of aborting when it reaches its memory ceiling.  Currently, we
treat the ceiling as a soft limit and temporarily exceed it as
necessary to allow garbage collection and certain internal allocations
to succeed, but refuse to allocate any Java objects until the heap
size drops back below the ceiling.
2010-12-27 15:55:23 -07:00
Joel Dice
5da8b96931 Merge remote branch 'origin/master' into r0.5 2010-12-21 15:28:34 -07:00
Joel Dice
2e86f0ac57 fix race condition leading to deadlock on exit
There is a delay between when we tell the OS to start a thread and
when it actually starts, and during that time a thread might
mistakenly think it was the last to exit, try to shut down the VM, and
then block in joinAll when it finds it wasn't the last one after all.

The solution is to increment Machine::liveCount and add the new thread
to the process tree before starting it -- all while holding
Machine::stateLock for atomicity.  This helps guarantee that when
liveCount is one, we can be sure there's really only one thread
running or staged to run.
2010-12-20 19:00:23 -07:00
Joel Dice
857dcd13e7 fix 64-bit constant comparisons on 32-bit platforms 2010-12-20 18:08:52 -07:00
Joel Dice
5d5a18c482 set Thread::exception to null before creating ExceptionInInitializerError
If we don't do this, the VM will crash when it tries to create a stack
trace for the error because makeObjectArray will return null
immediately when it sees there is a pending exception.
2010-12-20 16:49:45 -07:00
Joel Dice
dd29c94715 Merge remote branch 'origin/master' into r0.5 2010-12-20 13:30:37 -07:00
Joel Dice
74d2afd707 use "no-underscore" naming convention for 64-bit Windows
GCC 4.5.1 and later use a naming convention where functions are not
prefixed with an underscore, whereas previous versions added the
underscore.  This change was made to ensure compatibility with
Microsoft's compiler.  Since GCC 4.5.0 has a serious code generation
bug, we now only support later versions, so it makes sense to assume
the newer convention.
2010-12-20 12:11:29 -07:00
Joel Dice
306f1282d0 throw ArithmeticException on divide-by-zero 2010-12-19 17:47:21 -07:00
Joel Dice
d18240cbd6 check for stack overflow on entry to all non-leaf methods
We now check for stack overflow in the JIT build as well as the
interpreted build, throwing a StackOverflowError if the limit
(currently hard-coded to 64KB, but should be easy to make
configurable) is exceeded.
2010-12-19 15:23:19 -07:00
Joel Dice
cac2d2cac5 fix race condition in monitorRelease
There was an unlikely but dangerous race condition in monitorRelease
such that when a thread released a monitor and then tried to notify
the next thread in line, the latter thread might exit before it can be
notified.  This potentially led to a crash as the former thread tried
to acquire and notify the latter thread's private lock after it had
been disposed.

The solution is to do as we do in the interrupt and join cases: call
acquireSystem first and thereby either block the target thread from
exiting until we're done or find that it has already exited, in which
case nothing needs to be done.

I also looked at monitorNotify to see if we have a similar bug there,
but in that case the target thread can't exit without first acquiring
and releasing the monitor, and since we ensure that no thread can
execute monitorNotify without holding the monitor, there's no
potential for a race.
2010-12-16 16:46:25 -07:00
Joel Dice
6c53068f4f clear Thread::stack before vmInvoke_safeStack in compile-arm.S 2010-12-15 10:41:18 -07:00
Joel Dice
d5d414aa52 update gprIndex when switching to stack-based argument passing
This is necessary when passing a 64-bit value on 32-bit ARM since
otherwise we risk using a register for the following argument instead
of the stack.
2010-12-10 14:01:22 -07:00
Joel Dice
64b11f0c64 close ZipFile when done with it in Zip test 2010-12-10 01:20:44 -07:00
Joel Dice
651ad20fc3 fix GC safety bugs 2010-12-09 22:17:57 -07:00