@@ -35,6 +35,8 @@ public void AddsSigned()
3535 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( def ) ;
3636 var result = op1 + op2 ;
3737 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
38+
39+ engine . FreeMachineCodeForFunction ( def ) ;
3840 }
3941
4042 [ Test ]
@@ -60,6 +62,7 @@ public void ShiftsRight([Range(0, 256)] int op1, [Range(0, 8)] int op2)
6062 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( def ) ;
6163 var result = op1 >> op2 ;
6264 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
65+ engine . FreeMachineCodeForFunction ( def ) ;
6366 }
6467
6568 [ Test ]
@@ -85,6 +88,7 @@ public void ComparesGreaterThan([Range(0, 10)] int op1, [Range(0, 10)] int op2)
8588 var func = engine . GetPointerToGlobal < Int32Int32Int8Delegate > ( def ) ;
8689 var result = op1 > op2 ? 1 : 0 ;
8790 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
91+ engine . FreeMachineCodeForFunction ( def ) ;
8892 }
8993
9094 [ Test ]
@@ -116,6 +120,9 @@ public void CallsFunction([Range(0, 10)] int op1, [Range(0, 10)] int op2)
116120 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( entryDef ) ;
117121 var result = op1 + op2 ;
118122 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
123+
124+ engine . FreeMachineCodeForFunction ( entryDef ) ;
125+ engine . FreeMachineCodeForFunction ( addDef ) ;
119126 }
120127
121128 [ Test ]
@@ -139,6 +146,8 @@ public void ReturnsConstant([Range(0, 10)] int input)
139146 var engine = module . CreateMCJITCompiler ( ) ;
140147 var func = engine . GetPointerToGlobal < Int32Delegate > ( def ) ;
141148 Assert . That ( func ( ) , Is . EqualTo ( input ) ) ;
149+
150+ engine . FreeMachineCodeForFunction ( def ) ;
142151 }
143152
144153 [ Test ]
@@ -163,5 +172,7 @@ public void ReturnsSizeOf()
163172 var engine = module . CreateMCJITCompiler ( ) ;
164173 var func = engine . GetPointerToGlobal < Int32Delegate > ( def ) ;
165174 Assert . That ( func ( ) , Is . EqualTo ( 8 ) ) ;
175+
176+ engine . FreeMachineCodeForFunction ( def ) ;
166177 }
167178}
0 commit comments