Commit Graph

2785 Commits

Author SHA1 Message Date
Joel Dice
948a2523f1 use vm::run to implement IsAssignableFrom and IsInstanceOf
Under certain circumstances, the implementations of these functions
may throw errors, so we need to wrap them using vm::run so we don't
try to unwind past the JNI boundary.
2011-04-09 21:07:10 -06:00
Joel Dice
239fd98781 fix compilation of unusual exception handlers
As described in commit 36aa0d6, apps such as jython which generate
bytecode dynamically can produce patterns of bytecode for which the
VM's compiler could not handle properly.  However, that commit
introduced a regression and had to be partially reverted.

It turns out the real problem was the call to Compiler::restoreState
which we made before checking whether we were actually ready to
compile the exception handler (we delay compiling an exception handler
until and unless the try/catch block it serves has been compiled so we
can calculate the stack maps properly).  That confused the compiler in
rare cases, so we now only call restoreState once we're actually ready
to compile the handler.
2011-04-09 12:44:28 -06:00
Joel Dice
c0f39fbe0c implement System.nanoTime
This is a quick and coarse, but servicable, implementation.
2011-04-08 20:32:33 -06:00
Marcel van den Boer
76fa43548d Implementation of String.replace(CharSequence, CharSequence) 2011-04-08 20:31:33 -06:00
Joel Dice
97aec1691e fix jsr/ret stack mapping regression
My last commit introduced a regression in JIT compilation of
subroutines.  This reverts the specific change which caused the
regression.  Further work will be needed to address the case which
that change was intended to fix (namely, exception handlers which
apply to multiple try/catch blocks).
2011-04-08 20:15:36 -06:00
Joel Dice
36aa0d6792 improve handling of unusual bytecode in JIT compiler
Bytecode generated by compilers other than javac or ecj (such as
jython's dynamically generated classes) can contain unreachable code
and exception handlers which apply to more than one try/catch scope.
Previously, the VM's JIT compiler did not handle either of these cases
well, hence this commit.
2011-04-08 18:50:22 -06:00
Joel Dice
60db8cc047 add some commented-out debug code to defineClass
When uncommented, this code will write each defined class to disk,
which allows one to examine e.g. dynamically-generated classes using
e.g. javap.
2011-04-08 18:46:43 -06:00
Joel Dice
d3581be38e don't abort when parsing malformed UTF8 strings
Previously, we would abort the process if we encountered a truncated
multibyte character in parseUtf8NonAscii (called by the JNI method
NewStringUTF).  Now we simply terminate the string at that point.
2011-04-07 14:39:27 -06:00
Joel Dice
af9288f4ee don't abort when parsing malformed UTF8 strings
Previously, we would abort the process if we encountered a truncated
multibyte character in parseUtf8NonAscii (called by the JNI method
NewStringUTF).  Now we simply terminate the string at that point.
2011-04-07 14:26:54 -06:00
JET
706f9d91ad Fixed bug with *nix LANG var region parsing. 2011-04-05 15:13:29 -06:00
Joel Dice
b0ae6343ad provide proper implementations of JVM_GetDeclaredClasses, JVM_GetDeclaringClass 2011-03-31 19:47:26 -06:00
Joel Dice
ef86530080 call static initializer of superclass before that of class itself
Also, assume any class which has an ancestor class which has a static
initializer needs initialization even if it doesn't have one itself,
per the Java Language Spec.
2011-03-31 19:43:49 -06:00
Joel Dice
1c7abe782d specify valid code source for system classes
This enables use of a class's protection domain to determine what JAR
or directory it came from.
2011-03-31 19:38:44 -06:00
Joel Dice
8d9412c1e8 remove redundant statement in parseUtf8
VM heap allocated memory is already zero'd out, so there's no need to
explicitly end strings with a null character.
2011-03-31 19:10:20 -06:00
Joel Dice
384682431a implement JVM_GetSystemPackages stub 2011-03-31 19:00:42 -06:00
Joel Dice
916e6787de set Thread.blocker during thread construction
This avoids an NPE in Thread.blockedOn.
2011-03-31 18:58:59 -06:00
Joel Dice
6506760dd9 implement Unsafe.putByte 2011-03-28 08:55:20 -06:00
Joel Dice
572f2d81eb handle case where value has acquired more than one resource in resetFrame 2011-03-28 08:54:37 -06:00
Joel Dice
3e92f18ab0 remove redundant conditional from resetFrame 2011-03-27 21:15:54 -06:00
Joel Dice
9fe41b2afc only return declared interfaces from Class.getInterfaces
The result of Class.getInterfaces should not include interfaces
declared to be implemented/extended by superclasses/superinterfaces,
only those declared by the class itself.  This is important because it
influences how java.io.ObjectStreamClass calculates serial version
IDs.
2011-03-27 20:29:31 -06:00
Joel Dice
56e832d3e8 fix JVM_GetArrayElement and JVM_SetArrayElement
The old versions only handled object arrays properly, but they need to
handle primitive arrays as well.
2011-03-27 20:25:47 -06:00
Joel Dice
62e10cf992 return only non-negative values from takeHash
Some broken code implicitly relies on System.identityHashCode always
returning a non-negative number (e.g. old versions of
com/sun/xml/bind/v2/util/CollisionCheckStack.hash).
2011-03-27 20:22:59 -06:00
Joel Dice
c75cf7ebb6 release all resources in resetFrame
Code including subroutines and conditionals can result in frame and
register resources being held by values which aren't in scope when
resetFrame is called, so we need to clean them up after cleaning the
in-scope values.
2011-03-27 14:15:05 -06:00
Joel Dice
8283e1da46 ignore instances of DelegatingClassLoader in JVM_LatestUserDefinedLoader 2011-03-27 14:13:36 -06:00
Joel Dice
d16bf57634 implement JVM_MaxObjectInspectionAge stub and Unsafe.getShort 2011-03-27 14:12:41 -06:00
Joel Dice
686cbc3637 implement JVM_ResolveClass
This just reuses code in avian.Classes which was formerly only used in
the Avian classpath build.
2011-03-26 23:24:48 -06:00
Joel Dice
ba028b86bf set java.vm.vendor system property during startup 2011-03-26 23:24:05 -06:00
Joel Dice
ad79bbcbd5 update class loader map when creating new array class
This ensures that we don't create redundant array classes later.
2011-03-26 23:21:37 -06:00
Joel Dice
d5ae053f11 handle invokevirtual calls to non-virtual methods
OpenJDK's sun.reflect.MethodAccessorGenerator can generate
invokevirtual calls to private methods (which we normally consider
non-virtual); we must compile them as non-virtual calls since they
aren't in the vtable.
2011-03-26 23:13:05 -06:00
Joel Dice
0f38673baa fix line number and exception handler scope regression
It turns out commit 31eb047 was too aggressive and led to incorrect
calculation of line numbers for machine addresses, as well as
potentially incorrect exception handler scope calculation.  This fixes
the regression.
2011-03-26 19:55:23 -06:00
Joel Dice
89947f4655 set default thread context classloader to app loader, not boot loader 2011-03-26 19:01:48 -06:00
Joel Dice
16a8777fd2 override getResource(s) in SystemClassLoader
OpenJDK's java.lang.ClassLoader.getResource makes use of
sun.misc.Launcher to load bootstrap resources, which is not
appropriate for the Avian build, so we override it to ensure we get
the behavior we want.
2011-03-26 18:24:17 -06:00
Joel Dice
6bd9ec3735 enable link time optimization when using GCC 4.6 or greater 2011-03-26 14:44:08 -06:00
Joel Dice
01b3f1cb93 fix GCC 4.6 unused variable warnings 2011-03-26 14:43:03 -06:00
Joel Dice
d02d7c9846 fix IllegalAccessException in LazyLoading test 2011-03-26 12:00:40 -06:00
Joel Dice
3fd6af152f fix Windows and GCC 3.4 builds 2011-03-26 11:45:33 -06:00
Joel Dice
ba0cc803a6 implement various JVM_* methods
This includes a proper implementation of JVM_ActiveProcessorCount, as
well as JVM_SetLength and JVM_NewMultiArray.  Also, we now accept up
to JNI_VERSION_1_6 in JVM_IsSupportedJNIVersion.
2011-03-26 11:15:52 -06:00
Joel Dice
3dd091c67a implement jar and file URL stream handlers 2011-03-25 19:14:21 -06:00
Joel Dice
31eb047391 handle redundant, unreachable gotos in JIT compiler
I recently encountered a Batik JAR with a method containing a
redundant goto which confused the JIT compiler because it was refered
to in the exception handler and line number tables despite being
unreachable.  I don't know how such code was generated, but this
commit ensures the compiler can handle it.
2011-03-25 19:13:10 -06:00
Joel Dice
639ef50079 handle null caller in JVM_GetCallerClass 2011-03-25 19:13:10 -06:00
Joel Dice
7b4b43e119 implement JVM_CompileClass and JVM_CompileClasses stubs
These don't currently do anything but return false.
2011-03-25 19:13:10 -06:00
Joel Dice
20baef4e69 implement File.toString 2011-03-25 19:12:47 -06:00
Joel Dice
838cf9fdd1 avoid calling doCollect recursively
We must not allocate heap objects from doCollect, since it might
trigger a GC while one is already in progress, which can cause trouble
when we're still queuing up objects to finalize, among other things.
To avoid this, I've added extra fields to the finalizer and cleaner
types which we can use to link instances up during GC without
allocating new memory.
2011-03-25 19:11:38 -06:00
Joel Dice
b9f8188544 don't try to release monitor if we get OOME when trying to acquire it
We can't blindly try release the monitors for all synchronized methods
when unwinding the stack since we may not have finished acquiring the
most recent one when the exception was thrown.
2011-03-25 18:40:51 -06:00
Joel Dice
3e93d5d337 fix Value::home integer overflow
A method with a large number of local variable slots may imply offsets
larger than a int8_t can represent, so we now use an int16_t instead.
2011-03-25 18:27:02 -06:00
Joel Dice
960bd28296 preallocate monitor node in monitorWait
If we don't preallocate the memory we need to reacquire the lock after
we finish waiting, we risk an OOME which may unwind the stack into
code which assumes we still have acquire the lock successfully.
2011-03-25 18:21:15 -06:00
Joel Dice
d928d695ff try harder in low memory situations in Zone::allocate
Instead of giving up when the backing allocator's tryAllocate method
returns null, we switch to the allocate method to show we mean
business.  This makes use of zones more robust under low memory
situations since it allows us to exceed the soft memory ceiling when
the only alternative is to abort.
2011-03-25 18:14:34 -06:00
JET
5b830343ba Properties.java UTF-16 support refactoring. 2011-03-23 17:06:33 -06:00
JET
b29e692c31 Merge branch 'master' into localization 2011-03-23 10:24:44 -06:00
Joel Dice
61552b6b8a check for and handle instances of sun.misc.Cleaner during GC
OpenJDK uses an alternative to Object.finalize for resource cleanup in
the form of sun.misc.Cleaner.  Normally, OpenJDK's
java.lang.ref.Reference.ReferenceHandler thread handles this, calling
Cleaner.clean on any instances it finds in its "pending" queue.
However, Avian handles reference queuing internally, so it never
actually adds anything to that queue, so the VM must call
Cleaner.clean itself.
2011-03-19 15:10:52 -06:00