Skip to content

Commit

Permalink
selectors: vyper o(1) function start offset fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Feb 24, 2025
1 parent 6e5197e commit 003b53c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/selectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ fn analyze(
*vm.stack.peek_mut()? = Element {
data: if ret.op == op::EQ { VAL_0_B } else { VAL_1_B },
label: Some(Label::SelCmp(selector)),
};

// Vyper _selector_section_dense()/_selector_section_sparse()
if ret.op == op::EQ && vm.stack.data.len() >= 2 {
let fh = vm.stack.data[vm.stack.data.len() - 2].data;
let target = u16::from_be_bytes([fh[29], fh[30]]) as usize;
// assert!(vm.code[target] == op::JUMPDEST);
if target < vm.code.len() && vm.code[target] == op::JUMPDEST {
selectors.insert(selector, target);
}
}
}

Expand Down Expand Up @@ -97,15 +107,6 @@ fn analyze(
}
}

// Vyper again
StepResult {
op: op::AND,
args: match_first_two!(elabel!(scmp @ Label::SelCmp(_)), ot),
..
} if ot.data == VAL_1_B => {
vm.stack.peek_mut()?.label = Some(scmp);
}

StepResult {
op: op::SHR,
args: [_, elabel!(Label::CallData), ..],
Expand Down

0 comments on commit 003b53c

Please sign in to comment.