[GR-51945][GR-71030][GR-71031] Add BytecodeDescriptor; Add InstructionTracer #12435
+5,826
−664
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MyBytecodeRootNodeGen.Bytecodeclass that can be accessed via theMyBytecodeRootNodeGen.BYTECODEsingleton. This new class allows you to parse, serialize, deserialize, and bytecode nodes in addition to the already existing static methods in the generated code.InstructionDescriptorgenerated implementation for the bytecode interpreter. The instructions can be accessed via the new BytecodeDescriptor like this:MyBytecodeRootNodeGen.BYTECODE.getInstructionDescriptors(). There is alsoMyBytecodeRootNodeGen.BYTECODE.dump()to produce a human-readable instruction format.BytecodeDescriptor.update(MyLanguage, BytecodeConfig)to update the bytecode config for all current and root nodes created in the future of a language.InstructionTracerwithonInstructionEnter(InstructionAccess, BytecodeNode, int, Frame). Tracers can be attached per root viaBytecodeRootNodes.addInstructionTracer(InstructionTracer)and per descriptor viaBytecodeDescriptor.addInstructionTracer(TruffleLanguage, InstructionTracer). Attaching a tracer invalidates affected roots and may trigger reparse and comes at a significant cost.PrintInstructionTracerandInstructionHistogramTracer. These are intended for diagnostics.engine.TraceBytecodeto enable printing each executed Bytecode DSL instruction. Use theengine.BytecodeMethodFilteroption to print instructions only for a given method.engine.BytecodeHistogramto enable printing a bytecode histogram on engine close. Useengine.BytecodeHistogramIntervalto configure the interval at which the histogram is reset and printed.