MathInterpreter: Replace Instruction polymorphism with bytecode#20
Open
mspraggs wants to merge 1 commit intoaportelli:developfrom
Open
MathInterpreter: Replace Instruction polymorphism with bytecode#20mspraggs wants to merge 1 commit intoaportelli:developfrom
mspraggs wants to merge 1 commit intoaportelli:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi Antonin,
I hope you're keeping well.
This change replaces the
Instructionclass hierarchy with a bytecode-based instruction representation. Instead of anInstructioninstance, each instruction opcode is specified by a single byte, and instruction arguments are packed into the bytecode array. The arithmetic operations are represented by a single byte, the load, store and call operations are encoded as a byte followed by the variable or function address, and the constant instruction is encoded as a single opcode followed by the double-precision floating point value. I hope this makes sense. If not, this should provide a fuller explanation.Replacing the polymorphic instruction classes with a packed bytecode array increases the locality of reference during execution. After some rough benchmarks I found the improvement was a factor of two, though more performance could be squeezed out through other modifications. For example, the
std::dequecontainer wrapped by thestd::stackcould be replaced with astd::vector.Let me know what you think.
Best,
Matt