From 13c36612b5313d58a618ce109d01b98df2924a40 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 28 Nov 2018 13:53:10 +0100 Subject: [PATCH] =?UTF-8?q?increment=20=E2=86=92=20reserve.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend.rs | 14 +++++++------- src/function_body.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index eea8f129d0..e504df7d1e 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -196,12 +196,12 @@ pub fn define_label(ctx: &mut Context, label: Label) { pub struct StackDepth(u32); impl StackDepth { - pub fn increment(&mut self) { - self.0 += 1; + pub fn reserve(&mut self, slots: u32) { + self.0 += slots; } - pub fn decrement(&mut self) { - self.0 -= 1; + pub fn free(&mut self, slots: u32) { + 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) { // For now, do an actual push (and pop below). In the future, we could // do on-the-fly register allocation here. - ctx.sp_depth.increment(); + ctx.sp_depth.reserve(1); dynasm!(ctx.asm ; push Rq(gpr) ); @@ -224,7 +224,7 @@ fn push_i32(ctx: &mut Context, gpr: GPR) { } fn pop_i32(ctx: &mut Context) -> GPR { - ctx.sp_depth.decrement(); + ctx.sp_depth.free(1); let gpr = ctx.regs.take_scratch_gpr(); dynasm!(ctx.asm ; pop Rq(gpr) @@ -342,7 +342,7 @@ pub fn prologue(ctx: &mut Context, stack_slots: u32) { ; mov rbp, rsp ; 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) { diff --git a/src/function_body.rs b/src/function_body.rs index bdf64f1af1..c49699f1b4 100644 --- a/src/function_body.rs +++ b/src/function_body.rs @@ -73,9 +73,9 @@ impl ControlFrame { pub fn outgoing_stack_depth(&self) -> StackDepth { let mut outgoing_stack_depth = self.stack_depth; 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. - outgoing_stack_depth.increment(); + outgoing_stack_depth.reserve(1); } outgoing_stack_depth }