# HG changeset patch # User Roland Schatz # Date 1454578687 -3600 # Node ID 805d58f2cd8c9de4e3234eebe5fabc55eeb3d4f1 # Parent 657ccda6d2816df5696bbc15802d374a55c8dfbc Use explicit StackSlot instead of int offset for the deopt rescue slot. diff -r 657ccda6d281 -r 805d58f2cd8c jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java Wed Feb 03 19:03:02 2016 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java Thu Feb 04 10:38:07 2016 +0100 @@ -24,6 +24,7 @@ import jdk.vm.ci.code.BytecodeFrame; import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.DataPatch; import jdk.vm.ci.code.site.Infopoint; import jdk.vm.ci.code.site.Site; @@ -99,9 +100,9 @@ protected final int totalFrameSize; /** - * Offset in bytes for the custom stack area (relative to sp). + * The deopt rescue slot. Must be non-null if there is a safepoint in the method. */ - protected final int customStackAreaOffset; + protected final StackSlot deoptRescueSlot; public static class Comment { @@ -115,7 +116,7 @@ } public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, - int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, int customStackAreaOffset) { + int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) { this.name = name; this.targetCode = targetCode; this.targetCodeSize = targetCodeSize; @@ -129,7 +130,7 @@ this.dataSectionPatches = dataSectionPatches; this.isImmutablePIC = isImmutablePIC; this.totalFrameSize = totalFrameSize; - this.customStackAreaOffset = customStackAreaOffset; + this.deoptRescueSlot = deoptRescueSlot; assert validateFrames(); } diff -r 657ccda6d281 -r 805d58f2cd8c jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java Wed Feb 03 19:03:02 2016 +0100 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java Thu Feb 04 10:38:07 2016 +0100 @@ -22,6 +22,7 @@ */ package jdk.vm.ci.hotspot; +import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.DataPatch; import jdk.vm.ci.code.site.Site; import jdk.vm.ci.inittimer.SuppressFBWarnings; @@ -55,9 +56,9 @@ @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage; public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, - int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, int customStackAreaOffset, HotSpotResolvedJavaMethod method, int entryBCI, + int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot, HotSpotResolvedJavaMethod method, int entryBCI, int id, long jvmciEnv, boolean hasUnsafeAccess) { - super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackAreaOffset); + super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, deoptRescueSlot); this.method = method; this.entryBCI = entryBCI; this.id = id; diff -r 657ccda6d281 -r 805d58f2cd8c src/share/vm/jvmci/jvmciCodeInstaller.cpp --- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp Wed Feb 03 19:03:02 2016 +0100 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Thu Feb 04 10:38:07 2016 +0100 @@ -464,7 +464,7 @@ // Make sure a valid compile_id is associated with every compile id = CompileBroker::assign_compile_id_unlocked(Thread::current(), method, entry_bci); } - result = JVMCIEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, + result = JVMCIEnv::register_method(method, nm, entry_bci, &_offsets, _orig_pc_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, compiler, _debug_recorder, _dependencies, env, id, has_unsafe_access, _has_wide_vector, installed_code, compiled_code, speculation_log); @@ -494,7 +494,19 @@ _code_handle = JNIHandles::make_local(HotSpotCompiledCode::targetCode(compiled_code)); _code_size = HotSpotCompiledCode::targetCodeSize(compiled_code); _total_frame_size = HotSpotCompiledCode::totalFrameSize(compiled_code); - _custom_stack_area_offset = HotSpotCompiledCode::customStackAreaOffset(compiled_code); + + oop deoptRescueSlot = HotSpotCompiledCode::deoptRescueSlot(compiled_code); + if (deoptRescueSlot == NULL) { + _orig_pc_offset = -1; + } else { + _orig_pc_offset = StackSlot::offset(deoptRescueSlot); + if (StackSlot::addFrameSize(deoptRescueSlot)) { + _orig_pc_offset += _total_frame_size; + } + if (_orig_pc_offset < 0) { + JVMCI_ERROR("invalid deopt rescue slot: %d", _orig_pc_offset); + } + } // Pre-calculate the constants section size. This is required for PC-relative addressing. _data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); @@ -629,6 +641,9 @@ if (site_InfopointReason::SAFEPOINT() == reason || site_InfopointReason::CALL() == reason || site_InfopointReason::IMPLICIT_EXCEPTION() == reason) { TRACE_jvmci_4("safepoint at %i", pc_offset); site_Safepoint(buffer, pc_offset, site, CHECK_OK); + if (_orig_pc_offset < 0) { + JVMCI_ERROR_OK("method contains safepoint, but has not deopt rescue slot"); + } } else { TRACE_jvmci_4("infopoint at %i", pc_offset); site_Infopoint(buffer, pc_offset, site, CHECK_OK); diff -r 657ccda6d281 -r 805d58f2cd8c src/share/vm/jvmci/jvmciCodeInstaller.hpp --- a/src/share/vm/jvmci/jvmciCodeInstaller.hpp Wed Feb 03 19:03:02 2016 +0100 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.hpp Thu Feb 04 10:38:07 2016 +0100 @@ -63,7 +63,7 @@ jobject _code_handle; jint _code_size; jint _total_frame_size; - jint _custom_stack_area_offset; + jint _orig_pc_offset; jint _parameter_count; jint _constants_size; #ifndef PRODUCT diff -r 657ccda6d281 -r 805d58f2cd8c src/share/vm/jvmci/jvmciJavaClasses.hpp --- a/src/share/vm/jvmci/jvmciJavaClasses.hpp Wed Feb 03 19:03:02 2016 +0100 +++ b/src/share/vm/jvmci/jvmciJavaClasses.hpp Thu Feb 04 10:38:07 2016 +0100 @@ -89,7 +89,7 @@ int_field(HotSpotCompiledCode, dataSectionAlignment) \ objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/site/DataPatch;") \ int_field(HotSpotCompiledCode, totalFrameSize) \ - int_field(HotSpotCompiledCode, customStackAreaOffset) \ + oop_field(HotSpotCompiledCode, deoptRescueSlot, "Ljdk/vm/ci/code/StackSlot;") \ end_class \ start_class(HotSpotCompiledCode_Comment) \ oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \