Commit Graph

3082 Commits

Author SHA1 Message Date
Stanisław Szymczyk
de1f5c7b9f fix pthread mutex and condition leak
Hi,

I did some more tests with my x86 QNX Avian port and found one major problem
in Avian VM while trying to run Apache Ivy. The problem manifests as
follows:

1. MySystem::Thread X is created, during its creation pthread mutex and
conditional variable are initialized
2. Program runs for some time
3. MySystem Thread X is disposed, it's memory is freed (during garbage
collection I guess)
4. Program runs for some time
5. MySystem::Thread Y is created in exactly the same memory address as
MySystem::Thread X disposed in step 3 (I suppose that's due to the way
memory allocator works in Avian)
6. During MySystem::Thread Y creation pthread mutex and conditional variable
initialization fail silently with EBUSY. QNX documentation says it means
"The given mutex was previously initialized and hasn't been destroyed."
which is correct, because it's exactly in the same memory address as mutex
and conditional variable of MySystem::Thread X and they haven't been
destroyed during MySystem::Thread X disposal

Fortunately solution for this is easy, see the attached patch. Now Apache
Ivy works without any problems.

Regards,
Stanisław Szymczyk
2012-12-04 10:14:44 -07:00
Carsten Elton Sorensen
2b44fb6b93 Compile fix for GCC 4.7.2 in C++11 mode 2012-11-30 11:14:35 +01:00
Mike Keesey
e4dfb79618 Merge pull request #20 from csoren/master
A simple fix to accept upper case size suffixes for the -Xm parameters
2012-11-12 18:26:15 -08:00
Carsten Elton Sørensen
53b1a2423a Accept M and K suffixes for memory sizes like the java command 2012-11-12 22:35:58 +01:00
Mike Keesey
4c6155951d Merge pull request #19 from pcarrier/classpath
classpath: java.nio.ByteOrder
2012-11-11 19:24:43 -08:00
Pierre Carrier
74b070f9cc classpath: java.nio.ByteOrder
Used by jruby.
(Not saying I'm gonna implement String.format :)
2012-11-11 06:06:18 +01:00
Pierre Carrier
f8ea506021 classpath: j.l.{Integer,Long}.to{Octal,Binary}String
Offer support for toOctalString and toBinaryString in Integer and Long.
2012-11-05 00:10:02 +01:00
Pierre Carrier
be952acbcb classpath: Closeable & Flushable 2012-11-04 02:14:17 +01:00
Joshua Warner
33fed1b710 Merge branch 'master' of github.com:ReadyTalk/avian 2012-10-30 14:00:16 -06:00
Joshua Warner
4c20465294 add basic URLClassLoader implementation 2012-10-30 09:34:16 -06:00
Joel Dice
be12db20cb preserve all methods in avian.OpenJDK from removal in openjdk.pro
OpenJDK.getDeclaringClass is called from JVM_GetDeclaringClass, so we
need to tell ProGuard to preserve it along with the other method we
had already included.
2012-10-16 08:33:35 -06:00
Joel Dice
3665753d1f fix MSVC build regression 2012-10-13 13:09:24 -06:00
Joel Dice
8f308291b0 eliminate call stack recursion in compile method
Some OSes (notably, Windows CE) restrict the size of the call stack
such that recursive compilation of branch instructions can lead to
stack overflow in methods with large numbers of such instructions.  In
fact, a worst-case method could even lead to overflow when the stack
size limit is relatively generous.

The solution is to convert this recursion into iteration with an
explicit stack to maintain state about alternate paths through each
branch.
2012-10-13 09:46:12 -06:00
Joel Dice
3e0ab35ba1 fix PersistentSet.remove side-effect bug
The whole point of PersistentSet is to provide non-destructive write
operations, which means the add and remove methods should have no
effect on previous revisions.  However, a bug in remove caused shared
tree nodes to be modified, corrupting any revisions with which they
were shared.
2012-10-13 09:39:14 -06:00
Joel Dice
a3c4b60f43 rename package avian.avian_vm_resource to avian.avianvmresource
This package name must match the URL protocol we use for loading
embedded resources, but OpenJDK's URL class won't tolerate underscores
in a protocol name.  Also, I had not updated the names of the native
methods in avian.avianvmresource.Handler, leading to
UnsatisfiedLinkErrors when they were called.
2012-10-06 15:33:24 -06:00
Joel Dice
7946aaf48f update static table mapping code in bootimage.cpp to match machine.cpp
Commit c918cbc added a reference to ensure
sun.misc.Unsafe.getLongVolatile could be implemented efficiently on
32-bit platforms, but I forgot to update bootimage.cpp to account for
it.
2012-10-06 15:30:59 -06:00
Joel Dice
3a452309b3 update static table class reference in updateClassTables
Commit c918cbc added this reference to ensure
sun.misc.Unsafe.getLongVolatile could be implemented efficiently on
32-bit platforms.  However, I neglected to ensure the reference was
updated to point to the final class instance instead of the temporary
one used in parseClass.  This led to extra memory usage and
inconsistent locking behavior, plus broken bootimage builds.
2012-10-06 15:25:12 -06:00
Joel Dice
45073db421 fix Call[Static]<type>MethodA float argument marshalling 2012-10-05 10:56:07 -06:00
Joel Dice
f8d3494b1c clear any weak/soft/phantom references to finalizable objects before queuing
If we don't clear these references, we risk finalizing objects which
can still be reached by one of the special reference types.

It's a bit of a chicken-and-egg problem.  We need to visit finalizable
objects before visiting weak references, since some of the weak
references and/or their targets may become reachable once the
finalizable objects are visited.  However, that ordering means we have
no efficient way of distinguishing between objects which are reachable
from one or more normal GC roots and those which are only reachable
via the finalization queue.  The solution is to clear all weak
references to finalizable objects before visiting them.
2012-10-05 10:06:01 -06:00
Joel Dice
c680dd4215 use ldmneia on Clang < 4 and GCC, ldmiane on Clang >= 4
I don't know why this instruction was renamed, but we have to deal
with it.
2012-10-03 17:01:00 -06:00
Joel Dice
16c526b775 fix OS X 10.8 and iOS 6.0 builds
This also adds support for Clang ARM builds, which involved removing
unused functions from arm.cpp to avoid link-time warnings.
2012-10-03 13:36:51 -06:00
Joel Dice
1ce012aa68 fix abort in classpath-openjdk.cpp due to buffer overflow
This addresses the case where -Djava.home=<some really long path>.

https://github.com/ReadyTalk/avian/issues/15
2012-10-03 09:43:51 -06:00
Joel Dice
ab5ec510bf handle zero length arrays properly in JNIEnv::NewString 2012-10-03 08:16:41 -06:00
Xerxes Rånby
2a15201b18 gcc define __ARM_PCS_VFP for -mfloat-abi=hard, use it to detect armhf builds.
Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
2012-10-01 13:39:18 +02:00
Joel Dice
1d4c9d32fb return null from JNIEnv::GetSuperclass for interfaces per spec 2012-09-28 15:03:14 -06:00
Xerxes Rånby
23ea8f7d76 Fix missing armv4 blx and bkpt compile errors.
Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
2012-09-25 15:54:32 +02:00
Joel Dice
3693201911 make JVM_GetSystemPackage a bit smarter
The original stub implementation just echoed back its argument, but
that confused URLClassLoader when dealing with sealed JARs --
returning a non-null value for a non-system class from
JVM_GetSystemPackage made URLClassloader think it had already loaded a
class from a package which was supposed to be sealed, resulting in
SecurityExceptions which ultimately triggered NoClassDefFoundErrors.
The solution is to only return non-null values for actual system
classes.
2012-09-24 17:43:34 -06:00
Joel Dice
e20c5cd9c6 fix a couple of OpenJDK reflection bugs
We weren't wrapping exceptions thrown by invoked methods in
InvocationTargetExceptions in JVM_InvokeMethod or
JVM_NewInstanceFromConstructor.  Also, JVM_GetCallerClass is supposed
to ignore Method.invoke frames when walking the stack.
2012-09-22 20:22:33 -06:00
Joel Dice
2d9bbec214 fix a couple of ByteBuffer regressions
The compact() and put(ByteBuffer) methods regressed as of the recent
refactoring to support direct byte buffers.
2012-09-14 11:40:26 -06:00
Joel Dice
3a5abaf58a fix incorrect reporting of fixie collection status in heap.cpp (part 2)
My earlier fix (f8e8609) was almost -- but not quite -- sufficient.
It asked the heap to mark the dead fixies too early, so some of them
were marked dead even though they ultimately survived, causing us to
clear weak JNI references when we shouldn't.
2012-09-12 17:23:19 -06:00
Joel Dice
2190d0e99a fix reads of out-of-bounds values in tokenizer.h 2012-09-12 15:25:17 -06:00
Joel Dice
c918cbced1 fix sun.misc.Unsafe.getLongVolatile for static fields on 32-bit platforms
The existing code did not handle static field lookups for
synchronization on 32-bit systems, which is necessary because such
systems generally don't support atomic operations on 64-bit values.
2012-09-11 19:28:02 -06:00
Joel Dice
90fa4c9b69 add JNI_GetCreatedJavaVMs stub
Recent versions of IcedTea will not run unless libjvm.so exports this
symbol.  The quick fix is to provide a stub which just always returns
-1 to indicate an error.  I'll leave a proper implementation for when
we need to support an app that actually uses this function.
2012-09-07 19:05:05 -06:00
Joel Dice
eee2ce27e4 ignore DetachCurrentThread calls for the main thread
My earlier commit to allow detaching the main thread (1f1c3c4) seems
to have caused subtle stability problems
(e.g. https://groups.google.com/group/avian/msg/d2c797c0dcf925c3), so
for now we'll just ignore that operation, which leaks a bit of memory
but should be harmless otherwise.
2012-09-07 08:47:49 -06:00
Joel Dice
d3b32ecffd Merge branch 'openjdk-version' of https://github.com/xranby/avian 2012-09-05 12:38:42 -06:00
Xerxes Rånby
db0c14d742 Set java.vm.info based on makefile info= and
set java.vm.version based on makefile version=
in order to display relevant OpenJDK -version information.

Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
2012-09-05 15:30:49 +02:00
Xerxes Rånby
d88a33329a Add a non-versioned SONAME to Avian libjvm.so that
matches the Hotspot Server/Client libjvm.so SONAME,
this allow libjava.so in OpenJDK 7 to find the Avian libjvm.so during ldopen.
2012-09-05 10:29:12 +02:00
Joel Dice
24f682f5b6 fix 64-bit shifts on x86_32 (part 2)
My earlier attempt (fa5d76b) missed an important detail, and somehow I
forgot to test the 32-bit OpenJDK build which made that omission
obvious.  Here's the fix.
2012-09-03 08:44:13 -06:00
Joel Dice
3f039864d1 fix memcpy argument order bug in jvmConstantPoolGetDoubleAt 2012-08-29 12:10:31 -06:00
Joel Dice
9ceacf16e9 don't throw an exception from resolveClass when throw_ == false
resolveClass was correctly respecting throw_ == false if the requested
class was not found, but it still threw an exception if e.g. the
superclass was missing.  Now we catch such exceptions and return null
as appropriate.
2012-08-29 18:34:51 -06:00
Joel Dice
7534eecdb3 implement JVM_ConstantPoolGetDoubleAt 2012-08-29 18:34:28 -06:00
Joel Dice
374bdb3726 implement Runtime.maxMemory for OpenJDK port
Some apps refuse to run if Runtime.maxMemory returns a value that's
"too small", so our stub implementation returning zero was not
sufficient.  Now we return the actual heap size limit in bytes.
2012-08-29 18:32:45 -06:00
Joel Dice
8c48a44e54 set main thread context classloader correctly for OpenJDK port
sun.misc.Launcher has its own idea about what the application
classloader should be, but we need to override it with the system
classloader created by the VM.  This is achieved by running
Launcher.getLauncher (which has the side effect of setting
Thread.contextClassLoader) and then overriding it.
2012-08-29 18:27:37 -06:00
Gernot Kvas
c2b53497ab Fix stacktrace when building with MSVC 2012-08-26 20:14:37 -06:00
Joel Dice
1f1c3c4c41 allow main thread to use DetachCurrentThread
When I originally implemented DetachCurrentThread, I assumed it didn't
make sense for the main thread to detach itself from the VM, and I was
concerned that allowing it might cause problems for any other threads
still attached.  However, detaching the main thread is allowed by the
JNI spec as of Java 2, and OpenJDK's java command does this just
before calling DestroyJavaVM.  Therefore, this commit ensures that the
VM doesn't abort if the main thread is detached.
2012-08-24 18:14:01 -06:00
Joel Dice
bac4099acb fix crash in findFrameMapInSimpleTable due to bug in instanceof implementation
We weren't adding entries to the frame map for calls to the instanceof
thunk when compiling methods.  However, that thunk may trigger a GC,
in which case we'll need to unwind the stack, which will lead to a
crash if we don't have a frame map entry for that instruction.
2012-08-17 12:47:38 -06:00
Mike Jensen
3372210f45 Added .get() implementation 2012-08-16 16:13:51 -06:00
Joel Dice
38454ce7d4 fix MSVC build of test JNI library 2012-08-15 17:43:45 -06:00
Gernot Kvas
ff9757e811 fix Win32 build regressions
Date: Wed, 15 Aug 2012 15:59:25 -0700 (PDT)
From: Gernot Kvas <gernot.kvas@gmail.com>
Reply-To: avian@googlegroups.com
To: avian@googlegroups.com
Subject: Win32 build regression

Hi,

As I've forked on the July 19th and haven't updated since, I decided to
merge master into my WinCE branch. I found out that the following commits
have introduced build regressions on Windows:

1.)https://github.com/ReadyTalk/avian/commit/5a7c78e71ac7b4045c23d215162fb1284
8f1a5f3

=> strncasecmp is undefined for Windows

2.)https://github.com/ReadyTalk/avian/commit/b98abe3f94dbf552595554787ef2115c3
009856c

=> fpclassify and related constants are undefined for Windows

3.)https://github.com/ReadyTalk/avian/commit/20a290b992112f9b376d3a8d0180c1cca
8dd21e2

=> signbit is undefined for Windows

I attached a patch that makes everything build through (within Visual
Studio, the makefile still fails)
2012-08-15 17:43:44 -06:00
Joel Dice
127d56d0fe fix register masks used for planning in arm.cpp
We can't use a floating point register where an integer register is
needed, or we may generate an invalid instruction.
2012-08-13 09:22:18 +00:00