Commit Graph

3966 Commits

Author SHA1 Message Date
Joel Dice
918b7828f1 fix StackOverflowError stack walking in tails=true builds
The various Architecture::nextFrame implementations were not walking
the stack correctly when a StackOverflowError was thrown.  The
throwStackOverflow thunk is called before the frame of the most
recently called method has been fully created, and because tails=true
builds use a different calling convention, we need to treat this
situation carefully when building a stack trace or unwinding.
Otherwise, we will skip past all the java frames to the next native
frame, which is what was happening.
2014-03-14 09:59:04 -06:00
Joel Dice
73e60adeab always add a trap instruction after a throw
Tail call and dead code optimizations can cause code after a throw to
be eliminated, which confuses findUnwindTarget because it doesn't know
what code is throwing the exception.  So we need at least one
instruction to follow the call to the throw_ thunk.  Previously, we
only added such an instruction when we knew the throw was the last
instruction in the bytecode, but it turns out there are other cases
where it is needed, including certain try/finally situations.
2014-03-14 09:54:05 -06:00
Joel Dice
7cfbdc8fdb call crash if the signal handler is unable to handle the signal
Otherwise, the OS will just keep asking us to handle the signal in an
infinite loop.
2014-03-14 09:50:10 -06:00
Joshua Warner
7fa8c7ec20 remove unused constants (fixes #198) 2014-03-14 09:06:19 -06:00
Joel Dice
70b5ea6838 Merge pull request #191 from bigfatbrowncat/avian-droid
Android classpath support in Windows
2014-03-12 16:38:37 -06:00
Mike Jensen
e0497a594b Merge pull request #196 from dicej/concurrent
implement ConcurrentHashMap and fix test class misspelling
2014-03-12 14:23:21 -06:00
Joel Dice
dd359ef937 rename Concurrent to ConcurrentHashMapTest 2014-03-12 13:04:20 -06:00
Joel Dice
4d05bfd540 fix Completeion/Completion misspelling 2014-03-12 10:44:24 -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
Vasily Litvinov
e3ddb14fd2 Merge branch 'avian-droid' of https://github.com/bigfatbrowncat/avian into avian-droid 2014-03-12 01:11:41 +04:00
Vasily Litvinov
5403a43edf Enabling org_conscrypt_NativeCrypto.cpp build 2014-03-12 01:11:33 +04:00
Joshua Warner
b6c3bc6f4d Merge pull request #195 from jentfoo/ExecutorCompletionService_and_LinkedBlockingQueue
Added interface BlockingDeque, and implementation for ExecutorCompletionService and LinkedBlockingQueue
2014-03-11 09:51:58 -06:00
Mike Jensen
efb31dd09a Added verify function to avoid throwing so many runtime exceptions in the tests 2014-03-11 09:20:34 -06:00
Mike Jensen
68fca60d21 Added interface BlockingDeque, and implementation for ExecutorCompletionService and LinkedBlockingQueue.
I had to implement a blocking queue for ExecutorCompletionService.  LinkedBlockingQueue could be very easily extended right now to implement the java 7 LinkedBlockingDeque.  Right now LinkedBlockingQueue just synchronizes and depends on LinkedList implementation.  But I wrote a very complete unit test suite so we if we want to put a more concurrent design here, we have a complete test suite to verify against.# Please enter the commit message for your changes. Lines starting
2014-03-10 19:06:37 -06:00
Joshua Warner
ed89e0c67d Merge pull request #194 from jentfoo/FutureTask
Added implementation and tests for FutureTask.
2014-03-10 16:51:36 -06:00
Mike Jensen
ccb6083045 Attempting to prevent interrupting threads after future has completed.
We added a 4th state, so we have "Canceling and Canceled".  We are in canceling state if we previously were running, and will not transition to canceled till after the interrupt has been sent.  So at the end if we are not running, or already canceled, we will sleep, waiting for the interrupt to occur so we can be sure we handle it before we let the thread complete.
This also fixes a condition where we returned true on a cancel after a task has already been canceled
2014-03-10 16:14:10 -06:00
Joshua Warner
60d841df06 Merge pull request #186 from dicej/getDeclaredMethods
fix Class.getDeclaredMethods
2014-03-10 13:09:04 -06:00
Mike Jensen
d56087240d Changes so that we only set the running thread if we actually ARE the running thread 2014-03-10 12:43:22 -06:00
Mike Jensen
83a31314e0 Added implementation and tests for FutureTask.
I also was missing the set operation for AtomicReference, and cleaned a couple things up from LockSupport.
2014-03-10 10:53:49 -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
Joshua Warner
492294bfe6 Merge pull request #189 from jentfoo/interface_improvements
interface improvements and LockSupport implementation
2014-03-07 20:48:40 -07:00
Joshua Warner
f0fa06b3b7 Merge pull request #192 from dicej/inner-class-modifiers
match Java's schizophrenic concept of inner class access modifiers
2014-03-07 08:19:38 -07: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
Ilya Mizus
7cac232bd4 Tools fixed 2014-03-06 18:35:20 +04:00
Ilya Mizus
57f50ca7ea Some small cleanup before pull request 2014-03-06 18:33:23 +04:00
Vasily Litvinov
24ba96192c Merge branch 'avian-droid' of https://github.com/bigfatbrowncat/avian into avian-droid 2014-03-05 03:03:07 +04:00
Vasily Litvinov
0982debca7 Got rid of __DISABLE_IPV6_PROTO macro 2014-03-05 03:02:48 +04:00
Ilya Mizus
33a48afd17 NativeCrypto is back for non-Windows platforms 2014-03-05 01:33:41 +04:00
Mike Jensen
d94fc8f009 Fix for travis build failure for needing to initialize the new field in Thread. 2014-03-04 11:21:14 -07:00
Mike Jensen
d5e3acd7a5 Add parkBlocker variable to Thread.java 2014-03-03 16:45:28 -07:00
Mike Jensen
7dd799476a Interfaces and the foundation for a ReentrantLock implementation 2014-03-03 16:04:56 -07:00
Mike Jensen
b5dd74c3d8 Adds the Deque interface, and allows LinkedList to implement that interface.
This also changes ConcurrentLinkedQueue to implement the Queue interface, and just throw exceptions for operations which are not currently implemented.
2014-03-03 16:02:12 -07:00
Joshua Warner
6ed98b85f8 Merge pull request #188 from dicej/volatile
move Unsafe.get{Object|Int}Volatile from classpath-openjdk.cpp to builti...
2014-03-03 15:32:57 -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
Vasily Litvinov
6ae149809f Enabled "FIXME_STUB" macro 2014-03-04 00:41:58 +04:00
Ilya Mizus
301fb1ae13 Refactoring 2014-02-28 11:18:48 +04:00
Joel Dice
1cd822b23e Merge pull request #180 from joshuawarner32/move-allocator
Move allocator & Slice into util
2014-02-27 08:55:24 -07:00
Ilya Mizus
6df337b0c4 Added errno descriptions for Android classpath on Windows 2014-02-27 01:56:17 +03:00
Joshua Warner
e837502d43 Merge pull request #184 from dicej/zip-available
remove redundant decrement in ZipFile.getInputStream inner class
2014-02-26 15:55:48 -07:00
Joel Dice
2036eeaaa6 Merge pull request #182 from joshuawarner32/ffi-split
split out ffi::call from System
2014-02-26 15:46:05 -07:00
Joshua Warner
e6eead07fa call vm::dynamicCall directly, instead of through System 2014-02-26 15:10:41 -07:00
Joel Dice
094af1e794 remove redundant decrement in ZipFile.getInputStream inner class
We were decrementing the "remaining" field twice for each byte read
using the no-arg read method, which resulted in available() returning
a value that was too small.
2014-02-26 14:48:28 -07:00
Joshua Warner
53816970ea Merge pull request #183 from dicej/codesource
move OpenJDK.getProtectionDomain into Classes.java
2014-02-26 14:47:02 -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
Vasily Litvinov
63a691f41d Adding a define to tell Android Classpath to disable IPv6, removing -fPIC on Windows as it's useless there and generates warnings 2014-02-26 19:41:55 +04:00
Joshua Warner
deca71da52 build arm and powerpc targets in the ci build 2014-02-25 21:38:29 -07:00
Joshua Warner
2ac9070399 fix arm/powerpc build 2014-02-25 21:33:08 -07:00
Joshua Warner
db19c7b3a2 add Slice::resize and Slice::alloc 2014-02-25 20:34:03 -07:00
Joshua Warner
892d359ba0 use size_t for Vector::minimumCapacity 2014-02-25 20:34:03 -07:00
Joshua Warner
b711aef1b3 use Slice in Vector 2014-02-25 20:34:03 -07:00