Fix legalization of heap_addrs with 32-bit indices. (#480)

This makes several changes:
 - It adds an index_type to heap declarations, allowing heaps to specify the
   type for indexing. This also anticipates 64-bit heap support.

 - It adds a memory_type to deref global values, allowing deref globals to
   have types other than pointers. This is used to allow the bound variable
   in dynamic heaps to have type i32, to match the index type in heaps
   with i32 index type.

 - And, it fixes heap legalization to do the bounds check in the heap's
   index type.
This commit is contained in:
Dan Gohman
2018-08-28 13:37:33 -07:00
committed by GitHub
parent 00ddf3a7a6
commit eb439c9a68
13 changed files with 396 additions and 70 deletions

View File

@@ -177,6 +177,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
let gv = func.create_global_value(ir::GlobalValueData::Deref {
base: addr,
offset: 0.into(),
memory_type: self.pointer_type(),
});
func.create_heap(ir::HeapData {
@@ -186,6 +187,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
style: ir::HeapStyle::Static {
bound: 0x1_0000_0000.into(),
},
index_type: I32,
})
}
@@ -196,12 +198,14 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
let base_gv = func.create_global_value(ir::GlobalValueData::Deref {
base: base_gv_addr,
offset: 0.into(),
memory_type: self.pointer_type(),
});
let bound_gv_addr =
func.create_global_value(ir::GlobalValueData::VMContext { offset: 0.into() });
let bound_gv = func.create_global_value(ir::GlobalValueData::Deref {
base: bound_gv_addr,
offset: 0.into(),
memory_type: self.pointer_type(),
});
func.create_table(ir::TableData {