{"record":{"id":"3d66f9d8695d26d7","repo":"oracle/graal","slug":"graph-too-large-to-safely-compile-in-reasonable-ti","errorCode":null,"errorMessage":"Graph too large to safely compile in reasonable time. Graph contains more than %d basic blocks","messagePattern":"Graph too large to safely compile in reasonable time\\. Graph contains more than (.+?) basic blocks","errorType":"exception","errorClass":"RetryableBailoutException","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/cfg/ControlFlowGraph.java","lineNumber":409,"sourceCode":"        }\n    }\n\n    @SuppressWarnings(\"try\")\n    private void identifyBlocks(boolean makeModifiable) {\n        try (DebugCloseable a = CFG_Build.start(graph.getDebug())) {\n            identifyBlocksImpl(makeModifiable);\n        }\n    }\n\n    private void identifyBlocksImpl(boolean makeModifiable) {\n        int numBlocks = 0;\n        for (AbstractBeginNode begin : graph.getNodes(AbstractBeginNode.TYPE)) {\n            GraalError.guarantee(begin.predecessor() != null || (begin instanceof AbstractMergeNode || begin instanceof StartNode), \"Disconnected control flow %s encountered\", begin);\n            HIRBlock block = makeModifiable ? new HIRBlock.ModifiableBlock(begin, this) : new HIRBlock.UnmodifiableBlock(begin, this);\n            identifyBlock(block);\n            numBlocks++;\n            if (numBlocks > AbstractControlFlowGraph.LAST_VALID_BLOCK_INDEX) {\n                throw new RetryableBailoutException(\"Graph too large to safely compile in reasonable time. Graph contains more than %d basic blocks\",\n                                AbstractControlFlowGraph.LAST_VALID_BLOCK_INDEX);\n            }\n        }\n        reversePostOrder = ReversePostOrder.identifyBlocks(this, numBlocks);\n        buildConfig.modifiableBlocks = makeModifiable;\n    }\n\n    @Override\n    public int getNumberOfLoops() {\n        return loops.size();\n    }\n\n    public double localLoopFrequency(LoopBeginNode lb) {\n        return localLoopFrequencyData.get(lb).getLoopFrequency();\n    }\n\n    public ProfileSource localLoopFrequencySource(LoopBeginNode lb) {\n        return localLoopFrequencyData.get(lb).getProfileSource();","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/cfg/ControlFlowGraph.java#L391-L427","documentation":"ControlFlowGraph.identifyBlocksImpl counts one HIRBlock per AbstractBeginNode; block indices are stored in bounded data structures, so exceeding AbstractControlFlowGraph.LAST_VALID_BLOCK_INDEX triggers a RetryableBailoutException stating the graph is too large to compile safely. Retryable means the compilation is re-attempted with a degraded configuration (e.g., less inlining) rather than permanently failing.","triggerScenarios":"A graph with more than the hard block-index limit (LAST_VALID_BLOCK_INDEX) basic blocks: gigantic methods, explosive inlining, or loop explosion/full unrolling that multiplies branch structure past the limit.","commonSituations":"AOT-compiling huge generated dispatch methods; eager inlining of interpreter loops in Truffle; raising inlining/unrolling budgets to extremes; machine-generated state machines.","solutions":["Confirm the retry path succeeds: a RetryableBailout normally recompiles with more conservative settings — only intervene if compilation ultimately fails","Reduce graph growth: less inlining (smaller MaximumInlineSize / more conservative profiles), less loop explosion, smaller methods","Split the giant method into smaller compilation units","If compiling generated code, cap the size of the largest generated methods"],"exampleFix":"# before: unbounded eager inlining grows one graph past the block limit\n-Dgraal.MaximumInlineSize=1000\n\n# after: keep graphs within the limit\n-Dgraal.MaximumInlineSize=200  # plus split the largest generated methods","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Compiler retries internally on RetryableBailoutException; harness-level fallback:\ntry { g = compile(m); } catch (RetryableBailoutException e) { g = compileWithConservativeInlining(m); }","preventionTips":["Keep graphs bounded: moderate inlining budgets and modest generated-method sizes","Watch for this after raising inlining/unrolling options aggressively","Split very large generated methods before AOT compilation"],"tags":["graalvm","control-flow-graph","graph-size","retryable-bailout"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}