{"record":{"id":"c021255f0a099426","repo":"oracle/graal","slug":"too-many-decompiles","errorCode":null,"errorMessage":"too many decompiles: {} {}","messagePattern":"too many decompiles: (.+?) (.+?)","errorType":"error_code","errorClass":"ForceDeoptSpeculationPhase.TooManyDeoptimizationsError","httpStatus":null,"severity":"critical","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/CompilationTask.java","lineNumber":395,"sourceCode":"                }\n                ListIterator<BasePhase<? super LowTierContext>> lowTierPhasesIterator = suites.getLowTier().findPhase(SchedulePhase.FinalSchedulePhase.class);\n                if (lowTierPhasesIterator != null) {\n                    lowTierPhasesIterator.previous();\n                    lowTierPhasesIterator.add(new ForceDeoptSpeculationPhase(decompileCount));\n                }\n            }\n        }\n\n        /**\n         * Checks whether the recompilation limit is exceeded, and if so, throws an exception.\n         *\n         * @param options the option values\n         * @param method the compiled method\n         */\n        private void performRecompilationCheck(OptionValues options, HotSpotResolvedJavaMethod method) {\n            if (checkRecompileCycle && (MethodRecompilationLimit.getValue(options) >= 0 && decompileCount >= MethodRecompilationLimit.getValue(options))) {\n                ProfilingInfo info = profileProvider.getProfilingInfo(null, method);\n                throw new ForceDeoptSpeculationPhase.TooManyDeoptimizationsError(\"too many decompiles: \" + decompileCount + \" \" + ForceDeoptSpeculationPhase.getDeoptSummary(info));\n            }\n        }\n\n        private static final TimerKey CompilationReplayTime = DebugContext.timer(\"CompilationReplayTime\").doc(\"The time spent in recorded/replayed compilations.\");\n\n        private static final CounterKey CompilationReplayBytecodes = DebugContext.counter(\"CompilationReplayBytecodes\").doc(\"The size of bytecodes compiled in recorded/replayed compilations.\");\n\n        /**\n         * Performs a recorded or replayed compilation.\n         *\n         * @param initialDebug the initial debug context\n         * @return the compilation result\n         */\n        @SuppressWarnings(\"try\")\n        private HotSpotCompilationRequestResult performCompilationWithReplaySupport(DebugContext initialDebug) {\n            OptionValues options = initialDebug.getOptions();\n            HotSpotGraalCompiler selectedCompiler;\n            if (compiler.getGraalRuntime().getReplayCompilationSupport() != null) {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/CompilationTask.java#L377-L413","documentation":"Before (re)compiling a method, CompilationTask.performRecompilationCheck verifies that the method's deoptimization count has reached MethodRecompilationLimit; if so it throws ForceDeoptSpeculationPhase.TooManyDeoptimizationsError with the decompile count and a deopt summary. This aborts a pathological compile/deoptimize cycle instead of looping forever.","triggerScenarios":"Running with checkRecompilationCycle enabled and MethodRecompilationLimit >= 0 (it is on by default with a finite limit), when a method's accumulated decompiles (decompileCount) >= the limit at the start of a compilation; the summary comes from profileProvider.getProfilingInfo(null, method) for the failing method.","commonSituations":"Degenerate profiling feedback or unstable speculation causing the method to deopt and recompile repeatedly (e.g. flipping branch profiles in benchmarks, broken custom speculation plugins); lowering MethodRecompilationLimit too far; class redefinition (instrumentation) churn.","solutions":["Inspect the deopt summary in the message to find which speculation/deopt reason loops, and fix the root cause (e.g. stabilizing profiles or fixing the custom phase/speculation)","Raise or disable the guard for diagnosis: -Dgraal.MethodRecompilationLimit=-1 (or a larger value)","Report the reproducer to the Graal team if it occurs with a stock configuration on unmodified code"],"exampleFix":"# before\njava -XX:+UseJVMCICompiler MyApp\n# TooManyDeoptimizationsError: too many decompiles: 5 ...\n\n# after (diagnosis: raise the limit while investigating the deopt loop)\njava -XX:+UseJVMCICompiler -Dgraal.MethodRecompilationLimit=-1 MyApp\n# then use -Dgraal.Dump=... and the deopt summary to find the unstable speculation","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// usually not caught: TooManyDeoptimizationsError is a Graal-internal Error surfaced via a crashed compilation; treat as a bug report trigger, not a recoverable path","preventionTips":["Keep MethodRecompilationLimit at defaults; only raise it for diagnosis","Watch for repeated deopt+recompile of the same method in logs before it hits the limit","Avoid unstable custom speculation/profile injection in plugins"],"tags":["graal-compiler","deoptimization","recompilation","hotspot"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}