Skip to content

Instantly share code, notes, and snippets.

@headius

headius/.diff Secret

Last active January 23, 2023 16:58
Show Gist options
  • Save headius/ecb1281bb3642daec3365fec428103de to your computer and use it in GitHub Desktop.
Save headius/ecb1281bb3642daec3365fec428103de to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/ir/IRBuilder.java b/core/src/main/java/org/jruby/ir/IRBuilder.java
index b27f350233..49aebd9e90 100644
--- a/core/src/main/java/org/jruby/ir/IRBuilder.java
+++ b/core/src/main/java/org/jruby/ir/IRBuilder.java
@@ -630,6 +630,8 @@ public class IRBuilder {
Variable ret = getValueInTemporaryVariable(values);
if (valueNode instanceof ArrayNode) {
buildMultipleAsgn19Assignment(multipleAsgnNode, null, ret);
+ } else if (valueNode instanceof SideEffectFree){
+ buildMultipleAsgn19Assignment(multipleAsgnNode, null, ret);
} else {
Variable tmp = createTemporaryVariable();
addInstr(new ToAryInstr(tmp, ret));
@@ -3156,6 +3158,15 @@ public class IRBuilder {
for (Node an: masgnPre.children()) {
if (values == null) {
buildArgsMasgn(an, argsArray, false, -1, -1, i, false);
+ } else if (values.canCopyPropagate()) {
+ Variable rhsVal = createTemporaryVariable();
+ // assign first argument to copy of value, rest get nil
+ if (i == 0) {
+ addInstr(new CopyInstr(rhsVal, values));
+ } else {
+ addInstr(new CopyInstr(rhsVal, new Nil()));
+ }
+ assigns.add(new Tuple<>(an, rhsVal));
} else {
Variable rhsVal = createTemporaryVariable();
addInstr(new ReqdArgMultipleAsgnInstr(rhsVal, values, i));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment