@@ -104,33 +104,33 @@ public GcSlotTable() { }
104104 /// <summary>
105105 /// based on <a href="https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/gcinfodecoder.cpp">GcSlotDecoder::DecodeSlotTable</a>
106106 /// </summary>
107- public GcSlotTable ( byte [ ] image , Machine machine , GcInfoTypes gcInfoTypes , ref int bitOffset )
107+ public GcSlotTable ( NativeReader imageReader , Machine machine , GcInfoTypes gcInfoTypes , ref int bitOffset )
108108 {
109109 _machine = machine ;
110110
111- if ( NativeReader . ReadBits ( image , 1 , ref bitOffset ) != 0 )
111+ if ( imageReader . ReadBits ( 1 , ref bitOffset ) != 0 )
112112 {
113- NumRegisters = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . NUM_REGISTERS_ENCBASE , ref bitOffset ) ;
113+ NumRegisters = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . NUM_REGISTERS_ENCBASE , ref bitOffset ) ;
114114 }
115- if ( NativeReader . ReadBits ( image , 1 , ref bitOffset ) != 0 )
115+ if ( imageReader . ReadBits ( 1 , ref bitOffset ) != 0 )
116116 {
117- NumStackSlots = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . NUM_STACK_SLOTS_ENCBASE , ref bitOffset ) ;
118- NumUntracked = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . NUM_UNTRACKED_SLOTS_ENCBASE , ref bitOffset ) ;
117+ NumStackSlots = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . NUM_STACK_SLOTS_ENCBASE , ref bitOffset ) ;
118+ NumUntracked = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . NUM_UNTRACKED_SLOTS_ENCBASE , ref bitOffset ) ;
119119 }
120120 NumSlots = NumRegisters + NumStackSlots + NumUntracked ;
121121
122122 GcSlots = new List < GcSlot > ( ) ;
123123 if ( NumRegisters > 0 )
124124 {
125- DecodeRegisters ( image , gcInfoTypes , ref bitOffset ) ;
125+ DecodeRegisters ( imageReader , gcInfoTypes , ref bitOffset ) ;
126126 }
127127 if ( NumStackSlots > 0 )
128128 {
129- DecodeStackSlots ( image , machine , gcInfoTypes , NumStackSlots , false , ref bitOffset ) ;
129+ DecodeStackSlots ( imageReader , machine , gcInfoTypes , NumStackSlots , false , ref bitOffset ) ;
130130 }
131131 if ( NumUntracked > 0 )
132132 {
133- DecodeStackSlots ( image , machine , gcInfoTypes , NumUntracked , true , ref bitOffset ) ;
133+ DecodeStackSlots ( imageReader , machine , gcInfoTypes , NumUntracked , true , ref bitOffset ) ;
134134 }
135135 }
136136
@@ -150,50 +150,50 @@ public override string ToString()
150150 return sb . ToString ( ) ;
151151 }
152152
153- private void DecodeRegisters ( byte [ ] image , GcInfoTypes gcInfoTypes , ref int bitOffset )
153+ private void DecodeRegisters ( NativeReader imageReader , GcInfoTypes gcInfoTypes , ref int bitOffset )
154154 {
155155 // We certainly predecode the first register
156- uint regNum = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . REGISTER_ENCBASE , ref bitOffset ) ;
157- GcSlotFlags flags = ( GcSlotFlags ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
156+ uint regNum = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . REGISTER_ENCBASE , ref bitOffset ) ;
157+ GcSlotFlags flags = ( GcSlotFlags ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
158158 GcSlots . Add ( new GcSlot ( GcSlots . Count , ( int ) regNum , null , flags ) ) ;
159159
160160 for ( int i = 1 ; i < NumRegisters ; i ++ )
161161 {
162162 if ( ( uint ) flags != 0 )
163163 {
164- regNum = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . REGISTER_ENCBASE , ref bitOffset ) ;
165- flags = ( GcSlotFlags ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
164+ regNum = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . REGISTER_ENCBASE , ref bitOffset ) ;
165+ flags = ( GcSlotFlags ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
166166 }
167167 else
168168 {
169- uint regDelta = NativeReader . DecodeVarLengthUnsigned ( image , gcInfoTypes . REGISTER_DELTA_ENCBASE , ref bitOffset ) + 1 ;
169+ uint regDelta = imageReader . DecodeVarLengthUnsigned ( gcInfoTypes . REGISTER_DELTA_ENCBASE , ref bitOffset ) + 1 ;
170170 regNum += regDelta ;
171171 }
172172 GcSlots . Add ( new GcSlot ( GcSlots . Count , ( int ) regNum , null , flags ) ) ;
173173 }
174174 }
175175
176- private void DecodeStackSlots ( byte [ ] image , Machine machine , GcInfoTypes gcInfoTypes , uint nSlots , bool isUntracked , ref int bitOffset )
176+ private void DecodeStackSlots ( NativeReader imageReader , Machine machine , GcInfoTypes gcInfoTypes , uint nSlots , bool isUntracked , ref int bitOffset )
177177 {
178178 // We have stack slots left and more room to predecode
179- GcStackSlotBase spBase = ( GcStackSlotBase ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
180- int normSpOffset = NativeReader . DecodeVarLengthSigned ( image , gcInfoTypes . STACK_SLOT_ENCBASE , ref bitOffset ) ;
179+ GcStackSlotBase spBase = ( GcStackSlotBase ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
180+ int normSpOffset = imageReader . DecodeVarLengthSigned ( gcInfoTypes . STACK_SLOT_ENCBASE , ref bitOffset ) ;
181181 int spOffset = gcInfoTypes . DenormalizeStackSlot ( normSpOffset ) ;
182- GcSlotFlags flags = ( GcSlotFlags ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
182+ GcSlotFlags flags = ( GcSlotFlags ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
183183 GcSlots . Add ( new GcSlot ( GcSlots . Count , - 1 , new GcStackSlot ( spOffset , spBase ) , flags , isUntracked ) ) ;
184184
185185 for ( int i = 1 ; i < nSlots ; i ++ )
186186 {
187- spBase = ( GcStackSlotBase ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
187+ spBase = ( GcStackSlotBase ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
188188 if ( ( uint ) flags != 0 )
189189 {
190- normSpOffset = NativeReader . DecodeVarLengthSigned ( image , gcInfoTypes . STACK_SLOT_ENCBASE , ref bitOffset ) ;
190+ normSpOffset = imageReader . DecodeVarLengthSigned ( gcInfoTypes . STACK_SLOT_ENCBASE , ref bitOffset ) ;
191191 spOffset = gcInfoTypes . DenormalizeStackSlot ( normSpOffset ) ;
192- flags = ( GcSlotFlags ) NativeReader . ReadBits ( image , 2 , ref bitOffset ) ;
192+ flags = ( GcSlotFlags ) imageReader . ReadBits ( 2 , ref bitOffset ) ;
193193 }
194194 else
195195 {
196- int normSpOffsetDelta = NativeReader . DecodeVarLengthSigned ( image , gcInfoTypes . STACK_SLOT_DELTA_ENCBASE , ref bitOffset ) ;
196+ int normSpOffsetDelta = imageReader . DecodeVarLengthSigned ( gcInfoTypes . STACK_SLOT_DELTA_ENCBASE , ref bitOffset ) ;
197197 normSpOffset += normSpOffsetDelta ;
198198 spOffset = gcInfoTypes . DenormalizeStackSlot ( normSpOffset ) ;
199199 }
0 commit comments