-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pure-Ruby Enumerable#inject with new block arg instr.
This is a modified version of the same inject used in Truffle, but with a different form for the "single block arg" instruction. With the previous (broken) version of this code using |o,|, I saw a significant improvement in the performance of rubykon's bench "full_playout.rb". Unfortunately with this new fixed version, that improvement has disappeared and I have not figured out why. It is possible that the addition of the fixed path, which allocates an Array for more than two args passed, has now taken all the gains back again.
Showing
9 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/org/jruby/ir/instructions/ReceiveSingleBlockArgInstr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.jruby.ir.instructions; | ||
|
||
import org.jruby.ir.IRVisitor; | ||
import org.jruby.ir.Operation; | ||
import org.jruby.ir.operands.Operand; | ||
import org.jruby.ir.operands.Variable; | ||
import org.jruby.ir.persistence.IRReaderDecoder; | ||
import org.jruby.ir.persistence.IRWriterEncoder; | ||
import org.jruby.ir.runtime.IRRuntimeHelpers; | ||
import org.jruby.ir.transformations.inlining.CloneInfo; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
|
||
public class ReceiveSingleBlockArgInstr extends ReceiveArgBase implements FixedArityInstr { | ||
public ReceiveSingleBlockArgInstr(Variable result) { | ||
super(Operation.RECV_SINGLE_BLOCK_ARG, result, -1); | ||
} | ||
|
||
@Override | ||
public String[] toStringNonOperandArgs() { | ||
return new String[] {}; | ||
} | ||
|
||
@Override | ||
public Instr clone(CloneInfo info) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void encode(IRWriterEncoder e) { | ||
super.encode(e); | ||
} | ||
|
||
@Override | ||
public Operand[] getOperands() { | ||
return Operand.EMPTY_ARRAY; | ||
} | ||
|
||
@Override | ||
public void setOperand(int i, Operand operand) { | ||
} | ||
|
||
public static ReceiveSingleBlockArgInstr decode(IRReaderDecoder d) { | ||
return new ReceiveSingleBlockArgInstr(d.decodeVariable()); | ||
} | ||
|
||
@Override | ||
public void visit(IRVisitor visitor) { | ||
visitor.ReceiveSingleBlockArgInstr(this); | ||
} | ||
|
||
@Override | ||
public IRubyObject receiveArg(ThreadContext context, IRubyObject[] args, boolean acceptsKeywordArguments) { | ||
return IRRuntimeHelpers.receiveSingleBlockArg(context, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters