{"record":{"id":"436406077469ac4d","repo":"oracle/graal","slug":"emitting-code-to-read-the-contents-of-the-protecti","errorCode":null,"errorMessage":"Emitting code to read the contents of the protection key register is not currently supported on %s","messagePattern":"Emitting code to read the contents of the protection key register is not currently supported on (.+?)","errorType":"exception","errorClass":"GraalError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGeneratorTool.java","lineNumber":1029,"sourceCode":"     */\n    void emitSpeculationFence();\n\n    /**\n     * Write value to the protection key register.\n     *\n     * @param value to be written\n     */\n    default void emitProtectionKeyRegisterWrite(Value value) {\n        throw new GraalError(\"Emitting code to write a value to the protection key register is not currently supported on %s\", target().arch);\n    }\n\n    /**\n     * Read contents of the protection key register.\n     *\n     * @return value read from the register\n     */\n    default Value emitProtectionKeyRegisterRead() {\n        throw new GraalError(\"Emitting code to read the contents of the protection key register is not currently supported on %s\", target().arch);\n    }\n\n    default VirtualStackSlot allocateStackMemory(int sizeInBytes, int alignmentInBytes) {\n        return getResult().getFrameMapBuilder().allocateStackMemory(sizeInBytes, alignmentInBytes);\n    }\n\n    default Value emitTimeStamp() {\n        throw new GraalError(\"Emitting code to return the current value of the timestamp counter is not currently supported on %s\", target().arch);\n    }\n\n    @SuppressWarnings(\"unused\")\n    default void emitProcid(AllocatableValue dst) {\n        throw new GraalError(\"Emitting code to return the current value of the procid is not currently supported on %s\", target().arch);\n    }\n\n    default Value emitReadCallerStackPointer(Stamp wordStamp) {\n        /*\n         * We do not know the frame size yet. So we load the address of the first spill slot","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGeneratorTool.java#L1011-L1047","documentation":"Default implementation of emitProtectionKeyRegisterRead() in LIRGeneratorTool; it throws GraalError naming the architecture whenever a backend without protection-key-register read support lowers such a node. The architecture is interpolated via target().arch in the message, telling you exactly which backend lacks the feature.","triggerScenarios":"A graph node lowers to a protection key register read (e.g., code that samples PKRU state) while compiling on a backend whose LIRGenerator does not override this method (currently all standard backends, since only new/riscv-style pkey work introduces it).","commonSituations":"Using memory-protection-key language features or intrinsics on a mainstream architecture; experimental branches emitting the read on unported backends; cross-compiling for an arch where pkeys do not exist.","solutions":["Avoid emitting protection-key reads on unsupported architectures by gating the frontend node on target().arch","Implement emitProtectionKeyRegisterRead in the target backend's LIRGenerator","Disable the protection-key feature in the guest language/runtime configuration on that platform"],"exampleFix":"// before\nValue pkru = getLIRGeneratorTool().emitProtectionKeyRegisterRead();\n\n// after: gate on backend support\nif (backendSupportsPkeyRead(arch)) {\n    Value pkru = getLIRGeneratorTool().emitProtectionKeyRegisterRead();\n} else {\n    pkru = ConstantNode.forInt(0, graph()); // feature disabled path\n}","handlingStrategy":"validation","validationCode":"if (backendOverrides(lirGen.getClass(), \"emitProtectionKeyRegisterRead\")) {\n    Value pkru = gen.emitProtectionKeyRegisterRead();\n} else {\n    throw GraalError.unsupported(\"pkey read not available on \" + arch);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check target().arch before lowering capability-specific reads","Model missing capabilities as unsupported in the frontend, not as backend crashes","Cover each new capability hook with per-arch compile tests"],"tags":["graalvm","lir","backend","protection-keys","unsupported-operation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}