Skip to content

Commit c57fbdf

Browse files
committed
after review changes
1 parent 3b3f0e1 commit c57fbdf

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/main/java/org/truffleruby/core/string/StringNodes.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ protected Object slice(Object string, Object start, Object length) {
622622

623623
@Specialization(guards = "isRubyRange(range)")
624624
protected Object sliceRange(Object string, Object range, NotProvided other,
625-
@Cached @Exclusive RubyStringLibrary libString,
625+
@Cached @Shared RubyStringLibrary strings,
626626
@Cached RangeNodes.NormalizedStartLengthNode startLengthNode,
627627
@Cached @Exclusive ConditionProfile negativeStart) {
628-
final int stringLength = codePointLength(libString.getTString(string), libString.getEncoding(string));
628+
final int stringLength = codePointLength(strings.getTString(string), strings.getEncoding(string));
629629
final int[] startLength = startLengthNode.execute(range, stringLength);
630630

631631
int start = startLength[0];
@@ -1536,7 +1536,7 @@ protected Object initializeCopySelfIsSameAsFrom(RubyString self, Object from) {
15361536
"!tstring.isNative()",
15371537
"tstring.isImmutable()" }, limit = "1")
15381538
protected Object initializeCopyImmutable(RubyString self, Object from,
1539-
@Cached @Exclusive RubyStringLibrary stringsFrom,
1539+
@Cached @Shared RubyStringLibrary stringsFrom,
15401540
@Cached @Shared StringHelperNodes.StringGetAssociatedNode stringGetAssociatedNode,
15411541
@Bind("stringsFrom.getTString(from)") AbstractTruffleString tstring) {
15421542
self.setTString(tstring, stringsFrom.getEncoding(from));
@@ -1552,7 +1552,7 @@ protected Object initializeCopyImmutable(RubyString self, Object from,
15521552
"!tstring.isNative()",
15531553
"tstring.isMutable()" }, limit = "1")
15541554
protected Object initializeCopyMutable(RubyString self, Object from,
1555-
@Cached @Exclusive RubyStringLibrary stringsFrom,
1555+
@Cached @Shared RubyStringLibrary stringsFrom,
15561556
@Cached @Shared StringHelperNodes.StringGetAssociatedNode stringGetAssociatedNode,
15571557
@Cached MutableTruffleString.SubstringByteIndexNode copyMutableTruffleStringNode,
15581558
@Bind("stringsFrom.getTString(from)") AbstractTruffleString tstring) {
@@ -1570,12 +1570,12 @@ protected Object initializeCopyMutable(RubyString self, Object from,
15701570

15711571
@Specialization(guards = { "!areEqual(self, from)", "tstring.isNative()" })
15721572
protected Object initializeCopyNative(RubyString self, RubyString from,
1573-
@Cached @Exclusive RubyStringLibrary libString,
1573+
@Cached @Shared RubyStringLibrary stringsFrom,
15741574
@Cached @Shared StringHelperNodes.StringGetAssociatedNode stringGetAssociatedNode,
15751575
@Cached TruffleString.GetInternalNativePointerNode getInternalNativePointerNode,
15761576
@Cached MutableTruffleString.FromNativePointerNode fromNativePointerNode,
15771577
@Bind("from.tstring") AbstractTruffleString tstring) {
1578-
var encoding = libString.getEncoding(from);
1578+
var encoding = stringsFrom.getEncoding(from);
15791579
var tencoding = encoding.tencoding;
15801580
final Pointer fromPointer = (Pointer) getInternalNativePointerNode.execute(tstring, tencoding);
15811581

@@ -1744,8 +1744,8 @@ protected RubyString replace(RubyString string, RubyString other,
17441744

17451745
@Specialization
17461746
protected RubyString replace(RubyString string, ImmutableRubyString other,
1747-
@Cached @Exclusive RubyStringLibrary libString) {
1748-
string.setTString(other.tstring, libString.getEncoding(other));
1747+
@Cached @Exclusive RubyStringLibrary libOther) {
1748+
string.setTString(other.tstring, libOther.getEncoding(other));
17491749
return string;
17501750
}
17511751

@@ -1860,7 +1860,7 @@ public abstract static class ScrubNode extends PrimitiveArrayArgumentsNode {
18601860
limit = "1")
18611861
protected RubyString scrubAsciiCompat(Object string, RubyProc block,
18621862
@Cached @Shared RubyStringLibrary strings,
1863-
@Cached @Shared TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
1863+
@Cached @Exclusive TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
18641864
@Bind("strings.getTString(string)") AbstractTruffleString tstring,
18651865
@Bind("strings.getEncoding(string)") RubyEncoding encoding) {
18661866
final Encoding enc = encoding.jcoding;
@@ -1945,7 +1945,7 @@ protected RubyString scrubAsciiCompat(Object string, RubyProc block,
19451945
limit = "1")
19461946
protected RubyString scrubAsciiIncompatible(Object string, RubyProc block,
19471947
@Cached @Shared RubyStringLibrary strings,
1948-
@Cached @Shared TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
1948+
@Cached @Exclusive TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
19491949
@Bind("strings.getTString(string)") AbstractTruffleString tstring,
19501950
@Bind("strings.getEncoding(string)") RubyEncoding encoding) {
19511951
final Encoding enc = encoding.jcoding;
@@ -3209,7 +3209,7 @@ protected Object stringAwkSplitAsciiOnly(Object string, int limit, Object block,
32093209
@Cached @Exclusive ConditionProfile trailingEmptyStringProfile,
32103210
@Cached TruffleString.MaterializeNode materializeNode,
32113211
@Cached TruffleString.ReadByteNode readByteNode,
3212-
@Cached @Shared TruffleString.SubstringByteIndexNode substringNode,
3212+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringNode,
32133213
@Cached @Exclusive LoopConditionProfile loopProfile,
32143214
@Bind("strings.getTString(string)") AbstractTruffleString tstring,
32153215
@Bind("strings.getEncoding(string)") RubyEncoding encoding) {
@@ -3285,7 +3285,7 @@ protected Object stringAwkSplit(Object string, int limit, Object block,
32853285
@Cached @Exclusive ConditionProfile trailingSubstringProfile,
32863286
@Cached CreateCodePointIteratorNode createCodePointIteratorNode,
32873287
@Cached TruffleStringIterator.NextNode nextNode,
3288-
@Cached @Shared TruffleString.SubstringByteIndexNode substringNode,
3288+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringNode,
32893289
@Cached @Exclusive LoopConditionProfile loopProfile,
32903290
@Bind("strings.getTString(string)") AbstractTruffleString tstring,
32913291
@Bind("strings.getEncoding(string)") RubyEncoding encoding) {
@@ -3458,7 +3458,7 @@ protected Object stringChrAtOutOfBounds(Object string, int byteIndex,
34583458
protected Object stringChrAtSingleByte(Object string, int byteIndex,
34593459
@Cached @Shared RubyStringLibrary strings,
34603460
@Cached @Shared TruffleString.GetByteCodeRangeNode codeRangeNode,
3461-
@Cached @Shared TruffleString.SubstringByteIndexNode substringByteIndexNode,
3461+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringByteIndexNode,
34623462
@Bind("strings.getTString(string)") AbstractTruffleString tstring,
34633463
@Bind("strings.getEncoding(string)") RubyEncoding encoding) {
34643464
return createSubString(substringByteIndexNode, tstring, encoding, byteIndex, 1);
@@ -3473,7 +3473,7 @@ protected Object stringChrAt(Object string, int byteIndex,
34733473
@Cached @Shared RubyStringLibrary strings,
34743474
@Cached @Shared TruffleString.GetByteCodeRangeNode codeRangeNode,
34753475
@Cached GetActualEncodingNode getActualEncodingNode,
3476-
@Cached @Shared TruffleString.SubstringByteIndexNode substringByteIndexNode,
3476+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringByteIndexNode,
34773477
@Cached TruffleString.ForceEncodingNode forceEncodingNode,
34783478
@Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
34793479
@Cached ConditionProfile brokenProfile,
@@ -3647,7 +3647,7 @@ protected Object stringFindCharacterOffsetTooLarge(Object string, int offset,
36473647
protected Object stringFindCharacterSingleByte(Object string, int offset,
36483648
@Cached @Shared RubyStringLibrary strings,
36493649
@Cached @Shared SingleByteOptimizableNode singleByteOptimizableNode,
3650-
@Cached @Shared TruffleString.SubstringByteIndexNode substringNode) {
3650+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringNode) {
36513651
// Taken from Rubinius's String::find_character.
36523652
return createSubString(substringNode, strings, string, offset, 1);
36533653
}
@@ -3662,7 +3662,7 @@ protected Object stringFindCharacter(Object string, int offset,
36623662
@Cached @Shared RubyStringLibrary strings,
36633663
@Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
36643664
@Cached @Shared SingleByteOptimizableNode singleByteOptimizableNode,
3665-
@Cached @Shared TruffleString.SubstringByteIndexNode substringNode) {
3665+
@Cached @Exclusive TruffleString.SubstringByteIndexNode substringNode) {
36663666
// Taken from Rubinius's String::find_character.
36673667
var tstring = strings.getTString(string);
36683668
var tencoding = strings.getTEncoding(string);
@@ -3685,7 +3685,7 @@ protected RubyString stringFromCodepointSimple(int code, RubyEncoding encoding,
36853685
@Cached ConditionProfile isUTF8Profile,
36863686
@Cached ConditionProfile isUSAsciiProfile,
36873687
@Cached ConditionProfile isAscii8BitProfile,
3688-
@Cached @Shared TruffleString.FromCodePointNode fromCodePointNode) {
3688+
@Cached @Exclusive TruffleString.FromCodePointNode fromCodePointNode) {
36893689
final TruffleString tstring;
36903690
if (isUTF8Profile.profile(encoding == Encodings.UTF_8)) {
36913691
tstring = TStringConstants.UTF8_SINGLE_BYTE[code];
@@ -4169,7 +4169,7 @@ public abstract static class StringToInumPrimitiveNode extends PrimitiveArrayArg
41694169
protected Object base10(Object string, int base, boolean strict, boolean raiseOnError,
41704170
@Cached @Shared RubyStringLibrary libString,
41714171
@Cached @Shared TruffleString.ParseLongNode parseLongNode,
4172-
@Cached BranchProfile notLazyLongProfile,
4172+
@Cached @Shared BranchProfile notLazyLongProfile,
41734173
@Cached @Shared FixnumOrBignumNode fixnumOrBignumNode,
41744174
@Cached @Shared BranchProfile exceptionProfile) {
41754175
var tstring = libString.getTString(string);
@@ -4188,7 +4188,7 @@ protected Object base0(Object string, int base, boolean strict, boolean raiseOnE
41884188
@Cached @Shared TruffleString.ParseLongNode parseLongNode,
41894189
@Cached TruffleString.CodePointAtByteIndexNode codePointNode,
41904190
@Cached ConditionProfile notEmptyProfile,
4191-
@Cached @Exclusive BranchProfile notLazyLongProfile,
4191+
@Cached @Shared BranchProfile notLazyLongProfile,
41924192
@Cached @Shared FixnumOrBignumNode fixnumOrBignumNode,
41934193
@Cached @Shared BranchProfile exceptionProfile) {
41944194
var tstring = libString.getTString(string);

0 commit comments

Comments
 (0)