Commit Graph

733 Commits

Author SHA1 Message Date
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
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
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
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
Joshua Warner
41adb74eb1 remove powerpc support 2014-04-29 13:26:40 -06:00
Joshua Warner
34962ff334 Merge pull request #245 from dicej/jdk8
add support for using the OpenJDK 8 class library
2014-04-24 18:50:38 -06:00
Joel Dice
7de555c797 add support for using the OpenJDK 8 class library
This ensures that all tests pass when Avian is built with an
openjdk=$path option such that $path points to either OpenJDK 7 or 8.

Note that I have not yet tried using the openjdk-src option with
OpenJDK 8.  I'll work on that next.
2014-04-23 15:36:56 -06:00
Joel Dice
9b7d0d1624 update copyright years 2014-04-23 15:33:41 -06:00
Joel Dice
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
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
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
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
Joshua Warner
7fa8c7ec20 remove unused constants (fixes #198) 2014-03-14 09:06:19 -06: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
Joshua Warner
e6eead07fa call vm::dynamicCall directly, instead of through System 2014-02-26 15:10:41 -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
bc9f7d2f87 refactor SignalRegistrar interface 2014-02-21 23:37:32 -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
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
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
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
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
Geoff Nixon
69ea1f5721 Bugfixes for Mac OS X, etc. 2013-10-31 01:35:56 -07:00
Joel Dice
87b02eb949 update copyright years
Previously, I used a shell script to extract modification date ranges
from the Git history, but that was complicated and unreliable, so now
every file just gets the same year range in its copyright header.  If
someone needs to know when a specific file was modified and by whom,
they can look at the Git history themselves; no need to include it
redundantly in the header.
2013-07-02 20:52:38 -06:00
Joel Dice
84e23659f9 remove unecessary PROTECT statements
Since there's no possibility of garbage collection during the
lifetimes of these local variables, there's no need to protect the
references.
2013-05-14 14:33:37 -06:00
Simon Ochsenreither
e088fa07ae Make exception messages match the ones from OpenJDK/Android
This commit changes the exception message format of
ClassCastException and CloneNotSupportedException.
2013-05-14 15:04:34 +02:00
Joel Dice
fcfdd6be3a initialize the class if necessary when the "new" operator is invoked
This is one of the conditions specified in
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.1,
which I had forgotten about.
2013-05-13 13:12:58 -06:00
Joel Dice
bbc5d7fb50 only initialize class when necessary to avoid deadlock
Previously, we would attempt to initialize a class (e.g. call its
static initializer) whenever a method in that class was called, as
well as in any of the cases listed in
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.

However, the above approach may lead to deadlock in an app which
relies on being able to call non-static methods in parallel with a
static initializer invocation in the same class.  Thus, this commit
ensures that we initialize classes only in the cases defined by the
standard.
2013-04-30 22:48:43 -06:00
Joel Dice
023787d121 fix special case of exception handler table translation
scalac may generate bytecode such that an exception is thrown within
the bounds of a handler for that exception such that the throw is the
last instruction in the method, which we weren't handling properly.
2013-04-22 21:25:15 -06:00
Joel Dice
49d8ccb1bd update Context::executableSize after allocating objectPool
This ensures that, if an exception is thrown later but before the
method has been fully compiled, we will know exactly how much memory
to free.  Previously, we would abort when trying to free the wrong
amount due to an assertion failure.
2013-04-09 18:43:46 -06:00
Joel Dice
b436bd460a fix NaN handling in floating point comparisons 2013-04-03 16:19:33 -06:00
Joel Dice
cc8d655762 use %x,%x format for listing start and end addresses
This matches the format expected by recent versions of GDB's
disassemble command.
2013-04-03 16:07:06 -06:00
Joel Dice
ca84dd26f1 fix System.loadLibrary for OpenJDK tails=true build 2013-03-05 15:43:49 -07: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
5e2d00010b move headers from src to src/avian
This is necessary to avoid name conflicts on various platforms.  For
example, iOS has its own util.h, and Windows has a process.h.  By
including our version as e.g. "avian/util.h", we avoid confusion with
the system version.
2013-02-27 13:33:29 -07:00
Joshua Warner
4c8b593539 break Architecture out of Assembler 2013-02-23 23:03:01 -07:00
Joshua Warner
b9e281612b move runtime-array to include 2013-02-19 22:56:05 -07:00
Joshua Warner
987af120d8 move codegen headers to include/ 2013-02-19 22:21:22 -07:00
Joshua Warner
d7f088c9e7 adjust package structure in codegen (vm -> avian::codegen and avian::codegen::lir)
The eventual intent with the lir namespace is to formalize some of
the important bits of Assembler interface, to be tested, debug-printed,
and potentially, serialized.

Also, group arguments to apply(...) in OperandInfos
2013-02-12 17:47:57 -07:00
Joshua Warner
3589d5c205 Merge branch 'master' of git://github.com/ReadyTalk/avian
Conflicts:
	src/codegen/arm/assembler.cpp
	src/common.h
	src/machine.cpp
2013-02-12 17:37:19 -07:00
Joshua Warner
f7b49ddb06 allow codegen targets (Architectures and Assemblers) to co-exist
The primary motivation behind this is to allow all the different Assemblers
to be built at once, on a single machine. This should dramatically reduce
the time required to make sure that a particular change doesn't break
the build for one of the not-so-common architectures (arm, powerpc)

Simply pass "codegen-targets=all" to make to compile all
src/codegen/<arch>/assembler.cpp.

Note that while these architectures are built, they will not be fully-
functional.  Certain stuff is assumed to be the same across the entire
build (such as TargetBytesPerWord), but this isn't the case anymore.
2013-02-12 17:16:40 -07:00
Joshua Warner
68776e5d73 move all codegen source in to codegen/ dir 2013-02-10 18:55:38 -07:00
Joshua Warner
964d054117 move RUNTIME_ARRAY into it's own header 2013-02-10 18:07:11 -07:00
Joshua Warner
5dd770d7ea rename cast -> fieldAtOffset 2013-02-10 18:07:03 -07:00
Joshua Warner
d26d8fdb9f rename ceiling -> ceilingDivide 2013-02-10 18:06:15 -07:00
Alexey Pelykh
4228f69a0d Additional AOT_ONLY ifdef 2013-02-09 09:42:26 +02:00
Alexey Pelykh
4d03650544 Replaced TODO comments with messages ; More correct AVIAN_AOT_ONLY usage 2013-02-09 09:42:21 +02:00
Joel Dice
7b07b5b9a3 print more of the stack map when DebugFrameMaps is enabled 2012-12-12 16:04:26 -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
3665753d1f fix MSVC build regression 2012-10-13 13:09:24 -06:00
Joel Dice
8f308291b0 eliminate call stack recursion in compile method
Some OSes (notably, Windows CE) restrict the size of the call stack
such that recursive compilation of branch instructions can lead to
stack overflow in methods with large numbers of such instructions.  In
fact, a worst-case method could even lead to overflow when the stack
size limit is relatively generous.

The solution is to convert this recursion into iteration with an
explicit stack to maintain state about alternate paths through each
branch.
2012-10-13 09:46:12 -06:00
Joel Dice
bac4099acb fix crash in findFrameMapInSimpleTable due to bug in instanceof implementation
We weren't adding entries to the frame map for calls to the instanceof
thunk when compiling methods.  However, that thunk may trigger a GC,
in which case we'll need to unwind the stack, which will lead to a
crash if we don't have a frame map entry for that instruction.
2012-08-17 12:47:38 -06:00
Joel Dice
20a290b992 use signbit instead of isinf to determine floating point sign
glibc's use of isinf's return value to indicate sign is a non-standard
extension which can't be relied upon on other platforms.
2012-08-12 14:52:48 -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
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
265ab63e19 fix crash when AOT compiling switch statement with only a default case
The existing code handled such odd switch statements correctly in the
JIT case, but did the wrong thing for the AOT case, leading to an
assertion failure later on.
2012-07-19 13:26:06 -06:00
Joel Dice
86be0c409c fix incorrect jvalue marshalling in compile.cpp
4512a9a introduced a new ArgumentList constructor which was handling
some types incorrectly (e.g. implicitly converting floats to
integers).  This commit fixes it.
2012-07-06 10:56:04 -06:00
Joel Dice
365f863080 disable constant offset check when cross-compiling for a different word size 2012-06-28 16:21:24 -06:00
Joshua Warner
fe1f069309 abort on startup if Thread field offset constants don't match the real runtime values 2012-06-20 13:16:08 -06:00
Joel Dice
886dd184aa fix incorrect stack unwinding for asynchronous stack traces
Our Thread.getStackTrace implementation is tricky because it might be
invoked on a thread executing arbitrary native or Java code, and there
are numerous edge cases to consider.  Unsurprisingly, there were a few
lingering, non-fatal bugs revealed by Valgrind recently, one involving
the brief interval just before and after returning from invokeNative,
and the other involving an off-by-one error in x86.cpp's nextFrame
implementation.  This commit fixes both.
2012-06-18 14:27:18 +00:00
Joel Dice
4512a9a38e implement NewObjectA, Get<type>MethodA, and GetStatic<type>MethodA 2012-06-15 17:41:40 -06:00
Joel Dice
c00f811a2f initialize count_ from starting point in MyStackWalker(MyStackWalker*)
When we're initializing a stack walker based on an existing instance,
we should initialize all the fields from that instance, including
count_.
2012-06-14 09:58:20 -06:00
Joel Dice
d61501453f add support for LZMA on Windows 2012-06-02 15:43:42 -06:00
Joel Dice
5d9f7b2bc3 add optional LZMA support for compressing embedded JARs, boot images, and shared objects 2012-06-02 09:06:22 -06:00
Joel Dice
879df617df add use-clang option for building with LLVM Clang instead of GCC
This also fixes several errors and warnings emitted by Clang.
2012-06-01 17:43:42 -06:00
Joel Dice
0addd8c814 update copyright years 2012-05-11 17:43:27 -06:00
Joel Dice
f0152f1d33 Merge branch 'jdk7' 2012-05-11 16:41:18 -06:00
Joel Dice
90fae940a7 throw IncompatibleClassChangeError on unexpected static status
If a class references a field or method as static and we find it's
actually non-static -- or vice-versa -- we ought to throw an error
rather than abort.
2012-05-11 13:19:55 -06:00
Joshua Warner
fa9814b86d remove lots of unnecessary sizeof computations with a convenient 'operator new' overload 2012-05-08 16:14:54 -06:00
Joshua Warner
64b9407420 Merge branch 'master' into jdk7 2012-05-07 15:05:56 -06:00
Joshua Warner
fde7a3e7a1 give virtualThunks names based on index, to avoid conflicts 2012-05-07 15:05:40 -06:00
Joshua Warner
7c38ea75e4 give thunks symbol names in the bootimage build, use Heap::allocate instead of malloc 2012-05-07 10:00:59 -06:00
Joel Dice
189340954a fix build regression due to last merge 2012-05-04 18:59:15 -06:00
Joel Dice
5ef5158bc1 Merge remote branch 'oss/master' into jdk7 2012-05-04 18:54:31 -06:00
Joel Dice
ea4e0a2f5d fix a couple of subtle Thread.getStackTrace bugs
The first problem was that, on x86, we failed to properly keep track
of whether to expect the return address to be on the stack or not when
unwinding through a frame.  We were relying on a "stackLimit" pointer
to tell us whether we were looking at the most recently-called frame
by comparing it with the stack pointer for that frame.  That was
inaccurate in the case of a thread executing at the beginning of a
method before a new frame is allocated, in which case the most recent
two frames share a stack pointer, confusing the unwinder.  The
solution involves keeping track of how many frames we've looked at
while walking the stack.

The other problem was that compareIpToMethodBounds assumed every
method was followed by at least one byte of padding before the next
method started.  That assumption was usually valid because we were
storing the size following method code prior to the code itself.
However, the last method of an AOT-compiled code image is not followed
by any such method header and may instead be followed directly by
native code with no intervening padding.  In that case, we risk
interpreting that native code as part of the preceding method, with
potentially bizarre results.

The reason for the compareIpToMethodBounds assumption was that methods
which throw exceptions as their last instruction generate a
non-returning call, which nonetheless push a return address on the
stack which points past the end of the method, and the unwinder needs
to know that return address belongs to that method.  A better solution
is to add an extra trap instruction to the end of such methods, which
is what this patch does.
2012-05-04 18:51:58 -06:00
Joel Dice
19de383aae Merge branch 'master' into jdk7
Conflicts:
	makefile
2012-05-04 11:33:16 -06:00
Joshua Warner
a09736e749 write java symbols to bootimage 2012-05-03 10:13:56 -06:00
Joel Dice
8cb6446bec handle zero-length arrays in truncate functions 2012-03-17 12:57:59 -06:00
Joel Dice
d78247ab9a implement -Xss command line option 2012-03-14 12:36:42 -06:00
Joel Dice
8590695f2d constrain exception handler bounds to bytecode length
Scala occasionally generates exception handler tables with interval
bounds which fall outside the range of valid bytecode indexes, so we
must clamp them or risk out-of-bounds array accesses.
2012-03-11 05:00:08 -06:00
Joel Dice
e8e3c9066f implement sun.misc.Unsafe raw memory access methods
The primitive get/put methods are implemented as intrinsics by the
compiler for performance.
2012-03-06 13:07:59 -07:00
Joel Dice
5203cb5dcf implement JNI methods NewWeakGlobalRef and DeleteWeakGlobalRef 2012-02-29 11:51:30 -07:00
Joel Dice
5a5d2a8dd2 fix JNI float argument passing
Floats are implicitly promoted to doubles when passed as part of a
variable-length argument list, so we can't treat them the same way as
32-bit integers.
2012-02-28 15:35:28 -07:00
Joel Dice
4d0b127989 support multiple sequential VM instances with bootimage build
Until now, the bootimage build hasn't supported using the Java
invocation API to create a VM, destroy it, and create another in the
same process.  Ideally, we would be able to create multiple VMs
simultaneously without any interference between them.  In fact, Avian
is designed to support this for the most part, but there are a few
places we use global, mutable state which prevent this from working.
Most notably, the bootimage is modified in-place at runtime, so the
best we can do without extensive changes is to clean up the bootimage
when the VM is destroyed so it's ready for later instances.  Hence
this commit.

Ultimately, we can move towards a fully reentrant VM by making the
bootimage immutable, but this will require some care to avoid
performance regressions.  Another challenge is our Posix signal
handlers, which currently rely on a global handle to the VM, since you
can't, to my knowledge, pass a context pointer when registering a
signal handler.  Thread local variables won't necessarily help, since
a thread might attatch to more than one VM at a time.
2011-11-10 13:33:36 -07:00
Joel Dice
8501ce8711 avoid using runtime-generated thunks for bootimage native methods 2011-10-03 08:05:49 -06:00
Joel Dice
db9f9a300d Revert "remove distinction between thunks and bootThunks in compile.cpp"
This reverts commit 88d614eb25.

It turns out we still need separate sets of thunks for AOT-compiled
and JIT-compiled code to ensure we can always generate efficient jumps
and calls to thunks on architectures such as ARM and PowerPC, whose
relative jumps and calls have limited ranges.
2011-10-01 18:11:02 -06:00
Joel Dice
b063f10ad5 fix Windows build 2011-09-30 14:44:25 -06:00
Joel Dice
88d614eb25 remove distinction between thunks and bootThunks in compile.cpp
Now that the AOT-compiled code image is position-independent, there is
no further need for this distinction.  In fact, it was harmful,
because we were still using runtime-generated thunks when we should
have been using the ones in the code image.  This resulted in
EXC_BAD_ACCESS errors on non-jailbroken iOS devices.
2011-09-30 13:17:28 -06:00
Joel Dice
0372d999d3 use TargetBytesPerWord instead of BytesPerWord where appropriate 2011-09-23 23:25:52 -06:00
Joel Dice
3fa4a7001d fix x86->powerpc boot image cross build
This fixes the remaining cross-endian translation issues needed to
build powerpc boot images on x86.
2011-09-23 22:31:24 -06:00
Joel Dice
559af69269 various ARM fixes 2011-09-20 19:50:38 -06:00
Joel Dice
c537dcfd34 generate read-only code image in bootimage build
This avoids the requirement of putting the code image in a
section/segment which is both writable and executable, which is good
for security and avoids trouble with systems like iOS which disallow
such things.

The implementation relies on relative addressing such that the offset
of the desired address is fixed as a compile-time constant relative to
the start of the memory area of interest (e.g. the code image, heap
image, or thunk table).  At runtime, the base pointer to the memory
area is retrieved from the thread structure and added to the offset to
compute the final address.  Using the thread pointer allows us to
generate read-only, position-independent code while avoiding the use
of IP-relative addressing, which is not available on all
architectures.
2011-09-20 16:30:30 -06:00
Joel Dice
349d381d95 progress towards cross-endian bootimage builds
This fixes a number of bugs concerning cross-architecture bootimage
builds involving diffent endianesses.  There will be more work to do
before it works.
2011-09-16 20:53:08 -06:00
Joel Dice
ab840c91db Merge branch 'oss-master' into ios 2011-09-12 20:27:59 -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
84a6daa400 fix unused parameter warning 2011-09-01 11:36:00 -06:00
Joel Dice
e505cbe99d more progress towards cross-architecture bootimage builds
This commit fixes a lot of bugs.  All tests are now pass for Linux
x86_64 to Linux i386 cross builds.
2011-08-31 21:18:00 -06:00
Joel Dice
5b4f17997f progress towards cross-architecture bootimage builds
This monster commit is the first step towards supporting
cross-architecture bootimage builds.  The challenge is to build a heap
and code image for the target platform where the word size and
endianess may differ from those of the build architecture.  That means
the memory layout of objects may differ due to alignment and size
differences, so we can't just copy objects into the heap image
unchanged; we must copy field by field, resizing values, reversing
endianess and shifting offsets as necessary.

This commit also removes POD (plain old data) type support from the
type generator because it added a lot of complication and little
value.
2011-08-29 19:00:17 -06:00
Joel Dice
3df3892d34 throw AbstractMethodError when appropriate in prepareMethodForCall
Otherwise, we'll crash later when we try to compile an abstract
method.
2011-08-12 14:19:21 -06:00
Joel Dice
c3824c6844 fix crash when encountering invokespecial call to abstract method
We must throw an AbstractMethodError when such a call is executed (not
when the call is compiled), so we compile this case as a call to a
thunk which throws such an error.
2011-07-17 19:54:55 -06:00
Joel Dice
a2933c1f9e update copyright years in compile.cpp 2011-07-16 19:08:39 -06:00
Joel Dice
3ec4ef9bd2 fix stack unwinding from native methods for tails=true build
We can't clear t->trace->targetMethod until after findUnwindTarget has
been called or we'll lose track of where we are on the stack.
2011-07-13 18:06:02 -06:00
Joel Dice
92adc83caf remove NPE debug logging 2011-05-29 11:16:52 -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
7c30e44601 add appropriate memory barriers to double-checked locking code 2011-04-10 14:46:53 -06:00
Joel Dice
8091803b59 set MaxNativeCallFootprint to 5 on 32-bit systems
Thunks such as divideLong now take a pointer and two int64_t
arguments, which amounts to 5 words of stack space on a 32-bit system.
2011-04-10 12:55:42 -06:00
Joel Dice
3febd7cea7 load libfontmanager.so before trying to resolve FontManager.initIDs
sun.font.FontManager.initIDs is a native method defined in
libfontmanager.so, yet there seems to be no mechanism in OpenJDK's
class library to actually load that library, so we lazily load it
before trying to resolve the method.
2011-04-10 11:26:44 -06:00
Joel Dice
239fd98781 fix compilation of unusual exception handlers
As described in commit 36aa0d6, apps such as jython which generate
bytecode dynamically can produce patterns of bytecode for which the
VM's compiler could not handle properly.  However, that commit
introduced a regression and had to be partially reverted.

It turns out the real problem was the call to Compiler::restoreState
which we made before checking whether we were actually ready to
compile the exception handler (we delay compiling an exception handler
until and unless the try/catch block it serves has been compiled so we
can calculate the stack maps properly).  That confused the compiler in
rare cases, so we now only call restoreState once we're actually ready
to compile the handler.
2011-04-09 12:44:28 -06:00
Joel Dice
97aec1691e fix jsr/ret stack mapping regression
My last commit introduced a regression in JIT compilation of
subroutines.  This reverts the specific change which caused the
regression.  Further work will be needed to address the case which
that change was intended to fix (namely, exception handlers which
apply to multiple try/catch blocks).
2011-04-08 20:15:36 -06:00
Joel Dice
36aa0d6792 improve handling of unusual bytecode in JIT compiler
Bytecode generated by compilers other than javac or ecj (such as
jython's dynamically generated classes) can contain unreachable code
and exception handlers which apply to more than one try/catch scope.
Previously, the VM's JIT compiler did not handle either of these cases
well, hence this commit.
2011-04-08 18:50:22 -06:00
Joel Dice
ef86530080 call static initializer of superclass before that of class itself
Also, assume any class which has an ancestor class which has a static
initializer needs initialization even if it doesn't have one itself,
per the Java Language Spec.
2011-03-31 19:43:49 -06:00
Joel Dice
1c7abe782d specify valid code source for system classes
This enables use of a class's protection domain to determine what JAR
or directory it came from.
2011-03-31 19:38:44 -06:00
Joel Dice
d5ae053f11 handle invokevirtual calls to non-virtual methods
OpenJDK's sun.reflect.MethodAccessorGenerator can generate
invokevirtual calls to private methods (which we normally consider
non-virtual); we must compile them as non-virtual calls since they
aren't in the vtable.
2011-03-26 23:13:05 -06:00
Joel Dice
0f38673baa fix line number and exception handler scope regression
It turns out commit 31eb047 was too aggressive and led to incorrect
calculation of line numbers for machine addresses, as well as
potentially incorrect exception handler scope calculation.  This fixes
the regression.
2011-03-26 19:55:23 -06:00
Joel Dice
01b3f1cb93 fix GCC 4.6 unused variable warnings 2011-03-26 14:43:03 -06:00
Joel Dice
31eb047391 handle redundant, unreachable gotos in JIT compiler
I recently encountered a Batik JAR with a method containing a
redundant goto which confused the JIT compiler because it was refered
to in the exception handler and line number tables despite being
unreachable.  I don't know how such code was generated, but this
commit ensures the compiler can handle it.
2011-03-25 19:13:10 -06:00
Joel Dice
b9f8188544 don't try to release monitor if we get OOME when trying to acquire it
We can't blindly try release the monitors for all synchronized methods
when unwinding the stack since we may not have finished acquiring the
most recent one when the exception was thrown.
2011-03-25 18:40:51 -06:00
Joel Dice
86733a25f4 increase executable area size to 30MB
Big applications can exceed the 16MB limit we previously used.
Increasing this above 30MB (if/when desired) will require changes to
the ARM and PowerPC JIT code to work around immediate branch encoding
limits on those platforms,
2011-03-17 21:24:35 -06:00
Joel Dice
110e2e1d52 fix putstatic code order regression in compile.cpp
Also, ensure that class is initialized before getting or setting
static fields in lazy loading code.
2011-03-17 08:46:46 -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
255fc9f9d3 handle long conditional immediate branches properly on PowerPC
Due to encoding limitations, the immediate operand of conditional
branches can be no more than 32KB forward or backward.  Since the
JIT-compiled form of some methods can be larger than 32KB, and we also
do conditional jumps to code outside the current method in some cases,
we must work around this limitation.

The strategy of this commit is to provide inline, intermediate jump
tables where necessary.  A given conditional branch whose target is
too far for a direct jump will instead point to an unconditional
branch in the nearest jump table which points to the actual target.

Unconditional immediate branches are also limited on PowerPC, but this
limit is 32MB, which is not an impediment in practice.  If it does
become a problem, we'll need to encode such branches using multiple
instructions.
2011-02-27 23:03:13 -07:00