Skip to content

Commit 347fab0

Browse files
horakivoeregon
authored andcommitted
Using limit=1 instead of getIdentityCacheLimit and getIdentityCacheContextLimit
1 parent a4bfa4f commit 347fab0

File tree

6 files changed

+10
-23
lines changed

6 files changed

+10
-23
lines changed

src/main/java/org/truffleruby/cext/UnwrapNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public abstract static class UnwrapCArrayNode extends RubyBaseNode {
186186
@ExplodeLoop
187187
@Specialization(
188188
guards = { "size == cachedSize", "cachedSize <= MAX_EXPLODE_SIZE" },
189-
limit = "getIdentityCacheLimit()")
189+
limit = "1")
190190
protected Object[] unwrapCArrayExplode(Object cArray,
191191
@CachedLibrary("cArray") InteropLibrary interop,
192192
@Bind("getArraySize(cArray, interop)") int size,

src/main/java/org/truffleruby/core/symbol/RubySymbol.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public boolean isString() {
134134

135135
@ExportMessage
136136
public static class AsString {
137-
@Specialization(guards = "symbol == cachedSymbol", limit = "getIdentityCacheLimit()")
137+
@Specialization(guards = "symbol == cachedSymbol", limit = "1")
138138
protected static String asStringCached(RubySymbol symbol,
139139
@Cached("symbol") RubySymbol cachedSymbol,
140140
@Cached("cachedSymbol.getString()") String cachedString) {
@@ -145,10 +145,6 @@ protected static String asStringCached(RubySymbol symbol,
145145
protected static String asStringUncached(RubySymbol symbol) {
146146
return symbol.getString();
147147
}
148-
149-
protected static int getIdentityCacheLimit() {
150-
return RubyLanguage.getCurrentLanguage().options.IDENTITY_CACHE;
151-
}
152148
}
153149
// endregion
154150
// endregion

src/main/java/org/truffleruby/core/symbol/SymbolNodes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public abstract static class HashSymbolNode extends RubyBaseNode {
8787
// Cannot cache a Symbol's hash while pre-initializing, as it will change in SymbolTable#rehash()
8888
@Specialization(
8989
guards = { "isSingleContext()", "symbol == cachedSymbol", "!preInitializing" },
90-
limit = "getIdentityCacheContextLimit()")
90+
limit = "1")
9191
protected long hashCached(RubySymbol symbol,
9292
@Cached(value = "isPreInitializing(getContext())") boolean preInitializing,
9393
@Cached(value = "symbol") RubySymbol cachedSymbol,
@@ -137,7 +137,7 @@ public static ToProcNode create() {
137137
"isSingleContext()",
138138
"symbol == cachedSymbol",
139139
"getRefinements(callerFrame) == cachedRefinements" },
140-
limit = "getIdentityCacheLimit()")
140+
limit = "1")
141141
protected RubyProc toProcCached(Frame callerFrame, RubySymbol symbol, Object[] rubyArgs, RootCallTarget target,
142142
@Cached("symbol") RubySymbol cachedSymbol,
143143
@Cached("getRefinements(callerFrame)") Map<RubyModule, RubyModule[]> cachedRefinements,
@@ -150,7 +150,7 @@ protected RubyProc toProcCached(Frame callerFrame, RubySymbol symbol, Object[] r
150150
guards = {
151151
"symbol == cachedSymbol",
152152
"getRefinements(callerFrame) == NO_REFINEMENTS" },
153-
limit = "getIdentityCacheLimit()")
153+
limit = "1")
154154
protected RubyProc toProcCachedNoRefinements(
155155
Frame callerFrame, RubySymbol symbol, Object[] rubyArgs, RootCallTarget target,
156156
@Cached("symbol") RubySymbol cachedSymbol,

src/main/java/org/truffleruby/language/RubyBaseNode.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,6 @@ protected final CoreExceptions coreExceptions() {
244244
return getContext().getCoreExceptions();
245245
}
246246

247-
protected int getIdentityCacheContextLimit() {
248-
return getLanguage().options.CONTEXT_SPECIFIC_IDENTITY_CACHE;
249-
}
250-
251-
protected final int getIdentityCacheLimit() {
252-
return getLanguage().options.IDENTITY_CACHE;
253-
}
254-
255247
protected final int getDefaultCacheLimit() {
256248
return getLanguage().options.DEFAULT_CACHE;
257249
}

src/main/java/org/truffleruby/language/objects/SingletonClassNode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static SingletonClassNode create() {
4343

4444
@Specialization(
4545
// no need to guard on the context, the rubyClass is context-specific
46-
guards = { "rubyClass == cachedClass", "cachedSingletonClass != null" },
47-
limit = "getIdentityCacheContextLimit()")
46+
guards = { "isSingleContext()", "rubyClass == cachedClass", "cachedSingletonClass != null" },
47+
limit = "1")
4848
protected RubyClass singletonClassClassCached(RubyClass rubyClass,
4949
@Cached("rubyClass") RubyClass cachedClass,
5050
@Cached("getSingletonClassOfClassOrNull(getContext(), cachedClass)") RubyClass cachedSingletonClass) {
@@ -58,8 +58,8 @@ protected RubyClass singletonClassClassUncached(RubyClass rubyClass) {
5858

5959
@Specialization(
6060
// no need to guard on the context, the RubyDynamicObject is context-specific
61-
guards = { "object == cachedObject", "!isRubyClass(cachedObject)" },
62-
limit = "getIdentityCacheContextLimit()")
61+
guards = { "isSingleContext()", "object == cachedObject", "!isRubyClass(cachedObject)" },
62+
limit = "1")
6363
protected RubyClass singletonClassInstanceCached(RubyDynamicObject object,
6464
@Cached("object") RubyDynamicObject cachedObject,
6565
@Cached("getSingletonClassForInstance(getContext(), object)") RubyClass cachedSingletonClass) {

src/main/java/org/truffleruby/language/objects/shared/WriteBarrierNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ protected void alreadySharedUncached(RubyDynamicObject value) {
6565
guards = { "getDepth() < MAX_DEPTH", "value.getShape() == cachedShape", "!cachedShape.isShared()" },
6666
assumptions = "cachedShape.getValidAssumption()",
6767
// limit of 1 to avoid creating many nodes if the value's Shape is polymorphic.
68-
// GR-36904: Not simply using "1" so the cached nodes are cleared when writeBarrierUncached() is activated.
69-
limit = "getIdentityCacheLimit()")
68+
limit = "1")
7069
protected void writeBarrierCached(RubyDynamicObject value,
7170
@Cached("value.getShape()") Shape cachedShape,
7271
@Cached("createShareObjectNode()") ShareObjectNode shareObjectNode) {

0 commit comments

Comments
 (0)