Skip to content

Commit

Permalink
Remove BEQ.
Browse files Browse the repository at this point in the history
BEQ appeared to only get used by case/when statements where a
when has a literal array as a first element. This meant that for
when with a literal array, we were calling #== instead of #===.

I could not reproduce this behavior in MRI, and the following
code shows that we are doing something wrong.

```ruby
class Array
  def ===(other)
    p :===
    self == other
  end
end

case x
when []
end
```

MRI prints out :=== while JRuby does not.

This logic apears to be from when we used to process whens with
multiple arguments differently. Today, those cases get built as
separate conditions, and I believe this removed code is no longer
valid.
headius committed Aug 11, 2017
1 parent ca55782 commit e8afd73
Showing 7 changed files with 81 additions and 196 deletions.
171 changes: 77 additions & 94 deletions core/src/main/java/org/jruby/ir/IRBuilder.java

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/IRVisitor.java
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ private void error(Object object) {
public void AttrAssignInstr(AttrAssignInstr attrassigninstr) { error(attrassigninstr); }
public void ArrayDerefInstr(ArrayDerefInstr arrayderefinstr) { error(arrayderefinstr); }
public void BacktickInstr(BacktickInstr instr) { error(instr); }
public void BEQInstr(BEQInstr beqinstr) { error(beqinstr); }
public void BFalseInstr(BFalseInstr bfalseinstr) { error(bfalseinstr); }
public void BlockGivenInstr(BlockGivenInstr blockgiveninstr) { error(blockgiveninstr); }
public void BNEInstr(BNEInstr bneinstr) { error(bneinstr); }
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/Operation.java
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ public enum Operation {

/** control-flow **/
JUMP(OpFlags.f_is_jump_or_branch),
BEQ(OpFlags.f_is_jump_or_branch),
BNE(OpFlags.f_is_jump_or_branch),
B_UNDEF(OpFlags.f_is_jump_or_branch),
B_NIL(OpFlags.f_is_jump_or_branch),
83 changes: 0 additions & 83 deletions core/src/main/java/org/jruby/ir/instructions/BEQInstr.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -217,7 +217,6 @@ public Instr decodeInstr() {
case B_TRUE: return BTrueInstr.decode(this);
case B_UNDEF: return BUndefInstr.decode(this);
case BACKTICK_STRING: return BacktickInstr.decode(this);
case BEQ: return BEQInstr.decode(this);
case BINDING_LOAD: return LoadLocalVarInstr.decode(this);
case BINDING_STORE: return StoreLocalVarInstr.decode(this);
case BLOCK_GIVEN: return BlockGivenInstr.decode(this);
9 changes: 0 additions & 9 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -588,15 +588,6 @@ public void ArrayDerefInstr(ArrayDerefInstr arrayderefinstr) {
jvmStoreLocal(arrayderefinstr.getResult());
}

@Override
public void BEQInstr(BEQInstr beqInstr) {
jvmMethod().loadContext();
visit(beqInstr.getArg1());
visit(beqInstr.getArg2());
jvmMethod().invokeHelper("BEQ", boolean.class, ThreadContext.class, IRubyObject.class, IRubyObject.class);
jvmAdapter().iftrue(getJVMLabel(beqInstr.getJumpTarget()));
}

@Override
public void BFalseInstr(BFalseInstr bFalseInstr) {
Operand arg1 = bFalseInstr.getArg1();
11 changes: 4 additions & 7 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -2244,22 +2244,19 @@ static IRubyObject[] restructureBlockArgs(IRubyObject value, Signature signature
return new IRubyObject[] { value };
}

public static boolean BEQ(ThreadContext context, IRubyObject value1, IRubyObject value2) {
return value1.op_equal(context, value2).isTrue();
public static RubyString appendByteList(RubyString target, ByteList source) {
target.getByteList().append(source);
return target;
}

@JIT
public static boolean BNE(ThreadContext context, IRubyObject value1, IRubyObject value2) {
boolean eql = value2 == context.nil || value2 == UndefinedValue.UNDEFINED ?
value1 == value2 : value1.op_equal(context, value2).isTrue();

return !eql;
}

public static RubyString appendByteList(RubyString target, ByteList source) {
target.getByteList().append(source);
return target;
}

@Deprecated
public static RubyString appendByteList19(RubyString target, ByteList source, int codeRange) {
target.cat19(source, codeRange);

0 comments on commit e8afd73

Please sign in to comment.