# HG changeset patch # User Thomas Wuerthinger # Date 1363031731 -3600 # Node ID 169ec449974af55c81dd3a9df2c3c860cf756154 # Parent b89a97928e72a0fbd9a09c05694e465279fec452# Parent aadd8f02449a4f791ff673ab03a393aa023db33d Merge. diff -r aadd8f02449a -r 169ec449974a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Mar 11 20:10:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Mar 11 20:55:31 2013 +0100 @@ -152,7 +152,7 @@ * not null * @return the outcome of the installation as a {@link CodeInstallResult}. */ - CodeInstallResult installCode(HotSpotCompilationResult compResult, HotSpotInstalledCode code, HotSpotCodeInfo info); + CodeInstallResult installCode(HotSpotCompilationResult compResult, HotSpotInstalledCode code, HotSpotCodeInfo info, boolean[] triggeredDeoptimizations); void initializeConfiguration(HotSpotVMConfig config); diff -r aadd8f02449a -r 169ec449974a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Mar 11 20:10:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Mar 11 20:55:31 2013 +0100 @@ -34,11 +34,11 @@ */ public class CompilerToVMImpl implements CompilerToVM { - private native int installCode0(HotSpotCompilationResult comp, HotSpotInstalledCode code, HotSpotCodeInfo info); + private native int installCode0(HotSpotCompilationResult comp, HotSpotInstalledCode code, HotSpotCodeInfo info, boolean[] triggeredDeoptimizations); @Override - public CodeInstallResult installCode(HotSpotCompilationResult comp, HotSpotInstalledCode code, HotSpotCodeInfo info) { - return CodeInstallResult.values()[installCode0(comp, code, info)]; + public CodeInstallResult installCode(HotSpotCompilationResult comp, HotSpotInstalledCode code, HotSpotCodeInfo info, boolean[] triggeredDeoptimizations) { + return CodeInstallResult.values()[installCode0(comp, code, info, triggeredDeoptimizations)]; } @Override diff -r aadd8f02449a -r 169ec449974a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Mon Mar 11 20:10:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Mon Mar 11 20:55:31 2013 +0100 @@ -38,10 +38,16 @@ private static final long serialVersionUID = 156632908220561612L; private final HotSpotResolvedJavaMethod method; + private final boolean isDefault; long nmethod; - public HotSpotInstalledCode(HotSpotResolvedJavaMethod method) { + public HotSpotInstalledCode(HotSpotResolvedJavaMethod method, boolean isDefault) { this.method = method; + this.isDefault = isDefault; + } + + public boolean isDefault() { + return isDefault; } @Override diff -r aadd8f02449a -r 169ec449974a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon Mar 11 20:10:27 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Mon Mar 11 20:55:31 2013 +0100 @@ -817,15 +817,16 @@ public void installMethod(HotSpotResolvedJavaMethod method, int entryBCI, CompilationResult compResult, CodeInfo[] info) { HotSpotCodeInfo hsInfo = makeInfo(method, compResult, info); - graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(method, entryBCI, compResult), null, hsInfo); + HotSpotInstalledCode code = new HotSpotInstalledCode(method, true); + graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(method, entryBCI, compResult), code, hsInfo, null); } @Override public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, CodeInfo[] info) { HotSpotCodeInfo hsInfo = makeInfo(method, compResult, info); HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; - HotSpotInstalledCode code = new HotSpotInstalledCode(hotspotMethod); - CodeInstallResult result = graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(hotspotMethod, -1, compResult), code, hsInfo); + HotSpotInstalledCode code = new HotSpotInstalledCode(hotspotMethod, false); + CodeInstallResult result = graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(hotspotMethod, -1, compResult), code, hsInfo, null); if (result != CodeInstallResult.OK) { return null; } diff -r aadd8f02449a -r 169ec449974a src/share/vm/code/nmethod.cpp --- a/src/share/vm/code/nmethod.cpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/code/nmethod.cpp Mon Mar 11 20:55:31 2013 +0100 @@ -490,6 +490,7 @@ _compiler = NULL; #ifdef GRAAL _graal_installed_code = NULL; + _triggered_deoptimizations = NULL; #endif #ifdef HAVE_DTRACE_H _trap_offset = 0; @@ -585,7 +586,8 @@ int comp_level, GrowableArray* leaf_graph_ids #ifdef GRAAL - , Handle installed_code + , Handle installed_code, + Handle triggered_deoptimizations #endif ) { @@ -613,7 +615,8 @@ comp_level, leaf_graph_ids #ifdef GRAAL - , installed_code + , installed_code, + triggered_deoptimizations #endif ); if (nm != NULL) { @@ -839,7 +842,8 @@ int comp_level, GrowableArray* leaf_graph_ids #ifdef GRAAL - , Handle installed_code + , Handle installed_code, + Handle triggered_deoptimizations #endif ) : CodeBlob("nmethod", code_buffer, sizeof(nmethod), @@ -866,6 +870,7 @@ #ifdef GRAAL _graal_installed_code = installed_code(); + _triggered_deoptimizations = (typeArrayOop)triggered_deoptimizations(); #endif if (compiler->is_graal()) { // Graal might not produce any stub sections @@ -1685,8 +1690,16 @@ #ifdef GRAAL // Follow Graal method - if (_graal_installed_code != NULL && can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { - return; + if (_graal_installed_code != NULL) { + if (HotSpotInstalledCode::isDefault(_graal_installed_code)) { + if (!is_alive->do_object_b(_graal_installed_code)) { + _graal_installed_code = NULL; + } + } else { + if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { + return; + } + } } #endif @@ -1910,9 +1923,12 @@ } #ifdef GRAAL - if (_graal_installed_code != NULL) { + if(_graal_installed_code != NULL) { f->do_oop((oop*) &_graal_installed_code); } + if (_triggered_deoptimizations != NULL) { + f->do_oop((oop*) &_triggered_deoptimizations); + } #endif RelocIterator iter(this, low_boundary); diff -r aadd8f02449a -r 169ec449974a src/share/vm/code/nmethod.hpp --- a/src/share/vm/code/nmethod.hpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/code/nmethod.hpp Mon Mar 11 20:55:31 2013 +0100 @@ -119,6 +119,7 @@ #ifdef GRAAL // Needed to keep nmethods alive that are not the default nmethod for the associated Method. oop _graal_installed_code; + typeArrayOop _triggered_deoptimizations; #endif // To support simple linked-list chaining of nmethods: @@ -271,7 +272,8 @@ int comp_level, GrowableArray* leaf_graph_ids #ifdef GRAAL - , Handle installed_code + , Handle installed_code, + Handle triggered_deoptimizations #endif ); @@ -312,7 +314,8 @@ int comp_level, GrowableArray* leaf_graph_ids = NULL #ifdef GRAAL - , Handle installed_code = NULL + , Handle installed_code = Handle(), + Handle triggered_deoptimizations = Handle() #endif ); diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Mon Mar 11 20:55:31 2013 +0100 @@ -326,7 +326,7 @@ } // constructor used to create a method -CodeInstaller::CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code) { +CodeInstaller::CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code, Handle triggered_deoptimizations) { GraalCompiler::initialize_buffer_blob(); CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); jobject comp_result_obj = JNIHandles::make_local(comp_result()); @@ -344,7 +344,7 @@ GrowableArray* leaf_graph_ids = get_leaf_graph_ids(comp_result); result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, - GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, leaf_graph_ids, installed_code); + GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, leaf_graph_ids, installed_code, triggered_deoptimizations); method->clear_queued_for_compilation(); } diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalCodeInstaller.hpp --- a/src/share/vm/graal/graalCodeInstaller.hpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.hpp Mon Mar 11 20:55:31 2013 +0100 @@ -78,7 +78,7 @@ public: // constructor used to create a method - CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code); + CodeInstaller(Handle& comp_result, methodHandle method, GraalEnv::CodeInstallResult& result, nmethod*& nm, Handle installed_code, Handle triggered_deoptimizations); // constructor used to create a stub CodeInstaller(Handle& target_method, BufferBlob*& blob, jlong& id); diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon Mar 11 20:55:31 2013 +0100 @@ -791,15 +791,16 @@ C2V_END -C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject info)) +C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject info, jobject triggered_deoptimizations)) ResourceMark rm; HandleMark hm; Handle compResultHandle = JNIHandles::resolve(compResult); nmethod* nm = NULL; methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(compResult)); Handle installed_code_handle = JNIHandles::resolve(installed_code); + Handle triggered_deoptimizations_handle = JNIHandles::resolve(triggered_deoptimizations); GraalEnv::CodeInstallResult result; - CodeInstaller installer(compResultHandle, method, result, nm, installed_code_handle); + CodeInstaller installer(compResultHandle, method, result, nm, installed_code_handle, triggered_deoptimizations_handle); if (result != GraalEnv::ok) { assert(nm == NULL, "should be"); @@ -1096,7 +1097,7 @@ {CC"getMetaspaceConstructor", CC"("REFLECT_CONSTRUCTOR"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceConstructor)}, {CC"getJavaField", CC"("REFLECT_FIELD")"HS_RESOLVED_FIELD, FN_PTR(getJavaField)}, {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, - {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE HS_CODE_INFO")I", FN_PTR(installCode0)}, + {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE HS_CODE_INFO"[Z)I", FN_PTR(installCode0)}, {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, {CC"disassembleNMethod", CC"(J)"STRING, FN_PTR(disassembleNMethod)}, {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalEnv.cpp --- a/src/share/vm/graal/graalEnv.cpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalEnv.cpp Mon Mar 11 20:55:31 2013 +0100 @@ -43,6 +43,7 @@ #include "runtime/sharedRuntime.hpp" #include "utilities/dtrace.hpp" #include "graal/graalRuntime.hpp" +#include "graal/graalJavaAccess.hpp" // ------------------------------------------------------------------ // Note: the logic of this method should mirror the logic of @@ -418,7 +419,8 @@ bool has_debug_info, bool has_unsafe_access, GrowableArray* leaf_graph_ids, - Handle installed_code) { + Handle installed_code, + Handle triggered_deoptimizations) { GRAAL_EXCEPTION_CONTEXT; NMethodSweeper::possibly_sweep(); nm = NULL; @@ -463,7 +465,7 @@ debug_info, dependencies, code_buffer, frame_words, oop_map_set, handler_table, &implicit_tbl, - compiler, comp_level, leaf_graph_ids, installed_code); + compiler, comp_level, leaf_graph_ids, installed_code, triggered_deoptimizations); // Free codeBlobs //code_buffer->free_blob(); @@ -492,7 +494,7 @@ // (Put nm into the task handle *before* publishing to the Java heap.) if (task != NULL) task->set_code(nm); - if (installed_code.is_null()) { + if (HotSpotInstalledCode::isDefault(installed_code())) { if (entry_bci == InvocationEntryBci) { if (TieredCompilation) { // If there is an old version we're done with it diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalEnv.hpp --- a/src/share/vm/graal/graalEnv.hpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalEnv.hpp Mon Mar 11 20:55:31 2013 +0100 @@ -146,7 +146,8 @@ bool has_debug_info, bool has_unsafe_access, GrowableArray* leaf_graph_ids, - Handle installed_code); + Handle installed_code, + Handle triggered_deoptimizations); // converts the Klass* representing the holder of a method into a // InstanceKlass*. This is needed since the holder of a method in diff -r aadd8f02449a -r 169ec449974a src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Mon Mar 11 20:10:27 2013 +0100 +++ b/src/share/vm/graal/graalJavaAccess.hpp Mon Mar 11 20:55:31 2013 +0100 @@ -75,6 +75,7 @@ start_class(HotSpotInstalledCode) \ long_field(HotSpotInstalledCode, nmethod) \ oop_field(HotSpotInstalledCode, method, "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;") \ + boolean_field(HotSpotInstalledCode, isDefault) \ end_class \ start_class(HotSpotCodeInfo) \ long_field(HotSpotCodeInfo, start) \