Skip to content

Implement timeout argument in wasm2js_atomic_wait_i32#4385

Merged
sbc100 merged 1 commit intomainfrom
wasm2js_atomic_wait_i32
Dec 11, 2021
Merged

Implement timeout argument in wasm2js_atomic_wait_i32#4385
sbc100 merged 1 commit intomainfrom
wasm2js_atomic_wait_i32

Conversation

@sbc100
Copy link
Member

@sbc100 sbc100 commented Dec 10, 2021

Also, fix bug where pointer was being used direcltly to
index into Int32Array. I suppose this code had basically
zero users until I tried to land this change in emscripten:
emscripten-core/emscripten#15742

@sbc100 sbc100 requested review from kripken and tlively December 10, 2021 23:31
@sbc100 sbc100 enabled auto-merge (squash) December 10, 2021 23:32
Also, fix bug where pointer was being used direcltly to
index into Int32Array.  I suppose this code had basically
zero users until I tried to land this change in emscripten:
emscripten-core/emscripten#15742
@sbc100 sbc100 force-pushed the wasm2js_atomic_wait_i32 branch from 1d8ce69 to f870efe Compare December 11, 2021 00:03
@sbc100 sbc100 merged commit 3b371d7 into main Dec 11, 2021
@sbc100 sbc100 deleted the wasm2js_atomic_wait_i32 branch December 11, 2021 16:26
if (timeoutHigh >= 0) {
// Convert from nanoseconds to milliseconds
// Taken from convertI32PairToI53 in emscripten's library_int53.js
timeout = ((timeoutLow / 1e6) >>> 0) + timeoutHigh * (4294967296 / 1e6);
Copy link
Member

Choose a reason for hiding this comment

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

I think maybe (timeoutLow / 1e6) >>> 0 should be (timeoutLow >>> 0) / 1e6. That would allow timeouts of less than 1ms as the current code rounds the output.

Copy link
Contributor

@MaxGraey MaxGraey Dec 13, 2021

Choose a reason for hiding this comment

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

I thought of that too at first, but it looks like the timeout cannot be sub-millisecond according to the specification. timeout is rational () value:

  1. Let q be ? ToNumber(timeout).
  2. If q is NaN or +∞𝔽, let t be +∞; else if q is -∞𝔽, let t be 0; else let t be max(ℝ(q), 0).

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, maybe this differs between countries, but isn't ℝ the set of real numbers, not rational? See wikipedia, The rational numbers (Q) are included in the real numbers (R) (link)

JS does a ToNumber, so it converts to a double, and sub-millisecond values are allowed IIUC

Copy link
Contributor

@MaxGraey MaxGraey Dec 13, 2021

Choose a reason for hiding this comment

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

Ah, right! I got confused with natural (ℕ).

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.

4 participants