src/share/vm/prims/methodHandles.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/prims/methodHandles.cpp	Mon Oct 13 17:32:20 2014
--- new/src/share/vm/prims/methodHandles.cpp	Mon Oct 13 17:32:19 2014

*** 34,43 **** --- 34,44 ---- #include "runtime/compilationPolicy.hpp" #include "runtime/javaCalls.hpp" #include "runtime/reflection.hpp" #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" + #include "utilities/exceptions.hpp" /* * JSR 292 reference implementation: method handles * The JDK 7 reference implementation represented method handle
*** 53,82 **** --- 54,87 ---- */ bool MethodHandles::_enabled = false; // set true after successful native linkage MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL; //------------------------------------------------------------------------------ // MethodHandles::generate_adapters // void MethodHandles::generate_adapters() { if (SystemDictionary::MethodHandle_klass() == NULL) return; + + /** + * Generates method handle adapters. Returns 'false' if memory allocation + * failed and true otherwise. + */ + bool MethodHandles::generate_adapters() { + if (SystemDictionary::MethodHandle_klass() == NULL) { + return true; + } assert(_adapter_code == NULL, "generate only once"); ResourceMark rm; TraceTime timer("MethodHandles adapters generation", TraceStartupTime); _adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size); ! if (_adapter_code == NULL) { vm_exit_out_of_memory(adapter_code_size, OOM_MALLOC_ERROR, "CodeCache: no room for MethodHandles adapters"); { + return false; + } + CodeBuffer code(_adapter_code); MethodHandlesAdapterGenerator g(&code); g.generate(); code.log_section_sizes("MethodHandlesAdapterBlob"); } + return true; } //------------------------------------------------------------------------------ // MethodHandlesAdapterGenerator::generate //
*** 1399,1408 **** --- 1404,1415 ---- if (TraceInvokeDynamic) { tty->print_cr("MethodHandle support loaded (using LambdaForms)"); } if (enable_MH) { MethodHandles::generate_adapters(); + if (MethodHandles::generate_adapters() == false) { + THROW_MSG(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for method handle adapters"); + } MethodHandles::set_enabled(true); } } JVM_END

src/share/vm/prims/methodHandles.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File