parseman 0.61.2 → 0.61.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4064,7 +4064,7 @@ function regex(pattern, flags = "") {
4064
4064
  }
4065
4065
 
4066
4066
  // src/version.ts
4067
- var PARSEMAN_VERSION = "0.61.2";
4067
+ var PARSEMAN_VERSION = "0.61.4";
4068
4068
 
4069
4069
  // src/table/lex-body.ts
4070
4070
  function buildLexBodyRecognizer(spec, constants) {
package/dist/cli/index.js CHANGED
@@ -5700,7 +5700,7 @@ function regex(pattern, flags = "") {
5700
5700
  }
5701
5701
 
5702
5702
  // src/version.ts
5703
- var PARSEMAN_VERSION = "0.61.2";
5703
+ var PARSEMAN_VERSION = "0.61.4";
5704
5704
 
5705
5705
  // src/table/lex-body.ts
5706
5706
  function buildLexBodyRecognizer(spec, constants) {
package/dist/index.js CHANGED
@@ -5653,7 +5653,7 @@ function sourceLeaf(root, fn) {
5653
5653
  }
5654
5654
 
5655
5655
  // src/version.ts
5656
- var PARSEMAN_VERSION = "0.61.2";
5656
+ var PARSEMAN_VERSION = "0.61.4";
5657
5657
 
5658
5658
  // src/table/lex-body.ts
5659
5659
  function buildLexBodyRecognizer(spec, constants) {
@@ -19520,13 +19520,21 @@ function selectHotSites(code, entries, siteBytes, budget, profile) {
19520
19520
  let spent = 0;
19521
19521
  for (const ip of ranked) {
19522
19522
  if (w(ip) === 0) break;
19523
- const bytes2 = siteBytes.get(ip);
19524
- if (spent + bytes2 > budget) continue;
19525
- spent += bytes2;
19523
+ spent += siteBytes.get(ip);
19524
+ if (spent > budget) break;
19526
19525
  selected.add(ip);
19527
19526
  }
19528
19527
  return selected;
19529
19528
  }
19529
+ function fitHotSites(code, entries, siteBytes, fixed, ceiling, sourceBytes, profile) {
19530
+ const ranked = [...selectHotSites(code, entries, siteBytes, ceiling - fixed, profile)];
19531
+ for (; ranked.length > 0; ranked.pop()) {
19532
+ const sites = new Set(ranked);
19533
+ const bytes2 = sourceBytes(sites);
19534
+ if (bytes2 <= ceiling) return { sites, bytes: bytes2 };
19535
+ }
19536
+ return void 0;
19537
+ }
19530
19538
  function staticWeights(code, entries) {
19531
19539
  let weight = /* @__PURE__ */ new Map();
19532
19540
  const kids = [];
@@ -19666,19 +19674,20 @@ function compileRuleMap(ruleMap, opts = {}) {
19666
19674
  }
19667
19675
  const ceiling = budget / SUPERCOMPILE_GROWTH;
19668
19676
  if (ceiling <= fixed) return none;
19669
- let target = ceiling;
19670
- for (; ; ) {
19671
- const sites = selectHotSites(artifact.code, Object.values(artifact.rules), siteBytes, target - fixed, profile);
19672
- if (sites.size === 0) {
19673
- return {
19674
- ...none,
19675
- refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
19676
- };
19677
- }
19678
- const bytes2 = emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length;
19679
- if (bytes2 <= ceiling) return { sites, bytes: Math.ceil(bytes2 * SUPERCOMPILE_GROWTH) };
19680
- target *= Math.min(ceiling / bytes2, 0.99);
19681
- }
19677
+ const fit = fitHotSites(
19678
+ artifact.code,
19679
+ Object.values(artifact.rules),
19680
+ siteBytes,
19681
+ fixed,
19682
+ ceiling,
19683
+ (sites) => emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length,
19684
+ profile
19685
+ );
19686
+ if (fit !== void 0) return { sites: fit.sites, bytes: Math.ceil(fit.bytes * SUPERCOMPILE_GROWTH) };
19687
+ return {
19688
+ ...none,
19689
+ refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
19690
+ };
19682
19691
  };
19683
19692
  return {
19684
19693
  keys: ruleMap.map(([key]) => key),