Make module information lookup from runtime safe.
This commit uses a two-phase lookup of stack map information from modules rather than giving back raw pointers to stack maps. First the runtime looks up information about a module from a pc value, which returns an `Arc` it keeps a reference on while completing the stack map lookup. Second it then queries the module information for the stack map from a pc value, getting a reference to the stack map (which is now safe because of the `Arc` held by the runtime).
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
// struct VMContext {
|
||||
// interrupts: *const VMInterrupts,
|
||||
// externref_activations_table: *mut VMExternRefActivationsTable,
|
||||
// stack_map_lookup: *const dyn StackMapLookup,
|
||||
// module_info_lookup: *const dyn ModuleInfoLookup,
|
||||
// signature_ids: [VMSharedSignatureIndex; module.num_signature_ids],
|
||||
// imported_functions: [VMFunctionImport; module.num_imported_functions],
|
||||
// imported_tables: [VMTableImport; module.num_imported_tables],
|
||||
@@ -77,7 +77,7 @@ pub struct VMOffsets {
|
||||
// precalculated offsets of various member fields
|
||||
interrupts: u32,
|
||||
externref_activations_table: u32,
|
||||
stack_map_lookup: u32,
|
||||
module_info_lookup: u32,
|
||||
signature_ids: u32,
|
||||
imported_functions: u32,
|
||||
imported_tables: u32,
|
||||
@@ -149,7 +149,7 @@ impl From<VMOffsetsFields> for VMOffsets {
|
||||
num_defined_globals: fields.num_defined_globals,
|
||||
interrupts: 0,
|
||||
externref_activations_table: 0,
|
||||
stack_map_lookup: 0,
|
||||
module_info_lookup: 0,
|
||||
signature_ids: 0,
|
||||
imported_functions: 0,
|
||||
imported_tables: 0,
|
||||
@@ -168,12 +168,12 @@ impl From<VMOffsetsFields> for VMOffsets {
|
||||
.interrupts
|
||||
.checked_add(u32::from(fields.pointer_size))
|
||||
.unwrap();
|
||||
ret.stack_map_lookup = ret
|
||||
ret.module_info_lookup = ret
|
||||
.externref_activations_table
|
||||
.checked_add(u32::from(fields.pointer_size))
|
||||
.unwrap();
|
||||
ret.signature_ids = ret
|
||||
.stack_map_lookup
|
||||
.module_info_lookup
|
||||
.checked_add(u32::from(fields.pointer_size * 2))
|
||||
.unwrap();
|
||||
ret.imported_functions = ret
|
||||
@@ -507,10 +507,10 @@ impl VMOffsets {
|
||||
self.externref_activations_table
|
||||
}
|
||||
|
||||
/// The offset of the `*const dyn StackMapLookup` member.
|
||||
/// The offset of the `*const dyn ModuleInfoLookup` member.
|
||||
#[inline]
|
||||
pub fn vmctx_stack_map_lookup(&self) -> u32 {
|
||||
self.stack_map_lookup
|
||||
pub fn vmctx_module_info_lookup(&self) -> u32 {
|
||||
self.module_info_lookup
|
||||
}
|
||||
|
||||
/// The offset of the `signature_ids` array.
|
||||
|
||||
Reference in New Issue
Block a user