Commit Graph

557 Commits

Author SHA1 Message Date
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