Commit Graph

488 Commits

Author SHA1 Message Date
Johannes Schindelin
d00f799d2e Regex: special-case a(a*?)(a?)(a??)(a+)(a*)a
Among other challenges, this regular expression is designed to demonstrate
that thread prioritization is finicky: Given the string 'aaaaaa' to match,
the first four threads will try to grab the second 'a', the third thread
(the one that matched the '(a??)' group) having scheduled the same
instruction pointer to the '(a+)' group that the second -- higher-priority
-- thread will try to advance to only after processing the '(a??)' group's
SPLIT. The second thread must override the third thread in that case,
essentially stopping the latter.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
edb48ffec2 Regex: support prioritized threads
If we want to match greedy or reluctant regular expressions, we have
to make sure that certain threads are split off with a higher priority
than others. We will use the ThreadQueues' natural order as priority
order: high to low.

To support splitting into different-priority threads, let's introduce
a second SPLIT opcode: SPLIT_JMP. The latter prefers to jump while the
former prefers to execute the opcode directly after the SPLIT opcode.

There is a subtle challenge here, though: let's assume that there are
two current threads and the higher-priority one wants to jump where
the lower-priority one is already. In the PikeVM implementation
before this change, queueImmediately() would see that there is
already a thread queued for that program counter and *not* queue the
higher-priority one.

Example: when matching the pattern '(a?)(a??)(a?)' against the string
'aa', after the first character, the first (high priority) thread
will have matched the first group while the second thread matched the
second group. In the following step, therefore, the first thread will
want to SPLIT_JMP to match the final 'a' to the third group but the
second thread already queued that program counter.

The proposed solution is to introduce a third thread queue: 'queued'.
When queuing threads to be executed after reading the next character
from the string to match, they are not directly queued into 'next' but
into 'queued'. Every thread requiring immediate execution (i.e. before
reading the next character) will be queued into 'current'. Whenever
'current' is drained, the next thread from 'queued' that has not been
queued to 'current' yet will be executed.

That way, we can guarantee that 1) no lower-priority thread can override
a higher-priority thread and 2) infinite loop are prevented.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
63b06ebde8 Regex: optimize matching characters
Instead of having an opcode 'CHAR', let's have the opcodes that fall
within the range of a char *be* the opcode 'match this character'.

While at it, break the ranges of the different types of opcodes apart
into ranges so that related operations are clustered.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
b03283033e Add a unit test for the regular expression engine
We still do not parse the regular expression patterns, but we can at
least test that the hardcoded 'a(bb)+a' works as expected.

This class will be extended as we support more and more features.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
2073d4bffb Prepare the Matcher class for multiple groups
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
e6ad10de04 Implement Pattern / Matcher classes based on the PikeVM
Based on the just-implemented PikeVM, let's test it with a specific
regular expression. At this point, no parsing is implemented but instead
an explicit program executing a(bb)?a is hardcoded.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
944f5f3567 Start implementing a regular expression engine
So far, these are humble beginnings indeed. Based on the descriptions of

	http://swtch.com/%7Ersc/regexp/regexp2.html

I started implementing a Thompson NFA / Pike VM.

The idea being that eventually, regular expressions are to be compiled
into special-purpose bytecode for the Pike VM that executes a varying
number of threads in lock-step over each character of the text to match.

The thread count is bounded by the length of the program: two different
threads with identical instruction pointer at the same character-to-match
would yield exactly the same outcome (and therefore, we can execute just
one such thread instead of possibly many).

To allow for matching groups, each thread carries a state with it, saving
the group offsets acquired so far.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Johannes Schindelin
84829dc390 Refactor Pattern / Matcher classes
This makes both the Pattern and the Matcher class abstract so that more
specialized patterns than the trivial patterns we support so far can be
implemented as convenient subclasses of the respective abstract base
classes.

To ease development, we work on copies in test/regex/ in the 'regex'
package. That way, it can be developed in Eclipse (because it does not
interfere with Oracle JRE's java.util.regex.* classes).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-03 12:28:10 -06:00
Joshua Warner
c3e3447c62 Merge pull request #107 from dscho/temp-file
Delete temporary test file afterwards
2013-12-02 19:54:38 -08:00
Mike Jensen
a2e1e1eec9 Merge pull request #102 from dscho/proxy-annotations
This looks good to me, good work.
2013-12-02 09:13:01 -08:00
Johannes Schindelin
0681531dc0 Test complicated annotation constructs
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-27 10:39:28 -06:00
Johannes Schindelin
6c57bd9174 Verify that Proxy instances have access to annotations' default values
For quick access, the sezpoz library stores lists in
META-INF/annotations/ of classes that have been annotated in a
special way.

To support the use case where the annotations actually changed since
sezpoz stored said lists, sezpoz then creates proxy instances for the
annotations to provide some backwards compatibility: as long as there
are default values for any newly-introduced annotation values,
everything is groovy.

Therefore, let's make sure that proxy instances inherit the
annotations' default values.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-27 10:39:28 -06:00
Johannes Schindelin
7d7aaa003e Delete temporary test file afterwards
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-26 16:05:14 -06:00
Joshua Warner
c3bbe555be make Sockets test Java6-compilable, make it more generic, and move it to 'extra' 2013-11-08 10:05:53 -07:00
Ilya Mizus
45ee25f68c Implement socket API 2013-11-08 09:55:43 -07:00
Joshua Warner
fd81e126ef fix Dates test for openjdk and stub out java.util.TimeZone 2013-11-07 20:44:02 -07:00
Joshua Warner
76b0bb4872 remove non-conforming ZipEntry.getJavaTime API and associated tests (which failed the openjdk build) 2013-11-07 19:13:13 -07:00
Joshua Warner
dd460ab55e Merge pull request #99 from dscho/fix-get-annotation
Fix NPE in Field#getAnnotation
2013-11-06 09:03:45 -08:00
Joshua Warner
4cf3d9de88 Merge pull request #95 from dscho/compatible-serialization
Java-compatible (de)serialization of TreeMap, ArrayList and Number
2013-11-06 09:02:12 -08:00
Joshua Warner
d0d4f600dc Merge pull request #94 from dscho/serialization
Implement Java-compatible serialization
2013-11-06 08:49:14 -08:00
Johannes Schindelin
ff50034206 Fix NPE in Field#getAnnotation
When the class whose field is to be inspected has no annotations at all,
at least my javac here (1.6.0_51 on MacOSX) does not produce any class
addendum.

Therefore, let's verify that the addendum is not null before proceeding.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:46:56 -06:00
Johannes Schindelin
dddd9e5016 Serialize test: augment the hexdump with address and ASCII dump
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:12:18 -06:00
Johannes Schindelin
7e72f4362b Add a test to ensure TreeMap's (de)serialization compatibility with OpenJDK
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:12:18 -06:00
Johannes Schindelin
48e0912ad4 Test the new, Java-compatible (de)serialization
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:10:51 -06:00
Johannes Schindelin
6159f5cd3c Support Logger#log(Level,String,Object)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:07:58 -06:00
Johannes Schindelin
dba8d39e63 Implement Class#getDeclaredClasses
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:07:58 -06:00
Joshua Warner
da69b735f4 Merge branch 'addzip' of git://github.com/CUBoulderBoy/avian into CUBoulderBoy-addzip 2013-11-04 17:38:27 -07:00
Joshua Warner
d128838617 Merge pull request #92 from dscho/collections
Various improvements regarding Collections
2013-11-04 16:33:06 -08:00
Joshua Warner
ac32e0de39 Merge pull request #91 from dscho/intro-sort
Replace Arrays.sort() with an efficient sort algorithm
2013-11-04 16:31:08 -08:00
Johannes Schindelin
a2feec0bab Add a pseudo-integration test for getResources()
This adds an extra class path element to the VM running the unit tests,
writes files with identical file names into both directories and then
verifies that SystemClassLoader#getResources can find them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:53:02 -06:00
Johannes Schindelin
6a81623690 Implement the Arrays#copyOf family
... as introduced in Java 6.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 15:11:00 -06:00
Johannes Schindelin
d37b5ada37 Implement Collections#sort
This is really a verbatim translation of Arrays#sort.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 12:08:22 -06:00
Johannes Schindelin
605701e40a Replace Arrays.sort() with an efficient sort algorithm
This change reuses the existing insertion sort (which was previously what
Arrays.sort() executed) in a full intro sort pipeline.

The implementation is based on the Musser paper on intro sort (Musser,
David R. "Introspective sorting and selection algorithms." Softw., Pract.
Exper. 27.8 (1997): 983-993.) and Wikipedia's current description of the
heap sort: http://en.wikipedia.org/wiki/Heapsort.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 00:27:04 -06:00
Johannes Schindelin
95fcc9ac8e Test the newly-introduced Integer#decode method
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
c1ec6020a6 Verify that String#lastIndexOf handles large fromIndex correctly
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
6f64e3aaab Verify that two-dimensional object arrays have the correct component type
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Joshua Warner
b20dcd268c Merge pull request #85 from dscho/simple-regex
Simple regex
2013-10-21 13:30:57 -07:00
Johannes Schindelin
359f99c0f7 Add a unit test for regular expressions
We do not really support regular expressions yet, but we do support
trivial patterns including ones with escaped characters. Let's make sure
that that works as advertised.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 13:34:33 -05:00
Johannes Schindelin
db99aada94 Test date parsing/formatting
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:41:40 -05:00
Johannes Schindelin
974073ed17 Make sure to test java.io.File#lastModified
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-17 14:30:41 -05:00
Mike Jensen
2e921b803d Added a simple test to show the original issue 2013-07-17 11:53:35 -06:00
Chris Jordan
2d89826ec7 zipentry test 2013-07-08 16:46:00 -06:00
Riley Moses
08d441a905 Add tests for creating zip files using both write methods 2013-07-08 14:50:17 -06:00
Joel Dice
a098926547 run Shutdown.shutdown on exit when using OpenJDK library
The OpenJDK library wants to track and run the shutdown hooks itself
rather than let the VM do it, so we need to tell it when we're
exiting.

Also, in machine.cpp we need to use only the modifiers specified in
the InnerClasses attribute for inner classes rather than OR them with
the flags given at the top level of the class file.
2013-04-19 13:00:47 -06:00
Joel Dice
81d7786716 fix Class.getModifiers for inner classes and implement JVM_GetDeclaringClass and JVM_GetEnclosingMethodInfo properly
This fixes a couple of tests in the Scala test suite
(run/reflection-modulemirror-toplevel-badpath.scala and
run/reflection-constructormirror-nested-good.scala).
2013-04-17 15:12:58 -06:00
Joel Dice
aa513c2c1d set default file.encoding to UTF-8 in classpath-openjdk.cpp
This default makes more sense than ASCII, which is what it had been.
2013-04-16 19:35:21 -06:00
Joel Dice
b436bd460a fix NaN handling in floating point comparisons 2013-04-03 16:19:33 -06:00
Joel Dice
3497354bbf allow extra flags to be passed to make in ci.sh 2013-03-15 17:48:47 -06:00
Joel Dice
3309a9f4ad ensure that array classes implement Cloneable and Serializable in bootimage build 2013-03-15 13:26:18 -06:00
Joel Dice
96a4b6e508 test non-debug build first in ci.sh
If something's broken, the script will fail faster if we test the
faster build first, giving us quicker feedback.
2013-03-15 13:17:53 -06:00
Joel Dice
c3e34b9438 exit with error code from test.sh if any test fails 2013-03-15 13:17:04 -06:00
Joshua Warner
9327043bc5 Merge branch 'master' into wip
Conflicts:
	makefile
	src/codegen/arm/assembler.cpp
	src/codegen/powerpc/assembler.cpp
	src/codegen/x86/assembler.cpp
2013-02-27 19:27:07 -07:00
Joel Dice
27d7c8a3c0 skip bootimage test in ci.sh if openjdk is set 2013-02-27 13:47:43 -07:00
Joshua Warner
43de16a94d Merge branch 'master' into wip
Conflicts:
	src/bootimage.cpp
2013-02-19 09:13:42 -07:00
Joshua Warner
24c0fab9bf add unit tests for arg parser 2013-02-19 09:06:25 -07:00
Joel Dice
fd0b2b844b test various configurations besides the default in Travis CI 2013-02-16 08:36:41 -07:00
Joshua Warner
33d245d0f7 add unittest framework 2013-02-14 20:54:20 -07:00
Joshua Warner
1258b23ea1 add remote-test capability
To execute tests on a remote host (for instance, because you're cross-compiling),
simply do:

make remote-test=true remote-test-host=<host_to_test_on> test

You can set several variables to control the functionality of remote-test.
See them below, along with their default values:

remote-test-host = localhost # host to ssh to
remote-test-port = 22
remote-test-user = ${USER} # user to execute tests as
remote-test-dir = /tmp/avian-test-${USER} # dir to rsync build output to
2013-02-14 18:47:48 -07:00
Joel Dice
1890e348fb fix handling of classe, method, and field names with non-ASCII characters 2013-02-03 14:10:47 -07:00
Joel Dice
b75497c8ff implement JNIEnv::NewLocalRef 2012-12-20 09:05:30 -07:00
Joel Dice
d200019d10 implement JNI reflection methods
These include FromReflectedMethod, ToReflectedMethod,
FromReflectedField, and ToReflectedField.
2012-12-19 12:39:33 -07:00
Joel Dice
663d8da975 fix stack mapping bug for try blocks containing jsr/ret instructions
In order to calculate the initial stack map of GC roots for an
exception handler, we do a logical "and" of maps across all the
instructions contained in the try block for that handler.  This is
complicated by the presence of jsr/ret instructions, though, because
instructions in a subroutine may have multiple maps associated with
them corresponding to all the paths from which execution might flow to
them.

The bug in this case was that we were using an uninitialized map in
our calculation, resulting in a map with no GC roots at all.  By the
time the map was initialized, the damage had already been done.  The
solution is to treat an uninitialized map as if it has roots at all
positions so that it has no effect on the calculation until it has
been initialized with real data.
2012-12-12 15:54:15 -07:00
Joel Dice
45073db421 fix Call[Static]<type>MethodA float argument marshalling 2012-10-05 10:56:07 -06: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
fa5d76b43e fix 64-bit shifts on x86_32 2012-08-13 08:26:39 -06:00
Joel Dice
a3a816c9a4 remove test of DataOutputStream from Integers.java
We haven't implemented that class yet, so the test only compiles with
the OpenJDK port.
2012-08-12 20:58:07 -06:00
Joel Dice
69ffa28e1b fix shift instruction implementations on ARM
Unlike x86, ARM does not implicitly mask the shift value, so we must
do so explicitly.
2012-08-11 19:09:03 +00:00
Joel Dice
2687333a37 Merge remote-tracking branch 'github/master' 2012-08-12 15:03:40 -06:00
Joel Dice
b98abe3f94 fix float to integer conversion
Java requires that NaNs be converted to zero and that numbers at or
beyond the limits of integer representation be clamped to the largest
or smallest value that can be represented, respectively.
2012-08-12 14:31:58 -06:00
Joel Dice
e2ff771baa handle basic argument substitution in MessageFormat.format
Thanks to Remi for an initial version of this patch.
2012-08-11 08:58:40 -06:00
Joel Dice
373a92d4d6 add Buffers test 2012-08-11 08:01:44 -06:00
Joel Dice
01be4b23bb implement JNI methods needed by AWT
These include PushLocalFrame, PopLocalFrame, NewDirectByteBuffer,
GetDirectBufferAddress, and GetDirectBufferCapacity.
2012-08-11 06:56:19 -06:00
Joel Dice
96d5dae06c specify UTF-8 explicitly in Strings.testDecode
This fixes a test failure with the OpenJDK port.
2012-08-04 18:41:44 -06:00
Joel Dice
c63668c1ce fix ArrayIndexOutOfBoundsException when decoding a UTF-8 stream 2012-08-04 16:11:27 -06:00
Damjan Jovanovic
5a09774353 tests don't compile when building with OpenJDK
I get this error when compiling with "make openjdk=...." on both x86_64 and
arm:

compiling test classes
test/Arrays.java:90: error: reference to equals is ambiguous, both method
equals(float[],float[]) in Arrays and method equals(Object[],Object[]) in
Arrays match
      expect(java.util.Arrays.equals(null, null));

test/Arrays.java:95: error: reference to hashCode is ambiguous, both method
hashCode(double[]) in Arrays and method hashCode(Object[]) in Arrays match
      java.util.Arrays.hashCode(null);

The attached patch fixes this.
2012-08-04 07:29:39 -06:00
Joel Dice
2cb5a74991 fix mixed marshalling of mixed float/double argument lists on armhf
When we skip a single-precision register to ensure a double-precision
load is aligned, we need to remember that in case we see another
single-precision argument later on, which we must backfill into that
register we skipped according to the ABI.
2012-08-01 16:48:26 +00:00
Joel Dice
67ec092e9a add JNI test to test suite 2012-08-01 16:04:12 +00:00
Joel Dice
836fc21106 fix bugs in File.getParent and listFiles
getParent should return the same value regardless of whether it ends
in a file separator, and listFiles should return null for
non-directories.
2012-07-31 09:27:18 -06:00
Joel Dice
2d6bfa5383 Merge github.com:ReadyTalk/avian 2012-07-24 16:17:09 -06:00
Joel Dice
de086d1046 fix typo in Arrays test 2012-07-24 11:38:43 -06:00
Joshua Warner
fffde5f445 add Arrays test for equals and hashCode, handle corner cases with null 2012-07-24 11:31:47 -06:00
Joel Dice
9974d91648 implement DatagramChannel.receive and fix Datagrams to be Java 6 compatible 2012-07-10 14:09:14 -06:00
Joel Dice
3d99ff37cb Merge remote-tracking branch 'origin/master' into dicej-master 2012-07-09 16:46:21 -06:00
Joel Dice
2ab304acb8 Merge github.com:mkeesey/avian 2012-07-07 16:29:18 -06:00
Mike Keesey
7947981b4b Fixed issue where BitSet didn't handle a range of 64 bits correctly on bulk operations - now just return the predefined MASK which has all the bits set when requesting that all the bits be set. 2012-07-06 23:33:05 -06:00
Dain
26209efac2 Fix an off-by-1 error in the remove method.
The change to only grow the array when the capacity has been reached
exposed a bug in the remove method when shifting the array elements.
2012-07-06 14:03:56 -06:00
Mike Keesey
9c9ee5c26d Made the bulk clear() fast like bulk set() and flip() for BitSet. 2012-07-05 22:16:19 -06:00
Mike Keesey
5f1b086150 Fixed an off-by-one error when deciding if we should grow BitSets. 2012-07-03 21:28:59 -06:00
Joel Dice
c602f4673b implement java.nio.channels.DatagramChannel 2012-07-03 11:24:05 -06:00
Mike Keesey
6e30366d07 Adding EnumSet, which is backed by a speedy BitSet. 2012-07-02 14:28:51 -06:00
Mike Keesey
d419899ac1 Adding both forms of flip() to BitSet. 2012-07-02 14:28:40 -06:00
Mike Keesey
31311160c3 Adding cardinality() to BitSet. 2012-07-02 14:28:34 -06:00
Joel Dice
156644b8e5 fix incorrect array sizing in populateMultiArray
We were assuming the array element size was always the native word
size, which is not correct in general for primitive arrays, and this
led to wasted space at best and memory corruption at worst.
2012-06-26 10:43:47 -06:00
Joel Dice
153b78f479 fix ArrayList performance issue
The ArrayList(Collection) constructor was allocating two arrays
instead of one due to an off-by-one error in ArrayList.grow.  This
commit fixes that and makes grow and shrink more robust.
2012-06-14 10:55:03 -06:00
Mike Keesey
a5c9dd6f24 Fixing some issues with runtime annotations within avian.
We were not properly converting dots to slashes internally for package names
and we did not properly handle Method.getAnnotations and
Method.getAnnotation(Class<T>) on methods without any annotations.

Added some tests to cover these cases.
2012-05-22 14:02:51 -06:00
Joel Dice
1119675b7a override InputStream.available for FileInputStream and the instance returned by ZipFile.getInputStream 2012-05-04 19:55:53 -06:00
Joel Dice
756f58210a add test for sun.misc.Unsafe functionality 2012-03-13 08:28:33 -06:00
Joel Dice
4aefa211a3 File.createNewFile should return false if the file already exists 2012-03-13 08:26:51 -06:00
Joel Dice
71295e54c7 handle constants larger than 8 bits in subtractBorrowCR 2012-03-11 04:59:42 -06:00
Joel Dice
6c9a1e1643 add "throws IOException" to java.io.File.createTempFile 2012-03-11 04:57:22 -06:00
Joel Dice
c6ac66e45a fix bug in isAssignableFrom such that primitive array types were considered to be subclasses of the Object array type 2012-02-27 18:16:01 -07:00
Joel Dice
750e5f903c include leading slash in path when parsing URLs in URLStreamHandler
This matches the behavior of OpenJDK's version.
2012-02-18 15:14:16 -07:00
Joshua Warner
bbb4529752 implement File.setExecutable(), File.canExecute(), and File.createTempFile() 2012-02-09 14:23:24 -07:00
Joel Dice
9ba7c504da Merge remote branch 'origin/SWT3.7_UrlUpdates' into oss-master 2011-12-29 11:00:59 -07:00
Seth Goings
51ae790e54 Added UrlTest.java to tests dir 2011-12-29 10:36:33 -07:00
Ben Limmer
d76191d2bb Adding unit tests for File.isAbsolute() method. 2011-12-29 10:17:01 -07:00
Seth Goings
a0c12ad259 Added another floatToIntBits test 2011-12-29 09:51:44 -07:00
Seth Goings
f5a168f584 Fixed tests for floatToIntBits. Probably want to add more comprehensive tests tomorrow (or today... as of 2 minutes) 2011-12-28 23:58:33 -07:00
Ben Limmer
b3850ac76d Initial attempt at resolving SWT3.7 missing operatons in Avian. Everything seems to be working except floatToIntBits, hence the test case failing. 2011-12-28 15:52:53 -07:00
Joel Dice
6153a5c83b Merge remote-tracking branch 'git/master' 2011-11-04 08:11:14 -06:00
Joshua Warner
90dc552463 implement Process.destroy 2011-11-03 12:30:51 -06:00
Joel Dice
916c96c2b9 fix access violation introduced in last commit 2011-09-14 13:27:17 -06:00
Joel Dice
be01e5b687 fix handling of 64-bit arguments to Method.invoke on 32-bit architectures
The previous code failed to account for alignment padding in the
Double and Long classes.
2011-09-12 20:26:32 -06:00
Joel Dice
5dbcbb825b fix Logging test for tails=true build
In the tails=true build, the calling method cannot always be
determined due to stack frames being optimized away, so we must be
prepared for LogRecord.getSourceMethodName to return null.
2011-08-05 18:04:38 -06:00
Joel Dice
c3fa08c430 fix Thread.interrupt and Thread.interrupted
These were both totally broken; the latter wasn't even implemented.
This commit fixes/implements them and adds a simple test to exercise
them.
2011-07-12 14:15:43 -06:00
Joel Dice
b4169ede91 fix reversed arguments to maybeRex in sseMoveRR
This was causing 8-byte SSE-to-SSE moves involving registers
xmm8-xmm15 to be misencoded on x86_64, leading to incorrect code
generation in methods with lots of local variables of type double.
2011-07-06 11:09:06 -06:00
Joel Dice
7bea2b6b7d fix putstatic/putfield for 64-bit volatiles
We must call acquireMonitorForObject before popping the
putstatic/pushfield operands off the stack to avoid clobbering said
operands.
2011-05-23 12:38:12 -06:00
Joel Dice
d02d7c9846 fix IllegalAccessException in LazyLoading test 2011-03-26 12:00:40 -06:00
Joel Dice
453ceb42ab implement lazy class/field/method resolution in JIT compiler
Unlike the interpreter, the JIT compiler tries to resolve all the
symbols referenced by a method when compiling that method.  However,
this can backfire if a symbol cannot be resolved: we end up throwing
an e.g. NoClassDefFoundError for code which may never be executed.
This is particularly troublesome for code which supports multiple
APIs, choosing one at runtime.

The solution is to defer to stub code for symbols which can't be
resolved at JIT compile time.  Such a stub will try again at runtime
to resolve the needed symbol and throw an appropriate error if it
still can't be found.
2011-03-15 18:07:13 -06:00
Joel Dice
48e569c65a add tail call test 2011-03-15 17:51:32 -06:00
Joel Dice
e6cf992af7 uncomment testStatic call in DefineClass
I had commented it out for debugging purposes and forgot to uncomment
it.
2011-03-15 17:33:09 -06:00
Joel Dice
944e223335 use wait/notifyAll too avoid starvation in Trace test
Thread.yield is not enough to ensure that the tracing thread does not
starve the test thread on some QEMU VMs, so we use wait/notifyAll to
make sure both threads have opportunities to run and the test actually
finishes.
2011-02-26 12:40:54 -07:00
Joel Dice
bead78d982 wrap primitive return values using correct types in Method.invoke
The VM uses Integer and Long instances internally to wrap the results
of dynamic method invocations, but Method.invoke should use the
correct, specific type for the primitive (e.g. Character for char).
2011-02-22 17:54:56 -07:00
Joel Dice
20f4510122 fix ARM stack unwinding (part 2)
My previous attempt at this was incomplete; it did not address
Java->native->Java->native call sequences, nor did it address
continuations.  This commit takes care of both.
2011-02-20 13:49:40 -07:00
Joel Dice
59183c7821 fix subroutine stack mapping bug leading to crashes during GC
The stack mapping code was broken for cases of stack slots being
reused to hold primitives or addresses within subroutines after
previously being used to hold object references.  We now bitwise "and"
the stack map upon return from the subroutine with the map as it
existed prior to calling the subroutine, which has the effect of
clearing map locations previously marked as GC roots where
appropriate.
2011-02-16 14:29:57 -07:00
Joel Dice
c743140e08 add new subroutine test
This test covers the case where a local stack slot is first used to
store an object reference and later to store a subroutine return
address.  Unfortunately, this confuses the VM's stack mapping code;
I'll be working on a fix for that next.

The new test requires generating bytecode from scratch, since there's
no reliable way to get javac to generate the code we want.  Since we
already had primitive bytecode construction code in Proxy.java, I
factored it out so we can reuse it in Subroutine.java.
2011-02-16 11:41:33 -07:00
Joel Dice
c4ededda83 add progress indicators to Trace test
Also, add a yield call to the tracing thread so it doesn't monopolize
the CPU.
2011-02-01 18:14:53 -07:00
Joel Dice
a0a8c554d5 add a couple of test cases to NullPointer.java 2011-02-01 08:40:56 -07:00
Joel Dice
69af8a13aa add Thread.getStackTrace test 2011-01-31 09:55:58 -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
e16d5f83af Merge remote branch 'origin/master' into r0.5 2011-01-25 17:30:21 -07:00
Joel Dice
966650f105 make StackOverflow test useful in tails=true build 2011-01-25 17:13:59 -07:00
Joel Dice
0cc6156932 remove redundant code from DefineClass and Zip tests 2011-01-21 16:11:36 -07:00
Joel Dice
3aff7dc861 add TreeSet(Collection) constructor 2011-01-20 09:39:16 -07:00
Joel Dice
b57e734ceb implement Character.forDigit 2011-01-20 09:33:50 -07:00
Joel Dice
51c56c1b3c add PrintStream.print[ln] overloads for primitives and char arrays 2011-01-20 08:26:56 -07:00
Joel Dice
9c36105b8f fix misleading pathnames in bootimage build instructions 2011-01-19 16:00:18 -07:00
Joel Dice
b4941cddbe close FileInputStream before deleting file in FileOutput test
Otherwise, Windows won't let us delete it.
2011-01-17 10:33:43 -07:00
Joel Dice
4a9ff55060 File.length should return 0 for non-existent files 2011-01-17 09:48:34 -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
3fe9171766 Merge remote branch 'origin/master' into r0.5 2011-01-16 19:40:01 -07:00
Joel Dice
d5ba7412cd update DefineClass to exercise Class.newInstance
This is an attempt to reproduce an issue reported on the discussion
group.  However, the current form of the test is passing, so further
work will be necessary to trigger the bug.
2011-01-15 10:33:56 -07:00
Joel Dice
b6978c6c68 always create file if necessary in Java_java_io_FileOutputStream_open
Previously, we would only create the file if it did not already exist
*and* we weren't appending.  Now we do so whether appending or not.
2011-01-14 11:26:00 -07:00
Joel Dice
ff18524906 add DefineClass to test suite
As reported on the discussion group, there is a problem with the
ClassLoader.defineClass implementation sunch that this test is not
currently passing, at least for the mode=debug and bootimage=true
builds.  I plan to address these failures soon, but I wanted to add a
test first to make sure I could reproduce them.
2011-01-13 08:59:55 -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
857dcd13e7 fix 64-bit constant comparisons on 32-bit platforms 2010-12-20 18:08:52 -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
64b11f0c64 close ZipFile when done with it in Zip test 2010-12-10 01:20:44 -07:00
Joel Dice
7164743009 fix Array.makeObjectArray regression 2010-12-01 15:44:09 -07:00
Joel Dice
84520cde51 Merge remote branch 'origin/master' into openjdk 2010-12-01 14:40:58 -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
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
878e98954b add QueryDump heap dump analysis tool 2010-11-22 10:04:28 -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
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
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
75de0a621b fix windows.cpp MySystem::now 2010-11-07 12:35:31 -07: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
1d4b54a9f6 fix failure to add abstract virtuals to class with no declared virtuals 2010-09-25 16:35:18 -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
88942a9672 search for jar file in Zip.java instead of trying to load by hard-coded name 2010-09-20 17:30:39 -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
d5b35bea6e remove redundant import from FileOutput.java 2010-09-12 14:41:01 -06:00
Zsombor Gegesy
6752505cb8 add File.canRead()/File.canWrite() implementation 2010-09-11 21:23:46 +02: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
250a77dc13 handle empty strings properly in Pattern.split
We were incorrectly returning an empty array when the input was empty,
whereas we ought to return an array containing a single empty string.
When the pattern to match was empty, we went into a loop to create an
infinite list of empty strings, only to crash once we've run out of
memory.  This commit addresses both problems.
2010-09-06 11:16:27 -06:00
Joel Dice
7eabe13921 verify file contents in FileOutput test 2010-08-16 09:30:39 -06:00
Zsombor Gegesy
1daa93d3c4 add ability to append to files 2010-08-16 09:23:48 -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
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
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
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
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
fb5796b740 don't use SSE for long-to-double conversion on 32-bit systems 2009-11-04 00:02:38 +00:00
Joel Dice
3b4be3decd defer to helper thunk for frem and drem 2009-10-24 19:29:20 -06:00
Joel Dice
064ad572bc use truncation, not rounding in float2Int instructions 2009-10-20 15:43:24 -06:00
Joel Dice
23197da679 fix handling of subroutines in methods of return type long on 32-bit systems 2009-10-06 03:17:12 +00:00
Joel Dice
4f78783ef1 various bugfixes for SSE-based floating-point support 2009-10-05 14:25:12 +00:00
Joel Dice
5dad9bddd6 snapshot 2009-10-04 19:56:48 +00:00
Joel Dice
325f93b4d1 Merge branch 'master' into wip
Conflicts:

	src/compile.cpp
	src/compiler.cpp
	src/machine.h
	src/x86.cpp
2009-09-20 15:43:32 -06:00
Joel Dice
7aa906d97b support runtime-visible annotations and java.lang.reflect.Proxy 2009-09-18 18:01:54 -06:00
Joel Dice
4f794f533e fix handling of reachable, moved weak references in postVisit 2009-09-01 17:23:30 -06:00
Joel Dice
4297fa04b3 run java finalizers in a separate thread to guarantee no application locks are held when doing so 2009-08-24 17:51:31 -06:00
Joel Dice
4c14a9ab66 implement enough of java.util.regex to ensure String methods work for trivial regular expressions 2009-08-20 11:14:05 -06:00
Joel Dice
c27aa559e5 comment out use of currently-unsupported regex functionality in Strings test 2009-08-18 14:21:40 -06:00
Joel Dice
20c1ea08e6 remove a test from Misc.java since it's been moved to Strings.java 2009-08-14 08:53:33 -06:00
Joel Dice
7fcbf9d85c fix reading 2-byte UTF-8 constants 2009-08-14 08:52:31 -06:00
Joel Dice
935329d7cf fix 32-bit shift case in unsignedShiftRightC 2009-08-11 12:36:25 -06:00
Josh warner
af4d82ef7e Merge branch 'master' of git://oss.readytalk.com/avian 2009-08-10 13:42:57 -06:00
Josh warner
1d3ef1fc43 Merge branch 'master' of git://oss.readytalk.com/avian, fixed problems that occured in broader testing
Conflicts:
	src/compile.cpp
	src/compiler.cpp
	src/powerpc.cpp
	src/x86.S
	src/x86.cpp
2009-08-10 13:20:23 -06:00
Joel Dice
012d548bbb fix sign extension from int to long on x86_64 2009-08-07 14:48:30 -06:00
Joel Dice
e5947b5ec0 remove bashism from test.sh 2009-08-06 15:58:26 -06:00