From 676df38b11f0057506c2b650e4e06b606e548da8 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Sat, 2 Nov 2024 18:14:22 +0100 Subject: [PATCH] rune: Remove unused slot --- crates/rune/src/compile/v1/assemble.rs | 11 +++++----- crates/rune/src/runtime/inst.rs | 4 ---- crates/rune/src/runtime/vm.rs | 28 ++++++-------------------- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/crates/rune/src/compile/v1/assemble.rs b/crates/rune/src/compile/v1/assemble.rs index 90d76ba97..e1e13c6a1 100644 --- a/crates/rune/src/compile/v1/assemble.rs +++ b/crates/rune/src/compile/v1/assemble.rs @@ -2517,10 +2517,6 @@ fn expr_object<'a, 'hir>( if let Some(linear) = exprs_with(cx, span, hir.assignments, |hir| &hir.assign)?.into_converging() { - let slot = - cx.q.unit - .new_static_object_keys_iter(span, hir.assignments.iter().map(|a| a.key.1))?; - match hir.kind { hir::ExprObjectKind::EmptyStruct { hash } => { cx.asm.push( @@ -2536,7 +2532,6 @@ fn expr_object<'a, 'hir>( Inst::Struct { addr: linear.addr(), hash, - slot, out: needs.alloc_output()?, }, span, @@ -2547,7 +2542,6 @@ fn expr_object<'a, 'hir>( Inst::StructVariant { addr: linear.addr(), hash, - slot, out: needs.alloc_output()?, }, span, @@ -2567,6 +2561,11 @@ fn expr_object<'a, 'hir>( )?; } hir::ExprObjectKind::Anonymous => { + let slot = cx + .q + .unit + .new_static_object_keys_iter(span, hir.assignments.iter().map(|a| a.key.1))?; + cx.asm.push( Inst::Object { addr: linear.addr(), diff --git a/crates/rune/src/runtime/inst.rs b/crates/rune/src/runtime/inst.rs index d9fdc8920..44d4f623b 100644 --- a/crates/rune/src/runtime/inst.rs +++ b/crates/rune/src/runtime/inst.rs @@ -657,8 +657,6 @@ pub enum Inst { addr: InstAddress, /// The type of the struct to construct. hash: Hash, - /// The static slot of the object keys. - slot: usize, /// Where to write the constructed struct. out: Output, }, @@ -694,8 +692,6 @@ pub enum Inst { addr: InstAddress, /// The type hash of the object variant to construct. hash: Hash, - /// The static slot of the object keys. - slot: usize, /// Where to write the constructed variant. out: Output, }, diff --git a/crates/rune/src/runtime/vm.rs b/crates/rune/src/runtime/vm.rs index e1c54b52c..2b64b29c4 100644 --- a/crates/rune/src/runtime/vm.rs +++ b/crates/rune/src/runtime/vm.rs @@ -2979,7 +2979,7 @@ impl Vm { /// Operation to allocate an object struct. #[cfg_attr(feature = "bench", inline(never))] - fn op_struct(&mut self, addr: InstAddress, hash: Hash, _: usize, out: Output) -> VmResult<()> { + fn op_struct(&mut self, addr: InstAddress, hash: Hash, out: Output) -> VmResult<()> { let rtti = vm_try!(self .unit .lookup_rtti(hash) @@ -3025,13 +3025,7 @@ impl Vm { /// Operation to allocate an object variant. #[cfg_attr(feature = "bench", inline(never))] - fn op_struct_variant( - &mut self, - addr: InstAddress, - hash: Hash, - _: usize, - out: Output, - ) -> VmResult<()> { + fn op_struct_variant(&mut self, addr: InstAddress, hash: Hash, out: Output) -> VmResult<()> { let rtti = vm_try!(self .unit .lookup_variant_rtti(hash) @@ -3917,13 +3911,8 @@ impl Vm { Inst::EmptyStruct { hash, out } => { vm_try!(self.op_empty_struct(hash, out)); } - Inst::Struct { - addr, - hash, - slot, - out, - } => { - vm_try!(self.op_struct(addr, hash, slot, out)); + Inst::Struct { addr, hash, out } => { + vm_try!(self.op_struct(addr, hash, out)); } Inst::ConstConstruct { addr, @@ -3933,13 +3922,8 @@ impl Vm { } => { vm_try!(self.op_const_construct(addr, hash, count, out)); } - Inst::StructVariant { - addr, - hash, - slot, - out, - } => { - vm_try!(self.op_struct_variant(addr, hash, slot, out)); + Inst::StructVariant { addr, hash, out } => { + vm_try!(self.op_struct_variant(addr, hash, out)); } Inst::String { slot, out } => { vm_try!(self.op_string(slot, out));