From ec936d0a8e7023f0fa5b3cc5e7e91a0fe1134e81 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sun, 29 Sep 2024 12:49:01 +0000 Subject: [PATCH 1/2] fix parsing table cache bug --- src/Compiler/Facilities/prim-parsing.fs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Compiler/Facilities/prim-parsing.fs b/src/Compiler/Facilities/prim-parsing.fs index 3088a5579ed..8cab9f3b2df 100644 --- a/src/Compiler/Facilities/prim-parsing.fs +++ b/src/Compiler/Facilities/prim-parsing.fs @@ -151,7 +151,10 @@ module internal Implementation = //------------------------------------------------------------------------- // Read the tables written by FSYACC. - type AssocTable(elemTab: uint16[], offsetTab: uint16[], cache: int[], cacheSize: int) = + type AssocTable(elemTab: uint16[], offsetTab: uint16[], cache: int[]) = + + do Array.fill cache 0 cache.Length -1 + let cacheSize = cache.Length / 2 member t.ReadAssoc(minElemNum, maxElemNum, defaultValueOfAssoc, keyToFind) = // do a binary chop on the table @@ -273,13 +276,8 @@ module internal Implementation = let lhsPos = (Array.zeroCreate 2: Position[]) let reductions = tables.reductions let cacheSize = 7919 // the 1000'th prime - // Use a simpler hash table with faster lookup, but only one - // hash bucket per key. let actionTableCache = ArrayPool.Shared.Rent(cacheSize * 2) let gotoTableCache = ArrayPool.Shared.Rent(cacheSize * 2) - // Clear the arrays since ArrayPool does not - Array.Clear(actionTableCache, 0, actionTableCache.Length) - Array.Clear(gotoTableCache, 0, gotoTableCache.Length) use _cacheDisposal = { new IDisposable with @@ -289,10 +287,10 @@ module internal Implementation = } let actionTable = - AssocTable(tables.actionTableElements, tables.actionTableRowOffsets, actionTableCache, cacheSize) + AssocTable(tables.actionTableElements, tables.actionTableRowOffsets, actionTableCache) let gotoTable = - AssocTable(tables.gotos, tables.sparseGotoTableRowOffsets, gotoTableCache, cacheSize) + AssocTable(tables.gotos, tables.sparseGotoTableRowOffsets, gotoTableCache) let stateToProdIdxsTable = IdxToIdxListTable(tables.stateToProdIdxsTableElements, tables.stateToProdIdxsTableRowOffsets) From 69506dd9a049cd2fdc9c39c9c87d24e4a1555cfa Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:06:52 +0000 Subject: [PATCH 2/2] ran fantomas --- src/Compiler/Facilities/prim-parsing.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/Facilities/prim-parsing.fs b/src/Compiler/Facilities/prim-parsing.fs index 8cab9f3b2df..6bbbd6071ef 100644 --- a/src/Compiler/Facilities/prim-parsing.fs +++ b/src/Compiler/Facilities/prim-parsing.fs @@ -152,7 +152,7 @@ module internal Implementation = // Read the tables written by FSYACC. type AssocTable(elemTab: uint16[], offsetTab: uint16[], cache: int[]) = - + do Array.fill cache 0 cache.Length -1 let cacheSize = cache.Length / 2