Commit Graph

1827 Commits

Author SHA1 Message Date
Joel Dice
17449eaf1b progress towards fixing the ARM build 2011-01-28 17:16:08 -07:00
Joel Dice
cac232a84e add comments to x86.cpp 2011-01-28 17:15:57 -07:00
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
220f7760b7 fix MSVC build regressions 2011-01-21 16:14:21 -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
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
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
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
651ad20fc3 fix GC safety bugs 2010-12-09 22:17:57 -07:00
Joel Dice
2d0ff83653 fix assertion abort when generating boot image
In makeCodeImage, we were passing zero to Promise::Listener::resolve,
which would lead to an assertion error if the address of the code
image was further from the base of the address space (i.e. zero) than
could be spanned by a jump on the target architecture.  Since, in this
context, we immediately overwrite the value stored, we may pass
whatever we want to this function (we're only calling it so we can
retrieve the location of the value in the image), and the code image
pointer is a better choice for the above reason.
2010-12-09 21:09:48 -07:00
Joel Dice
3d49173b0b avoid inifinite recursion if java.lang.Object is missing; refactoring
When trying to create an array class, we try to resolve
java.lang.Object so we can use its vtable in the array class.
However, if Object is missing, we'll try to create and throw a
ClassNotFoundException, which requires creating an array to store the
stack trace, which requires creating an array class, which requires
resolving Object, etc..  This commit short-circuits this process by
telling resolveClass not to create and throw an exception if it can't
find Object.

While doing the above work, I noticed that the implementations of
Classpath::makeThrowable in classpath-avian.cpp and
classpath-openjdk.cpp were identical, so I made makeThrowable a
top-level function.

Finally, I discovered that Thread.setDaemon can only be called before
the target thread has been started, which allowed me to simplify the
code to track daemon threads in the VM.
2010-12-09 19:38:12 -07:00
Joel Dice
d381ece44b rework loadLibrary interception to handle builtins properly 2010-12-08 21:38:16 -07:00
Joel Dice
bc2b4802ec add todo comment to classpath-common.h 2010-12-08 21:36:02 -07:00
Joel Dice
544cebb7f0 use MyBlock::start when computing constant pool offsets, not MyBlock::offset 2010-12-07 18:17:41 -07:00
Joel Dice
314bdae80d freeze BranchEvent operands to ensure they aren't clobbered as temporaries 2010-12-07 18:16:19 -07:00
Joel Dice
378f7086b7 fix return address code offset calculation on ARM
We have to be careful about how we calculate return addresses on ARM
due to padding introduced by constant pools interspersed with code.
When calculating the offset of code where we're inserting a constant
pool, we want the offset of the end of the pool for jump targets, but
we want the offset just prior to the beginning of the pool (i.e. the
offset of the instruction responsible for jumping past the pool) when
calculating a return address.
2010-12-07 15:57:11 -07:00
Joel Dice
a5742f5985 update copyright years 2010-12-05 20:21:09 -07:00
Joel Dice
019e032f4f add boot-javahome.cpp
This should have been included in an earlier commit.
2010-12-05 18:04:25 -07:00
Joel Dice
1271678d41 various fixes for embedded resource loading in OpenJDK build 2010-12-05 17:40:50 -07:00
Joel Dice
b1b433b63a remove debug code from GetMethodID 2010-12-05 17:37:13 -07:00
Joel Dice
0bd6822ed7 fix PowerPC build 2010-12-03 13:42:13 -07:00
Joel Dice
3d56a3211d revert part of earlier comment involving setDaemon and runJavaThread
The code added to runJavaThread was unecessary and harmful since it
allowed the global daemon thread count to become permanently
out-of-sync with the actual number of daemon threads.
2010-12-01 20:29:56 -07:00
Joel Dice
4a3b5ad1ab fix windows cross openjdk-src build
This mainly involves some makefile ugliness to work around bugs in the
native Windows OpenJDK code involving conflicting static and
not-static declarations which GCC 4.0 and later justifiably reject but
MSVC tolerates.
2010-12-01 20:05:22 -07:00
Joel Dice
7164743009 fix Array.makeObjectArray regression 2010-12-01 15:44:09 -07:00
Joel Dice
8cbe323d52 update Avian_avian_Machine_dumpHeap to reflect classpath refactoring 2010-12-01 15:43:27 -07:00
Joel Dice
1722b68277 handle case of not-yet-started thread in setDaemon 2010-12-01 15:42:46 -07:00
Joel Dice
84520cde51 Merge remote branch 'origin/master' into openjdk 2010-12-01 14:40:58 -07:00
Joel Dice
6d1ad1e5ba intercept UnixFileSystem.checkAccess calls to handle embedded java home case 2010-12-01 13:40:43 -07:00
Joel Dice
8f06ac402a compare library to RTLD_DEFAULT, not zero in JVM_FindLibraryEntry
Although RTLD_DEFAULT is zero on Linux, it's not on OS X.
2010-12-01 09:54:29 -07:00
Joel Dice
4b1b3e032b add new array classes to classloader map upon creation
We were already doing this for non-array classes; we need to do it for
all classes or else risk creating duplicates.
2010-11-30 20:27:36 -07:00
Joel Dice
21a54cdf55 set java.protocol.handler.pkgs on Windows as well as Posix
Also, fix cut-and-paste error where we should have called
fieldAddendum instead of methodAddendum.
2010-11-30 20:25:48 -07:00
Joel Dice
1d9489a76e fix a couple of 64-bit-op-on-32-bit-system bugs
We weren't properly handling the case where a 64-bit value is
multipled with itself in multiplyRR, leading to wrong code.  Also,
addCarryCR didn't know how to handle constants more than 8-bits wide.
2010-11-30 16:58:51 -07:00
Joel Dice
19dca18cd0 disable Math.abs(long) intrinsic on 32-bit x86
It never worked and caused the compiler to crash instead due to an
impossible-to-fulfill constraint.
2010-11-30 11:36:18 -07:00
Joel Dice
8de53aeacc fix Windows openjdk-src build 2010-11-29 17:39:41 -07:00
Joel Dice
70a36c05b9 fix time==0 case in Unsafe.park and implement JVM_DumpThreads
Also, set name field on system threads for OpenJDK build to avoid NPEs
in Thread.getName.
2010-11-27 16:27:30 -07:00
Joel Dice
3cba6edf1f print path elements if DebugFind == true in parsePath 2010-11-27 16:27:22 -07:00
Joel Dice
0f04865e93 implement -jar option in main.cpp 2010-11-27 14:46:07 -07:00
Joel Dice
1f6ccbf5b7 meant to add my_net_util.c in previous commit 2010-11-27 14:45:38 -07:00
Joel Dice
adc5c95214 fix GC safety bug in resolveClass 2010-11-27 14:44:49 -07:00
Joel Dice
d4708907ea fix non-openjdk build 2010-11-27 11:31:34 -07:00
Joel Dice
e68dfe1e89 various fixes to get Eclipse 3.6 working
* add libnet.so and libnio.so to built-in libraries for openjdk-src build

 * implement sun.misc.Unsafe.park/unpark

 * implement JVM_SetClassSigners/JVM_GetClassSigners

 * etc.
2010-11-27 11:25:02 -07:00
Joel Dice
459f4d5194 fix openjdk-src bootimage build
The main change here is to use a lazily-populated vector to associate
runtime data with classes instead of referencing them directly from
the class which requires updating immutable references in the heap
image.  The other changes employ other strategies to avoid trying to
update immutable references.
2010-11-26 12:41:31 -07:00
Joel Dice
4f23601b56 fix corner cases which led to crashes in JIT compiler
Compiling the entire OpenJDK class library into a bootimage revealed
some corner cases which broke the compiler, including synchronization
in a finally block and gotos targeting the first instruction of an
unsynchronized method.
2010-11-26 12:36:43 -07:00
Joel Dice
44fcc5c04e clean up properly if pthread_kill fails in MySystem::visit 2010-11-22 16:57:02 -07:00
Joel Dice
b8063285f3 fix deadlock MySystem::visit in posix.cpp
We must call notifyAll on visitLock after setting threadVisitor to
null in case another thread is waiting to do a visit of its own.
Otherwise, the latter thread will wait forever, eventually deadlocking
the whole VM at the next GC since it's in an active state.
2010-11-22 16:46:10 -07:00
Joel Dice
19dbc61e9f for heapdump=true builds, optionally generate dump on OOM
If the VM runs out of heap space and the "avian.heap.dump" system
property was specified at startup, the VM will write a heap dump to
the filename indicated by that property.  This dump may be analyzed
using e.g. DumpStats.java.
2010-11-18 10:55:00 -07:00
Joel Dice
7b85afedec ensure that sa_sigaction is non-null before attempting to call it 2010-11-18 10:24:58 -07:00
Joel Dice
86ed206f5a remove temporary debug code from posix.cpp 2010-11-18 10:19:48 -07:00
Joel Dice
aea02e545f fix race condition in interrupting/joining threads as they are exiting
My recent commit to ensure that OS resources are released immediately
upon thread exit introduced a race condition where interrupting or
joining a thread as it exited could lead to attempts to use
already-released resources.  This commit adds locking to avoid the
race.
2010-11-16 10:50:19 -07:00
Joel Dice
3ff1f9c59f remove temporary debugging code from posix.cpp 2010-11-16 10:49:56 -07:00
Joel Dice
a611ccda6f Merge remote branch 'origin/master' into openjdk
Conflicts:
	makefile
	src/compile.cpp
	src/compiler.cpp
	src/type-generator.cpp
2010-11-16 10:18:08 -07:00
Joel Dice
937b7a7d34 Merge remote branch 'origin/arm' 2010-11-16 09:56:35 -07:00
Joel Dice
64601e6f3e name VM-internal classes for heapdump=true builds
This makes heap dumps more useful since these classes are now refered
to by name instead of number.

This commit also adds a couple of utilities for parsing heap dumps:
PrintDump and DumpStats.
2010-11-16 09:31:49 -07:00
Joel Dice
86188cfc04 fix OS X openjdk and openjdk-src builds 2010-11-15 20:28:53 -07:00
Joel Dice
bc326fb5e9 fix ARM bootimage=true build 2010-11-16 02:38:36 +00:00
Joel Dice
3fb834d008 fix pre-GCC-4.4 ARM build 2010-11-15 23:56:34 +00:00
Joel Dice
02bdec6f8c fix Cygwin/MSYS openjdk-src builds 2010-11-15 16:27:00 -07:00
Joel Dice
8e23893af0 fix PowerPC builds on OS X 10.5+
The primary change is to ensure we output a Mach-O file of appropriate
endianness when cross-compiling for an opposite-endian architecture.
Earlier versions of XCode's linker accepted files of either
endianness, reguardless of architecture, but later versions don't,
hence the change.
2010-11-14 18:45:37 -07:00
Joel Dice
6bf74bf380 optimize loads of constant values by using PC-relative addressing on ARM
Previously, loading an arbitrary 32-bit constant required up to four
instructions (128 bytes), since we did so one byte at a time via
immediate-mode operations.

The preferred way to load constants on ARM is via PC-relative
addressing, but this is challenging because immediate memory offsets
are limited to 4096 bytes in either direction.  We frequently need to
compile methods which are larger than 4096, or even 8192, bytes, so we
must intersperse code and data if we want to use PC-relative loads
everywhere.

This commit enables pervasive PC-relative loads by handling the
following cases:

 1. Method is shorter than 4096 bytes: append data table to end

 2. Method is longer than 4096 bytes, but no basic block is longer
 than 4096 bytes: insert data tables as necessary after blocks, taking
 care to minimize the total number of tables

 3. Method is longer than 4096 bytes, and some blocks are longer than
 4096 bytes: split large basic blocks and insert data tables as above
2010-11-13 19:42:29 -07:00
Joel Dice
0ca6c3ed53 fix native Windows GCC 3.4 OpenJDK build 2010-11-12 18:29:12 -07:00
Joel Dice
26a59612bb fix native Windows GCC 3.4 build 2010-11-12 16:53:16 -07:00
Joel Dice
f21d2b68b8 fix another ARM immediate offset bug
Some memory operations can only handle 8-bit immediate values, so we
need to use a temporary register for those which don't fit.
2010-11-09 17:31:52 -07:00
Joel Dice
6f555d4202 minor code cleanup in compile.cpp 2010-11-09 17:31:42 -07:00
Joel Dice
f64d6c857b clean up OS resources immediately upon thread exit
Previously, we waited until the next GC to do this, but that can be
too long for workloads which create a lot of short-lived threads but
don't do much allocation.
2010-11-09 15:46:16 -07:00
Joel Dice
7978102cb6 use register for indexing if constant offset is too large (or too small)
Immediate indexes on ARM must be no more than 12 bits, so we must use
a temporary register for values which don't fit.
2010-11-09 11:36:38 -07:00
Joel Dice
70fcbc2788 freeze index site in BoundsCheckEvent::compile
This ensures we don't use it as a temporary register when generating
the comparison.
2010-11-09 11:34:56 -07:00
Joel Dice
632e50efe6 fix non-continuations ARM build 2010-11-09 02:13:23 +00:00
Joel Dice
8ca5e9780e fix OS X build 2010-11-07 21:23:25 -07:00
Joel Dice
0f0427f23b implement continuations support for ARM 2010-11-08 04:18:10 +00:00
Joel Dice
36a8ba28e5 disable debug logging in compile.cpp 2010-11-08 04:15:31 +00:00
Joel Dice
5d5dbd860b fix ARM tails=true build
This requires adding LinkRegister to the list of reserved registers,
since it must be preserved in the thunk code generated by
compileDirectInvoke.  An alternative would be to explicitly preserve
it in that special case, but that would complicate the code quite a
bit.
2010-11-08 00:41:44 +00:00
Joel Dice
cfc09f8fdb Merge commit 'origin/master' into arm 2010-11-07 21:10:41 +00:00
Joel Dice
75de0a621b fix windows.cpp MySystem::now 2010-11-07 12:35:31 -07:00
Joel Dice
6cf3666ed9 fix timezone lookup for Windows openjdk-src build 2010-11-07 12:24:40 -07:00
Joel Dice
33b945c10b fix Windows openjdk (non-openjdk-src) build 2010-11-07 10:08:04 -07:00
Joel Dice
e1b808024a initial support for Windows OpenJDK build
All the tests are passing for openjdk-src builds, but the non-src
openjdk build is crashing and there's trouble loading time zone info
from the embedded java.home directory.
2010-11-06 22:21:19 -06:00
Joel Dice
df299f3564 fix build against latest JRE 1.6.0_22
This commit accomodates a new field in java.lang.Thread and implements
JVM_FindClassFromBootLoader.
2010-11-05 15:34:28 -06:00
Joel Dice
d0a6096eb0 add support for accessing embedded JARs as if they were directories
This allows OpenJDK to access time zone data which is normally found
under java.home, but which we must embed in the executable itself to
create a self-contained build.  The VM intercepts various file
operations, looking for paths which start with a prefix specified by
the avian.embed.prefix property and redirecting those operations to an
embedded JAR.

For example, if avian.embed.prefix is "/avian-embedded", and code
calls File.exists() with a path of
"/avian-embedded/javahomeJar/foo.txt", the VM looks for a function
named javahomeJar via dlsym, calls the function to find the memory
region containing the embeded JAR, and finally consults the JAR to see
if the file "foo.txt" exists.
2010-11-05 13:18:28 -06:00
Joel Dice
4cb796d2fb only return null from JVM_GetClassLoader when called from Unsafe.getUnsafe
sun.misc.Unsafe.getUnsafe expects a null result if the class loader is
the boot classloader and will throw a SecurityException otherwise
(whereas it should really be checking both for null and comparing
against the system classloader).  However, just returning null
whenever the loader is the boot loader can cause trouble for embedded
apps which put everything in the boot loader, including application
resources.

Therefore, we only return null if it's the boot loader and we're being
called from Unsafe.getUnsafe.
2010-11-04 11:43:50 -06:00
Joel Dice
cabad6926f enable standalone OpenJDK builds
As described in readme.txt, a standalone OpenJDK build embeds all
libraries, classes, and other files needed at runtime in the resulting
binary, eliminating dependencies on external resources.
2010-11-04 11:02:09 -06:00
Joel Dice
cb69ac23bd Merge remote branch 'origin/master' into openjdk
Conflicts:
	classpath/java/lang/String.java
	src/posix.cpp
2010-11-03 11:54:41 -06:00
Joel Dice
25ca40931d keep track of original class in resolveField so we can throw an exception with a useful message 2010-10-24 11:49:59 -06:00
Joel Dice
6f839323a7 use user-specified boot classpath exclusively when present 2010-10-24 11:49:12 -06:00
Joel Dice
9c603c6525 fix member offset calculation inconsistencies in type-generator.cpp 2010-10-23 20:41:45 -06:00
Joel Dice
6df0b2cfd9 look for 32-bit JRE libraries under lib/i386 2010-10-23 20:40:48 -06:00
Joel Dice
081d2d68ce handle and ignore SIGPIPE on Posix systems
We must handle this signal or we'll get the default behavior of
exiting the process whenever we get an unexpected network
disconnection.
2010-10-14 23:43:35 +00:00
Joel Dice
ca251dfa17 print error message on failed dlopen if Verbose is true in posix.cpp 2010-10-13 13:37:09 -06:00
Joel Dice
1f67aea456 fix process=interpret build 2010-09-27 17:12:08 -06:00
Joel Dice
c1c9d2111b remove GNU Classpath and Apache Harmony compatibility code
Rather than try to support mixing Avian's core classes with those of
an external class library -- which necessitates adding a lot of stub
methods which throw UnsupportedOperationExceptions, among other
comprimises -- we're looking to support such external class libraries
in their unmodified forms.  The latter strategy has already proven
successful with OpenJDK's class library.  Thus, this commit removes
the stub methods, etc., which not only cleans up the code but avoids
misleading application developers as to what classes and methods
Avian's built-in class library supports.
2010-09-27 15:58:02 -06:00
Joel Dice
8c789fb92c return empty object array from MyProcessor::getStackTrace on failure 2010-09-27 09:39:44 -06:00
Joel Dice
1d4b54a9f6 fix failure to add abstract virtuals to class with no declared virtuals 2010-09-25 16:35:18 -06:00
Joel Dice
268d2de175 cache array class lookups in element class; misc. bugfixes 2010-09-25 15:54:01 -06:00
Joel Dice
a2cc95d196 remove trailing whitespace in compile.cpp 2010-09-25 15:52:43 -06:00
Joel Dice
e75b57a127 don't abort when compiling an array lookup with a constant negative index
Instead, just compile it as a direct call to the thunk which throws an
ArrayIndexOutOfBoundsException.
2010-09-25 15:48:15 -06:00
Joel Dice
ebc54c234f fix signedness error for wide iinc implementation 2010-09-23 08:50:09 -06:00
Joel Dice
b023d147df fix JVM_Available for when fd is a fifo or socket 2010-09-23 08:49:36 -06:00
Joel Dice
89f6adc93c fix various classloading deadlocks and races 2010-09-22 13:58:46 -06:00
Joel Dice
efd3ccb04f set java.home to path of JRE, not JDK 2010-09-20 18:38:38 -06:00
Joel Dice
17f495eb27 rework OpenJDK build to derive classpath and library path from environment
We now consult the JAVA_HOME environment variable to determine where
to find the system library JARs and SOs.  Ultimately, we'll want to
support self-contained build, but this allows Avian to behave like a
conventional libjvm.so.
2010-09-20 17:31:23 -06:00
Joel Dice
64e42da348 implement avian.Handler.ResourceInputStream.available 2010-09-17 16:11:04 -06:00
Joel Dice
93c9395f1d comment-out debug logging 2010-09-17 16:10:26 -06:00
Joel Dice
a0a23b4692 implement JVM_Yield 2010-09-17 16:10:01 -06:00
Joel Dice
d0d53e2e10 fix custom-classloader-related concurrency problems and other bugs
The main changes in this commit ensure that we don't hold the global
class lock when doing class resolution using application-defined
classloaders.  Such classloaders may do their own locking (in fact,
it's almost certain), making deadlock likely when mixed with VM-level
locking in various orders.

Other changes include a fix to avoid overflow when waiting for
extremely long intervals and a GC root stack mapping bug.
2010-09-16 20:49:02 -06:00
Joel Dice
f485016637 implement more JVM_* methods and avoid duplicate array class loading 2010-09-14 18:52:57 -06:00
Joel Dice
d819a75f36 more work towards OpenJDK classpath support
The biggest change in this commit is to split the system classloader
into two: one for boot classes (e.g. java.lang.*) and another for
application classes.  This is necessary to make OpenJDK's security
checks happy.

The rest of the changes include bugfixes and additional JVM method
implementations in classpath-openjdk.cpp.
2010-09-14 10:49:41 -06:00
Joel Dice
561ee6dff9 add debug logging to finder.cpp 2010-09-13 20:38:55 -06:00
Joel Dice
66280458c8 implement more JVM_* methods 2010-09-10 17:47:23 -06:00
Joel Dice
ea2509666a reverse operands when calling builtin isAssignableFrom
Our builtin function reverses the meanings of the operands relative to
the JNI method.
2010-09-10 17:45:52 -06:00
Joel Dice
64100d17c7 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian into openjdk 2010-09-10 15:58:43 -06:00
Joel Dice
cddea7187d preliminary support for using OpenJDK's class library
Whereas the GNU Classpath port used the strategy of patching Classpath
with core classes from Avian so as to minimize changes to the VM, this
port uses the opposite strategy: abstract and isolate
classpath-specific features in the VM similar to how we abstract away
platform-specific features in system.h.  This allows us to use an
unmodified copy of OpenJDK's class library, including its core classes
and augmented by a few VM-specific classes in the "avian" package.
2010-09-10 15:05:29 -06:00
Joel Dice
d9e79db062 Merge branch 'master' into arm 2010-09-03 23:26:08 +01:00
jet
a1f5456451 All tests passing for ARM port in JIT mode. 2010-09-03 12:52:11 -06:00
Joel Dice
dd0a696932 handle logical AND with a constant in a single instruction where possible 2010-09-03 18:32:22 +01:00
Joel Dice
e7a48c0fa2 save return address in powerpc.cpp's MyAssembler::saveFrame
We've been getting away with not doing this so far since our Java
calling convention matches the native calling convention concerning
where the return address is saved, so when our thunk calls native code
it gets saved for us automatically.  However, there was still the
danger that a thread would interrupt another thread after the stack
pointer was saved to the thread field but before the native code was
called and try to get a stack trace, at which point it would try to
find the return address relative to that stack pointer and find
garbage instead.  This commit ensures that we save the return address
before saving the stack pointer to avoid such a situation.
2010-09-02 17:28:20 -06:00
Joel Dice
bd01784249 save return address in arm.cpp's MyAssembler::saveFrame
This is necessary to allow safe stack unwinding (e.g. for exception
handling and garbage collection) from native code.
2010-09-03 00:18:19 +01:00
jet
a20d7e028b Longs.java test now progresses further before failure. 2010-09-02 16:09:01 -06:00
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
jet
b26dd4abf1 All but 6 tests are now passing in JIT mode on ARM. 2010-08-31 18:35:55 -06:00
Joel Dice
a4914daae4 remove unused functions from powerpc.cpp 2010-08-30 16:55:48 -06:00
jet
b6a839950f Nine tests (including float and integer calculations) are now passing. 2010-08-30 16:13:10 -06:00
Joel Dice
56b59cef5c use r6 instead of r0 in popFrameAndUpdateStackAndReturn
This avoids clobbering the return value.
2010-08-30 16:16:02 +01:00
jet
f740570ff6 Further debugging of ARM "Hello World!" JIT functionality. 2010-08-27 18:52:33 -06:00
jet
5c00cfac6f Incomplete debugging of "Hello World!" on ARM. 2010-08-24 17:59:01 -06:00
Joel Dice
be1ba2ccf8 fix gnu build 2010-08-16 09:24:27 -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
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
jet
d9aac52b3d First version; interpreted mode works and JIT mode compiles. 2010-07-12 14:18:36 -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
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
a31ae24005 Merge branch 'wip' 2010-05-03 16:32:40 -06:00
Eric Scharff
9909c0cec3 Fix Mac OS X specific path bug
In Mac OS X, if a path contains a space, the path of the main executable
will contain a special URL-encoded character (%20 in this case).  This
probably happens when any non-ASCII character is provided.

The fix is to use CFURLCreateStringByReplacingPercentEscapes which
creates a path that the POSIX API likes better.
2010-04-26 10:24:53 -06:00
JET
3aac50555b fixed ARM interpreted-mode regression 2010-04-20 15:51:35 -06:00
JET
1ea2a3a6dc Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2010-04-20 10:04:47 -06:00
JET
c666ab58e3 Improved (should now be complete) Unicode support (UTF-8 for *nix and UTF-16 for Windows). 2010-04-20 10:03:07 -06:00
Joel Dice
e5fad03632 fix MSVC build rot 2010-04-15 11:11:10 -06:00
JET
34f51114a1 Merge branch 'master' into wip 2010-04-14 09:27:24 -06:00
JET
b2f5e71d22 ARM and UTF-8 work 2010-04-14 09:26:50 -06:00
Joel Dice
03ec9e6f19 Merge branch 'master' into wip 2010-04-14 09:22:42 -06:00
Joel Dice
3e5b2cbc7b fix miscompilation of 64-bit volatile field reads and writes on x86_32
We were generating code which clobbered the data we were putting into
64-bit volatile fields (and potentially also clobbering the target or
source object in the case of non-static fields) due to misplaced
synchronization code.  Reordering this code ensures that both the data
and the target or source survive across calls to synchronization
helper functions.
2010-03-01 18:24:25 -07:00
Joel Dice
c2a9424f91 implement compileTimeMemoryBarrier in arch.h
This has the same implementation as programOrderMemoryBarrier in
x86.h, but makes it available on all architectures.
2010-02-04 18:30:13 -07:00
Joel Dice
99bb7924b0 fix stack frame mapping code for exception handlers
Previously, the stack frame mapping code (responsible for statically
calculating the map of GC roots for a method's stack frame during JIT
compilation) would assume that the map of GC roots on entry to an
exception handler is the same as on entry to the "try" block which the
handler is attached to.  Technically, this is true, but the algorithm
we use does not consider whether a local variable is still "live"
(i.e. will be read later) when calculating the map - only whether we
can expect to find a reference there via normal (non-exceptional)
control flow.  This can backfire if, within a "try" block, the stack
location which held an object reference on entry to the block gets
overwritten with a non-reference (i.e. a primitive).  If an exception
is later thrown from such a block, we might end up trying to treat
that non-reference as a reference during GC, which will crash the VM.

The ideal way to fix this is to calculate the true interval for which
each value is live and use that to produce the stack frame maps.  This
would provide the added benefit of ensuring that the garbage collector
does not visit references which, although still present on the stack,
will not be used again.

However, this commit uses the less invasive strategy of ANDing
together the root maps at each GC point within a "try" block and using
the result as the map on entry to the corresponding exception
handler(s).  This should give us safe, if not optimal, results.  Later
on, we can refine it as described above.
2010-02-04 18:03:32 -07:00
Joel Dice
c9b9db1621 reimplement Java object monitors (second try)
See commit 8120bee4dc for the original
problem description and solution.  That commit and a couple of related
ones had to be reverted when we found they had introduced GC-safety
regressions leading to crashes.

This commit restores the reverted code and fixes the regressions.
2010-02-04 17:56:21 -07:00
Joel Dice
48834be209 revert recent commits to reimplement Java object monitors
We're seeing race conditions which occasionally lead to assertion
failures and thus crashes, so I'm reverting these changes for now:

29309fb414
e92674cb73
8120bee4dc
2010-02-04 08:18:39 -07:00
Joel Dice
29309fb414 update Thread field offsets to reflect recent additions
Every time we add or remove fields to Thread, we need to update the
assembly code to reflect the new offsets.
2010-02-02 12:26:09 -07:00
Joel Dice
e92674cb73 fix race condition in monitorWait
We don't want to check Thread::waiting until we have re-acquired the
monitor, since another thread might notify us between releasing
Thread::lock and acquiring the monitor.
2010-02-02 12:24:05 -07:00
Joel Dice
3bc37d6e2a fix encoding of single byte register-to-memory moves on x86_64
We need to prefix instructions of the form "mov R,M" with a REX byte
when R is %spl, %bpl, %sil, or %dil.  Such moves are unencodable on
32-bit x86, and, because of the order in which we pick registers,
pretty rare on 64-bit systems, which is why this took so long to
notice.
2010-02-02 11:37:08 -07:00
Joel Dice
8120bee4dc reimplement Java object monitors to avoid running out of OS handles
Due to SWT's nasty habit of creating a new object monitor for every
task added to Display.asyncExec, we've found that, on Windows at
least, we tend to run out of OS handles due to the large number of
mutexes we create between garbage collections.

One way to address this might be to trigger a GC when either the
number of monitors created since the last GC exceeds a certain number
or when the total number of monitors in the VM reaches a certain
number.  Both of these risk hurting performance, especially if they
force major collections which would otherwise be infrequent.  Also,
it's hard to know what the values of such thresholds should be on a
given system.

Instead, we reimplement Java monitors using atomic compare-and-swap
(CAS) and thread-specific native locks for blocking in the case of
contention.  This way, we can create an arbitrary number of monitors
without creating any new native locks.  The total number of native
locks needed by the VM is bounded instead by the number of live
threads plus a small constant.

Note that if we ever add support for an architecture which does not
support CAS, we'll need to provide a fallback monitor implementation.
2010-02-01 18:40:47 -07:00
Joel Dice
45476eb591 fix handling of volatile longs and doubles on PowerPC
We were miscompiling methods which contained getfield, getstatic,
putfield, or putstatic instructions for volatile 64-bit primitives on
32-bit PowerPC due to not noticing that values in registers are clobbered
across function calls.

The solution is to create a separate Compiler::Operand instance for each
object monitor reference before and after the function call to avoid
confusing the compiler.  To avoid duplicate entries in the constant pool,
we add code look for and, if found, reuse any existing entry for the same
constant.
2010-01-27 17:46:04 -07:00
jet
ea4b4bfcbf Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2010-01-06 10:57:55 -07:00
Joel Dice
3686d2131d fix jsr/ret code generation bug
We were generating code to marshal values into place prior to a jump,
but placing it after the jump instruction, which made it useless.
2010-01-04 17:17:16 -07:00
Joel Dice
20f92bbd05 specify java.home system property in GNU Classpath build
Currently, we just set this to /tmp (or the equivalent) since Avian
doesn't really have a home.  This avoids a NullPointerException from
javax/xml/parsers/SAXParserFactory.
2010-01-04 17:14:00 -07:00
jet
8c8020811a Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-12-28 11:14:26 -07:00
Joel Dice
664cb3cd39 don't try to parse annotation tables more than once; use defining classloader when loading array classes during linking 2009-12-24 17:58:48 -07:00
Joel Dice
805d1d13d8 mark system classloader initialized when using GNU Classpath to avoid security exceptions; only look for field in interfaces after looking in class and superclasses 2009-12-24 17:57:07 -07:00
Joel Dice
40c65f66bf add (commented-out) debug logging to gnu.cpp 2009-12-24 17:54:02 -07:00
Joel Dice
7b2322e7f7 accept any source site in resolveTargetSites, whether it matches the next read or not 2009-12-24 17:47:58 -07:00
jet
77990b9489 Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-12-23 09:26:17 -07:00
Joel Dice
f588a62ae3 fix Classpath 0.98 compatibility issues 2009-12-22 21:34:04 -07:00
Joel Dice
30db38ebd6 replace calls to ExceptionOccurred with calls to ExceptionCheck
The latter is cheaper (avoids a state transition and possible memory
allocation) when we just want to know if an exception is thrown
without needing a handle to that exception.
2009-12-16 19:25:03 -07:00
Joel Dice
4c0ede8b9a reuse JNI references when possible
Before allocating a new reference in NewGlobalReference or when
creating a local reference, we look for a previously-allocated
reference pointing to the same object.  This is a linear search, but
usually the number of elements in the reference list is small, whereas
the memory, locking, and allocation overhead of creating duplicate
references can be large.
2009-12-16 19:16:51 -07:00
Joel Dice
7cf25a0fc3 fix process=interpret build 2009-12-14 18:01:28 -07:00
Joel Dice
d5f5c2351b use _ReadWriteBarrier intrinsic for MSVC build 2009-12-12 18:50:59 -07:00
Joel Dice
2b4361c060 fix GNU Classpath build 2009-12-05 19:40:46 -07:00
Joel Dice
b6ac05ba9d remove unecessary code from resolveSourceSites and resolveTargetSites 2009-12-05 15:49:53 -07:00
jent
4cf9e16897 Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2009-12-04 12:02:06 -07:00
jent
99a1c12682 Files to add Deflater and DeflaterOutputStream to java.util.zip for
avian
2009-12-04 12:01:31 -07:00
Joel Dice
0e4fabffb7 fix incorrect parameter to maybeRex call in sseMoveRR 2009-12-03 17:57:28 -07:00
Joel Dice
60333c88f5 fix continuations=true build for Windows x86_64 2009-12-03 12:46:29 -07:00
Joel Dice
7cdf63c045 fix continuations=true build for Darwin 2009-12-02 23:15:27 -07:00
Joel Dice
f0e66eea37 remove extra semicolon 2009-12-02 23:09:05 -07:00
Joel Dice
7a3bf85caf fix bootimage=true build for Windows 2009-12-02 20:08:07 -07:00
Joel Dice
b218117881 fix continuations=true build for Cygwin 2009-12-02 19:37:22 -07:00
Joel Dice
8b11f0c271 fix continuations=true build for Windows 2009-12-02 19:29:57 -07:00
Joel Dice
6118792ffd update copyright years 2009-12-02 19:08:29 -07:00
jet
e516f3ce1c Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-12-02 13:45:21 -07:00
Joel Dice
3777c9b429 fix MSVC build 2009-12-02 08:49:10 -07:00
Joel Dice
5a0e00ca39 GC safety bugfix 2009-12-01 22:41:12 -07:00
Joel Dice
80d3a286d1 check bootThunkTable as well as thunkTable in MyProcessor::getStackTrace
We need to check to see if we caught the thread somewhere in the thunk
code (i.e. about to call a helper function), in which case the stack
and base pointers are valid and may be used to create an accurate
trace.
2009-12-01 18:17:33 -07:00
Joel Dice
168e206812 fix GCC 3.4 build 2009-12-01 17:33:30 -07:00
Joel Dice
f216fe37ff fix regression which led to register exhaustion 2009-12-01 11:14:57 -07:00
Joel Dice
98275e175e powerpc bugfixes 2009-12-01 09:21:33 -07:00
Joel Dice
9ba71cf508 fix Darwin build 2009-12-01 08:23:11 -07:00
Joel Dice
0bdf1d8e82 use thunks for floating point ops if SSE is not available 2009-11-30 22:02:26 -07:00
Joel Dice
175cb8e89b more floating point bugfixes 2009-12-01 02:06:01 +00:00
Joel Dice
7fa10909f4 more bugfixes for handling 64-bit floats on 32-bit systems 2009-11-30 22:08:59 +00:00
jet
69c9bf5ff9 Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-11-30 14:00:51 -07:00
Joel Dice
851187f0ce refine memory barrier implementation and usage 2009-11-30 15:38:16 +00:00
Joel Dice
04454960ec various bugfixes for handling 64-bit floating point values on 32-bit systems 2009-11-30 15:10:34 +00:00
Joel Dice
d9de4c607c allow source operand of any type for move operations 2009-11-30 15:09:43 +00:00
Joel Dice
ec701b9994 whitespace tweaks 2009-11-30 15:08:45 +00:00
Joel Dice
79d281f7fa encourage loads from memory directly into SSE registers where appropriate 2009-11-30 02:17:08 +00:00
Joel Dice
1c61c1f421 fix x86 memoryBarrier implementation 2009-11-29 16:53:46 -07:00
Joel Dice
0b09c6aa30 avoid busy wait when entering "exclusive" state 2009-11-29 16:53:05 -07:00
Joel Dice
6d9e1270ca fix race conditions in atomic operations 2009-11-29 09:08:07 -07:00
Joel Dice
1558b85acf second attempt to fix "idle to active" fast path
If another thread succeeds in entering the "exclusive" state while we
use the fast path to transition the current thread to "active", we
must switch back to "idle" temporarily to allow the exclusive thread a
chance to continue, and then retry the transition to "active" via the
slow path.
2009-11-28 15:35:15 -07:00
Joel Dice
3418a8bcbe fix race condition introduced in previous commit 2009-11-28 15:24:02 -07:00
Joel Dice
75934c8342 provide fast paths for common thread state transitions
These paths reduce contention among threads by using atomic operations
and memory barriers instead of mutexes where possible.  This is
especially important for JNI calls, since each such call involves two
state transitions: from "active" to "idle" and back.
2009-11-28 15:01:54 -07:00
Joel Dice
f5490b800a Merge branch 'master' of oss.readytalk.com:/var/local/git/avian 2009-11-28 11:18:13 -07:00
Joel Dice
c615db31fb refine move cost calculation to avoid indirect moves (e.g. memory to memory) 2009-11-28 18:17:17 +00:00
Joel Dice
5ead8fab17 refactor code responsible for moving data in the compiler
This is partially to address incorrect code generation for 64-bit
floating-point values on x86_32 and partially to reduce unnecessary
moves.
2009-11-27 21:15:12 -07:00
Joel Dice
bd72745ff9 fix off-by-one error in intrinsic() 2009-11-27 21:01:27 -07:00
Joel Dice
f6a52e260b specify CONTEXT::ContextFlags before calling GetThreadContext
Previously, we assumed that the "context" parameter to
GetThreadContext was only an output parameter, but it actually uses at
the value of CONTEXT::ContextFlags on entry to decide what parts of
the structure to fill in.  We were getting lucking most of the time,
because whatever garbage was on the stack at that location had the
necessary bits set.  When we weren't so lucky, we got all zeros for
the register values which sometimes lead to a crash depending on the
state of the thread being examined.
2009-11-24 19:16:22 -07:00
Joel Dice
9f14d63592 initialize MyProcessor::getStackTrace::Visitor::trace in case visit is never called 2009-11-24 19:15:27 -07:00
Stan
728a6ba706 use MapViewOfFile instead of mmap on Windows 2009-11-24 08:24:37 -07:00
jet
993d210232 Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-11-23 10:04:16 -07:00
Joel Dice
a0d763d871 use cmpxchgq for 64-bit operands in atomicCompareAndSwap 2009-11-20 15:17:35 -07:00
Joel Dice
2276eece0e support atomicCompareAndSwap on powerpc for GCC versions prior to 4.1 2009-11-20 15:14:27 -07:00
Joel Dice
b83314e884 fix powerpc build 2009-11-20 10:42:02 -07:00
Joel Dice
15eada93ed implement atomicCompareAndSwap on x86_32 for GCC versions prior to 4.1 and for MSVC 2009-11-20 10:40:01 -07:00
Joel Dice
e91157a390 avoid acquiring a mutex recursively in markDirty 2009-11-19 19:41:49 -07:00
Joel Dice
5f5cc57d12 only use atomic operations if the compiler supports them 2009-11-19 19:32:54 -07:00
Joel Dice
fdde34694c use atomic operations in MyHeap::mark to avoid need for mutex 2009-11-19 18:13:00 -07:00
Joel Dice
c711ac5701 return null from NewString[UTF] if the char* parameter is null 2009-11-18 11:01:47 -07:00
jet
2f54eb5e55 Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip 2009-11-05 11:16:58 -07:00
Joel Dice
5b8a7ca566 temporarily disable use of SSE on 32-bit systems until a bug involving memory<->SSE-register moves is fixed 2009-11-04 15:16:06 +00:00
Joel Dice
fb5796b740 don't use SSE for long-to-double conversion on 32-bit systems 2009-11-04 00:02:38 +00:00
Joel Dice
82d2be8e71 implement JavaVM::AttachCurrentThreadAsDaemon 2009-11-03 14:52:14 -07:00
Joel Dice
4566e7a7dd avoid infinite loop in deadWord 2009-11-03 14:14:27 -07:00