# HG changeset patch # User Doug Simon # Date 1443556839 -7200 # Node ID 353eb2b44df8edce742c16fc28abc68aefb04e8b # Parent 02d95720c45505372fa95555f91c6acfef3e44dc added HotSpotStackIntrospection and made CompilerToVM.getNextStackFrame package-private diff -r 02d95720c455 -r 353eb2b44df8 jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Tue Sep 29 21:37:07 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.amd64/src/jdk/internal/jvmci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Tue Sep 29 22:00:39 2015 +0200 @@ -30,11 +30,13 @@ import jdk.internal.jvmci.code.Architecture; import jdk.internal.jvmci.code.RegisterConfig; import jdk.internal.jvmci.code.TargetDescription; +import jdk.internal.jvmci.code.stack.StackIntrospection; import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider; import jdk.internal.jvmci.hotspot.HotSpotConstantReflectionProvider; import jdk.internal.jvmci.hotspot.HotSpotJVMCIBackendFactory; import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider; import jdk.internal.jvmci.hotspot.HotSpotMetaAccessProvider; +import jdk.internal.jvmci.hotspot.HotSpotStackIntrospection; import jdk.internal.jvmci.hotspot.HotSpotVMConfig; import jdk.internal.jvmci.inittimer.InitTimer; import jdk.internal.jvmci.meta.ConstantReflectionProvider; @@ -147,6 +149,7 @@ HotSpotCodeCacheProvider codeCache; ConstantReflectionProvider constantReflection; HotSpotMetaAccessProvider metaAccess; + StackIntrospection stackIntrospection; try (InitTimer t = timer("create providers")) { try (InitTimer rt = timer("create MetaAccess provider")) { metaAccess = createMetaAccess(runtime); @@ -160,13 +163,16 @@ try (InitTimer rt = timer("create ConstantReflection provider")) { constantReflection = createConstantReflection(runtime); } + try (InitTimer rt = timer("create StackIntrospection provider")) { + stackIntrospection = new HotSpotStackIntrospection(runtime); + } } try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection); + return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); } } - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection); + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); } } diff -r 02d95720c455 -r 353eb2b44df8 jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java --- a/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Tue Sep 29 21:37:07 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Tue Sep 29 22:00:39 2015 +0200 @@ -29,11 +29,13 @@ import jdk.internal.jvmci.code.Architecture; import jdk.internal.jvmci.code.RegisterConfig; import jdk.internal.jvmci.code.TargetDescription; +import jdk.internal.jvmci.code.stack.StackIntrospection; import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider; import jdk.internal.jvmci.hotspot.HotSpotConstantReflectionProvider; import jdk.internal.jvmci.hotspot.HotSpotJVMCIBackendFactory; import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider; import jdk.internal.jvmci.hotspot.HotSpotMetaAccessProvider; +import jdk.internal.jvmci.hotspot.HotSpotStackIntrospection; import jdk.internal.jvmci.hotspot.HotSpotVMConfig; import jdk.internal.jvmci.inittimer.InitTimer; import jdk.internal.jvmci.runtime.JVMCIBackend; @@ -95,12 +97,14 @@ RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, runtime.getConfig()); HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); + StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection); + return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); } } - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection); + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, + StackIntrospection stackIntrospection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); } } diff -r 02d95720c455 -r 353eb2b44df8 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Tue Sep 29 21:37:07 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Tue Sep 29 22:00:39 2015 +0200 @@ -529,7 +529,7 @@ * @param methods the methods to look for, where {@code null} means that any frame is returned * @return the frame, or {@code null} if the end of the stack was reached during the search */ - public HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip) { + HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip) { return getNextStackFrameImpl(frame, methods, initialSkip); } diff -r 02d95720c455 -r 353eb2b44df8 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotStackIntrospection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotStackIntrospection.java Tue Sep 29 22:00:39 2015 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.jvmci.hotspot; + +import jdk.internal.jvmci.code.stack.InspectedFrameVisitor; +import jdk.internal.jvmci.code.stack.StackIntrospection; +import jdk.internal.jvmci.meta.ResolvedJavaMethod; + +public class HotSpotStackIntrospection implements StackIntrospection { + + protected final HotSpotJVMCIRuntimeProvider runtime; + + public HotSpotStackIntrospection(HotSpotJVMCIRuntimeProvider runtime) { + this.runtime = runtime; + } + + @Override + public T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor) { + CompilerToVM compilerToVM = runtime.getCompilerToVM(); + HotSpotStackFrameReference current = compilerToVM.getNextStackFrame(null, initialMethods, initialSkip); + while (current != null) { + T result = visitor.visitFrame(current); + if (result != null) { + return result; + } + current = compilerToVM.getNextStackFrame(current, matchingMethods, 0); + } + return null; + } +} diff -r 02d95720c455 -r 353eb2b44df8 jvmci/jdk.internal.jvmci.runtime/src/jdk/internal/jvmci/runtime/JVMCIBackend.java --- a/jvmci/jdk.internal.jvmci.runtime/src/jdk/internal/jvmci/runtime/JVMCIBackend.java Tue Sep 29 21:37:07 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.runtime/src/jdk/internal/jvmci/runtime/JVMCIBackend.java Tue Sep 29 22:00:39 2015 +0200 @@ -24,6 +24,7 @@ import jdk.internal.jvmci.code.CodeCacheProvider; import jdk.internal.jvmci.code.TargetDescription; +import jdk.internal.jvmci.code.stack.StackIntrospection; import jdk.internal.jvmci.meta.ConstantReflectionProvider; import jdk.internal.jvmci.meta.MetaAccessProvider; @@ -37,11 +38,13 @@ private final MetaAccessProvider metaAccess; private final CodeCacheProvider codeCache; private final ConstantReflectionProvider constantReflection; + private final StackIntrospection stackIntrospection; - public JVMCIBackend(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection) { + public JVMCIBackend(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { this.metaAccess = metaAccess; this.codeCache = codeCache; this.constantReflection = constantReflection; + this.stackIntrospection = stackIntrospection; } public MetaAccessProvider getMetaAccess() { @@ -59,4 +62,8 @@ public TargetDescription getTarget() { return codeCache.getTarget(); } + + public StackIntrospection getStackIntrospection() { + return stackIntrospection; + } }