Skip to content

Commit

Permalink
Fix issues relating to freezing dynamic strings
Browse files Browse the repository at this point in the history
* Don't freeze dynamic strings when concatenating two sequential
  string literals. (jruby#8380)
* For the sole remaining frozen DStr case, only freeze and do not
  create a debug frozen string.

Fixes jruby#8380
  • Loading branch information
headius committed Oct 26, 2024
1 parent feb5fb7 commit dd9f26b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
9 changes: 1 addition & 8 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1191,14 +1191,7 @@ public void BuildCompoundStringInstr(BuildCompoundStringInstr compoundstring) {
}
}
if (compoundstring.isFrozen()) {
if (runtime.getInstanceConfig().isDebuggingFrozenStringLiteral()) {
jvmMethod().loadContext();
jvmAdapter().ldc(compoundstring.getFile());
jvmAdapter().ldc(compoundstring.getLine());
jvmMethod().invokeIRHelper("freezeLiteralString", sig(RubyString.class, RubyString.class, ThreadContext.class, String.class, int.class));
} else {
jvmMethod().invokeIRHelper("freezeLiteralString", sig(RubyString.class, RubyString.class));
}
jvmMethod().invokeIRHelper("freezeLiteralString", sig(RubyString.class, RubyString.class));
}
jvmStoreLocal(compoundstring.getResult());
}
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/parser/RubyParserBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,6 @@ public Node literal_concat(Node head, Node tail) {
DStrNode newDStr = new DStrNode(head.getLine(), ((DStrNode) tail).getEncoding());
newDStr.add(head);
newDStr.addAll(tail);
if (frozenStringLiterals) newDStr.setFrozen(true);
return newDStr;
}

Expand Down

0 comments on commit dd9f26b

Please sign in to comment.