Commit Graph

225 Commits

Author SHA1 Message Date
Joel Dice
8a7944d25c add support for openjdk=$JDK8_HOME
All tests pass for the process=compile build.  Next step: process=interpret.
2015-08-06 13:30:18 -06:00
joshuawarner32@gmail.com
792684b935 first pass at minimal invokedynamic support for Java 8 lambdas
This is a bunch of commits squashed into one per Josh's request.

add dynamicTable field

add invokedynamic instruction

add defaultDynamic bootimage field

add dummy invokedynamic support in bootimage-generator

add defaultDynamic thunk

check dynamicTable offset

comment defaultDynamicThunk to fix unused function

comment defaultDynamicThunk to fix unused function

add dynamicTable / dynamicIndex stuff

comment dynamicIndex and dynamicTable

add invokedynamic instruction impl

stub out addDynamic

unstub addDynamic

don't allow tail calls in invokedynamic

implement stub JVM_GetTemporaryDirectory method

(build broken) begin add InvokeDynamicTest

Revert "(build broken) begin add InvokeDynamicTest"

This reverts commit 77f9c54e32ac66d0803eeab93e4a10d3541987a8.

add InternalError

add URLClassPath.c for openjdk-src builds

implement stub JVM_KnownToNotExist and JVM_GetResourceLookupCache methods

intercept open0 / open for openjdk

add basic java/lang/invoke stubs

remove non-public java/lang/invoke classes

fix invokedynamic example building

<wip debugging>
2015-08-06 13:30:05 -06:00
joshuawarner32@gmail.com
1f6e7be3b0 fix openjdk build after finder size_t change
I'm not sure how we didn't catch this when merging #425, but there you are.
2015-05-03 13:25:22 -06:00
Joel Dice
cbde34620c update copyright years 2015-03-13 12:52:59 -06:00
Joel Dice
dc7e68708f add JVM_GetResourceLookupCacheURLs
This improves support for building with openjdk=$jdk8.  Note, however,
that the Processes test does not pass, since JDK 8's
java.lang.UNIXProcess uses invokedynamic, which Avian does not yet
support.
2015-03-12 10:52:17 -06:00
Joel Dice
02cfe06850 fix OpenJDK 8 class library build 2015-02-27 13:59:06 -07:00
Joel Dice
7a4cae0dde load bootstrap classes in findInterfaceMethod
In afbd4ff, I made a low-risk, but very specific fix for a more
general problem: "bootstrap" classes (i.e. classes which the VM has
built-in knowledge of) need to be loaded from the classpath before any
of their methods are called.  Based on recent testing, I found there were
more cases than I previously thought where the VM tries to call methods on
"unloaded" bootstrap classes, so we needed a more general solution to
the problem.

This commit addresses it by closing the last (known) loophole by which
methods might be called on bootstrap classes: invokeinterface, and its
helper method findInterfaceMethod.  The fix is to check for bootstrap
classes in findInterfaceMethod and load the full versions if
necessary.  This process may lead to garbage collection and/or thrown
exceptions, which made me nervous about cases of direct or indirect
calls to findInterfaceMethod not expecting those events, which is why
I hadn't used that approach earlier.  However, it turns out there were
only a few places that made non-GC-safe calls to findInterfaceMethod,
and a bit of code rearrangement fixed that.
2015-02-06 13:51:32 -07:00
Joel Dice
afbd4ff303 fix crash when calling Class.getDeclaredMethods using the OpenJDK class library
This method ends up defering to JVM_GetClassDeclaredMethods, which
creates an array of java.lang.reflect.Method instances and then
calling getName on each one through the java.lang.reflect.Member
interface.  However, Method is a "bootstrap" class, meaning the VM has
built-in knowledge of it and includes a tentative version built-in but
must load the real version from the classpath at runtime before
invoking methods on it.  Normally this happens naturally when Method
instances are created in Java code, but here we're creating them in
the VM instead, which doesn't automatically cause the real class to be
loaded.  So we must do so explicitly.
2015-01-22 12:02:28 -07:00
Joshua Warner
f6e7a29f09 Merge pull request #392 from lostdj/patch-10
classpath-openjdk: Fix freeZipFileEntry()
2015-01-11 13:05:32 -07:00
Timofey Lagutin
da01d20c19 classpath-openjdk: Fix freeZipFileEntry()
Those ZipFile::Entries are part of ZipFile instance itself and will fail to free(). See :1504 and :1520 in openZipFile().
2015-01-11 22:49:15 +03:00
Timofey Lagutin
97734af72d classpath-openjdk: Fix getZipFileEntry()
'addSlash' argument was incorrectly understood: it is supposed to add slash only on retry (see ZIP_GetEntry2() zip_util.c in OpenJDK).
2015-01-11 21:44:41 +03:00
Xerxes Rånby
2e5990a6b0 OpenJDK: Implement JVM_FindClassFromCaller
8015256: Better class accessibility
Summary: Improve protection domain check in forName()

Signed-off-by: Xerxes Rånby <xerxes@gudinna.com>
2014-10-26 21:46:09 +01:00
Joel Dice
69d9ab004a implement JVM_isNaN
This method was previously unimplemented and untested.  However, the
JMH benchmark suite requires it, so now it's time to implement it.
2014-09-21 17:31:45 -06:00
Joel Dice
32aefaf421 ensure Thread::flags is always updated atomically
Since this field is sometimes updated from other threads, it is
essential that we always update it atomically.
2014-08-20 09:49:00 -06:00
Joshua Warner
0c464f3f84 Merge pull request #328 from dicej/windows
Windows
2014-08-19 12:53:59 -06:00
Joel Dice
42ae8cbe39 fix openjdk-src Windows build regression 2014-08-19 11:49:18 -06:00
Joel Dice
f94157aa38 fix GC safety bug in jvmFillInStackTrace
This fixes spurious Trace test failures with openjdk-src build.
2014-08-19 10:14:07 -06:00
Joel Dice
1bee015af3 fix Processes test failure for openjdk-src build with recent versions of OpenJDK 7
It looks like the UNIXProcess class has added posix_spawn support,
which is enabled by default unless overriden by the
jdk.lang.Process.launchMechanism system property.  For some reason I
haven't bothered to investigate, posix_spawn fails on MacOS, so this
patch sets the aforementioned property to "fork" to get the old,
working behavior.
2014-07-22 17:06:55 -06:00
Joshua Warner
bfddef54c6 fix openjdk-src build (oversight from type-generator refactor) 2014-07-15 08:31:22 -06:00
Joshua Warner
836cc41320 bulk, global reformat 2014-07-11 13:25:22 -06:00
Joshua Warner
7642b94308 reformat changes since master 2014-07-11 13:25:22 -06:00
Joshua Warner
cbad6931af retypedef object to GcObject*, remove (almost?) all unnecessary reinterpret_casts 2014-07-11 13:25:22 -06:00
Joshua Warner
b0490b8233 finish using setters 2014-07-11 13:25:22 -06:00
Joshua Warner
052f2498aa formalize Machine::roots in types.def 2014-07-11 13:25:21 -06:00
Joshua Warner
75f2dd013c remove old function-based accessors 2014-07-11 13:25:21 -06:00
Joshua Warner
a1583f1ecc touch up type safety in types.def 2014-07-11 13:25:20 -06:00
Joshua Warner
1da8170c66 apply jnienv + java-common changes 2014-07-11 13:25:19 -06:00
Joshua Warner
9c93c5989c apply classpath-common.h changes 2014-07-11 13:25:19 -06:00
Joshua Warner
00e2307c39 apply machine.h changes 2014-07-11 13:25:19 -06:00
Joshua Warner
9ffbd7e9fe staticly type GcClassLoader instances 2014-07-11 13:25:19 -06:00
Joshua Warner
51368651dc better statically type Processor interface 2014-07-11 13:25:19 -06:00
Joshua Warner
0ec87c6aa1 statically type Addendum.pool better 2014-07-11 13:25:19 -06:00
Joshua Warner
194e3b2701 add VMClass changes 2014-07-11 13:25:18 -06:00
Joshua Warner
9b36dca846 generate better typed accessors from type-generator (and switch to using standard library there) 2014-07-11 13:25:17 -06:00
Joshua Warner
263e349cae rename assert to assertT, to avoid conflict with std assert macro 2014-07-11 09:32:57 -06:00
Joshua Warner
b5699cc9dc move Machine::*Type to GcObject::*Type 2014-07-11 09:32:55 -06:00
Joel Dice
5d3c612d0e fix JNIEnv::FindClass calls from JNI_OnLoad for all supported class libraries
This also fixes the some Android build rot and updates the version of
OpenSSL used.
2014-07-01 10:53:26 -06:00
Joel Dice
4dc76a50a2 fix case of JNIEnv::FindClass called from JNI_OnLoad
If an JNI_OnLoad implementation calls FindClass when using the OpenJDK
class library, the calling method on the Java stack will be
ClassLoader.loadLibrary.  However, we must use the class loader of the
class attempting to load the library in this case, not the system
classloader.

Therefore, we now maintain a stack such that the latest class to load
a library in the current thread is at the top, and we use that class
whenever FindClass is called by ClassLoader.loadLibrary (via
JNI_OnLoad).

Note that this patch does not attempt to address the same problem for
the Avian or Android class libraries, but the same strategy should
work for them as well.
2014-06-23 17:25:42 -06:00
Mike Hearn
87125874b5 Set a property that the LambdaWorks SCrypt library expects to be present. 2014-06-05 21:32:39 +08:00
Joshua Warner
41adb74eb1 remove powerpc support 2014-04-29 13:26:40 -06:00
Joshua Warner
34962ff334 Merge pull request #245 from dicej/jdk8
add support for using the OpenJDK 8 class library
2014-04-24 18:50:38 -06:00
Joel Dice
7de555c797 add support for using the OpenJDK 8 class library
This ensures that all tests pass when Avian is built with an
openjdk=$path option such that $path points to either OpenJDK 7 or 8.

Note that I have not yet tried using the openjdk-src option with
OpenJDK 8.  I'll work on that next.
2014-04-23 15:36:56 -06:00
Joel Dice
9b7d0d1624 update copyright years 2014-04-23 15:33:41 -06:00
Joel Dice
f21f11efd6 fix broken Android build due to 617bd85
617bd85 broke the Android build by creating an unresolvable
order-of-operations bug in classpath-android.cpp's
MyClasspath::preBoot method.

The problem is that, while JNIEnv::FindClass is supposed to initialize
the class that it finds, this causes JniConstants::init to indirectly
invoke native methods which are not registered until JNI_OnLoad is
called (which happens after JniConstants::init is called).  However,
if we call JNI_OnLoad first, that causes methods to be invoked which
rely on JniConstants::init having already been run.

I haven't checked to see how Dalvik handles this, but I don't see any
way around the problem besides disabling initialization by
JNIEnv::FindClass until the preBoot phase is complete.  Moreover, it's
dangerous to allow Java code to be invoked so early anyway, since the
VM is not yet fully initialized.
2014-04-11 19:56:52 -06:00
Joel Dice
8740d76154 ensure ClassLoader.getPackage works with all class libraries
There's more work to do to derive all the properties of a given class
from its code source (e.g. JAR file), but this at least ensures that
ClassLoader.getPackage will actually return something non-null when
appropriate.
2014-03-19 11:21:26 -06:00
Joel Dice
c0d178d5f1 implement ConcurrentHashMap and AtomicReferenceArray
This is the simplest possible ConcurrentHashMap I could come up with
that works and is actually concurrent in the way one would expect.
It's pretty unconventional, being based on a persistent red-black
tree, and not particularly memory-efficient or cache-friendly.  I
think this is a good place to start, though, and it should perform
reasonably well for most workloads.  Patches for a more efficient
implementation are welcome!

I also implemented AtomicReferenceArray, since I was using it in my
first, naive attempt to implement ConcurrentHashMap.

I had to do a bit of refactoring, including moving some non-standard
stuff from java.util.Collections to avian.Data so I could make it
available to code outside the java.util package, which is why I had to
modify several unrelated files.
2014-03-12 10:44:24 -06:00
Joel Dice
866c057f0d fix Class.getDeclaredMethods
getDeclaredMethods was returning methods which were inherited from
interfaces but not (re)declared in the class itself, due to the VM's
internal use of VMClass.methodTable differing from its role in
reflection.  For reflection, we must only include the declared
methods, not the inherited but un-redeclared ones.

Previously, we saved the original method table in
ClassAddendum.methodTable before creating a new one which contains
both declared and inherited methods.  That wasted space, so this patch
replaces ClassAddendum.methodTable with
ClassAddendum.declaredMethodCount, which specifies how many of the
methods in VMClass.methodTable were declared in that class.

Alternatively, we could ensure that undeclared methods always have
their VMMethod.class_ field set to the declaring class instead of the
inheriting class.  I tried this, but it led to subtle crashes in
interface method lookup.  The rest of the VM relies not only on
VMClass.methodTable containing all inherited interface methods but
also that those methods point to the inheriting class, not the
declaring class.  Changing those assumptions would be a much bigger
(and more dangerous in terms of regression potential) effort than I
care to take on right now.  The solution I chose is a bit ugly, but
it's safe.
2014-03-10 08:51:00 -06:00
Joel Dice
25d69f38ee match Java's schizophrenic concept of inner class access modifiers
An inner class has two sets of modifier flags: one is declared in the
usual place in the class file and the other is part of the
InnerClasses attribute.  Not only is that redundant, but they can
contradict, and the VM can't just pick one and roll with it.  Instead,
Class.getModifiers must return the InnerClasses version, whereas
reflection must check the top-level version.  So even if
Class.getModifiers says the class is protected, it might still be
public for the purpose of reflection depending on what the
InnerClasses attribute says.  Crazy?  Yes.
2014-03-06 16:17:43 -07:00
Joel Dice
0a89683eff move Unsafe.get{Object|Int}Volatile from classpath-openjdk.cpp to builtin.cpp
This makes them available in all class libraries, not just the OpenJDK
library.  Note that I've also removed the unecessary idle statements,
per ab4adef.
2014-03-03 14:55:49 -07:00
Joel Dice
0c298eb513 move OpenJDK.getProtectionDomain into Classes.java
This way, apps can access the CodeSource of a class whether they're
using the OpenJDK class library or the Avian one.
2014-02-26 14:09:42 -07:00