Made changes for review

This commit is contained in:
Lachlan Sneff
2018-06-15 15:35:53 -04:00
committed by Dan Gohman
parent 3686fc2fc7
commit 38ab82bcc0
4 changed files with 13 additions and 26 deletions

View File

@@ -110,7 +110,7 @@ Program structure
In LLVM IR, the largest representable unit is the *module* which corresponds In LLVM IR, the largest representable unit is the *module* which corresponds
more or less to a C translation unit. It is a collection of functions and more or less to a C translation unit. It is a collection of functions and
global values that may contain references to external symbols too. global variables that may contain references to external symbols too.
In Cretonne IR, the largest representable unit is the *function*. This is so In Cretonne IR, the largest representable unit is the *function*. This is so
that functions can easily be compiled in parallel without worrying about that functions can easily be compiled in parallel without worrying about

View File

@@ -554,21 +554,18 @@ stack overflow checks in the prologue.
the stack pointer has reached or exceeded the limit, generate a trap with a the stack pointer has reached or exceeded the limit, generate a trap with a
``stk_ovf`` code. ``stk_ovf`` code.
The global value must be accessible and naturally aligned for a
pointer-sized value.
Setting `stack_limit` is an alternative way to detect stack overflow, when using Setting `stack_limit` is an alternative way to detect stack overflow, when using
a calling convention that doesn't perform stack probes. a calling convention that doesn't perform stack probes.
Global variables Global values
---------------- -------------
A *global value* is an :term:`accessible` object in memory whose address is A *global value* is an object whose value is not known at compile time. The
not known at compile time. The address is computed at runtime by value is computed at runtime by :inst:`global_value`, possibly using
:inst:`global_value`, possibly using information provided by the linker via information provided by the linker via relocations. There are multiple
relocations. There are multiple kinds of global values using different kinds of global values using different methods for determining their value.
methods for determining their address. Cretonne does not track the type or even Cretonne does not track the type of a global value, for they are just
the size of global values, they are just pointers to non-stack memory. values stored in non-stack memory.
When Cretonne is generating code for a virtual machine environment, globals can When Cretonne is generating code for a virtual machine environment, globals can
be used to access data structures in the VM's runtime. This requires functions be used to access data structures in the VM's runtime. This requires functions

View File

@@ -6,7 +6,7 @@
use cursor::{Cursor, FuncCursor}; use cursor::{Cursor, FuncCursor};
use flowgraph::ControlFlowGraph; use flowgraph::ControlFlowGraph;
use ir::condcodes::IntCC; use ir::condcodes::IntCC;
use ir::{self, InstBuilder, MemFlags}; use ir::{self, InstBuilder};
use isa::TargetIsa; use isa::TargetIsa;
/// Expand a `heap_addr` instruction according to the definition of the heap. /// Expand a `heap_addr` instruction according to the definition of the heap.
@@ -57,12 +57,7 @@ fn dynamic_addr(
pos.use_srcloc(inst); pos.use_srcloc(inst);
// Start with the bounds check. Trap if `offset + size > bound`. // Start with the bounds check. Trap if `offset + size > bound`.
let bound_addr = pos.ins().global_value(addr_ty, bound_gv); let bound = pos.ins().global_value(addr_ty, bound_gv);
let mut mflags = MemFlags::new();
// The bound variable is requied to be accessible and aligned.
mflags.set_notrap();
mflags.set_aligned();
let bound = pos.ins().load(offset_ty, mflags, bound_addr, 0);
let oob; let oob;
if size == 1 { if size == 1 {
@@ -163,12 +158,7 @@ fn offset_addr(
match pos.func.heaps[heap].base { match pos.func.heaps[heap].base {
ir::HeapBase::ReservedReg => unimplemented!(), ir::HeapBase::ReservedReg => unimplemented!(),
ir::HeapBase::GlobalValue(base_gv) => { ir::HeapBase::GlobalValue(base_gv) => {
let base_addr = pos.ins().global_value(addr_ty, base_gv); let base = pos.ins().global_value(addr_ty, base_gv);
let mut mflags = MemFlags::new();
// The base address variable is requied to be accessible and aligned.
mflags.set_notrap();
mflags.set_aligned();
let base = pos.ins().load(addr_ty, mflags, base_addr, 0);
pos.func.dfg.replace(inst).iadd(base, offset); pos.func.dfg.replace(inst).iadd(base, offset);
} }
} }

View File

@@ -93,7 +93,7 @@ pub trait FuncEnvironment {
/// ///
/// The index space covers both imported globals and globals defined by the module. /// The index space covers both imported globals and globals defined by the module.
/// ///
/// Return the global value reference that should be used to access the global and the /// Return the global variable reference that should be used to access the global and the
/// WebAssembly type of the global. /// WebAssembly type of the global.
fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue; fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalValue;