From 772460ea7f0c54937d808dd6991facaaa93aaec9 Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Sun, 4 Aug 2019 01:22:51 -0500 Subject: [PATCH] Add tuple unpacking optimization --- bytecode/src/bytecode.rs | 4 +++ compiler/src/peephole.rs | 58 ++++++++++++++++++++++++++-------------- vm/src/frame.rs | 20 +++++++------- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/bytecode/src/bytecode.rs b/bytecode/src/bytecode.rs index 40da926f4..0d5008b83 100644 --- a/bytecode/src/bytecode.rs +++ b/bytecode/src/bytecode.rs @@ -219,6 +219,9 @@ pub enum Instruction { spec: String, }, PopException, + Reverse { + amount: usize, + }, } use self::Instruction::*; @@ -438,6 +441,7 @@ impl Instruction { Unpack => w!(Unpack), FormatValue { spec, .. } => w!(FormatValue, spec), // TODO: write conversion PopException => w!(PopException), + Reverse { amount } => w!(Reverse, amount), } } } diff --git a/compiler/src/peephole.rs b/compiler/src/peephole.rs index adfd71e1f..c0bc5a0b4 100644 --- a/compiler/src/peephole.rs +++ b/compiler/src/peephole.rs @@ -10,8 +10,8 @@ struct InstructionMetadata { labels: Vec