mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 13:41:32 +00:00
Fix get global type
This commit is contained in:
@ -410,7 +410,7 @@ impl FuncEnvironment for FunctionEnvironment {
|
|||||||
let vmctx = func.create_global_value(ir::GlobalValueData::VMContext);
|
let vmctx = func.create_global_value(ir::GlobalValueData::VMContext);
|
||||||
let ptr_type = self.pointer_type();
|
let ptr_type = self.pointer_type();
|
||||||
|
|
||||||
let local_global_addr = match global_index
|
let (local_global_addr, ty) = match global_index
|
||||||
.local_or_import(&self.module_info.read().unwrap())
|
.local_or_import(&self.module_info.read().unwrap())
|
||||||
{
|
{
|
||||||
LocalOrImport::Local(local_global_index) => {
|
LocalOrImport::Local(local_global_index) => {
|
||||||
@ -429,12 +429,19 @@ impl FuncEnvironment for FunctionEnvironment {
|
|||||||
global_type: ptr_type,
|
global_type: ptr_type,
|
||||||
});
|
});
|
||||||
|
|
||||||
func.create_global_value(ir::GlobalValueData::Load {
|
let ty = self.module_info.read().unwrap().globals[local_global_index]
|
||||||
base: local_global_ptr_ptr,
|
.desc
|
||||||
offset: 0.into(),
|
.ty;
|
||||||
global_type: ptr_type,
|
|
||||||
readonly: true,
|
(
|
||||||
})
|
func.create_global_value(ir::GlobalValueData::Load {
|
||||||
|
base: local_global_ptr_ptr,
|
||||||
|
offset: 0.into(),
|
||||||
|
global_type: ptr_type,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
|
ty,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
LocalOrImport::Import(import_global_index) => {
|
LocalOrImport::Import(import_global_index) => {
|
||||||
let globals_base_addr = func.create_global_value(ir::GlobalValueData::Load {
|
let globals_base_addr = func.create_global_value(ir::GlobalValueData::Load {
|
||||||
@ -452,19 +459,26 @@ impl FuncEnvironment for FunctionEnvironment {
|
|||||||
global_type: ptr_type,
|
global_type: ptr_type,
|
||||||
});
|
});
|
||||||
|
|
||||||
func.create_global_value(ir::GlobalValueData::Load {
|
let ty = self.module_info.read().unwrap().imported_globals[import_global_index]
|
||||||
base: local_global_ptr_ptr,
|
.1
|
||||||
offset: 0.into(),
|
.ty;
|
||||||
global_type: ptr_type,
|
|
||||||
readonly: true,
|
(
|
||||||
})
|
func.create_global_value(ir::GlobalValueData::Load {
|
||||||
|
base: local_global_ptr_ptr,
|
||||||
|
offset: 0.into(),
|
||||||
|
global_type: ptr_type,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
|
ty,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(cranelift_wasm::GlobalVariable::Memory {
|
Ok(cranelift_wasm::GlobalVariable::Memory {
|
||||||
gv: local_global_addr,
|
gv: local_global_addr,
|
||||||
offset: (vm::LocalGlobal::offset_data() as i32).into(),
|
offset: (vm::LocalGlobal::offset_data() as i32).into(),
|
||||||
ty: ptr_type,
|
ty: Converter(ty).into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user