Commit Graph

2777 Commits

Author SHA1 Message Date
Joshua Warner
924f242e66 add compile.cpp changes 2014-07-11 13:25:20 -06:00
Joshua Warner
4df8f59f3c staticly type finalizer and cleaner 2014-07-11 13:25:20 -06:00
Joshua Warner
1e201e54fc staticly type GcContinuation* 2014-07-11 13:25:20 -06:00
Joshua Warner
b8ddc779a2 staticly type GcReference 2014-07-11 13:25:20 -06:00
Joshua Warner
bb331e9414 make callNode and methodRuntimeData.native better statically typed 2014-07-11 13:25:19 -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
6a0502bbfe add util.cpp/.h changes 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
9f5912c2b6 add stronger typing to method.code 2014-07-11 13:25:19 -06:00
Joshua Warner
9248f8f8ad add stronger typing to code.singleton 2014-07-11 13:25:18 -06:00
Joshua Warner
4754a92b75 split code.stackMap out of code.pool use 2014-07-11 13:25:18 -06:00
Joshua Warner
083dc17810 add stronger typing to code.lineNumberTable 2014-07-11 13:25:18 -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
7ea4b584b8 include stdc++ <new> 2014-07-11 09:32:57 -06:00
Joshua Warner
5adb558355 add Code to classpath 2014-07-11 09:32:57 -06:00
Joshua Warner
43bd838c86 generate accessors for array fields 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
Joshua Warner
13452beaab use arg-parser in type-generator 2014-07-11 09:12:34 -06:00
Joel Dice
1b83ef7eb3 only wrap Exceptions in ExceptionInInitializerErrors, not Errors 2014-07-10 13:43:10 -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
735eaaba21 Merge remote-tracking branch 'remotes/dicej/findclass-onload' 2014-07-01 08:39:56 -06:00
Joel Dice
254e3f938d fix unused declaration/definition warnings from GCC 4.9 2014-06-30 09:54:01 -06:00
Joel Dice
f40dcddd8d only generate crash dump if faulting instruction is in main executable
The VM should only assume it should/will crash if it triggers an
e.g. EXCEPTION_ACCESS_VIOLATION itself.  In other words, if some
non-VM code triggers such an event, the VM should let that code handle
it as appropriate.  Avian already does this properly, but it also
generates crash dumps for each event encountered if avian.crash.dir is
set, regardless if whether the VM triggered it or not.  This can be a
problem if such events are generated frequently -- a full memory dump
takes a long time to write and a lot of disk space.

Ideally, we'd have some reliable way to determine whether the faulting
instruction pointer belongs to the VM or not, but the closest thing I
could come up with was to compare the module that owns the address
with the module representing the main executable.  This can lead to
both false positives (e.g. application code in the main executable
which is not part of the VM) and false negatives (e.g. when the VM is
loaded from a library instead of the main executable), but it's still
an improvement over the status quo.

Even better would be to ensure that the VM's exception handler is the
very last one to run, so that we know for sure that the error is
unrecoverable and thus it is appropriate to do a full memory dump.
2014-06-27 12:45:05 -06:00
Joel Dice
9e7d27bd15 Merge pull request #281 from joshuawarner32/darwin-platform-reorg
rename platform=darwin -> platform={ios,macosx}, fix ios simulator build
2014-06-24 15:49:54 -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
Joel Dice
9d4f9901bc remove redundant PROTECT usage
This was causing crashes at GC time since we ended up visiting the
same reference twice in a single GC cycle.
2014-06-23 10:40:22 -06:00
Joshua Warner
9a6f7bd0bf rename platform=darwin -> platform={ios,macosx}, fix ios simulator build 2014-06-22 12:30:52 -06:00
Joshua Warner
ada6ce4cc3 fix arm compiler abort 2014-06-11 09:55:39 -06:00
Joel Dice
975b1ddfd8 Merge pull request #275 from mikehearn/prop-fix
Set a property that the LambdaWorks SCrypt library expects to be present
2014-06-05 13:37:47 -06:00
Joel Dice
b16dd4e63f only enter IdleState if necessary in idleIfNecessary
There's no need to enter IdleState (and incur synchronization
overhead) unless another thread is waiting to enter ExclusiveState.
This change improves the performance of the MemoryRamp test by a
factor of about 100.
2014-06-05 07:49:49 -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
05d80aee8b remove static references to TargetBytesPerWord in Compiler 2014-06-01 14:57:05 -06:00
Joshua Warner
1fb6a0bceb fix up creation of ir::Type 2014-06-01 14:22:51 -06:00
Joshua Warner
68b725900e remove old Subroutine comments 2014-06-01 10:04:56 -06:00
Joshua Warner
ec2e153aa8 fixup comments in Subroutine 2014-05-31 21:28:27 -06:00
Joshua Warner
9ed6a16340 make function and constant naming clearer (code review feedback) 2014-05-31 19:39:36 -06:00
Joshua Warner
1d86e668cb inline Frame::*ed* code 2014-05-30 23:57:07 -06:00
Joshua Warner
955f4918b4 parameterize many Frame:: methods by type 2014-05-30 23:57:02 -06:00
Joshua Warner
7abbace8fb replace Frame::StackType with ir::Type 2014-05-30 23:40:24 -06:00
Joshua Warner
37d104871c test line number table generation in subroutines 2014-05-30 23:40:24 -06:00
Joshua Warner
9273d5ca39 remove redundant Compiler::initLocal footprint parameter 2014-05-30 23:40:24 -06:00
Joshua Warner
b6a3ed763c add assert in Compiler::initLocal and fix ensuing problems 2014-05-30 23:40:24 -06:00
Joshua Warner
9a54c50db6 make asserts in loadLocal and storeLocal more strict 2014-05-30 23:40:23 -06:00
Joshua Warner
91c5599fc0 remove redundant Compiler::storeLocal footprint parameter 2014-05-30 23:40:23 -06:00
Joshua Warner
cc4525c31c add type/footprint assert in Compiler::storeLocal 2014-05-30 23:40:23 -06:00
Joshua Warner
e7837c243e remove redundant size parameter to appendBranch, rename type -> op 2014-05-30 23:40:23 -06:00
Joshua Warner
0eda1d7d11 add type asserts in appendBranch 2014-05-30 23:40:23 -06:00
Joshua Warner
c259faf24a remove redundant size parameters to appendReturn and appendCall 2014-05-30 23:40:23 -06:00
Joshua Warner
9282c78549 add type asserts in appendReturn and appendCall 2014-05-30 23:40:23 -06:00
Joshua Warner
148d35bab5 remove redundant size parameters to appendCombine and appendTranslate 2014-05-30 23:40:23 -06:00
Joshua Warner
d67820054e add type asserts in appendCombine and appendTranslate 2014-05-30 23:40:23 -06:00
Joshua Warner
008bb6b86e remove redundant Compiler::unaryOp type parameter 2014-05-30 23:40:23 -06:00
Joshua Warner
a0443f0ef1 add type asserts in Compiler::unaryOp 2014-05-30 23:40:22 -06:00
Joshua Warner
b14709c54c remove redundant Compiler::condJump type parameter 2014-05-30 23:40:22 -06:00
Joshua Warner
e3354617a6 add type asserts in Compiler::condJump 2014-05-30 23:40:22 -06:00
Joshua Warner
33d946d249 remove redundant Compiler::store srcType parameter 2014-05-30 23:40:22 -06:00
Joshua Warner
f6bc51647e add type assert in Compiler::store, fix ensuing problems 2014-05-30 23:40:22 -06:00
Joshua Warner
e3d01746e8 remove redundant Compiler::truncate srcType parameter 2014-05-30 23:40:22 -06:00
Joshua Warner
3029bb2d7e add type asserts in Compiler::truncate 2014-05-30 23:40:22 -06:00
Joshua Warner
b853f1a594 remove redundant f2i & i2f aType parameter 2014-05-30 23:40:22 -06:00
Joshua Warner
c9313d5802 add type assert in f2i & i2f 2014-05-30 23:40:22 -06:00
Joshua Warner
c843a97e23 remove redundant f2f aType parameter 2014-05-30 23:40:21 -06:00
Joshua Warner
963b371e04 remove redundant load srcType parameter 2014-05-30 23:40:21 -06:00
Joshua Warner
69966f1d36 add type assert in load, fix ensuing problems 2014-05-30 23:40:21 -06:00
Joshua Warner
6fdd5d13ca remove redundant return_ type parameter 2014-05-30 23:40:21 -06:00
Joshua Warner
746c0fa0e8 remove ir::Type::Invalid, no longer needed for Subroutine 2014-05-30 23:40:21 -06:00
Joshua Warner
5ad1a14a73 explode Subroutines in compile.cpp rather than handling them in Compiler 2014-05-30 23:40:21 -06:00
Joshua Warner
781977d19c add debug-util for printing java bytecode as it's compiled 2014-05-30 23:40:21 -06:00
Joshua Warner
2e40d38078 enforce more strong typing in compiler 2014-05-30 23:40:15 -06:00
Joshua Warner
7b0d577430 fix some return type & intrinsic typing 2014-05-30 23:19:41 -06:00
Joshua Warner
cb7f570f20 begin enforcing more strong typing 2014-05-30 22:51:03 -06:00
Joshua Warner
43eb49cf53 fix sizing of some stack ints 2014-05-30 22:41:11 -06:00
Joshua Warner
d62d083733 remove stack manipulation from AvianCallingConvention loop 2014-05-30 22:41:11 -06:00
Joshua Warner
9f36a8e0ec prepare to move stack manipulation out of CallEvent 2014-05-30 22:41:11 -06:00
Joshua Warner
ae534bed5f cleanup 2014-05-30 22:41:11 -06:00
Joshua Warner
cfc3bd212b remove stack manipulation from NativeCallingConvention calls 2014-05-30 22:41:11 -06:00
Joshua Warner
fe2962830c remove unused CallEvent::argumentStack variable, prepare to remove stack manipulation from NativeCallingConvention calls 2014-05-30 22:41:11 -06:00
Joshua Warner
d2e9911161 add asserts in CallEvent 2014-05-30 22:41:11 -06:00
Joshua Warner
1318b9ca2a remove redundant CallEvent::argumentCount parameter 2014-05-30 22:41:11 -06:00
Joshua Warner
f9cbca8f7d pair up stack for NativeCallingConvention 2014-05-30 22:41:11 -06:00
Joshua Warner
69edeaadee remove redundant Compiler::stackCall footprint argument 2014-05-30 22:41:11 -06:00
Joshua Warner
3c9a453d17 add extra asserts in CallEvent 2014-05-30 22:41:11 -06:00
Joshua Warner
97ce7d2b4e pass CallEvent arguments in Slice as well 2014-05-30 22:41:10 -06:00
Joshua Warner
4e00a1e304 add Frame::referenceStackCall 2014-05-30 22:41:10 -06:00
Joshua Warner
3aa85f2494 move return handling into Frame::stackCall 2014-05-30 22:41:10 -06:00
Joshua Warner
ad3ec1abf3 introduce Frame::stackCall util 2014-05-30 22:41:10 -06:00
Joshua Warner
86a98240b4 remove useless static_casts to retrieve ir::Value::type 2014-05-30 22:41:10 -06:00
Joshua Warner
479c056b2c move Compiler::Operand to ir::Value 2014-05-30 22:41:10 -06:00
Joshua Warner
865041b688 add asserts 2014-05-30 22:38:10 -06:00
Joshua Warner
42fec084b0 expose Value::type and add asserts 2014-05-30 22:16:39 -06:00
Joshua Warner
00253ce528 remove redundant Compiler::load srcSelectType parameter 2014-05-30 22:16:39 -06:00
Joshua Warner
4c4cc49510 use Compiler::truncateThenExtend in more places 2014-05-30 22:16:39 -06:00
Joshua Warner
26d8e8aa1f add Compiler::truncateThenExtend 2014-05-30 22:16:39 -06:00
Joshua Warner
99fa560257 merge Compiler::load and Compiler::loadz 2014-05-30 22:16:39 -06:00
Joshua Warner
85f114ea0f use ir::Type in Compiler::loadLocal 2014-05-30 22:16:39 -06:00
Joshua Warner
53b68a693d add more aggressive checks to Compiler::load* 2014-05-30 22:16:38 -06:00
Joshua Warner
27ea503233 switch Compiler::load* to use ir::Type rather than sizes 2014-05-30 22:16:38 -06:00
Joshua Warner
9c98986f99 remove redundant Compiler::store dstType parameter 2014-05-30 22:16:38 -06:00
Joshua Warner
0ee3eec478 add extra type checks to Compiler::store 2014-05-30 22:16:38 -06:00
Joshua Warner
8b1739dc0f remove redundant Compiler::stackCall resultSize parameter 2014-05-30 22:16:38 -06:00
Joshua Warner
1d466a800e remove redundant Compiler::call resultSize parameter 2014-05-30 22:16:38 -06:00
Joshua Warner
9805ff94b4 remove redundant Compiler::memory scale parameter 2014-05-30 22:16:38 -06:00
Joshua Warner
f9b781149e add extra type checks to Compiler::store and Compiler::memory 2014-05-30 22:16:38 -06:00
Joshua Warner
1fc6011bf7 add extra flavor type check to Compiler::store 2014-05-30 22:16:37 -06:00
Joshua Warner
aef5acce84 add flavor type check to Compiler::store 2014-05-30 22:16:35 -06:00
Joshua Warner
2ed52c05a8 use ir::Type in Compiler::store 2014-05-30 21:19:33 -06:00
Joshua Warner
8af9bb8297 change Compiler::register_ to Compiler::threadRegister, since it was only used as such 2014-05-30 21:19:32 -06:00
Joshua Warner
2d444830d0 use ir::Type in Compiler::unaryOp and Compiler::binaryOp 2014-05-30 21:19:32 -06:00
Joshua Warner
6ed7681dc0 use ir::Type in f2i and friends, instead of aSize 2014-05-30 21:19:27 -06:00
Joshua Warner
704c05f818 use ir::Type in place of Compiler::OperandType 2014-05-29 15:30:46 -06:00
Joshua Warner
d8914a9646 use ir::Type in Compiler::initLocal 2014-05-29 15:30:46 -06:00
Joshua Warner
4bfb359cdd use ir::Type in Compiler::pop 2014-05-29 15:30:46 -06:00
Joshua Warner
13342d28be use ir::Type in Compiler::save 2014-05-29 15:30:46 -06:00
Joshua Warner
75f0812f7a remove unused Compiler::push method 2014-05-29 15:30:46 -06:00
Joshua Warner
49a5a9f398 use ir::Type in Compiler::push 2014-05-29 15:30:45 -06:00
Joshua Warner
d9fee1025c use ir::Type in Compiler::return_ 2014-05-29 15:30:45 -06:00
Joshua Warner
587b1e3eda use ir::Type in place of lir::ValueType in Value 2014-05-29 15:30:45 -06:00
Joshua Warner
855534b152 introduce ir::Type and begin migrating i2f and friends to it 2014-05-29 15:30:45 -06:00
Joel Dice
6d68ae7c13 Merge pull request #268 from joshuawarner32/clean-shutdown
cleanly destroy MyProcessor
2014-05-20 18:30:05 -06:00
Joshua Warner
e2f613e063 cleanly destroy MyProcessor to allow for creating/destroying VMs in the same process multiple times 2014-05-20 17:26:11 -06:00
Joshua Warner
7ee03be2e9 add simple version flag 2014-05-20 13:13:17 -06:00
Joel Dice
4a83b671b3 fix crash on exit due to order of operations bug in ~RawMonitorResource
The problem (which we've only been able to reproduce consistently with
the openjdk-src process=interpret build on Linux virtual machines) was
a race condition during VM shutdown.  Thread "A" would exit, see there
were other threads still running and thus enter ZombieState, which
involves acquiring and releasing a lock using RawMonitorResource.
Then the last thread (thread "B") would exit, wait for thread "A" to
release the lock, then shut down the VM, freeing all memory.  However,
thread "A" writes to its Thread object one last time after releasing
the lock (in ~Resource, the destructor of the superclass of
RawMonitorResource, which sets Thread::resource).  If thread "B" frees
that Thread before ~Resource runs, we end up writing to freed memory.

Thus, we need to update Thread::resource before releasing the lock.
Apparently C++ destructors run in order from most derived to least
derived, which is not what we want here.  My solution to split
Resource into two classes, one that has no destructor and another that
extends it (called AutoResource) which does hafe a destructor.  Now
all the classes which used to extend Resource extend AutoResource,
except for RawMonitorResource, which extends Resource directly so it
can control the order of operations.
2014-05-10 23:25:59 -06:00
Joel Dice
0800508b4e move Runtime.freeMemory and totalMemory to builtin.cpp
This allows them to be shared between the Avian and Android class
library builds.

This commit also disables the URL test in Misc.java on Android, since
it's known to fail, and we still want to know whether the other tests
pass.
2014-05-10 18:56:04 -06:00
Joel Dice
3696edeb1e fix stack alignment bug in vmJumpAndInvoke
This was causing crashes on 32-bit OS X continuations=true builds.

There were two important differences between vmInvoke and
vmJumpAndInvoke: (1) vmInvoke expects its stack to be aligned on
entry, modulo the return address whereas the stack argument to
vmJumpAndInvoke is aligned without allowing for the return address,
and (2) vmInvoke pushes EBP before doing its frame allocation, whereas
vmJumpAndInvoke did not take that into account.  So in order for
vmJumpAndInvoke to allocate the exact same frame size that vmInvoke
would have when calling the same method, it needed to add an extra two
words beyond what it was already allocating.

Aside from alignment concerns, the code is not particularly sensitive
to vmJumpAndInvoke allocating a different frame size than vmInvoke,
since we store the frame pointer in a "thread local" variable:

   // remember this stack position, since we won't be able to rely on
   // %rbp being restored when the call returns
   movl   8(%ebp),%eax
   movl   %esp,TARGET_THREAD_SCRATCH(%eax)
...
GLOBAL(vmInvoke_returnAddress):
   // restore stack pointer
   movl   TARGET_THREAD_SCRATCH(%ebx),%esp

My original patch makes an equivalent change for the 64-bit changes,
but I'll leave that for after we release 1.0 since we're in
bugfix-only mode right now
2014-05-08 09:20:12 -06:00
Joshua Warner
518f428f13 add Field.getDeclaredAnnotations default method for android classpath (fixes Reflection test) 2014-05-07 14:48:21 -06:00
Joshua Warner
41adb74eb1 remove powerpc support 2014-04-29 13:26:40 -06:00
Joel Dice
172ef9a7e6 Merge pull request #246 from joshuawarner32/master
Stop using *Critical functions in throwIOException
2014-04-24 19:40:10 -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
Joshua Warner
690ba9cdc7 Stop using *Critical functions in throwIOException
This was a bug, wherein upon throwing an exception, we would try to
allocate memory for the message - all while holding a critical
reference to the jbyteArray representing the exception string.  This
caused an expect to fail in allocate3.
2014-04-24 15:23:05 -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
Joshua Warner
3cee8d1a5c Merge pull request #226 from dicej/android-bootimage
fix Android bootimage build
2014-04-13 13:22:37 -06:00
Joshua Warner
2fff3a6e13 Merge pull request #229 from dicej/preBoot
fix broken Android build due to 617bd85
2014-04-11 21:54:34 -06:00
Joshua Warner
77dcb97bf0 Merge pull request #225 from dicej/javahome
fix incorrect EXPORT definition for Windows/x86_64 in boot-javahome.cpp
2014-04-11 21:40:38 -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
1b8b27fb6b add expect call to ensure tryAllocateExecutable actually succeeds
For some reason, running Avian under the SVN version of Valgrind
caused mmap to fail, which caused tryAllocateExecutable to return a
null pointer, which led to a non-obvious crash later on.  Adding an
expect to check the result immediately will at least make it obvious
what went wrong.
2014-04-11 19:52:53 -06:00
Joel Dice
a71e75140e fix Android bootimage build
bb86500 was a step in the right direction, but there was a bug that
caused Type_pad fields to be inserted between every other field in for
a derived class when type-maps.cpp was generated, and this led to
miscompilation of e.g. Android's
java.lang.reflect.Constructor.getModifiers.
2014-04-11 19:48:06 -06:00
Joel Dice
8f4ed4dd4f fix incorrect EXPORT definition for Windows/x86_64 in boot-javahome.cpp
We should define EXPORT to be __declspec(dllexport) on Windows
regardless of architecture, not just non-x86_64 arches.  This fixes
errors to to embedded JAVA_HOME files not being found in openjdk-src
builds, e.g. lib/currency.data.
2014-04-11 19:26:56 -06:00
Joshua Warner
f7614bf8a7 Merge pull request #224 from bigfatbrowncat/avian-pack
Properties don't work in some cases
2014-04-10 08:09:18 -06:00
Vasily Litvinov
74209edb7d Replacing strcpy with memcpy - should be slightly faster because we're forced to know strlen, so no need in byte-by-byte copying 2014-04-10 01:02:11 +04:00
Vasily Litvinov
647e22bf81 Fixed memory leak (which triggered asserts in tests) 2014-04-09 19:36:34 +04:00
Vasily Litvinov
5828ef1d46 Fixing property copying 2014-04-09 16:02:48 +04:00
Ilya Mizus
6e3b170393 Trying to solve the properties memory problem 2014-04-09 10:16:53 +04:00
Joel Dice
617bd85578 initialize class in JNIEnv::FindClass
Although the JNI reference documentation does not mention it,
FindClass should initialize the class before it returns it.  That's
what HotSpot does, and that's what we have to do too.

In particular, OpenJDK's
Java_java_net_Inet6AddressImpl_lookupAllHostAddr relies on
Inet6Address's static initializer being run when it is resolved using
FindClass, or else it will crash.
2014-04-08 15:59:00 -06:00
Joshua Warner
e86fce28ec Merge pull request #220 from dicej/unsafe
fix some Unsafe bugs
2014-04-07 15:23:00 -06:00
Joel Dice
ca4f2224d9 Merge pull request #217 from bigfatbrowncat/avian-pack
Some improvements for Android lib core support
2014-04-07 14:51:12 -06:00
Joel Dice
1d9bdf8382 fix some Unsafe bugs
* Unsafe.arrayIndexScale was always returning the native word size,
   due to a thinko on my part

 * Unsafe.getLongVolatile and putLongVolatile did not work for array
   elements on 32-bit systems
2014-04-07 14:41:42 -06:00
Vasily Litvinov
b40a0ef590 Fixing compile error 2014-04-07 23:29:23 +04:00
Vasily Litvinov
5dd25f04ef Ignoring requests to load native conscrypt_jni library - it's linked statically 2014-04-07 23:25:57 +04:00
Joel Dice
8f4c0e78ce clean up System.getProperties and related methods
The behavior of Avian's versions of these methods was egregiously
non-standard, and there were problems with the Android implementations
as well.
2014-04-04 13:43:59 -06:00
Ilya Mizus
66edf1ff4a Fix for https://github.com/ReadyTalk/avian/issues/216 2014-04-04 20:21:16 +04:00
Joel Dice
a7e86e6cd4 implement Unsafe.{get|put}*Volatile 2014-03-31 17:31:28 -06:00
Ilya Mizus
81c8fc20ab Merge remote-tracking branch 'refs/remotes/ReadyTalk/master' into avian-pack 2014-03-26 09:20:38 +03:00
Joshua Warner
56cd1d51e0 fix lzma build 2014-03-25 15:10:24 -06:00
Joel Dice
fd778c2c76 remove redundant interfaces and generalize shift/reset generics
Turns out Function can do the jobs of both CallbackReceiver and
FunctionReceiver, so I've removed the latter two.

Also, shift and reset should work with a combination of types, not
just a single type, so I've expanded their generic signatures.
2014-03-21 07:38:29 -06:00
Joel Dice
fcb7059573 revert unintended change to jnienv.cpp 2014-03-21 07:38:28 -06:00
Joel Dice
ff57447507 fix handling of multiple shifts delimited by a single reset 2014-03-21 07:38:28 -06:00
Ilya Mizus
35b567c778 Merge branch 'master' of https://github.com/ReadyTalk/avian into avian-droid-2 2014-03-20 09:18:20 +04: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
Ilya Mizus
ffc439ad23 Merge branch 'master' of https://github.com/ReadyTalk/avian into avian-droid-2 2014-03-19 00:17:22 +04:00
Joshua Warner
a368dc0625 remove unused 'audit-codegen' tool 2014-03-16 19:42:03 -06:00
Joshua Warner
c37b13301a remove old unused code
Conflicts:
	include/avian/codegen/lir.h
2014-03-16 19:41:48 -06:00
Ilya Mizus
763c95d98e Replaced printf with __mingw_printf to avoid strange crushes 2014-03-16 00:52:58 +03:00
Ilya Mizus
abc9316702 NativeCrypto added for Windows 2014-03-15 21:21:24 +03:00
Joel Dice
58079887a9 fix broken Class.getDeclar{ed|ing}Classes implementations
classpath-common.h's getDeclaringClass was trying to look up
non-existing classes, which led to an abort, and I don't even know
what Class.getDeclaredClasses was trying to do, but it was ugly and
wrong.
2014-03-14 11:10:54 -06:00
Joshua Warner
56ec7fc1f9 Merge pull request #200 from dicej/stack-signal
fix a few stack walking and signal handling bugs
2014-03-14 10:45:18 -06:00
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
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
Joshua Warner
492294bfe6 Merge pull request #189 from jentfoo/interface_improvements
interface improvements and LockSupport implementation
2014-03-07 20:48:40 -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
57f50ca7ea Some small cleanup before pull request 2014-03-06 18:33:23 +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
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
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
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
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
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
Joshua Warner
a807966143 use Slice<uint8_t> in FixedAllocator 2014-02-25 20:34:03 -07:00
Joshua Warner
b083f3df04 move fixed allocator out of machine.h 2014-02-25 20:34:03 -07:00
Joshua Warner
52b23b8a6a move Allocator to include, properly namespaced 2014-02-25 19:13:41 -07:00
Ilya Mizus
2eaeaa2b12 Merge remote-tracking branch 'refs/remotes/ReadyTalk/master' into avian-droid 2014-02-26 01:27:32 +03:00
Joshua Warner
d95a8a9626 Merge pull request #179 from dicej/android-thread-join
fix Thread.join when using Android class library
2014-02-25 15:20:21 -07:00
Joel Dice
1445835c4f fix Thread.join when using Android class library
Android's Thread.join expects the VM to null-out Thread.vmThread when
the thread exits.  Otherwise, it will block forever.
2014-02-25 14:58:32 -07:00
Joel Dice
3912f2c0e4 Merge pull request #171 from joshuawarner32/master
Flatten "vm" dir and split signal handling out of vm::System
2014-02-25 14:11:09 -07:00
Joel Dice
c021329d0d add Avian_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8
Android's class library uses this to find out whether the VM supports
compareAndSwapLong natively.  Avian does on all platforms, so we just
return true.
2014-02-24 14:16:40 -07:00
Joshua Warner
f1806ce90e fix #172, regression in compiling shift operations 2014-02-24 13:24:14 -07:00
Joshua Warner
bc9f7d2f87 refactor SignalRegistrar interface 2014-02-21 23:37:32 -07:00
Joshua Warner
ca7d51edb3 add crash function to match the semantics of System::abort 2014-02-21 23:37:28 -07:00
Joshua Warner
730dade53e break out signal handling from System 2014-02-21 23:36:40 -07:00
Joshua Warner
5ffdfecdc2 remove vm from code paths, to match namespacing 2014-02-21 13:32:28 -07:00
Ilya Mizus
66f25193df OsConstants removed from blacklist 2014-02-21 23:14:07 +03:00
Ilya Mizus
a1d98280ab Merge remote-tracking branch 'refs/remotes/ReadyTalk/master' into avian-droid 2014-02-21 03:53:12 +03:00
Ilya Mizus
ff4c07f05b Changes to build on my libcore version 2014-02-21 03:50:06 +03:00
Joel Dice
1735a7976a do not omit calls to empty methods which may trigger class initialization
There's a small optimization in compileDirectInvoke which tries to
avoid generating calls to empty methods.  However, this causes
problems for code which uses such a call to ensure a class is
initialized -- if we omit that call, the class may not be
initialized and any side effects of that initialization may not
happen when the program expects them to.

This commit ensures that the compiler only omits empty method calls
when the target class does not need initialization.  It also removes
commented-out code in classpath-openjdk.cpp which was responsible for
loading libmawt proactively; that was a hack to get JogAmp to work
before we understood what the real problem was.
2014-02-10 08:40:14 -07:00
Joel Dice
66bd7e0814 use "lzma." prefix for LZMA-compressed embedded jars
Previously, we used "lzma:", which worked fine on Windows (where the
path separator is ";") but not on Unix-style OSes (where the path
separator is ":").  In the latter case, the VM would parse
"[lzma:bootJar]" as a path containing two elements, "[lzma" and
"bootJar]", which is not what was intended.  So now we use "lzma." as
the prefix, which works on all OSes.
2014-01-18 19:41:43 -07:00
Joel Dice
2b1177039e use armv7 memory barriers by default
armv7 and later provide weaker cache coherency models than armv6 and
earlier, so we cannot just implement memory barriers as no-ops.  This
patch uses the DMB instruction (or the equivalent OS-provided barrier
function) to implement barriers.  This should fix concurrency issues
on newer chips such as the Apple A6 and A7.

If you still need to support ARMv6 devices, you should pass
"armv6=true" to make when building Avian.  Ideally, the VM would
detect what kind of CPU it was executing on at runtime and direct the
JIT compiler accordingly, but I don't know how to do that on ARM.
Patches are welcome, though!
2014-01-10 17:32:54 -07:00
Joel Dice
bb86500155 fix Method.getModifiers crash due to bootimage miscompile
When calculating field offsets in the bootimage generator, we failed
to consider alignment at inheritence boundaries (i.e. the last field
inherited by from a superclass should be followed by enough padding to
align the first non-inherited field at a machine word boundary).  This
led to a mismatch between native code and Java code in terms of class
layouts, including that of java.lang.reflect.Method.
2014-01-07 09:04:13 -07:00
Joshua Warner
233a12bf2b remove unnecessary variable initialization 2014-01-03 14:04:57 -07:00
Joshua Warner
6d5f511d04 fix silly error in recent compiler refactor 2014-01-03 12:23:36 -07:00
Joel Dice
708519d812 implement Unsafe.objectFieldOffset for the Avian class library 2014-01-03 11:13:21 -07:00
Joel Dice
789c36a459 move Unsafe.putObjectVolatile and putOrderedObject implementations
This makes them available to all class libraries, not just OpenJDK.
2014-01-02 18:00:53 -07:00
Joel Dice
cc5b58725a implement Unsafe.putOrderedLong and putVolatileLong
The former just defers to the latter for now, since it provides
strictly weaker guarantees.  Thus it's correct to use full
volatile-style barriers, though not as efficient as it could be on
some architectures.
2014-01-02 17:49:56 -07:00
Joel Dice
ab4adef373 remove obsolete idle statement from Unsafe.getLongVolatile
Now that Josh has fixed the busy block bug (see commit 10d15d2), we
don't need this anymore.
2014-01-02 17:47:42 -07:00
Joel Dice
e19bdda13e fix uninitialized value warning in compile.cpp
Clang was complaining that newIp might be used uninitialized at the
bottom of our giant, unstructured compile loop, so I initialized it
with a bogus value, which means it will at least fail consistently if
Clang is right and there really is a path by which that code is
reached without otherwise initializing newIp.
2014-01-02 17:44:33 -07:00
Joshua Warner
fa65c67fbf Extract independent runtime thunks into their own file 2013-12-18 22:46:58 -07:00
Joshua Warner
f1c6b97373 Reformat a few extra-long lines 2013-12-18 22:25:23 -07:00
Joshua Warner
b3d6f5d94d Remove redundancy in compiling jump operations 2013-12-18 22:20:18 -07:00
Joshua Warner
ac984775a5 Remove redundancy in compiling arithmetic operations 2013-12-18 22:03:42 -07:00
Joshua Warner
eab36b3a23 Remove boilerplate code (nullaryOp methods in Compiler) 2013-12-18 16:51:20 -07:00
Joshua Warner
bd7b66a898 Remove boilerplate code (unaryOp methods in Compiler) 2013-12-18 16:43:15 -07:00
Joshua Warner
07d0f1172f Remove boilerplate code (float binaryOp methods in Compiler) 2013-12-18 15:22:38 -07:00
Joshua Warner
d5c1a094ca Remove boilerplate code (general binaryOp methods in Compiler) 2013-12-18 15:11:30 -07:00
Joshua Warner
b66a8549fd Remove boilerplate code (jump* methods in Compiler) 2013-12-18 14:38:05 -07:00
Joel Dice
38477c113c fix iOS 7 build using latest Xcode
It looks like the iOS 7 SDK doesn't have GCC anymore, so we need to
use clang instead.  Also, thread_act.h and thread_status.h have moved,
so I updated arm.h accordingly.  That might break the build for older
SDKs, but I don't have one available at the moment.  If it does break,
I'll fix it.
2013-12-18 11:10:04 -07:00
Joel Dice
15906ddb12 fix build regression on platforms with no native 64-bit CAS
Unsafe.compareAndSwapLong was moved from classpath-openjdk.cpp to
builtin.cpp, but the fieldForOffset helper function was not, which
only caused problems when I tried to build for ARM.  This commit moves
said helper function, along with Unsafe.getVolatileLong, which also
uses it.
2013-12-18 11:06:15 -07:00
Joel Dice
dae1f81d27 Merge pull request #138 from soc/topic/unsafe-compareAndSwap
Move Unsafe.compareAndSwapLong from classpath-openjdk.cpp to builtin.cpp
2013-12-18 08:35:01 -08:00
Simon Ochsenreither
55e9923ee6 Move Unsafe.compareAndSwapLong from ...
... classpath-openjdk.cpp to builtin.cpp.
2013-12-18 05:19:45 +01:00
Joshua Warner
0645b0e4cf prevent busywait loops from blocking the VM in interpret mode 2013-12-13 11:48:26 -07:00
Joshua Warner
0340be23ce make sure a busy-waiting loop can't block the GC (and hence the whole VM) 2013-12-13 10:39:36 -07:00
Joshua Warner
06432253ba consolidate many implicit list types into one 2013-12-11 10:54:50 -07:00
Joel Dice
19274ee3d6 Merge pull request #129 from joshuawarner32/openjdk-osx10.9-build-fix
Openjdk osx10.9 build fix
2013-12-07 19:42:08 -08:00
Joshua Warner
773417ab2b fix openjdk-src build failures on osx 10.9 2013-12-07 16:43:18 -07:00
Joshua Warner
9a899a2e4a fix FileInputStream for newer openjdk7 versions 2013-12-07 16:22:08 -07:00
Joel Dice
7056315c18 fix various Android test suite regressions and add more reflection tests
Most of these regressions were simply due to testing a lot more stuff,
esp. annotations and reflection, revealing holes in the Android
compatibility code.  There are still some holes, but at least the
suite is passing (except for a fragile test in Serialize.java which I
will open an issue for).

Sorry this is such a big commit; there was more to address than I
initially expected.
2013-12-06 18:48:47 -07:00
Joel Dice
abe8bc6fda fix exception wrapping for Method.invoke and static initializers
Method.invoke should initialize its class before invoking the method,
throwing an ExceptionInInitializerError if it fails, without wrapping
said error in an InvocationTargetException.

Also, we must initialize ExceptionInInitializerError.exception when
throwing instances from the VM, since OpenJDK's
ExceptionInInitializerError.getCause uses the exception field, not the
cause field.
2013-12-05 22:28:13 -07:00
Joshua Warner
8cda2446d5 implement sun.misc.Unsafe.throwException 2013-12-05 20:28:08 -07:00
Johannes Schindelin
18aeeae0e8 Implement Runtime#{free,total}Memory()
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-12-04 15:19:06 -06:00
Joshua Warner
2800ffe826 rename JNIEXPORT to AVIAN_EXPORT in common.h, to avoid conflicting with jni.h 2013-11-08 08:35:17 -07:00
Joshua Warner
3c1afdd272 make jni.h and avian/machine.h non-interfering 2013-11-07 19:15:31 -07: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
c78923d717 ObjectInputStream: add rudimentary support for objects
This is by no means a complete support for the deserialization compliant
to the Java Language Specification, but it is better to add the support
incrementally, for better readability of the commits.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-06 09:10:51 -06:00
Johannes Schindelin
efb3ef9b51 Initialize the context class loader to the app class loader
Previously, we initialized it to the boot class loader, but that is
inconsistent with Java; if compiling against OpenJDK's class library,
the context class loader is therefore initialized to the app class
loader, too.

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