MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / sdiv

Method sdiv

cranelift/interpreter/src/value.rs:564–582  ·  view source on GitHub ↗
(self, other: Self)

Source from the content-addressed store, hash-verified

562 }
563
564 fn sdiv(self, other: Self) -> ValueResult<Self> {
565 if self.is_float() {
566 return binary_match!(/(self, other); [F32, F64]);
567 }
568
569 let denominator = other.clone().into_int_signed()?;
570
571 // Check if we are dividing INT_MIN / -1. This causes an integer overflow trap.
572 let min = DataValueExt::int(1i128 << (self.ty().bits() - 1), self.ty())?;
573 if self == min && denominator == -1 {
574 return Err(ValueError::IntegerOverflow);
575 }
576
577 if denominator == 0 {
578 return Err(ValueError::IntegerDivisionByZero);
579 }
580
581 binary_match!(/(&self, &other); [I8, I16, I32, I64, I128])
582 }
583
584 fn udiv(self, other: Self) -> ValueResult<Self> {
585 if self.is_float() {

Callers 1

translate_sdivMethod · 0.80

Calls 5

into_int_signedMethod · 0.80
is_floatMethod · 0.45
cloneMethod · 0.45
bitsMethod · 0.45
tyMethod · 0.45

Tested by

no test coverage detected