< prev index next >

test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java

Print this page

        

*** 35,58 **** package compiler.jvmci.compilerToVM; import compiler.jvmci.common.CTVMUtilities; import java.lang.reflect.Method; - import jdk.vm.ci.hotspot.CompilerToVM; import jdk.vm.ci.hotspot.CompilerToVMHelper; - import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl; import jdk.vm.ci.hotspot.HotSpotStackFrameReference; import jdk.test.lib.Asserts; public class GetNextStackFrameTest { private static final int RECURSION_AMOUNT = 3; ! private static final HotSpotResolvedJavaMethodImpl REC_FRAME_METHOD; ! private static final HotSpotResolvedJavaMethodImpl FRAME1_METHOD; ! private static final HotSpotResolvedJavaMethodImpl FRAME2_METHOD; ! private static final HotSpotResolvedJavaMethodImpl FRAME3_METHOD; ! private static final HotSpotResolvedJavaMethodImpl FRAME4_METHOD; ! private static final HotSpotResolvedJavaMethodImpl RUN_METHOD; static { Method method; try { Class<?> aClass = GetNextStackFrameTest.class; --- 35,57 ---- package compiler.jvmci.compilerToVM; import compiler.jvmci.common.CTVMUtilities; import java.lang.reflect.Method; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotStackFrameReference; + import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.test.lib.Asserts; public class GetNextStackFrameTest { private static final int RECURSION_AMOUNT = 3; ! private static final ResolvedJavaMethod REC_FRAME_METHOD; ! private static final ResolvedJavaMethod FRAME1_METHOD; ! private static final ResolvedJavaMethod FRAME2_METHOD; ! private static final ResolvedJavaMethod FRAME3_METHOD; ! private static final ResolvedJavaMethod FRAME4_METHOD; ! private static final ResolvedJavaMethod RUN_METHOD; static { Method method; try { Class<?> aClass = GetNextStackFrameTest.class;
*** 67,77 **** method = aClass.getDeclaredMethod("frame4"); FRAME4_METHOD = CTVMUtilities.getResolvedMethod(method); method = Thread.class.getDeclaredMethod("run"); RUN_METHOD = CTVMUtilities.getResolvedMethod(Thread.class, method); } catch (NoSuchMethodException e) { ! throw new Error("TEST BUG: can't find a test method", e); } } public static void main(String[] args) { new GetNextStackFrameTest().test(); --- 66,76 ---- method = aClass.getDeclaredMethod("frame4"); FRAME4_METHOD = CTVMUtilities.getResolvedMethod(method); method = Thread.class.getDeclaredMethod("run"); RUN_METHOD = CTVMUtilities.getResolvedMethod(Thread.class, method); } catch (NoSuchMethodException e) { ! throw new Error("TEST BUG: can't find a test method : " + e, e); } } public static void main(String[] args) { new GetNextStackFrameTest().test();
*** 124,134 **** /** * Finds the first topmost frame from the list of methods to search */ private void findFirst() { checkNextFrameFor(null /* topmost frame */, ! new HotSpotResolvedJavaMethodImpl[] {FRAME2_METHOD, FRAME3_METHOD, FRAME4_METHOD}, FRAME4_METHOD, 0); } /** --- 123,133 ---- /** * Finds the first topmost frame from the list of methods to search */ private void findFirst() { checkNextFrameFor(null /* topmost frame */, ! new ResolvedJavaMethod[] {FRAME2_METHOD, FRAME3_METHOD, FRAME4_METHOD}, FRAME4_METHOD, 0); } /**
*** 137,166 **** */ private void walkThrough() { // Check that we would get a frame 4 starting from the topmost frame HotSpotStackFrameReference nextStackFrame = checkNextFrameFor( null /* topmost frame */, ! new HotSpotResolvedJavaMethodImpl[] {FRAME4_METHOD}, FRAME4_METHOD, 0); // Check that we would get a frame 3 starting from frame 4 when we try // to search one of the next two frames nextStackFrame = checkNextFrameFor(nextStackFrame, ! new HotSpotResolvedJavaMethodImpl[] {FRAME3_METHOD, FRAME2_METHOD}, FRAME3_METHOD, 0); // Check that we would get a frame 1 nextStackFrame = checkNextFrameFor(nextStackFrame, ! new HotSpotResolvedJavaMethodImpl[] {FRAME1_METHOD}, FRAME1_METHOD, 0); // Check that we would skip (RECURSION_AMOUNT - 1) methods and find a // recursionFrame starting from frame 1 nextStackFrame = checkNextFrameFor(nextStackFrame, ! new HotSpotResolvedJavaMethodImpl[] {REC_FRAME_METHOD}, REC_FRAME_METHOD, RECURSION_AMOUNT - 1); // Check that we would get a Thread::run method frame; nextStackFrame = checkNextFrameFor(nextStackFrame, ! new HotSpotResolvedJavaMethodImpl[] {RUN_METHOD}, RUN_METHOD, 0); // Check that there are no more frames after thread's run method nextStackFrame = CompilerToVMHelper.getNextStackFrame(nextStackFrame, null /* any */, 0); Asserts.assertNull(nextStackFrame, --- 136,165 ---- */ private void walkThrough() { // Check that we would get a frame 4 starting from the topmost frame HotSpotStackFrameReference nextStackFrame = checkNextFrameFor( null /* topmost frame */, ! new ResolvedJavaMethod[] {FRAME4_METHOD}, FRAME4_METHOD, 0); // Check that we would get a frame 3 starting from frame 4 when we try // to search one of the next two frames nextStackFrame = checkNextFrameFor(nextStackFrame, ! new ResolvedJavaMethod[] {FRAME3_METHOD, FRAME2_METHOD}, FRAME3_METHOD, 0); // Check that we would get a frame 1 nextStackFrame = checkNextFrameFor(nextStackFrame, ! new ResolvedJavaMethod[] {FRAME1_METHOD}, FRAME1_METHOD, 0); // Check that we would skip (RECURSION_AMOUNT - 1) methods and find a // recursionFrame starting from frame 1 nextStackFrame = checkNextFrameFor(nextStackFrame, ! new ResolvedJavaMethod[] {REC_FRAME_METHOD}, REC_FRAME_METHOD, RECURSION_AMOUNT - 1); // Check that we would get a Thread::run method frame; nextStackFrame = checkNextFrameFor(nextStackFrame, ! new ResolvedJavaMethod[] {RUN_METHOD}, RUN_METHOD, 0); // Check that there are no more frames after thread's run method nextStackFrame = CompilerToVMHelper.getNextStackFrame(nextStackFrame, null /* any */, 0); Asserts.assertNull(nextStackFrame,
*** 185,214 **** */ private void findNextSkipped() { // Get frame 4 HotSpotStackFrameReference nextStackFrame = CompilerToVMHelper .getNextStackFrame(null /* topmost frame */, ! new HotSpotResolvedJavaMethodImpl[] {FRAME4_METHOD}, 0); // Get frame 2 by skipping one method starting from frame 4 checkNextFrameFor(nextStackFrame, null /* any */, FRAME2_METHOD , 1 /* skip one */); } /** * Finds test method in the stack */ private void findYourself() { Method method; try { ! method = CompilerToVM.class.getDeclaredMethod("getNextStackFrame", HotSpotStackFrameReference.class, ! HotSpotResolvedJavaMethodImpl[].class, int.class); } catch (NoSuchMethodException e) { ! throw new Error("TEST BUG: can't find getNextStackFrame method"); } ! HotSpotResolvedJavaMethodImpl self ! = CTVMUtilities.getResolvedMethod(CompilerToVM.class, method); checkNextFrameFor(null /* topmost frame */, null /* any */, self, 0); } /** * Searches next frame and checks that it equals to expected --- 184,216 ---- */ private void findNextSkipped() { // Get frame 4 HotSpotStackFrameReference nextStackFrame = CompilerToVMHelper .getNextStackFrame(null /* topmost frame */, ! new ResolvedJavaMethod[] {FRAME4_METHOD}, 0); // Get frame 2 by skipping one method starting from frame 4 checkNextFrameFor(nextStackFrame, null /* any */, FRAME2_METHOD , 1 /* skip one */); } /** * Finds test method in the stack */ private void findYourself() { Method method; + Class<?> aClass = CompilerToVMHelper.CompilerToVMClass(); try { ! method = aClass.getDeclaredMethod( ! "getNextStackFrame", HotSpotStackFrameReference.class, ! ResolvedJavaMethod[].class, ! int.class); } catch (NoSuchMethodException e) { ! throw new Error("TEST BUG: can't find getNextStackFrame : " + e, e); } ! ResolvedJavaMethod self ! = CTVMUtilities.getResolvedMethod(aClass, method); checkNextFrameFor(null /* topmost frame */, null /* any */, self, 0); } /** * Searches next frame and checks that it equals to expected
*** 219,230 **** * @param skip amount of frames to be skipped * @return frame reference */ private HotSpotStackFrameReference checkNextFrameFor( HotSpotStackFrameReference currentFrame, ! HotSpotResolvedJavaMethodImpl[] searchMethods, ! HotSpotResolvedJavaMethodImpl expected, int skip) { HotSpotStackFrameReference nextStackFrame = CompilerToVMHelper .getNextStackFrame(currentFrame, searchMethods, skip); Asserts.assertNotNull(nextStackFrame); Asserts.assertTrue(nextStackFrame.isMethod(expected), --- 221,232 ---- * @param skip amount of frames to be skipped * @return frame reference */ private HotSpotStackFrameReference checkNextFrameFor( HotSpotStackFrameReference currentFrame, ! ResolvedJavaMethod[] searchMethods, ! ResolvedJavaMethod expected, int skip) { HotSpotStackFrameReference nextStackFrame = CompilerToVMHelper .getNextStackFrame(currentFrame, searchMethods, skip); Asserts.assertNotNull(nextStackFrame); Asserts.assertTrue(nextStackFrame.isMethod(expected),
< prev index next >