summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <[email protected]>2025-02-06 16:08:06 -0500
committerTakashi Kokubun <[email protected]>2025-04-18 21:52:57 +0900
commit75724a10e1c864ecf11a9e528ceabb4e90ac61b6 (patch)
tree349bc95a77e21b05cf81199410ea0ebc511f1273
parentbfae72b34b5dd0a1c3061b7f1fcf1d970eb71adf (diff)
Remove mock RubyOpcode
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13131
-rw-r--r--zjit/src/ir.rs55
1 files changed, 3 insertions, 52 deletions
diff --git a/zjit/src/ir.rs b/zjit/src/ir.rs
index f9d4d048b5..a2178a7757 100644
--- a/zjit/src/ir.rs
+++ b/zjit/src/ir.rs
@@ -200,57 +200,6 @@ impl FrameState {
}
}
-// TODO: get rid of this, currently used for testing only
-enum RubyOpcode {
- Putnil,
- Putobject(VALUE),
- Putstring(VALUE),
- Intern,
- Setlocal(usize),
- Getlocal(usize),
- Newarray(usize),
- Leave,
-}
-fn to_ssa(opcodes: &Vec<RubyOpcode>) -> Function {
- let mut result = Function::new();
- let mut state = FrameState::new();
- let block = result.entry_block;
- for opcode in opcodes {
- match opcode {
- RubyOpcode::Putnil => { state.push(Opnd::Const(Qnil)); },
- RubyOpcode::Putobject(val) => { state.push(Opnd::Const(*val)); },
- RubyOpcode::Putstring(val) => {
- let insn_id = result.push_insn(block, Insn::StringCopy { val: Opnd::Const(*val) });
- state.push(Opnd::Insn(insn_id));
- }
- RubyOpcode::Intern => {
- let val = state.pop();
- let insn_id = result.push_insn(block, Insn::StringIntern { val });
- state.push(Opnd::Insn(insn_id));
- }
- RubyOpcode::Newarray(count) => {
- let insn_id = result.push_insn(block, Insn::NewArray { count: *count });
- for idx in (0..*count).rev() {
- result.push_insn(block, Insn::ArraySet { idx, val: state.pop() });
- }
- state.push(Opnd::Insn(insn_id));
- }
- RubyOpcode::Setlocal(idx) => {
- let val = state.pop();
- state.setlocal(*idx, val);
- }
- RubyOpcode::Getlocal(idx) => {
- let val = state.getlocal(*idx);
- state.push(val);
- }
- RubyOpcode::Leave => {
- result.push_insn(block, Insn::Return { val: state.pop() });
- },
- }
- }
- result
-}
-
/// Get instruction argument
fn get_arg(pc: *const VALUE, arg_idx: isize) -> VALUE {
unsafe { *(pc.offset(arg_idx + 1)) }
@@ -303,7 +252,7 @@ pub fn iseq_to_ssa(iseq: *const rb_iseq_t) -> Function {
}
while insn_idx < iseq_size {
- // Switch blocks
+ // Get the block id for this instruction
if let Some(block_id) = insn_idx_to_block.get(&insn_idx) {
block = *block_id;
}
@@ -425,6 +374,7 @@ pub fn iseq_to_ssa(iseq: *const rb_iseq_t) -> Function {
mod tests {
use super::*;
+ /*
#[test]
fn test() {
let opcodes = vec![
@@ -528,4 +478,5 @@ mod tests {
],
});
}
+ */
}