Skip to content

v0.1.47

Choose a tag to compare

@gmpassos gmpassos released this 28 Jun 00:38
· 269 commits to master since this release
111ebd1

Wasm backend: integer division semantics + division-by-zero exceptions

Fixes the Dart/Java/Kotlin exception (try/catch/finally) playground examples, taking interpreter-vs-Wasm correctness to 76/77.

  • / on integer operands is integer (truncating) division in Java/Kotlin/C# — where the expression resolves to int — instead of an f64 quotient (so 10 / 3 is 3, not 3.33). Dart's / keeps its double result; ~/ is unchanged.
  • Integer division by zero raises a catchable exception whose message matches the interpreter (IntegerDivisionByZeroException for /, Unsupported operation: Infinity or NaN toInt for ~/). Applies to both ~/ and integer /.
  • A print whose argument is built from a value that just raised (e.g. the quotient in print('q = ${a ~/ b}')) is skipped when an exception is pending, matching the interpreter, which never reaches the print.

Validated on the native wasm_run runtime and on Chrome (WasmGC). The division-by-zero message assertions run on the VM only, since the interpreter's own message differs between the Dart VM and dart2js while the Wasm message is fixed.

Known remaining gap: Dart async/Future compilation (documented as a focused follow-up).

Full changes: https://github.com/ApolloVM/apollovm_dart/blob/master/CHANGELOG.md