|
1 | 1 | //! Implements ModuleEnvironment for cranelift-wasm. Code derived from cranelift-wasm/environ/dummy.rs |
2 | 2 | use crate::error::{LucetcError, LucetcErrorKind}; |
3 | 3 | use crate::pointer::NATIVE_POINTER; |
4 | | -use cranelift_codegen::entity::{entity_impl, EntityRef, PrimaryMap}; |
| 4 | +use cranelift_codegen::entity::{entity_impl, EntityRef, PrimaryMap, SecondaryMap}; |
5 | 5 | use cranelift_codegen::ir; |
6 | 6 | use cranelift_codegen::isa::TargetFrontendConfig; |
7 | 7 | use cranelift_wasm::{ |
@@ -73,7 +73,7 @@ pub struct ModuleInfo<'a> { |
73 | 73 | /// Function signatures: imported and local |
74 | 74 | pub functions: PrimaryMap<UniqueFuncIndex, Exportable<'a, SignatureIndex>>, |
75 | 75 | /// Function names. |
76 | | - pub function_names: HashMap<UniqueFuncIndex, String>, |
| 76 | + pub function_names: SecondaryMap<UniqueFuncIndex, &'a str>, |
77 | 77 | /// Provided by `declare_table` |
78 | 78 | pub tables: PrimaryMap<TableIndex, Exportable<'a, Table>>, |
79 | 79 | /// Provided by `declare_memory` |
@@ -105,7 +105,7 @@ impl<'a> ModuleInfo<'a> { |
105 | 105 | imported_memories: PrimaryMap::new(), |
106 | 106 | function_mapping: PrimaryMap::new(), |
107 | 107 | functions: PrimaryMap::new(), |
108 | | - function_names: HashMap::new(), |
| 108 | + function_names: SecondaryMap::new(), |
109 | 109 | tables: PrimaryMap::new(), |
110 | 110 | memories: PrimaryMap::new(), |
111 | 111 | globals: PrimaryMap::new(), |
@@ -410,8 +410,7 @@ impl<'a> ModuleEnvironment<'a> for ModuleInfo<'a> { |
410 | 410 | .function_mapping |
411 | 411 | .get(func_index) |
412 | 412 | .expect("function indices are valid"); |
413 | | - self.function_names |
414 | | - .insert(unique_func_index, name.to_owned()); |
| 413 | + self.function_names[unique_func_index] = name; |
415 | 414 | Ok(()) |
416 | 415 | } |
417 | 416 | } |
0 commit comments