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

Method verify_constant_size

cranelift/codegen/src/verifier/mod.rs:1167–1190  ·  view source on GitHub ↗
(
        &self,
        inst: Inst,
        opcode: Opcode,
        constant: Constant,
        errors: &mut VerifierErrors,
    )

Source from the content-addressed store, hash-verified

1165 }
1166
1167 fn verify_constant_size(
1168 &self,
1169 inst: Inst,
1170 opcode: Opcode,
1171 constant: Constant,
1172 errors: &mut VerifierErrors,
1173 ) -> VerifierStepResult {
1174 let type_size = match opcode {
1175 Opcode::F128const => types::F128.bytes(),
1176 Opcode::Vconst => self.func.dfg.ctrl_typevar(inst).bytes(),
1177 _ => unreachable!("unexpected opcode {opcode:?}"),
1178 } as usize;
1179 let constant_size = self.func.dfg.constants.get(constant).len();
1180 if type_size != constant_size {
1181 errors.fatal((
1182 inst,
1183 format!(
1184 "The instruction expects {constant} to have a size of {type_size} bytes but it has {constant_size}"
1185 ),
1186 ))
1187 } else {
1188 Ok(())
1189 }
1190 }
1191
1192 fn verify_is_address(
1193 &self,

Callers 1

Calls 6

OkFunction · 0.85
ctrl_typevarMethod · 0.80
fatalMethod · 0.80
bytesMethod · 0.45
lenMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected