Skip to content

JavaScript: account for the fact that our JavaScript bindings use a 32-bit address space#1384

Open
agarny wants to merge 2 commits intocellml:mainfrom
agarny:issue1366
Open

JavaScript: account for the fact that our JavaScript bindings use a 32-bit address space#1384
agarny wants to merge 2 commits intocellml:mainfrom
agarny:issue1366

Conversation

@agarny
Copy link
Copy Markdown
Contributor

@agarny agarny commented Apr 24, 2026

Fixes #1366.

agarny added 2 commits April 24, 2026 14:50
... rather than the generic areEquivalentVariables() method which doesn't include caching.
Indeed, in our WebAssembly module, the key was 32-bit (while 64-bit in C++/Python) which caused collisions and incorrect cache hits.

So, we replaced the Cantor-pairing key and std::map-based cache with a typed VariableKeyPair and std::unordered_map. This makes the cached-equivalence lookup more explicit, portable, and efficient.
Copilot AI review requested due to automatic review settings April 24, 2026 02:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes cache collisions in AnalyserModel::areEquivalentVariables() when used from the JavaScript (32-bit address space) bindings by changing the cache key strategy to avoid overflow-prone pairing.

Changes:

  • Replaced Cantor-pairing-based cache key with a (v1, v2) pair key in an unordered_map.
  • Canonicalized variable address ordering via std::swap before caching/lookup.
  • Updated generator code to use the cached AnalyserModel::areEquivalentVariables() method.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/generator.cpp Switches variable equivalence checks to use AnalyserModel’s cached method.
src/analysermodel_p.h Replaces the cache storage with an unordered_map keyed by a pointer-pair struct and custom hash.
src/analysermodel.cpp Updates areEquivalentVariables() to use the new key type and cache lookup/insert logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/analysermodel_p.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JavaScript: account for the fact that our JavaScript bindings use a 32-bit address space

3 participants