diff --git a/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java b/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java index d80625a4e85..a2be073aa25 100644 --- a/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java +++ b/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java @@ -74,7 +74,11 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco case DIVIDE: return value1 / value2; default: - throw new RuntimeException("BIntInstr has unknown op"); + throw new RuntimeException("IntegerMathInstr has unknown op"); } } + + public Op getOp() { + return op; + } } diff --git a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java index 4121a8233d1..6254eeccbb3 100644 --- a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java +++ b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java @@ -1749,6 +1749,29 @@ private void superCommon(String name, CallInstr instr, Operand[] args, Operand d jvmStoreLocal(instr.getResult()); } + @Override + public void IntegerMathInstr(IntegerMathInstr instr) { + visit(instr.getOperand1()); + visit(instr.getOperand2()); + switch (instr.getOp()) { + case ADD: + jvmAdapter().iadd(); + break; + case SUBTRACT: + jvmAdapter().isub(); + break; + case MULTIPLY: + jvmAdapter().imul(); + break; + case DIVIDE: + jvmAdapter().idiv(); + break; + default: + throw new NotCompilableException("IntegerMathInstr has unknown op: " + instr); + } + jvmStoreLocal(instr.getResult()); + } + @Override public void JumpInstr(JumpInstr jumpinstr) { jvmMethod().goTo(getJVMLabel(jumpinstr.getJumpTarget()));