@@ -113,37 +113,35 @@ func dropStatsIncrementInsts(filterIndex int, dropStatsMapFd int, nextLabel stri
113113 initLabel := fmt .Sprintf ("init_drop_stat_%d" , filterIndex )
114114
115115 return asm.Instructions {
116+ // Put the key on the stack
116117 asm .Mov .Reg (asm .R1 , asm .RFP ).WithSymbol (incLabel ),
117118 asm .Add .Imm (asm .R1 , int32 (dropStatsKeyStackOffset )),
118119 asm .Mov .Imm (asm .R2 , int32 (filterIndex )),
119120 asm .StoreMem (asm .R1 , 0 , asm .R2 , asm .DWord ),
120-
121+ // Lookup in the map
121122 asm .LoadMapPtr (asm .R1 , dropStatsMapFd ),
122123 asm .Mov .Reg (asm .R2 , asm .RFP ),
123124 asm .Add .Imm (asm .R2 , int32 (dropStatsKeyStackOffset )),
124125 asm .FnMapLookupElem .Call (),
125126 asm .JEq .Imm (asm .R0 , 0 , initLabel ),
126-
127+ // Increment if it exists
127128 asm .Mov .Reg (asm .R5 , asm .R0 ),
128129 asm .LoadMem (asm .R6 , asm .R5 , 0 , asm .DWord ),
129130 asm .Add .Imm (asm .R6 , 1 ),
130131 asm .StoreMem (asm .R5 , 0 , asm .R6 , asm .DWord ),
131-
132132 asm .Ja .Label (nextLabel ),
133-
133+ // Otherwise create the key and insert it
134134 asm .Mov .Reg (asm .R3 , asm .RFP ).WithSymbol (initLabel ),
135135 asm .Add .Imm (asm .R3 , int32 (dropStatsValStackOffset )),
136136 asm .Mov .Imm (asm .R4 , 1 ),
137137 asm .StoreMem (asm .R3 , 0 , asm .R4 , asm .DWord ),
138-
139138 asm .LoadMapPtr (asm .R1 , dropStatsMapFd ),
140139 asm .Mov .Reg (asm .R2 , asm .RFP ),
141140 asm .Add .Imm (asm .R2 , int32 (dropStatsKeyStackOffset )),
142141 asm .Mov .Reg (asm .R3 , asm .RFP ),
143142 asm .Add .Imm (asm .R3 , int32 (dropStatsValStackOffset )),
144143 asm .Mov .Imm (asm .R4 , 0 ),
145144 asm .FnMapUpdateElem .Call (),
146-
147145 asm .Ja .Label (nextLabel ),
148146 }
149147}
0 commit comments