Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

The JS target used WebAssembly for 64-bit integer division and modulo operations, which fails in Cloudflare Workers where WebAssembly is restricted.

Changes

  • Fallback detection: Added lazy initialization of WebAssembly helper with cached result to avoid repeated initialization attempts
  • BigInt implementations: Added JavaScript BigInt-based div/mod operations for both signed and unsigned 64-bit integers
  • Automatic fallback: Modified div/mod operations to use WebAssembly when available, falling back to BigInt when not

Implementation

The fallback is transparent - existing code continues to work without changes:

// Works in both standard JS and Cloudflare Workers
let result = 9223372036854775807L / 42L
let remainder = 18446744073709551615UL % 100UL

WebAssembly is preferred when available for performance. BigInt provides full correctness when WebAssembly is unavailable.

Original prompt

This section details on the original issue you should resolve

<issue_title>Make cloudflare worker our tier 1 js target</issue_title>
<issue_description>We should setup a github action for testing

ref: https://developers.cloudflare.com/workers/testing/miniflare/

TODO:

  • Add fallback implementation (BigInt based) for div/mod of (U)Int64.</issue_description>

<agent_instructions>Add fallback implementation (BigInt based) for div/mod of (U)Int64.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: hackwaly <540298+hackwaly@users.noreply.github.com>
Copilot AI changed the title [WIP] Add fallback implementation for div/mod of (U)Int64 Add BigInt fallback for Int64/UInt64 div/mod on JS target Nov 24, 2025
Copilot AI requested a review from hackwaly November 24, 2025 09:42
Copilot finished work on behalf of hackwaly November 24, 2025 09:42
@coveralls
Copy link
Collaborator

coveralls commented Nov 26, 2025

Pull Request Test Coverage Report for Build 1975

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.37%

Totals Coverage Status
Change from base Build 1968: 0.0%
Covered Lines: 10185
Relevant Lines: 11147

💛 - Coveralls

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.

Make cloudflare worker our tier 1 js target

3 participants