Skip to content

Commit

Permalink
rune: Remove unused slot
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Nov 2, 2024
1 parent bad6e5b commit 676df38
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
11 changes: 5 additions & 6 deletions crates/rune/src/compile/v1/assemble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -2536,7 +2532,6 @@ fn expr_object<'a, 'hir>(
Inst::Struct {
addr: linear.addr(),
hash,
slot,
out: needs.alloc_output()?,
},
span,
Expand All @@ -2547,7 +2542,6 @@ fn expr_object<'a, 'hir>(
Inst::StructVariant {
addr: linear.addr(),
hash,
slot,
out: needs.alloc_output()?,
},
span,
Expand All @@ -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(),
Expand Down
4 changes: 0 additions & 4 deletions crates/rune/src/runtime/inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
28 changes: 6 additions & 22 deletions crates/rune/src/runtime/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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));
Expand Down

0 comments on commit 676df38

Please sign in to comment.