Commit Graph

1073 Commits

Author SHA1 Message Date
Joshua Warner
d906db633c Merge pull request #454 from dicej/aot-lambda
support AOT-compilation of Java 8 lambda expressions
2015-09-28 07:44:51 -06:00
Joel Dice
d5a5b5309a support AOT-compilation of Java 8 lambda expressions
These expressions are tricky because they rely on invokedynamic, which
normally implies runtime code generation.  However, since lambdas
don't actually use the "dynamicness" of invokedynamic, we can convert
them into static calls to synthetic classes at compile time.

Since I had already written code to synthesize such classes in Java
and I didn't want to rewrite it in C++, I needed to add support for
running Java code to the bootimage generator.  And since the primary
VM used by the generator is purpose-built to generate AOT-compiled
code for a specific target architecture and is not capable of
generating or running JIT-compiled code for the host architecture, I
added support for loading a second, independent, host-specific VM for
running Java code.

The rest of the patch handles the fact that each method compilation
might cause new, synthetic classes to be created, so we need to make
sure those classes and their methods are included in the final heap
and code images.  This required breaking some giant code blocks out of
makeCodeImage into their own methods, which makes the diff look
scarier than it really is.
2015-09-13 14:21:24 -06:00
Joel Dice
9b2a02e92b avoid calling unrelated JNI methods during class initialization
The main goal here is to avoid making JNI calls from code that really
shouldn't need JNI (e.g. before this patch, ArrayList.add called
Math.max, which called Math.<clinit>, which called Random.<init>,
which called System.currentTimeMillis).

Besides following the "pay for only what you need" principle, this
change ensures we can call LambdaMetaFactory methods during AOT
compilation with a minimal VM (i.e. without compiling in JNI methods
we don't need).
2015-09-12 19:58:50 -06:00
Joshua Warner
e2f2ed68f0 ignore leading / for files on Windows (fixes #452) 2015-09-02 08:31:30 -06:00
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
Joel Dice
2465459079 implement basic Java 8 lambda support
The two big pieces here are basic invokedynamic support and a working
version of LambdaMetaFactory.metafactory.  The latter works by
dynamically building a synthetic class with three methods: a static
factory method, a constructor for the factory method to call, and a
method to satisfy the requested interface which defers to the
specified MethodHandle.

This work relies heavily on Avian's specific MethodType and
MethodHandle implementations, which provide extra, non-standard
features to make code generation easier.  That means we'll probably
need to use Avian's versions of java.lang.invoke.* even when building
with the OpenJDK or Android class libraries.
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
BCG
4093036e6f Closeable extends AutoCloseable; RandomAccessFile implements DataInput 2015-08-06 13:28:47 -06:00
BCG
b766193966 Fixed method signatures on format() methods to return PrintStream as in OpenJDK 2015-07-28 22:41:40 -04:00
BCG
a8bed52097 Added java.util.Formatter implementation. Basic/common formats work,
such as %s, %d, %x... also width, left justify, zerofill flags are
implemented. Many of the other formats do not work, see the comments in
avian.FormatString javadoc and look for FIXME and TODO items for more
information on features that are known to not work correctly.
2015-03-17 01:08:07 -04:00
Joel Dice
cbde34620c update copyright years 2015-03-13 12:52:59 -06:00
Brandon Craig
9928597543 repatch windows file delete 2015-03-06 14:37:06 -07:00
Brandon Craig
a188b15f2e fix java.io.File.delete() implementation for windows 2015-02-19 14:55:48 -07:00
Marcin Olawski
a5ff62fbad Swap the directionality of the links in Cell. 2015-02-08 22:38:56 +01:00
Marcin Olawski
0537cb4775 Add ByteArrayOutputStream.writeTo(OutputStream), UTFDataFormatException and Modifier.isTransient(int). 2015-02-08 16:09:08 +01:00
Marcin Olawski
ff17455baa Add Arrays.fill(* a,int start,int stop,* value). 2015-02-07 21:12:48 +01:00
Marcin Olawski
6462c159aa Add ArrayIndexOutOfBoundsException(int) and ClassNotFoundException.getException(). 2015-02-07 21:12:04 +01:00
Marcin Olawski
6f8a8b9436 Added Character.isJavaIdentifierStart(int), isJavaIdentifierPart(int) and made isJavaIdentifierStart(char), isJavaIdentifierPart(char) more compact. 2015-02-06 20:07:51 +01:00
Marcin Olawski
ab3ee4c6e2 Add Character.isJavaIdentifierStart(char ch) and isJavaIdentifierPart(char ch) 2015-02-06 15:26:40 +01:00
Joel Dice
c2a0210c7b fix ARM64 iOS JNI crashes
As documented at
https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html,
the ARM64 iOS ABI differs from the generic ABI in a few important
ways.  Specifically, arguments passed via the stack are aligned
according to their natural alignment instead of 8 bytes.  The VM's
dynamic call code was aligning each argument to 8 bytes, so native JNI
code couldn't find them in their expected places.

Also, we weren't setting the "os.arch" system property on ARM64, so I
fixed that too.
2015-02-05 17:20:53 -07:00
Joel Dice
d37cb93d50 remove redundant class qualifiers from Classes.java 2014-12-29 10:00:51 -07:00
Mike Jensen
ee0ad22415 Undo my collections changes, as I was wrong here 2014-12-15 17:15:00 -07:00
Mike Jensen
32a1fb21f2 Some small classpath tweaks to be compatible with openJDK's api 2014-12-15 16:26:41 -07:00
Mike Jensen
7baa5243b0 Add Collections.synchronizedList to classpath 2014-12-12 11:35:39 -07:00
Joel Dice
66f1b7cf8f Merge pull request #370 from lostdj/patch-8
Added missing MIX/MAX_VALUE for basic types.
2014-11-19 08:15:16 -07:00
lostdj
0ec230497b Added missing MIX/MAX_VALUE for basic types. 2014-11-19 14:27:11 +03:00
Timofey Lagutin
e657863656 String.equalsIgnoreCase(): fix nullptrex.
It's logical and conforms OpenJDK..
2014-11-19 14:06:31 +03:00
Joel Dice
78a0e207c0 Merge pull request #367 from lostdj/patch-6
Fix some native and managed function signatures.
2014-11-11 14:33:51 -07:00
lostdj
3cff81da8d Fix some native and managed function signatures. 2014-11-08 14:06:11 +03:00
Joel Dice
4fd8396ba3 fix WSA error 10093 when openning a ServerSocketChannel
We need to call Socket.init before trying to use the Windows Socket
library.  We were already doing this in SocketChannel.open, but not in
ServerSocketChannel.open.
2014-11-07 11:31:19 -07:00
Joel Dice
8ac58b7d77 add minimal NavigableMap interface 2014-11-05 14:27:24 -07:00
Joel Dice
2776e98bf5 use .dylib instead of .jnilib as OS X library suffix
This matches the behavior of System.mapLibraryName on
JDK 7 and later.
2014-10-28 14:53:43 -06:00
Joel Dice
f25d5921a5 implement StringWriter.getBuffer
This is used by json.org's JSON library.
2014-10-28 14:52:02 -06:00
Joshua Warner
331c635814 Merge pull request #357 from lostdj/patch-2
Added missing cp/avian/Math.atan2(double,double)
2014-10-11 20:47:17 -06:00
Ilya Mizus
75dda14691 Fixed small bug in getClassType() function. 2014-10-11 23:36:14 +04:00
Timofey Lagutin
d4d31af740 Added missing cp/avian/Math.atan2(double,double)
It was implemented as native function, but wasn't added to java.lang.Math.
2014-10-11 14:33:48 +04:00
Timofey Lagutin
a820370cb2 cp/avian/java-net.cpp: fix segfault
In Java_java_net_InetAddress_ipv4AddressForName:
  Throw nullptrex on hostname = null.
2014-10-10 19:06:36 +04:00
Ilya Mizus
85fec988d5 Added Class.getGenericSuperclass() and improved Member subclasses. Fixed Makefile on OS X 2014-10-09 02:32:56 +04:00
Joel Dice
998f99af44 Merge remote-tracking branch 'bfbc/avian-pack'
Conflicts:
	makefile
2014-10-08 14:04:00 -06:00
Joel Dice
fbcdfd6dec Merge remote-tracking branch 'dicej/android-upgrade' 2014-10-08 13:41:50 -06:00
Ilya Mizus
7d4cd23837 Some improvements in the code 2014-10-08 03:46:52 +04:00
Ilya Mizus
d1d97351b9 Reflection improved 2014-10-07 16:50:02 +04:00
Joel Dice
be91d792e4 fix Class.getInterfaces to return only declared interfaces
Previously, we returned all interfaces implemented directly or
indirectly, which did not match the JDK behavior.
2014-10-05 16:28:36 -06:00
Ilya Mizus
270bbc66f9 Added getGenericInterfaces() and fixed SignatureParser to work for everything except TypeVariable-s 2014-10-04 22:17:49 +04:00
Ilya Mizus
67cafb118c Added isAnonymousClass(), isLocalClass(), isMemberClass() functions to Class class 2014-10-02 23:51:25 +04:00
Joel Dice
b406e9c2ed Merge remote-tracking branch 'origin/master' into android-upgrade 2014-09-24 10:59:39 -06:00
Joel Dice
a81879129a add a TODO comment about class comparison 2014-09-03 16:24:15 -06:00
Joel Dice
831c529a98 make Class.getMethod (and getConstructor) more strict about parameter types
This matches the JDK behavior.
2014-08-28 17:00:33 -06:00
Joel Dice
7f4c0b3118 fix SSL stack and Android JAR resource loading 2014-08-22 07:20:19 -06:00
Joel Dice
b96cc3c575 update to more recent version of Android class library
Lots has changed since we forked Android's libcore, so merging the
latest upstream code has required extensive changes to the
Avian/Android port.

One big change is that we now use Avian's versions of
java.lang.Object, java.lang.Class, java.lang.ClassLoader, some
java.lang.reflect.* classes, etc. instead of the Android versions.
The main reason is that the Android versions have become very
Dex/Dalvik-specific, and since Avian is based on Java class files, not
dex archives, that code doesn't make sense here.  This has the side
benefit that we can share more native code with classpath-avian.cpp
and reduce the amount of Java/C++ code duplication.
2014-08-21 13:42:49 -06:00