# Code Review: InstructionRefactoring

**URL:** <https://www.ruby-forum.com/t/code-review-instructionrefactoring/178715>\
**Category:** IronRuby\
**Created:** [November 9, 2009, 10:22pm UTC](https://www.ruby-forum.com/t/code-review-instructionrefactoring/178715 "2009-11-09T22:22:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grujildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@grujildo](https://www.ruby-forum.com/u/grujildo)\
**Post date:** [November 9, 2009, 10:22pm UTC](https://www.ruby-forum.com/t/code-review-instructionrefactoring/178715/1 "2009-11-09T22:22:49Z")

</div>

tfpt review “/shelveset:InstructionRefactoring;REDMOND\tomat”

DLR, Python Ruby:

Makes all instruction classes internal except for the base Instruction  
class. Adds InstructionList class that represents incomplete instruction  
stream and provides Emit\* instructions (like ILGenerator). The class is  
converted to InstructionArray when finished. Both implement a debug view  
so that it is easy to see what instructions are being  
emitted/interpreted.

Implements cache for LoadObject instruction - instead of allocating a  
new instruction per object constant we store the constants into an array  
and have specialized pre-generated instructions to load them.  
Adds caching of branch instructions.  
Adds debug cookies to instruction list in DEBUG builds - each  
instruction can be associates with one or more debug cookies.  
LocalAccess instructions use this to store the variable names. The  
cookies are used in debug view.

Groups related instructions into separate files.  
Implements AddInstuction for all primitive arithmetic types.

Adds -X:CompilationThreshold option that sets the number of iterations  
before we start compiling code.  
Obsoletes InterpretedMode, NoAdaptiveCompilation and PerfStats  
properties on LanguageSetup. The options can still be set via  
dictionary.

Reduces the number of instruction instances that are executed at least  
once during the run of “mspec ci core” from 1,274,454 to 280,684.

Tomas
