increment → reserve.

This commit is contained in:
Sergey Pepyakin
2018-11-28 13:53:10 +01:00
committed by Dan Gohman
parent aa5643b9b5
commit 13c36612b5
2 changed files with 9 additions and 9 deletions

View File

@@ -196,12 +196,12 @@ pub fn define_label(ctx: &mut Context, label: Label) {
pub struct StackDepth(u32); pub struct StackDepth(u32);
impl StackDepth { impl StackDepth {
pub fn increment(&mut self) { pub fn reserve(&mut self, slots: u32) {
self.0 += 1; self.0 += slots;
} }
pub fn decrement(&mut self) { pub fn free(&mut self, slots: u32) {
self.0 -= 1; self.0 -= slots;
} }
} }
@@ -216,7 +216,7 @@ pub fn restore_stack_depth(ctx: &mut Context, stack_depth: StackDepth) {
fn push_i32(ctx: &mut Context, gpr: GPR) { fn push_i32(ctx: &mut Context, gpr: GPR) {
// For now, do an actual push (and pop below). In the future, we could // For now, do an actual push (and pop below). In the future, we could
// do on-the-fly register allocation here. // do on-the-fly register allocation here.
ctx.sp_depth.increment(); ctx.sp_depth.reserve(1);
dynasm!(ctx.asm dynasm!(ctx.asm
; push Rq(gpr) ; push Rq(gpr)
); );
@@ -224,7 +224,7 @@ fn push_i32(ctx: &mut Context, gpr: GPR) {
} }
fn pop_i32(ctx: &mut Context) -> GPR { fn pop_i32(ctx: &mut Context) -> GPR {
ctx.sp_depth.decrement(); ctx.sp_depth.free(1);
let gpr = ctx.regs.take_scratch_gpr(); let gpr = ctx.regs.take_scratch_gpr();
dynasm!(ctx.asm dynasm!(ctx.asm
; pop Rq(gpr) ; pop Rq(gpr)
@@ -342,7 +342,7 @@ pub fn prologue(ctx: &mut Context, stack_slots: u32) {
; mov rbp, rsp ; mov rbp, rsp
; sub rsp, framesize ; sub rsp, framesize
); );
ctx.sp_depth.0 += aligned_stack_slots - stack_slots; ctx.sp_depth.reserve(aligned_stack_slots - stack_slots);
} }
pub fn epilogue(ctx: &mut Context) { pub fn epilogue(ctx: &mut Context) {

View File

@@ -73,9 +73,9 @@ impl ControlFrame {
pub fn outgoing_stack_depth(&self) -> StackDepth { pub fn outgoing_stack_depth(&self) -> StackDepth {
let mut outgoing_stack_depth = self.stack_depth; let mut outgoing_stack_depth = self.stack_depth;
if self.ty != Type::EmptyBlockType { if self.ty != Type::EmptyBlockType {
// If there a return value then increment expected outgoing stack depth value // If there a return value then reserve expected outgoing stack depth value
// to account for the result value. // to account for the result value.
outgoing_stack_depth.increment(); outgoing_stack_depth.reserve(1);
} }
outgoing_stack_depth outgoing_stack_depth
} }