[wasm] Rename native_pointer() to pointer_type() to make it more apparent it's a type;
This commit is contained in:
committed by
Dan Gohman
parent
32d657d62a
commit
5f3cd868cd
@@ -75,7 +75,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
let val = match state.get_global(builder.func, global_index, environ) {
|
let val = match state.get_global(builder.func, global_index, environ) {
|
||||||
GlobalVariable::Const(val) => val,
|
GlobalVariable::Const(val) => val,
|
||||||
GlobalVariable::Memory { gv, ty } => {
|
GlobalVariable::Memory { gv, ty } => {
|
||||||
let addr = builder.ins().global_value(environ.native_pointer(), gv);
|
let addr = builder.ins().global_value(environ.pointer_type(), gv);
|
||||||
let mut flags = ir::MemFlags::new();
|
let mut flags = ir::MemFlags::new();
|
||||||
flags.set_notrap();
|
flags.set_notrap();
|
||||||
flags.set_aligned();
|
flags.set_aligned();
|
||||||
@@ -88,7 +88,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
match state.get_global(builder.func, global_index, environ) {
|
match state.get_global(builder.func, global_index, environ) {
|
||||||
GlobalVariable::Const(_) => panic!("global #{} is a constant", global_index),
|
GlobalVariable::Const(_) => panic!("global #{} is a constant", global_index),
|
||||||
GlobalVariable::Memory { gv, .. } => {
|
GlobalVariable::Memory { gv, .. } => {
|
||||||
let addr = builder.ins().global_value(environ.native_pointer(), gv);
|
let addr = builder.ins().global_value(environ.pointer_type(), gv);
|
||||||
let mut flags = ir::MemFlags::new();
|
let mut flags = ir::MemFlags::new();
|
||||||
flags.set_notrap();
|
flags.set_notrap();
|
||||||
flags.set_aligned();
|
flags.set_aligned();
|
||||||
@@ -1024,7 +1024,7 @@ fn translate_load<FE: FuncEnvironment + ?Sized>(
|
|||||||
let addr32 = state.pop1();
|
let addr32 = state.pop1();
|
||||||
// We don't yet support multiple linear memories.
|
// We don't yet support multiple linear memories.
|
||||||
let heap = state.get_heap(builder.func, 0, environ);
|
let heap = state.get_heap(builder.func, 0, environ);
|
||||||
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.native_pointer(), builder);
|
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.pointer_type(), builder);
|
||||||
// Note that we don't set `is_aligned` here, even if the load instruction's
|
// Note that we don't set `is_aligned` here, even if the load instruction's
|
||||||
// alignment immediate says it's aligned, because WebAssembly's immediate
|
// alignment immediate says it's aligned, because WebAssembly's immediate
|
||||||
// field is just a hint, while Cranelift's aligned flag needs a guarantee.
|
// field is just a hint, while Cranelift's aligned flag needs a guarantee.
|
||||||
@@ -1048,7 +1048,7 @@ fn translate_store<FE: FuncEnvironment + ?Sized>(
|
|||||||
|
|
||||||
// We don't yet support multiple linear memories.
|
// We don't yet support multiple linear memories.
|
||||||
let heap = state.get_heap(builder.func, 0, environ);
|
let heap = state.get_heap(builder.func, 0, environ);
|
||||||
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.native_pointer(), builder);
|
let (base, offset) = get_heap_addr(heap, addr32, offset, environ.pointer_type(), builder);
|
||||||
// See the comments in `translate_load` about the flags.
|
// See the comments in `translate_load` about the flags.
|
||||||
let flags = MemFlags::new();
|
let flags = MemFlags::new();
|
||||||
builder
|
builder
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ impl<'dummy_environment> DummyFuncEnvironment<'dummy_environment> {
|
|||||||
fn vmctx_sig(&self, sigidx: SignatureIndex) -> ir::Signature {
|
fn vmctx_sig(&self, sigidx: SignatureIndex) -> ir::Signature {
|
||||||
let mut sig = self.mod_info.signatures[sigidx].clone();
|
let mut sig = self.mod_info.signatures[sigidx].clone();
|
||||||
sig.params.push(ir::AbiParam::special(
|
sig.params.push(ir::AbiParam::special(
|
||||||
self.native_pointer(),
|
self.pointer_type(),
|
||||||
ir::ArgumentPurpose::VMContext,
|
ir::ArgumentPurpose::VMContext,
|
||||||
));
|
));
|
||||||
sig
|
sig
|
||||||
@@ -217,7 +217,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
|||||||
// The `callee` value is an index into a table of function pointers.
|
// The `callee` value is an index into a table of function pointers.
|
||||||
// Apparently, that table is stored at absolute address 0 in this dummy environment.
|
// Apparently, that table is stored at absolute address 0 in this dummy environment.
|
||||||
// TODO: Generate bounds checking code.
|
// TODO: Generate bounds checking code.
|
||||||
let ptr = self.native_pointer();
|
let ptr = self.pointer_type();
|
||||||
let callee_offset = if ptr == I32 {
|
let callee_offset = if ptr == I32 {
|
||||||
pos.ins().imul_imm(callee, 4)
|
pos.ins().imul_imm(callee, 4)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ pub trait FuncEnvironment {
|
|||||||
/// Get the Cranelift integer type to use for native pointers.
|
/// Get the Cranelift integer type to use for native pointers.
|
||||||
///
|
///
|
||||||
/// This returns `I64` for 64-bit architectures and `I32` for 32-bit architectures.
|
/// This returns `I64` for 64-bit architectures and `I32` for 32-bit architectures.
|
||||||
fn native_pointer(&self) -> ir::Type {
|
fn pointer_type(&self) -> ir::Type {
|
||||||
ir::Type::int(u16::from(self.triple().pointer_width().unwrap().bits())).unwrap()
|
ir::Type::int(u16::from(self.triple().pointer_width().unwrap().bits())).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user