Commit Graph

91 Commits

Author SHA1 Message Date
Joel Dice
afabe8e07e rework VM exception handling; throw OOMEs when appropriate
This rather large commit modifies the VM to use non-local returns to
throw exceptions instead of simply setting Thread::exception and
returning frame-by-frame as it used to.  This has several benefits:

 * Functions no longer need to check Thread::exception after each call
   which might throw an exception (which would be especially tedious
   and error-prone now that any function which allocates objects
   directly or indirectly might throw an OutOfMemoryError)

 * There's no need to audit the code for calls to functions which
   previously did not throw exceptions but later do

 * Performance should be improved slightly due to both the reduced
   need for conditionals and because undwinding now occurs in a single
   jump instead of a series of returns

The main disadvantages are:

 * Slightly higher overhead for entering and leaving the VM via the
   JNI and JDK methods

 * Non-local returns can make the code harder to read

 * We must be careful to register destructors for stack-allocated
   resources with the Thread so they can be called prior to a
   non-local return

The non-local return implementation is similar to setjmp/longjmp,
except it uses continuation-passing style to avoid the need for
cooperation from the C/C++ compiler.  Native C++ exceptions would have
also been an option, but that would introduce a dependence on
libstdc++, which we're trying to avoid for portability reasons.

Finally, this commit ensures that the VM throws an OutOfMemoryError
instead of aborting when it reaches its memory ceiling.  Currently, we
treat the ceiling as a soft limit and temporarily exceed it as
necessary to allow garbage collection and certain internal allocations
to succeed, but refuse to allocate any Java objects until the heap
size drops back below the ceiling.
2010-12-27 15:55:23 -07:00
Joel Dice
a5742f5985 update copyright years 2010-12-05 20:21:09 -07:00
Joel Dice
19dbc61e9f for heapdump=true builds, optionally generate dump on OOM
If the VM runs out of heap space and the "avian.heap.dump" system
property was specified at startup, the VM will write a heap dump to
the filename indicated by that property.  This dump may be analyzed
using e.g. DumpStats.java.
2010-11-18 10:55:00 -07:00
Joel Dice
6118792ffd update copyright years 2009-12-02 19:08:29 -07:00
Joel Dice
6d9e1270ca fix race conditions in atomic operations 2009-11-29 09:08:07 -07:00
Joel Dice
15eada93ed implement atomicCompareAndSwap on x86_32 for GCC versions prior to 4.1 and for MSVC 2009-11-20 10:40:01 -07:00
Joel Dice
e91157a390 avoid acquiring a mutex recursively in markDirty 2009-11-19 19:41:49 -07:00
Joel Dice
5f5cc57d12 only use atomic operations if the compiler supports them 2009-11-19 19:32:54 -07:00
Joel Dice
fdde34694c use atomic operations in MyHeap::mark to avoid need for mutex 2009-11-19 18:13:00 -07:00
Joel Dice
7b0378c180 support darwin/x86_64 2009-10-14 10:01:37 -06:00
Joel Dice
6aff383ee1 ensure Heap::needsMark and Heap::mark work correctly during GC 2009-09-01 18:31:18 -06:00
Joel Dice
1a0eef7e2d add support for building with MSVC on Windows 2009-08-26 18:26:44 -06:00
Joel Dice
30c7107aa3 enable DebugAllocation in heap.cpp when NDEBUG is not defined 2009-07-10 08:42:56 -06:00
Joel Dice
31976f585a add DebugAllocation option to heap.cpp to help detect allocation and deallocation errors 2009-06-11 17:23:02 -06:00
Joel Dice
58a90f2b84 fix regressions for non-bootimage case 2008-12-03 19:09:57 -07:00
Joel Dice
457c3d135e return Tenured from MyHeap::status if the object resides in the immortal heap 2008-12-02 19:41:22 -07:00
Joel Dice
d4363d250a mark and fix up absolute addresses in boot image code 2008-12-02 09:45:20 -07:00
Joel Dice
25ade1484a lots of bugfixes and refactoring 2008-12-01 19:38:00 -07:00
Joel Dice
0ef2ee1d02 refactor Segment::Map to support map data which is not allocated as part of the segment data 2008-11-29 13:37:03 -07:00
Joel Dice
702525fd32 support immortal heap area in heap.cpp 2008-11-28 19:31:06 -07:00
Joel Dice
80815d35f7 fix fixed object tracking in heap.cpp 2008-11-28 18:22:09 -07:00
Joel Dice
4d1af63ed2 initial work on booting from boot image 2008-11-28 15:02:45 -07:00
Joel Dice
18d25468fe optimize common case of setting a single object field so we don't acquire the heap lock unnecessarily 2008-04-23 18:08:24 -06:00
Joel Dice
0d3e6b7793 simplify memory allocation interfaces 2008-04-13 12:15:04 -06:00
Joel Dice
a388ca19ee fix build for GCC 4.3
Note that this requires removing the -Wconversion flag for now.  I'll
see about restoring it when I'm ready to tackle all those warnings.
2008-03-10 13:49:10 -06:00
Joel Dice
2edaa82801 prepend copyright notice and license to all source files; add license.txt and readme.txt 2008-02-19 11:06:52 -07:00
Joel Dice
94404b7f89 remove unused major collection interval code 2008-02-02 13:34:29 -07:00
Joel Dice
55e3e8871d trigger major GCs more aggressively under low memory conditions 2008-01-31 17:50:38 -07:00
Joel Dice
2f83468b80 remove context argument from Allocator::tryAllocate and Allocator::allocate, since we aren't using it after all 2008-01-14 16:37:24 -07:00
Joel Dice
a89c22b493 force major collection under low memory condition 2008-01-14 09:39:57 -07:00
Joel Dice
0298865efa refactor memory allocation to allow better detection and handling of low-memory conditions 2008-01-13 15:05:08 -07:00
Joel Dice
8e5ce11047 refactor memory management code
We now support immortal objects, which the GC will scan for references
but not consider for collection.  On x86_64, we allocate JIT code memory
via mmap, which lets us map memory into the bottom 2GB of the address
space, ensuring that 32-bit relative jumps and calls work.
2008-01-09 18:20:36 -07:00
Joel Dice
633990b5fe force a major GC whenever the tenured fixed object footprint doubles 2008-01-09 08:21:58 -07:00
Joel Dice
e3be0d197e maintain memory ceiling for tenured fixed objects and use it to trigger a major GC when appropriate 2008-01-08 17:02:27 -07:00
Joel Dice
a8e9cc521c move some generally useful bitset functions from heap.cpp to common.h 2008-01-06 12:21:38 -07:00
Joel Dice
6cecdc8295 relax rules for doing major collection; fix overconstrained assertion 2008-01-03 10:09:43 -07:00
Joel Dice
df20ce92f7 set Verbose=false 2008-01-01 18:48:04 -07:00
Joel Dice
eff3ba1418 fix thinko in visitDirtyFixies() 2008-01-01 18:45:23 -07:00
Joel Dice
e797a8f1ca fix GC bugs involving old fixed objects pointing to new objects 2008-01-01 18:08:27 -07:00
Joel Dice
e4fbadd051 JIT-related GC safety fixes 2007-12-16 15:41:07 -07:00
Joel Dice
b3918a0d7d support encoding instructions with indexed and scaled memory offsets 2007-12-13 18:59:56 -07:00
Joel Dice
22edd2e6a4 set Verbose to false in heap.cpp 2007-12-08 16:19:48 -07:00
Joel Dice
00b7fa3b9d assert that fixed object has object mask before marking it 2007-12-07 15:58:38 -07:00
Joel Dice
c096c8f1e4 only consider gen2 oversized if its capacity exceeds (InitialGen2CapacityInBytes / BytesPerWord) 2007-12-07 08:35:28 -07:00
Joel Dice
612f4fa0b8 shrink gen2 segment if it grows too large 2007-12-07 08:31:41 -07:00
Joel Dice
94bae01b39 never call wasCollected() on a fixed object, since it will give a random result 2007-10-29 16:12:16 -06:00
Joel Dice
a80677d673 fix aliasing warnings 2007-10-28 18:51:38 -06:00
Joel Dice
7f1837fecd move fixed object (mark and sweep) support into heap.cpp and refine algorithms for determining when and how much to GC 2007-10-28 13:14:53 -06:00
Joel Dice
60072b9fdc implement fixed object support 2007-10-27 19:54:30 -06:00
Joel Dice
3e1dbab0f0 move bitmap helper functions to common.h; preserve callee-saved registers in vmInvoke() 2007-10-11 20:52:16 -06:00