@@ -1643,9 +1643,10 @@ module Codebuf =
16431643// a safe approximation because code only gets smaller.
16441644if not ( origAvailBrFixups.ContainsKey tg) then
16451645 dprintn( " branch target" + formatCodeLabel tg+ " not found in code" )
1646- let origDest =
1647- if origAvailBrFixups.ContainsKey tgthen origAvailBrFixups.[ tg]
1648- else 666666
1646+ let origDest =
1647+ match origAvailBrFixups.TryGetValue( tg) with
1648+ | true , fixup-> fixup
1649+ | _ -> 666666
16491650let origRelOffset = origDest- origEndOfInstr
16501651- 128 <= origRelOffset&& origRelOffset<= 127
16511652end
@@ -1718,18 +1719,16 @@ module Codebuf =
17181719
17191720// Now apply the adjusted fixups in the new code
17201721 newReqdBrFixups|> List.iter( fun ( newFixupLoc , endOfInstr , tg , small ) ->
1721- if not ( newAvailBrFixups.ContainsKey tg) then
1722- failwith( " target" + formatCodeLabel tg+ " not found in new fixups" )
1723- try
1724- let n = newAvailBrFixups.[ tg]
1725- let relOffset = ( n- endOfInstr)
1726- if smallthen
1727- if Bytes.get newCode newFixupLoc<> 0x98 then failwith" br fixupsanity check failed"
1728- newCode.[ newFixupLoc] <- b0 relOffset
1729- else
1730- checkFixup32 newCode newFixupLoc0xf00dd00f l
1731- applyFixup32 newCode newFixupLoc relOffset
1732- with :? KeyNotFoundException-> ())
1722+ match newAvailBrFixups.TryGetValue( tg) with
1723+ | true , n->
1724+ let relOffset = n- endOfInstr
1725+ if smallthen
1726+ if Bytes.get newCode newFixupLoc<> 0x98 then failwith" br fixupsanity check failed"
1727+ newCode.[ newFixupLoc] <- b0 relOffset
1728+ else
1729+ checkFixup32 newCode newFixupLoc0xf00dd00f l
1730+ applyFixup32 newCode newFixupLoc relOffset
1731+ | _ -> failwith( " target" + formatCodeLabel tg+ " not found in new fixups" ))
17331732
17341733 newCode, newReqdStringFixups, newExnClauses, newSeqPoints, newScopes
17351734
@@ -2162,14 +2161,19 @@ module Codebuf =
21622161// Build a table mapping Abstract IL pcs to positions in the generated code buffer
21632162let pc2pos = Array.zeroCreate( instrs.Length+ 1 )
21642163let pc2labs = Dictionary()
2165- for ( KeyValue( lab, pc)) in code.Labelsdo
2166- if pc2labs.ContainsKey pcthen pc2labs.[ pc] <- lab:: pc2labs.[ pc] else pc2labs.[ pc] <- [ lab]
2164+ for KeyValue( lab, pc) in code.Labelsdo
2165+ match pc2labs.TryGetValue( pc) with
2166+ | true , labels->
2167+ pc2labs.[ pc] <- lab:: labels
2168+ | _ -> pc2labs.[ pc] <- [ lab]
21672169
21682170// Emit the instructions
21692171for pc= 0 to instrs.Lengthdo
2170- if pc2labs.ContainsKey pcthen
2171- for labin pc2labs.[ pc] do
2172- codebuf.RecordAvailBrFixup lab
2172+ match pc2labs.TryGetValue( pc) with
2173+ | true , labels->
2174+ for labin labelsdo
2175+ codebuf.RecordAvailBrFixup( lab)
2176+ | _ -> ()
21732177 pc2pos.[ pc] <- codebuf.code.Position
21742178if pc< instrs.Lengththen
21752179match instrs.[ pc] with