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

Method insert

cranelift/codegen/src/machinst/vcode.rs:1851–1881  ·  view source on GitHub ↗

Insert a constant; using this method indicates that a constant value will be used and thus will be emitted to the `MachBuffer`. The current implementation can deduplicate constants that are [VCodeConstantData::Pool] or [VCodeConstantData::WellKnown] but not [VCodeConstantData::Generated].

(&mut self, data: VCodeConstantData)

Source from the content-addressed store, hash-verified

1849 /// that are [VCodeConstantData::Pool] or [VCodeConstantData::WellKnown] but not
1850 /// [VCodeConstantData::Generated].
1851 pub fn insert(&mut self, data: VCodeConstantData) -> VCodeConstant {
1852 match data {
1853 VCodeConstantData::Generated(_) => self.constants.push(data),
1854 VCodeConstantData::Pool(constant, _) => match self.pool_uses.get(&constant) {
1855 None => {
1856 let vcode_constant = self.constants.push(data);
1857 self.pool_uses.insert(constant, vcode_constant);
1858 vcode_constant
1859 }
1860 Some(&vcode_constant) => vcode_constant,
1861 },
1862 VCodeConstantData::WellKnown(data_ref) => {
1863 match self.well_known_uses.entry(data_ref as *const [u8]) {
1864 Entry::Vacant(v) => {
1865 let vcode_constant = self.constants.push(data);
1866 v.insert(vcode_constant);
1867 vcode_constant
1868 }
1869 Entry::Occupied(o) => *o.get(),
1870 }
1871 }
1872 VCodeConstantData::U64(value) => match self.u64s.entry(value) {
1873 Entry::Vacant(v) => {
1874 let vcode_constant = self.constants.push(data);
1875 v.insert(vcode_constant);
1876 vcode_constant
1877 }
1878 Entry::Occupied(o) => *o.get(),
1879 },
1880 }
1881 }
1882
1883 /// Return the number of constants inserted.
1884 pub fn len(&self) -> usize {

Callers 13

newMethod · 0.45
newMethod · 0.45
newMethod · 0.45
sink_instMethod · 0.45
use_constantMethod · 0.45
collect_operandsMethod · 0.45
add_user_stack_mapMethod · 0.45
add_debug_tagsMethod · 0.45

Calls 3

pushMethod · 0.45
getMethod · 0.45
entryMethod · 0.45

Tested by 2