< prev index next >

test/hotspot/jtreg/compiler/exceptions/OptimizeImplicitExceptions.java

Print this page

137     private static void printCounters(TestMode testMode, ImplicitException impExcp, Method throwImplicitException_m, int invocations) {
138         System.out.println("testMode=" + testMode + " exception=" + impExcp + " invocations=" + invocations + "\n" +
139                            "decompilecount=" + WB.getMethodDecompileCount(throwImplicitException_m) + " " +
140                            "trapCount=" + WB.getMethodTrapCount(throwImplicitException_m) + " " +
141                            "trapCount(" + impExcp.getReason() + ")=" +
142                            WB.getMethodTrapCount(throwImplicitException_m, impExcp.getReason()) + " " +
143                            "globalDeoptCount=" + WB.getDeoptCount() + " " +
144                            "globalDeoptCount(" + impExcp.getReason() + ")=" + WB.getDeoptCount(impExcp.getReason(), null));
145         System.out.println("method compiled=" + WB.isMethodCompiled(throwImplicitException_m));
146     }
147 
148     // Checks after the test method has been JIT-compiled but before the compiled version has been invoked.
149     private static void checkSimple(TestMode testMode, ImplicitException impExcp, Exception ex, Method throwImplicitException_m, int invocations) {
150 
151         printCounters(testMode, impExcp, throwImplicitException_m, invocations);
152         // At this point, throwImplicitException() has been compiled but the compiled version has not been invoked yet.
153         Asserts.assertEQ(WB.getMethodCompilationLevel(throwImplicitException_m), 4, "Method should be compiled at level 4.");
154 
155         int trapCount = WB.getMethodTrapCount(throwImplicitException_m);
156         int trapCountSpecific = WB.getMethodTrapCount(throwImplicitException_m, impExcp.getReason());
157         Asserts.assertEQ(trapCount, invocations, "Trap count must much invocation count.");
158         Asserts.assertEQ(trapCountSpecific, invocations, "Trap count must much invocation count.");
159         Asserts.assertNotNull(ex.getMessage(), "Exceptions thrown in the interpreter should have a message.");
160     }
161 
162     // Checks after the JIT-compiled test method has been invoked 'invocations' times.
163     private static void check(TestMode testMode, ImplicitException impExcp, Exception ex,
164                               Method throwImplicitException_m, int invocations, int totalInvocations) {
165 
166         printCounters(testMode, impExcp, throwImplicitException_m, totalInvocations);
167         // At this point, the compiled version of 'throwImplicitException()' has been invoked 'invocations' times.
168         Asserts.assertEQ(WB.getMethodCompilationLevel(throwImplicitException_m), 4, "Method should be compiled at level 4.");
169         int deoptCount = WB.getDeoptCount();
170         int deoptCountReason = WB.getDeoptCount(impExcp.getReason(), null/*action*/);
171         if (testMode == TestMode.OMIT_STACKTRACES_IN_FASTTHROW) {
172             // No deoptimizations for '-XX:+OmitStackTraceInFastThrow'
173             Asserts.assertEQ(oldDeoptCount, deoptCount, "Wrong number of deoptimizations.");
174             Asserts.assertEQ(oldDeoptCountReason.get(impExcp.getReason()), deoptCountReason, "Wrong number of deoptimizations.");
175             // '-XX:+OmitStackTraceInFastThrow' never has message because it is using a global singleton exception.
176             Asserts.assertNull(ex.getMessage(), "Optimized exceptions have no message.");
177         } else if (testMode == TestMode.STACKTRACES_IN_FASTTHROW) {
178             // We always deoptimize for '-XX:-OmitStackTraceInFastThrow

137     private static void printCounters(TestMode testMode, ImplicitException impExcp, Method throwImplicitException_m, int invocations) {
138         System.out.println("testMode=" + testMode + " exception=" + impExcp + " invocations=" + invocations + "\n" +
139                            "decompilecount=" + WB.getMethodDecompileCount(throwImplicitException_m) + " " +
140                            "trapCount=" + WB.getMethodTrapCount(throwImplicitException_m) + " " +
141                            "trapCount(" + impExcp.getReason() + ")=" +
142                            WB.getMethodTrapCount(throwImplicitException_m, impExcp.getReason()) + " " +
143                            "globalDeoptCount=" + WB.getDeoptCount() + " " +
144                            "globalDeoptCount(" + impExcp.getReason() + ")=" + WB.getDeoptCount(impExcp.getReason(), null));
145         System.out.println("method compiled=" + WB.isMethodCompiled(throwImplicitException_m));
146     }
147 
148     // Checks after the test method has been JIT-compiled but before the compiled version has been invoked.
149     private static void checkSimple(TestMode testMode, ImplicitException impExcp, Exception ex, Method throwImplicitException_m, int invocations) {
150 
151         printCounters(testMode, impExcp, throwImplicitException_m, invocations);
152         // At this point, throwImplicitException() has been compiled but the compiled version has not been invoked yet.
153         Asserts.assertEQ(WB.getMethodCompilationLevel(throwImplicitException_m), 4, "Method should be compiled at level 4.");
154 
155         int trapCount = WB.getMethodTrapCount(throwImplicitException_m);
156         int trapCountSpecific = WB.getMethodTrapCount(throwImplicitException_m, impExcp.getReason());
157         Asserts.assertEQ(trapCount, invocations, "Trap count must match invocation count.");
158         Asserts.assertEQ(trapCountSpecific, invocations, "Trap count must match invocation count.");
159         Asserts.assertNotNull(ex.getMessage(), "Exceptions thrown in the interpreter should have a message.");
160     }
161 
162     // Checks after the JIT-compiled test method has been invoked 'invocations' times.
163     private static void check(TestMode testMode, ImplicitException impExcp, Exception ex,
164                               Method throwImplicitException_m, int invocations, int totalInvocations) {
165 
166         printCounters(testMode, impExcp, throwImplicitException_m, totalInvocations);
167         // At this point, the compiled version of 'throwImplicitException()' has been invoked 'invocations' times.
168         Asserts.assertEQ(WB.getMethodCompilationLevel(throwImplicitException_m), 4, "Method should be compiled at level 4.");
169         int deoptCount = WB.getDeoptCount();
170         int deoptCountReason = WB.getDeoptCount(impExcp.getReason(), null/*action*/);
171         if (testMode == TestMode.OMIT_STACKTRACES_IN_FASTTHROW) {
172             // No deoptimizations for '-XX:+OmitStackTraceInFastThrow'
173             Asserts.assertEQ(oldDeoptCount, deoptCount, "Wrong number of deoptimizations.");
174             Asserts.assertEQ(oldDeoptCountReason.get(impExcp.getReason()), deoptCountReason, "Wrong number of deoptimizations.");
175             // '-XX:+OmitStackTraceInFastThrow' never has message because it is using a global singleton exception.
176             Asserts.assertNull(ex.getMessage(), "Optimized exceptions have no message.");
177         } else if (testMode == TestMode.STACKTRACES_IN_FASTTHROW) {
178             // We always deoptimize for '-XX:-OmitStackTraceInFastThrow
< prev index next >