diff -r 11237ee74aae make/bsd/makefiles/gcc.make --- a/make/bsd/makefiles/gcc.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/bsd/makefiles/gcc.make Thu Aug 15 23:23:55 2013 -0700 @@ -177,7 +177,6 @@ ifeq ($(JVM_VARIANT_ZEROSHARK), true) endif CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions ifeq ($(USE_CLANG),) CFLAGS += -pthread CFLAGS += -fcheck-new diff -r 11237ee74aae make/bsd/makefiles/vm.make --- a/make/bsd/makefiles/vm.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/bsd/makefiles/vm.make Thu Aug 15 23:23:55 2013 -0700 @@ -108,9 +108,6 @@ endif # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN/BYFILE) -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - # Extra flags from gnumake's invocation or environment CFLAGS += $(EXTRA_CFLAGS) LFLAGS += $(EXTRA_CFLAGS) diff -r 11237ee74aae make/linux/makefiles/gcc.make --- a/make/linux/makefiles/gcc.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/linux/makefiles/gcc.make Thu Aug 15 23:23:55 2013 -0700 @@ -147,7 +147,6 @@ CFLAGS += $(LLVM_CFLAGS) endif CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions CFLAGS += -D_REENTRANT ifeq ($(USE_CLANG),) CFLAGS += -fcheck-new diff -r 11237ee74aae make/linux/makefiles/sparcWorks.make --- a/make/linux/makefiles/sparcWorks.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/linux/makefiles/sparcWorks.make Thu Aug 15 23:23:55 2013 -0700 @@ -51,8 +51,6 @@ ASFLAGS += $(ARCHFLAG) PICFLAG = -KPIC CFLAGS += $(PICFLAG) -# no more exceptions -CFLAGS += -features=no%except # Reduce code bloat by reverting back to 5.0 behavior for static initializers CFLAGS += -features=no%split_init # allow zero sized arrays diff -r 11237ee74aae make/linux/makefiles/vm.make --- a/make/linux/makefiles/vm.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/linux/makefiles/vm.make Thu Aug 15 23:23:55 2013 -0700 @@ -116,9 +116,6 @@ endif # ifneq ($(LP64), 1) # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN/BYFILE) -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - # Extra flags from gnumake's invocation or environment CFLAGS += $(EXTRA_CFLAGS) LFLAGS += $(EXTRA_CFLAGS) diff -r 11237ee74aae make/solaris/makefiles/gcc.make --- a/make/solaris/makefiles/gcc.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/solaris/makefiles/gcc.make Thu Aug 15 23:23:55 2013 -0700 @@ -72,7 +72,6 @@ VM_PICFLAG = $(VM_PICFLAG/$(LINK_ CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions CFLAGS += -D_REENTRANT CFLAGS += -fcheck-new diff -r 11237ee74aae make/solaris/makefiles/sparcWorks.make --- a/make/solaris/makefiles/sparcWorks.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/solaris/makefiles/sparcWorks.make Thu Aug 15 23:23:55 2013 -0700 @@ -233,10 +233,6 @@ endif # 64bit x86 # Inline functions CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il -# no more exceptions -CFLAGS/NOEX=-features=no%except - - # avoid compilation problems arising from fact that C++ compiler tries # to search for external template definition by just compiling additional # source files in th same context @@ -320,9 +316,6 @@ OPT_CFLAGS+=-xO3 endif # 32bit x86 -# no more exceptions -CFLAGS/NOEX=-noex - # Inline functions CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il @@ -421,9 +414,6 @@ endif # 32bit x86 # The following options run into misaligned ldd problem (raj) #OPT_CFLAGS = -fast -O4 $(ARCHFLAG/sparc) -xchip=ultra -# no more exceptions -CFLAGS/NOEX=-noex - # PIC is safer for SPARC, and is considerably slower # a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC" PICFLAG = -PIC diff -r 11237ee74aae make/solaris/makefiles/vm.make --- a/make/solaris/makefiles/vm.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/solaris/makefiles/vm.make Thu Aug 15 23:23:55 2013 -0700 @@ -103,9 +103,6 @@ endif # ifneq ($(LP64), 1) # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN) -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - # Extra flags from gnumake's invocation or environment CFLAGS += $(EXTRA_CFLAGS) diff -r 11237ee74aae make/windows/makefiles/compile.make --- a/make/windows/makefiles/compile.make Sat Aug 10 10:01:12 2013 +0400 +++ b/make/windows/makefiles/compile.make Thu Aug 15 23:23:55 2013 -0700 @@ -52,7 +52,7 @@ CXX=cl.exe # improving the quality of crash log stack traces involving jvm.dll. # These are always used in all compiles -CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 /WX +CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 /WX /EHsc # Let's add debug information when Full Debug Symbols is enabled !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" diff -r 11237ee74aae src/share/vm/ci/bcEscapeAnalyzer.cpp --- a/src/share/vm/ci/bcEscapeAnalyzer.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/bcEscapeAnalyzer.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -1056,8 +1056,8 @@ void BCEscapeAnalyzer::iterate_blocks(Ar int datacount = (numblocks + 1) * (stkSize + numLocals); int datasize = datacount * sizeof(ArgumentMap); - StateInfo *blockstates = (StateInfo *) arena->Amalloc(numblocks * sizeof(StateInfo)); - ArgumentMap *statedata = (ArgumentMap *) arena->Amalloc(datasize); + StateInfo *blockstates = (StateInfo *) arena->Amalloc(numblocks * sizeof(StateInfo), AllocFailStrategy::EXCEPTION); + ArgumentMap *statedata = (ArgumentMap *) arena->Amalloc(datasize, AllocFailStrategy::EXCEPTION); for (int i = 0; i < datacount; i++) ::new ((void*)&statedata[i]) ArgumentMap(); ArgumentMap *dp = statedata; state._vars = dp; @@ -1441,7 +1441,7 @@ BCEscapeAnalyzer::BCEscapeAnalyzer(ciMet _arg_returned.Clear(); _dirty.Clear(); Arena* arena = CURRENT_ENV->arena(); - _arg_modified = (uint *) arena->Amalloc(_arg_size * sizeof(uint)); + _arg_modified = (uint *) arena->Amalloc(_arg_size * sizeof(uint), AllocFailStrategy::EXCEPTION); Copy::zero_to_bytes(_arg_modified, _arg_size * sizeof(uint)); if (methodData() == NULL) diff -r 11237ee74aae src/share/vm/ci/ciEnv.cpp --- a/src/share/vm/ci/ciEnv.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/ciEnv.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -829,11 +829,10 @@ ciMethod* ciEnv::get_method_by_index(con char *ciEnv::name_buffer(int req_len) { if (_name_buffer_len < req_len) { if (_name_buffer == NULL) { - _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len); + _name_buffer = (char*) arena()->Amalloc(sizeof(char) * req_len, AllocFailStrategy::EXCEPTION); _name_buffer_len = req_len; } else { - _name_buffer = - (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len); + _name_buffer = (char*) arena()->Arealloc(_name_buffer, _name_buffer_len, req_len, AllocFailStrategy::EXCEPTION); _name_buffer_len = req_len; } } diff -r 11237ee74aae src/share/vm/ci/ciMethod.cpp --- a/src/share/vm/ci/ciMethod.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/ciMethod.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -191,7 +191,7 @@ void ciMethod::load_code() { Arena* arena = CURRENT_THREAD_ENV->arena(); // Load the bytecodes. - _code = (address)arena->Amalloc(code_size()); + _code = (address) arena->Amalloc(code_size(), AllocFailStrategy::EXCEPTION); memcpy(_code, me->code_base(), code_size()); // Revert any breakpoint bytecodes in ci's copy @@ -213,7 +213,7 @@ void ciMethod::load_code() { // for details. _exception_handlers = (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*) - * (_handler_count + 1)); + * (_handler_count + 1), AllocFailStrategy::EXCEPTION); if (_handler_count > 0) { for (int i=0; i<_handler_count; i++) { _exception_handlers[i] = new (arena) ciExceptionHandler( diff -r 11237ee74aae src/share/vm/ci/ciMethodBlocks.cpp --- a/src/share/vm/ci/ciMethodBlocks.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/ciMethodBlocks.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -256,8 +256,8 @@ ciMethodBlocks::ciMethodBlocks(Arena *ar int block_estimate = _code_size / 8; _blocks = new(_arena) GrowableArray(_arena, block_estimate, 0, NULL); - int b2bsize = _code_size * sizeof(ciBlock **); - _bci_to_block = (ciBlock **) arena->Amalloc(b2bsize); + int b2bsize = _code_size * sizeof(ciBlock**); + _bci_to_block = (ciBlock**) arena->Amalloc(b2bsize, AllocFailStrategy::EXCEPTION); Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord)); // create initial block covering the entire method diff -r 11237ee74aae src/share/vm/ci/ciMethodData.cpp --- a/src/share/vm/ci/ciMethodData.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/ciMethodData.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -93,7 +93,7 @@ void ciMethodData::load_data() { _data_size = mdo->data_size(); _extra_data_size = mdo->extra_data_size(); int total_size = _data_size + _extra_data_size; - _data = (intptr_t *) arena->Amalloc(total_size); + _data = (intptr_t*) arena->Amalloc(total_size, AllocFailStrategy::EXCEPTION); Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize); // Traverse the profile data, translating any oops into their diff -r 11237ee74aae src/share/vm/ci/ciTypeFlow.cpp --- a/src/share/vm/ci/ciTypeFlow.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/ci/ciTypeFlow.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -345,8 +345,8 @@ ciTypeFlow::StateVector::StateVector(ciT _monitor_count = -1; // Allocate the _types array int max_cells = analyzer->max_cells(); - _types = (ciType**)analyzer->arena()->Amalloc(sizeof(ciType*) * max_cells); - for (int i=0; iarena()->Amalloc(sizeof(ciType*) * max_cells, AllocFailStrategy::EXCEPTION); + for (int i = 0; i < max_cells; i++) { _types[i] = top_type(); } _trap_bci = -1; diff -r 11237ee74aae src/share/vm/code/nmethod.hpp --- a/src/share/vm/code/nmethod.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/code/nmethod.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -265,7 +265,7 @@ class nmethod : public CodeBlob { int comp_level); // helper methods - void* operator new(size_t size, int nmethod_size); + void* operator new(size_t size, int nmethod_size) throw (); const char* reloc_string_for(u_char* begin, u_char* end); // Returns true if this thread changed the state of the nmethod or diff -r 11237ee74aae src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -56,6 +56,8 @@ #include "shark/sharkCompiler.hpp" #endif +#include + #ifdef DTRACE_ENABLED // Only bother with this argument setup if dtrace is available @@ -1804,7 +1806,15 @@ void CompileBroker::invoke_compiler_on_m if (comp == NULL) { ci_env.record_method_not_compilable("no compiler", !TieredCompilation); } else { - comp->compile_method(&ci_env, target, osr_bci); + try { + comp->compile_method(&ci_env, target, osr_bci); + } catch (std::bad_alloc const & e) { + tty->print_cr("XXX out of memory exception: %s", e.what()); + ci_env.record_method_not_compilable("out of memory exception", !TieredCompilation); + } catch (...) { + tty->print_cr("XXX other exception"); + ci_env.record_method_not_compilable("other exception", !TieredCompilation); + } } if (!ci_env.failing() && task->code() == NULL) { diff -r 11237ee74aae src/share/vm/memory/allocation.cpp --- a/src/share/vm/memory/allocation.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/memory/allocation.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -688,31 +688,31 @@ void* Arena::internal_malloc_4(size_t x) // define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed. // #ifndef ALLOW_OPERATOR_NEW_USAGE -void* operator new(size_t size){ +void* operator new(size_t size) throw (std::bad_alloc) { assert(false, "Should not call global operator new"); return 0; } -void* operator new [](size_t size){ +void* operator new [](size_t size) throw (std::bad_alloc) { assert(false, "Should not call global operator new[]"); return 0; } -void* operator new(size_t size, const std::nothrow_t& nothrow_constant){ +void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw () { assert(false, "Should not call global operator new"); return 0; } -void* operator new [](size_t size, std::nothrow_t& nothrow_constant){ +void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw () { assert(false, "Should not call global operator new[]"); return 0; } -void operator delete(void* p) { +void operator delete(void* p) throw () { assert(false, "Should not call global delete"); } -void operator delete [](void* p) { +void operator delete [](void* p) throw () { assert(false, "Should not call global delete []"); } #endif // ALLOW_OPERATOR_NEW_USAGE diff -r 11237ee74aae src/share/vm/memory/allocation.hpp --- a/src/share/vm/memory/allocation.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/memory/allocation.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -55,7 +55,11 @@ class AllocFailStrategy { public: - enum AllocFailEnum { EXIT_OOM, RETURN_NULL }; + enum AllocFailEnum { + EXCEPTION, // throws a bad_alloc exception + EXIT_OOM, // exits the VM with an OOM message + RETURN_NULL // simply returns null + }; }; typedef AllocFailStrategy::AllocFailEnum AllocFailType; @@ -405,11 +409,22 @@ protected: bool check_for_overflow(size_t request, const char* whence, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) const { - if (UINTPTR_MAX - request < (uintptr_t)_hwm) { - if (alloc_failmode == AllocFailStrategy::RETURN_NULL) { + static int count = 0; + if (alloc_failmode == AllocFailStrategy::EXCEPTION) { + count++; + } + if ((UINTPTR_MAX - request < (uintptr_t)_hwm) || (alloc_failmode == AllocFailStrategy::EXCEPTION && count > 50000)) { + switch (alloc_failmode) { + case AllocFailStrategy::EXCEPTION: + count = 0; + printf("throw bad_alloc\n"); + throw std::bad_alloc(); + case AllocFailStrategy::EXIT_OOM: + signal_out_of_memory(request, whence); + break; + case AllocFailStrategy::RETURN_NULL: return false; } - signal_out_of_memory(request, whence); } return true; } diff -r 11237ee74aae src/share/vm/opto/block.cpp --- a/src/share/vm/opto/block.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/block.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -39,19 +39,23 @@ //----------------------------------------------------------------------------- -void Block_Array::grow( uint i ) { +void Block_Array::grow(uint i) { assert(i >= Max(), "must be an overflow"); debug_only(_limit = i+1); - if( i < _size ) return; - if( !_size ) { + if (i < _size) { + return; + } + if (_size == 0) { _size = 1; - _blocks = (Block**)_arena->Amalloc( _size * sizeof(Block*) ); + _blocks = (Block**) _arena->Amalloc(_size * sizeof(Block*), AllocFailStrategy::EXCEPTION); _blocks[0] = NULL; } uint old = _size; - while( i >= _size ) _size <<= 1; // Double to fit - _blocks = (Block**)_arena->Arealloc( _blocks, old*sizeof(Block*),_size*sizeof(Block*)); - Copy::zero_to_bytes( &_blocks[old], (_size-old)*sizeof(Block*) ); + while (i >= _size) { + _size <<= 1; // Double to fit + } + _blocks = (Block**) _arena->Arealloc(_blocks, old * sizeof(Block*), _size * sizeof(Block*), AllocFailStrategy::EXCEPTION); + Copy::zero_to_bytes(&_blocks[old], (_size - old) * sizeof(Block*)); } //============================================================================= diff -r 11237ee74aae src/share/vm/opto/c2compiler.cpp --- a/src/share/vm/opto/c2compiler.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/c2compiler.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -109,7 +109,11 @@ void C2Compiler::initialize() { // main startup thread. if (_runtimes != initialized) { - initialize_runtimes( initialize_runtime, &_runtimes); + try { + initialize_runtimes(initialize_runtime, &_runtimes); + } catch (std::bad_alloc const & e) { + tty->print_cr("exception during initialize_runtime: %s", e.what()); + } } // Mark this compiler object as ready to roll diff -r 11237ee74aae src/share/vm/opto/graphKit.cpp --- a/src/share/vm/opto/graphKit.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/graphKit.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -649,10 +649,13 @@ PreserveJVMState::PreserveJVMState(Graph PreserveJVMState::~PreserveJVMState() { GraphKit* kit = _kit; #ifdef ASSERT - assert(kit->bci() == _bci, "bci must not shift"); - Parse* parser = kit->is_Parse(); - int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); - assert(block == _block, "block must not shift"); + // In case of an exception the asserts don't hold. + if (!std::uncaught_exception()) { + assert(kit->bci() == _bci, "bci must not shift"); + Parse* parser = kit->is_Parse(); + int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); + assert(block == _block, "block must not shift"); + } #endif kit->set_map(_map); kit->set_sp(_sp); @@ -672,7 +675,10 @@ BuildCutout::BuildCutout(GraphKit* kit, } BuildCutout::~BuildCutout() { GraphKit* kit = _kit; - assert(kit->stopped(), "cutout code must stop, throw, return, etc."); + // In case of an exception the asserts don't hold. + if (!std::uncaught_exception()) { + assert(kit->stopped(), "cutout code must stop, throw, return, etc."); + } } //---------------------------PreserveReexecuteState---------------------------- diff -r 11237ee74aae src/share/vm/opto/graphKit.hpp --- a/src/share/vm/opto/graphKit.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/graphKit.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -79,7 +79,10 @@ class GraphKit : public Phase { #ifdef ASSERT ~GraphKit() { - assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms"); + // In case of an exception the asserts don't hold. + if (!std::uncaught_exception()) { + assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms"); + } } #endif diff -r 11237ee74aae src/share/vm/opto/memnode.hpp --- a/src/share/vm/opto/memnode.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/memnode.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -1232,7 +1232,10 @@ class MergeMemStream : public StackObj { } #ifdef ASSERT ~MergeMemStream() { - assert_synch(); + // In case of an exception the asserts don't hold. + if (!std::uncaught_exception()) { + assert_synch(); + } } #endif diff -r 11237ee74aae src/share/vm/opto/node.cpp --- a/src/share/vm/opto/node.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/node.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "libadt/vectset.hpp" +#include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" #include "opto/cfgnode.hpp" #include "opto/connode.hpp" @@ -631,12 +632,12 @@ void Node::destruct() { //------------------------------grow------------------------------------------- // Grow the input array, making space for more edges -void Node::grow( uint len ) { +void Node::grow(uint len) { Arena* arena = Compile::current()->node_arena(); uint new_max = _max; - if( new_max == 0 ) { + if (new_max == 0) { _max = 4; - _in = (Node**)arena->Amalloc(4*sizeof(Node*)); + _in = (Node**) arena->Amalloc(4 * sizeof(Node*), AllocFailStrategy::EXCEPTION); Node** to = _in; to[0] = NULL; to[1] = NULL; @@ -644,12 +645,14 @@ void Node::grow( uint len ) { to[3] = NULL; return; } - while( new_max <= len ) new_max <<= 1; // Find next power-of-2 + while (new_max <= len) { + new_max <<= 1; // Find next power-of-2 + } // Trimming to limit allows a uint8 to handle up to 255 edges. // Previously I was using only powers-of-2 which peaked at 128 edges. //if( new_max >= limit ) new_max = limit-1; - _in = (Node**)arena->Arealloc(_in, _max*sizeof(Node*), new_max*sizeof(Node*)); - Copy::zero_to_bytes(&_in[_max], (new_max-_max)*sizeof(Node*)); // NULL all new space + _in = (Node**) arena->Arealloc(_in, _max * sizeof(Node*), new_max * sizeof(Node*), AllocFailStrategy::EXCEPTION); + Copy::zero_to_bytes(&_in[_max], (new_max - _max) * sizeof(Node*)); // NULL all new space _max = new_max; // Record new max length // This assertion makes sure that Node::_max is wide enough to // represent the numerical value of new_max. @@ -658,21 +661,23 @@ void Node::grow( uint len ) { //-----------------------------out_grow---------------------------------------- // Grow the input array, making space for more edges -void Node::out_grow( uint len ) { +void Node::out_grow(uint len) { assert(!is_top(), "cannot grow a top node's out array"); Arena* arena = Compile::current()->node_arena(); uint new_max = _outmax; - if( new_max == 0 ) { + if (new_max == 0) { _outmax = 4; - _out = (Node **)arena->Amalloc(4*sizeof(Node*)); + _out = (Node**) arena->Amalloc(4 * sizeof(Node*), AllocFailStrategy::EXCEPTION); return; } - while( new_max <= len ) new_max <<= 1; // Find next power-of-2 + while (new_max <= len) { + new_max <<= 1; // Find next power-of-2 + } // Trimming to limit allows a uint8 to handle up to 255 edges. // Previously I was using only powers-of-2 which peaked at 128 edges. //if( new_max >= limit ) new_max = limit-1; assert(_out != NULL && _out != NO_OUT_ARRAY, "out must have sensible value"); - _out = (Node**)arena->Arealloc(_out,_outmax*sizeof(Node*),new_max*sizeof(Node*)); + _out = (Node**) arena->Arealloc(_out, _outmax * sizeof(Node*), new_max * sizeof(Node*), AllocFailStrategy::EXCEPTION); //Copy::zero_to_bytes(&_out[_outmax], (new_max-_outmax)*sizeof(Node*)); // NULL all new space _outmax = new_max; // Record new max length // This assertion makes sure that Node::_max is wide enough to @@ -1912,16 +1917,18 @@ void Node_Array::clear() { } //----------------------------------------------------------------------------- -void Node_Array::grow( uint i ) { - if( !_max ) { +void Node_Array::grow(uint i) { + if (_max == 0) { _max = 1; - _nodes = (Node**)_a->Amalloc( _max * sizeof(Node*) ); + _nodes = (Node**) _a->Amalloc(_max * sizeof(Node*), AllocFailStrategy::EXCEPTION); _nodes[0] = NULL; } uint old = _max; - while( i >= _max ) _max <<= 1; // Double to fit - _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*)); - Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) ); + while (i >= _max) { + _max <<= 1; // Double to fit + } + _nodes = (Node**) _a->Arealloc(_nodes, old * sizeof(Node*), _max * sizeof(Node*), AllocFailStrategy::EXCEPTION); + Copy::zero_to_bytes(&_nodes[old], (_max - old) * sizeof(Node*)); } //----------------------------------------------------------------------------- diff -r 11237ee74aae src/share/vm/opto/node.hpp --- a/src/share/vm/opto/node.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/node.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -212,7 +212,7 @@ public: // New Operator that takes a Compile pointer, this will eventually // be the "new" New operator. inline void* operator new( size_t x, Compile* C) { - Node* n = (Node*)C->node_arena()->Amalloc_D(x); + Node* n = (Node*)C->node_arena()->Amalloc_D(x, AllocFailStrategy::EXCEPTION); #ifdef ASSERT n->_in = (Node**)n; // magic cookie for assertion check #endif diff -r 11237ee74aae src/share/vm/opto/type.cpp --- a/src/share/vm/opto/type.cpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/type.cpp Thu Aug 15 23:23:55 2013 -0700 @@ -279,27 +279,27 @@ void Type::Initialize_shared(Compile* cu TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); - const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); fboth[0] = Type::CONTROL; fboth[1] = Type::CONTROL; TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); - const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); ffalse[0] = Type::CONTROL; ffalse[1] = Type::TOP; TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse ); - const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); fneither[0] = Type::TOP; fneither[1] = Type::TOP; TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither ); - const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); ftrue[0] = Type::TOP; ftrue[1] = Type::CONTROL; TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue ); - const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); floop[0] = Type::CONTROL; floop[1] = TypeInt::INT; TypeTuple::LOOPBODY = TypeTuple::make( 2, floop ); @@ -314,7 +314,7 @@ void Type::Initialize_shared(Compile* cu const Type **fmembar = TypeTuple::fields(0); TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar); - const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); + const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*), AllocFailStrategy::EXCEPTION); fsc[0] = TypeInt::CC; fsc[1] = Type::MEMORY; TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); @@ -1702,7 +1702,7 @@ const TypeTuple *TypeTuple::make( uint c //------------------------------fields----------------------------------------- // Subroutine call type with space allocated for argument types const Type **TypeTuple::fields( uint arg_cnt ) { - const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) )); + const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms + arg_cnt) * sizeof(Type*), AllocFailStrategy::EXCEPTION)); flds[TypeFunc::Control ] = Type::CONTROL; flds[TypeFunc::I_O ] = Type::ABIO; flds[TypeFunc::Memory ] = Type::MEMORY; @@ -1730,7 +1730,7 @@ const Type *TypeTuple::xmeet( const Type case Tuple: { // Meeting 2 signatures? const TypeTuple *x = t->is_tuple(); assert( _cnt == x->_cnt, "" ); - const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); + const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4(_cnt * sizeof(Type*), AllocFailStrategy::EXCEPTION)); for( uint i=0; i<_cnt; i++ ) fields[i] = field_at(i)->xmeet( x->field_at(i) ); return TypeTuple::make(_cnt,fields); @@ -1744,7 +1744,7 @@ const Type *TypeTuple::xmeet( const Type //------------------------------xdual------------------------------------------ // Dual: compute field-by-field dual const Type *TypeTuple::xdual() const { - const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); + const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4(_cnt * sizeof(Type*), AllocFailStrategy::EXCEPTION)); for( uint i=0; i<_cnt; i++ ) fields[i] = _fields[i]->dual(); return new TypeTuple(_cnt,fields); diff -r 11237ee74aae src/share/vm/opto/type.hpp --- a/src/share/vm/opto/type.hpp Sat Aug 10 10:01:12 2013 +0400 +++ b/src/share/vm/opto/type.hpp Thu Aug 15 23:23:55 2013 -0700 @@ -169,10 +169,10 @@ protected: public: - inline void* operator new( size_t x ) { + inline void* operator new(size_t x) { Compile* compile = Compile::current(); compile->set_type_last_size(x); - void *temp = compile->type_arena()->Amalloc_D(x); + void *temp = compile->type_arena()->Amalloc_D(x, AllocFailStrategy::EXCEPTION); compile->set_type_hwm(temp); return temp; }