core

Injected into every compilation unit. Not imported, and not on disk.

Methods

i32.clzCounts leading zero bits.
i32.ctzCounts trailing zero bits.
i32.popcntCounts set bits (population count).
i32.rotlRotates left, wrapping bits shifted off the top back into the bottom.
i32.rotrRotates right, wrapping bits shifted off the bottom back into the top.
i32.div_uUnsigned division, treating both operands as unsigned.
i32.rem_uUnsigned remainder, treating both operands as unsigned.
i32.lt_uUnsigned less-than.
i32.le_uUnsigned less-than-or-equal.
i32.gt_uUnsigned greater-than.
i32.ge_uUnsigned greater-than-or-equal.
i64.clzCounts leading zero bits.
i64.ctzCounts trailing zero bits.
i64.popcntCounts set bits (population count).
i64.rotlRotates left, wrapping bits shifted off the top back into the bottom.
i64.rotrRotates right, wrapping bits shifted off the bottom back into the top.
i64.div_uUnsigned division, treating both operands as unsigned.
i64.rem_uUnsigned remainder, treating both operands as unsigned.
i64.lt_uUnsigned less-than.
i64.le_uUnsigned less-than-or-equal.
i64.gt_uUnsigned greater-than.
i64.ge_uUnsigned greater-than-or-equal.
i64.mul_wide_sSigned 64x64 multiply producing the full 128-bit product.
i64.mul_wide_uUnsigned 64x64 multiply producing the full 128-bit product.
f32.absAbsolute value.
f32.sqrtSquare root.
f32.ceilRounds up, toward positive infinity.
f32.floorRounds down, toward negative infinity.
f32.truncRounds toward zero, discarding the fractional part.
f32.nearestRounds to the nearest integer, ties to even.
f32.minThe smaller of two values.
f32.maxThe larger of two values.
f32.copysignReturns self with the sign of rhs.
f64.absAbsolute value.
f64.sqrtSquare root.
f64.ceilRounds up, toward positive infinity.
f64.floorRounds down, toward negative infinity.
f64.truncRounds toward zero, discarding the fractional part.
f64.nearestRounds to the nearest integer, ties to even.
f64.minThe smaller of two values.
f64.maxThe larger of two values.
f64.copysignReturns self with the sign of rhs.

i32.clz #

inline line 28
@inline func i32.clz(self: i32) -> i32

Counts leading zero bits.

Returns 32 for an input of zero: every bit is a leading zero. This is the number of zeros above the most significant set bit, so (1).clz() is 31.

Returns
the number of leading zero bits, 0..=32
See also
i32.ctz, i32.popcnt
Source
func i32.clz(self: i32) -> i32 { return wasm.i32.clz(self); }

i32.ctz #

inline line 38
@inline func i32.ctz(self: i32) -> i32

Counts trailing zero bits.

Returns 32 for an input of zero, mirroring clz. For any other value it is the index of the lowest set bit.

Returns
the number of trailing zero bits, 0..=32
See also
i32.clz
Source
func i32.ctz(self: i32) -> i32 { return wasm.i32.ctz(self); }

i32.popcnt #

inline line 44
@inline func i32.popcnt(self: i32) -> i32

Counts set bits (population count).

Returns
the number of one bits, 0..=32
Source
func i32.popcnt(self: i32) -> i32 { return wasm.i32.popcnt(self); }

i32.rotl #

inline line 53
@inline func i32.rotl(self: i32, rhs: i32) -> i32

Rotates left, wrapping bits shifted off the top back into the bottom.

Unlike <<, no bits are lost. The rotate amount is taken modulo 32.

Parameters
rhs — how many bits to rotate by
See also
i32.rotr
Source
func i32.rotl(self: i32, rhs: i32) -> i32 { return wasm.i32.rotl(self, rhs); }

i32.rotr #

inline line 60
@inline func i32.rotr(self: i32, rhs: i32) -> i32

Rotates right, wrapping bits shifted off the bottom back into the top.

Parameters
rhs — how many bits to rotate by
See also
i32.rotl
Source
func i32.rotr(self: i32, rhs: i32) -> i32 { return wasm.i32.rotr(self, rhs); }

i32.div_u #

inline line 73
@inline func i32.div_u(self: i32, rhs: i32) -> i32

Unsigned division, treating both operands as unsigned.

/ is signed, so this is the only way to divide unsigned. The difference is not subtle: a.div_u(2) where a is -1 gives 2147483647, because -1 read as unsigned is 4294967295.

Traps on division by zero, like /.

Parameters
rhs — the divisor
See also
i32.rem_u
Source
func i32.div_u(self: i32, rhs: i32) -> i32 { return wasm.i32.div_u(self, rhs); }

i32.rem_u #

inline line 82
@inline func i32.rem_u(self: i32, rhs: i32) -> i32

Unsigned remainder, treating both operands as unsigned.

Traps on division by zero.

Parameters
rhs — the divisor
See also
i32.div_u
Source
func i32.rem_u(self: i32, rhs: i32) -> i32 { return wasm.i32.rem_u(self, rhs); }

i32.lt_u #

inline line 92
@inline func i32.lt_u(self: i32, rhs: i32) -> i32

Unsigned less-than.

< is signed. a.lt_u(1) where a is -1 is 0, because -1 read as unsigned is the largest value there is.

Returns
1 if self < rhs as unsigned, 0 otherwise
See also
i32.le_u, i32.gt_u, i32.ge_u
Source
func i32.lt_u(self: i32, rhs: i32) -> i32 { return wasm.i32.lt_u(self, rhs); }

i32.le_u #

inline line 99
@inline func i32.le_u(self: i32, rhs: i32) -> i32

Unsigned less-than-or-equal.

Returns
1 if self <= rhs as unsigned, 0 otherwise
See also
i32.lt_u
Source
func i32.le_u(self: i32, rhs: i32) -> i32 { return wasm.i32.le_u(self, rhs); }

i32.gt_u #

inline line 106
@inline func i32.gt_u(self: i32, rhs: i32) -> i32

Unsigned greater-than.

Returns
1 if self > rhs as unsigned, 0 otherwise
See also
i32.ge_u
Source
func i32.gt_u(self: i32, rhs: i32) -> i32 { return wasm.i32.gt_u(self, rhs); }

i32.ge_u #

inline line 113
@inline func i32.ge_u(self: i32, rhs: i32) -> i32

Unsigned greater-than-or-equal.

Returns
1 if self >= rhs as unsigned, 0 otherwise
See also
i32.gt_u
Source
func i32.ge_u(self: i32, rhs: i32) -> i32 { return wasm.i32.ge_u(self, rhs); }

i64.clz #

inline line 122
@inline func i64.clz(self: i64) -> i64

Counts leading zero bits.

Returns 64 for an input of zero.

Returns
the number of leading zero bits, 0..=64
See also
i64.ctz
Source
func i64.clz(self: i64) -> i64 { return wasm.i64.clz(self); }

i64.ctz #

inline line 131
@inline func i64.ctz(self: i64) -> i64

Counts trailing zero bits.

Returns 64 for an input of zero.

Returns
the number of trailing zero bits, 0..=64
See also
i64.clz
Source
func i64.ctz(self: i64) -> i64 { return wasm.i64.ctz(self); }

i64.popcnt #

inline line 137
@inline func i64.popcnt(self: i64) -> i64

Counts set bits (population count).

Returns
the number of one bits, 0..=64
Source
func i64.popcnt(self: i64) -> i64 { return wasm.i64.popcnt(self); }

i64.rotl #

inline line 146
@inline func i64.rotl(self: i64, rhs: i64) -> i64

Rotates left, wrapping bits shifted off the top back into the bottom.

The rotate amount is taken modulo 64.

Parameters
rhs — how many bits to rotate by
See also
i64.rotr
Source
func i64.rotl(self: i64, rhs: i64) -> i64 { return wasm.i64.rotl(self, rhs); }

i64.rotr #

inline line 153
@inline func i64.rotr(self: i64, rhs: i64) -> i64

Rotates right, wrapping bits shifted off the bottom back into the top.

Parameters
rhs — how many bits to rotate by
See also
i64.rotl
Source
func i64.rotr(self: i64, rhs: i64) -> i64 { return wasm.i64.rotr(self, rhs); }

i64.div_u #

inline line 162
@inline func i64.div_u(self: i64, rhs: i64) -> i64

Unsigned division, treating both operands as unsigned.

Traps on division by zero.

Parameters
rhs — the divisor
See also
i64.rem_u
Source
func i64.div_u(self: i64, rhs: i64) -> i64 { return wasm.i64.div_u(self, rhs); }

i64.rem_u #

inline line 171
@inline func i64.rem_u(self: i64, rhs: i64) -> i64

Unsigned remainder, treating both operands as unsigned.

Traps on division by zero.

Parameters
rhs — the divisor
See also
i64.div_u
Source
func i64.rem_u(self: i64, rhs: i64) -> i64 { return wasm.i64.rem_u(self, rhs); }

i64.lt_u #

inline line 181
@inline func i64.lt_u(self: i64, rhs: i64) -> i32

Unsigned less-than.

Note the result type: a comparison on i64 operands still yields i32, since WebAssembly has no boolean type and Reed's bool is i32.

Returns
1 if self < rhs as unsigned, 0 otherwise
See also
i64.le_u
Source
func i64.lt_u(self: i64, rhs: i64) -> i32 { return wasm.i64.lt_u(self, rhs); }

i64.le_u #

inline line 188
@inline func i64.le_u(self: i64, rhs: i64) -> i32

Unsigned less-than-or-equal.

Returns
1 if self <= rhs as unsigned, 0 otherwise
See also
i64.lt_u
Source
func i64.le_u(self: i64, rhs: i64) -> i32 { return wasm.i64.le_u(self, rhs); }

i64.gt_u #

inline line 195
@inline func i64.gt_u(self: i64, rhs: i64) -> i32

Unsigned greater-than.

Returns
1 if self > rhs as unsigned, 0 otherwise
See also
i64.ge_u
Source
func i64.gt_u(self: i64, rhs: i64) -> i32 { return wasm.i64.gt_u(self, rhs); }

i64.ge_u #

inline line 202
@inline func i64.ge_u(self: i64, rhs: i64) -> i32

Unsigned greater-than-or-equal.

Returns
1 if self >= rhs as unsigned, 0 otherwise
See also
i64.gt_u
Source
func i64.ge_u(self: i64, rhs: i64) -> i32 { return wasm.i64.ge_u(self, rhs); }

i64.mul_wide_s #

inline line 222
@inline func i64.mul_wide_s(self: i64, rhs: i64) -> (i64, i64)

Signed 64x64 multiply producing the full 128-bit product.

Ordinary * on i64 discards the top half on overflow. This keeps it, as two i64 values destructured together:

let (low, high): (i64, i64) = a.mul_wide_s(b);

The low half comes first. Multiplying 2^32 by 2^32 gives low == 0 and high == 1, since the product is exactly 2^64.

Requires the wide-arithmetic proposal in the engine.

Parameters
rhs — the right operand
Returns
the (low, high) halves of the 128-bit product
See also
i64.mul_wide_u
Source
func i64.mul_wide_s(self: i64, rhs: i64) -> (i64, i64) {
  return wasm.i64.mul_wide_s(self, rhs);
}

i64.mul_wide_u #

inline line 234
@inline func i64.mul_wide_u(self: i64, rhs: i64) -> (i64, i64)

Unsigned 64x64 multiply producing the full 128-bit product.

As mul_wide_s, but both operands are read as unsigned. The low half comes first.

Parameters
rhs — the right operand
Returns
the (low, high) halves of the 128-bit product
See also
i64.mul_wide_s
Source
func i64.mul_wide_u(self: i64, rhs: i64) -> (i64, i64) {
  return wasm.i64.mul_wide_u(self, rhs);
}

f32.abs #

inline line 243
@inline func f32.abs(self: f32) -> f32

Absolute value.

Clears the sign bit, so abs of -0.0 is +0.0 and abs of NaN is a NaN with the sign cleared rather than a trap.

Source
func f32.abs(self: f32) -> f32 { return wasm.f32.abs(self); }

f32.sqrt #

inline line 249
@inline func f32.sqrt(self: f32) -> f32

Square root.

Returns NaN for a negative operand rather than trapping.

Source
func f32.sqrt(self: f32) -> f32 { return wasm.f32.sqrt(self); }

f32.ceil #

inline line 255
@inline func f32.ceil(self: f32) -> f32

Rounds up, toward positive infinity.

See also
f32.floor, f32.trunc, f32.nearest
Source
func f32.ceil(self: f32) -> f32 { return wasm.f32.ceil(self); }

f32.floor #

inline line 263
@inline func f32.floor(self: f32) -> f32

Rounds down, toward negative infinity.

For a negative operand this rounds away from zero: floor of -1.7 is -2.0.

See also
f32.ceil, f32.trunc
Source
func f32.floor(self: f32) -> f32 { return wasm.f32.floor(self); }

f32.trunc #

inline line 272
@inline func f32.trunc(self: f32) -> f32

Rounds toward zero, discarding the fractional part.

Unlike floor, this rounds a negative operand toward zero: trunc of -1.7 is -1.0.

See also
f32.floor, f32.nearest
Source
func f32.trunc(self: f32) -> f32 { return wasm.f32.trunc(self); }

f32.nearest #

inline line 281
@inline func f32.nearest(self: f32) -> f32

Rounds to the nearest integer, ties to even.

Not the "round half away from zero" most languages use: 2.5 rounds to 2.0 and 3.5 rounds to 4.0, because each picks the even neighbour.

See also
f32.trunc, f32.floor, f32.ceil
Source
func f32.nearest(self: f32) -> f32 { return wasm.f32.nearest(self); }

f32.min #

inline line 291
@inline func f32.min(self: f32, rhs: f32) -> f32

The smaller of two values.

Returns NaN if either operand is NaN, which differs from a <-based comparison, and distinguishes -0.0 from +0.0.

Parameters
rhs — the other value
See also
f32.max
Source
func f32.min(self: f32, rhs: f32) -> f32 { return wasm.f32.min(self, rhs); }

f32.max #

inline line 300
@inline func f32.max(self: f32, rhs: f32) -> f32

The larger of two values.

Returns NaN if either operand is NaN.

Parameters
rhs — the other value
See also
f32.min
Source
func f32.max(self: f32, rhs: f32) -> f32 { return wasm.f32.max(self, rhs); }

f32.copysign #

inline line 310
@inline func f32.copysign(self: f32, rhs: f32) -> f32

Returns self with the sign of rhs.

The magnitude is always this value's; only the sign bit is taken from rhs. So (3.0).copysign(-1.0) is -3.0. Works on NaN and on zero, which is what makes it distinct from a multiply.

Parameters
rhs — the value to take the sign from
Source
func f32.copysign(self: f32, rhs: f32) -> f32 { return wasm.f32.copysign(self, rhs); }

f64.abs #

inline line 316
@inline func f64.abs(self: f64) -> f64

Absolute value.

Clears the sign bit, so abs of -0.0 is +0.0.

Source
func f64.abs(self: f64) -> f64 { return wasm.f64.abs(self); }

f64.sqrt #

inline line 322
@inline func f64.sqrt(self: f64) -> f64

Square root.

Returns NaN for a negative operand rather than trapping.

Source
func f64.sqrt(self: f64) -> f64 { return wasm.f64.sqrt(self); }

f64.ceil #

inline line 328
@inline func f64.ceil(self: f64) -> f64

Rounds up, toward positive infinity.

See also
f64.floor, f64.trunc, f64.nearest
Source
func f64.ceil(self: f64) -> f64 { return wasm.f64.ceil(self); }

f64.floor #

inline line 336
@inline func f64.floor(self: f64) -> f64

Rounds down, toward negative infinity.

For a negative operand this rounds away from zero: floor of -1.7 is -2.0.

See also
f64.ceil, f64.trunc
Source
func f64.floor(self: f64) -> f64 { return wasm.f64.floor(self); }

f64.trunc #

inline line 344
@inline func f64.trunc(self: f64) -> f64

Rounds toward zero, discarding the fractional part.

trunc of -1.7 is -1.0, where floor gives -2.0.

See also
f64.floor, f64.nearest
Source
func f64.trunc(self: f64) -> f64 { return wasm.f64.trunc(self); }

f64.nearest #

inline line 352
@inline func f64.nearest(self: f64) -> f64

Rounds to the nearest integer, ties to even.

2.5 rounds to 2.0 and 3.5 rounds to 4.0.

See also
f64.trunc, f64.floor, f64.ceil
Source
func f64.nearest(self: f64) -> f64 { return wasm.f64.nearest(self); }

f64.min #

inline line 361
@inline func f64.min(self: f64, rhs: f64) -> f64

The smaller of two values.

Returns NaN if either operand is NaN, and distinguishes -0.0 from +0.0.

Parameters
rhs — the other value
See also
f64.max
Source
func f64.min(self: f64, rhs: f64) -> f64 { return wasm.f64.min(self, rhs); }

f64.max #

inline line 370
@inline func f64.max(self: f64, rhs: f64) -> f64

The larger of two values.

Returns NaN if either operand is NaN.

Parameters
rhs — the other value
See also
f64.min
Source
func f64.max(self: f64, rhs: f64) -> f64 { return wasm.f64.max(self, rhs); }

f64.copysign #

inline line 378
@inline func f64.copysign(self: f64, rhs: f64) -> f64

Returns self with the sign of rhs.

(3.0).copysign(-1.0) is -3.0. Only the sign bit is taken from rhs.

Parameters
rhs — the value to take the sign from
Source
func f64.copysign(self: f64, rhs: f64) -> f64 { return wasm.f64.copysign(self, rhs); }