Skip to content

Commit e331311

Browse files
committed
Remove last use of the THREAD_CACHE option, and the option itself.
1 parent 9b9f2d0 commit e331311

File tree

4 files changed

+14
-63
lines changed

4 files changed

+14
-63
lines changed

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

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.truffleruby.RubyLanguage;
1919
import org.truffleruby.SuppressFBWarnings;
2020
import org.truffleruby.cext.ValueWrapperManagerFactory.AllocateHandleNodeGen;
21-
import org.truffleruby.cext.ValueWrapperManagerFactory.GetHandleBlockHolderNodeGen;
2221
import org.truffleruby.core.fiber.RubyFiber;
2322
import org.truffleruby.extra.ffi.Pointer;
2423
import org.truffleruby.language.ImmutableRubyObject;
@@ -299,51 +298,29 @@ public static class HandleBlockHolder {
299298
protected HandleBlock sharedHandleBlock = null;
300299
}
301300

302-
@GenerateUncached
303-
public abstract static class GetHandleBlockHolderNode extends RubyBaseNode {
304-
305-
public abstract HandleBlockHolder execute(ValueWrapper wrapper);
306-
307-
@Specialization(guards = "cachedThread == currentJavaThread(wrapper)", limit = "getCacheLimit()")
308-
protected HandleBlockHolder getHolderOnKnownThread(ValueWrapper wrapper,
309-
@Cached("currentJavaThread(wrapper)") Thread cachedThread,
310-
@Cached("getBlockHolder(wrapper)") HandleBlockHolder threadData) {
311-
return threadData;
312-
}
313-
314-
@Specialization(replaces = "getHolderOnKnownThread")
315-
protected HandleBlockHolder getBlockHolder(ValueWrapper wrapper) {
316-
return getContext().getValueWrapperManager().getBlockHolder(getLanguage());
317-
}
318-
319-
protected static Thread currentJavaThread(ValueWrapper wrapper) {
320-
return Thread.currentThread();
321-
}
322-
323-
public int getCacheLimit() {
324-
return getLanguage().options.THREAD_CACHE;
325-
}
326-
327-
public static GetHandleBlockHolderNode create() {
328-
return GetHandleBlockHolderNodeGen.create();
329-
}
330-
}
331-
332301
@GenerateUncached
333302
public abstract static class AllocateHandleNode extends RubyBaseNode {
334303

335304
public abstract long execute(ValueWrapper wrapper);
336305

337306
@Specialization(guards = "!isSharedObject(wrapper)")
338-
protected long allocateHandleOnKnownThread(ValueWrapper wrapper,
339-
@Cached GetHandleBlockHolderNode getBlockHolderNode) {
340-
return allocateHandle(wrapper, getContext(), getLanguage(), getBlockHolderNode.execute(wrapper), false);
307+
protected long allocateHandleOnKnownThread(ValueWrapper wrapper) {
308+
return allocateHandle(
309+
wrapper,
310+
getContext(),
311+
getLanguage(),
312+
getContext().getValueWrapperManager().getBlockHolder(getLanguage()),
313+
false);
341314
}
342315

343316
@Specialization(guards = "isSharedObject(wrapper)")
344-
protected long allocateSharedHandleOnKnownThread(ValueWrapper wrapper,
345-
@Cached GetHandleBlockHolderNode getBlockHolderNode) {
346-
return allocateHandle(wrapper, getContext(), getLanguage(), getBlockHolderNode.execute(wrapper), true);
317+
protected long allocateSharedHandleOnKnownThread(ValueWrapper wrapper) {
318+
return allocateHandle(
319+
wrapper,
320+
getContext(),
321+
getLanguage(),
322+
getContext().getValueWrapperManager().getBlockHolder(getLanguage()),
323+
true);
347324
}
348325

349326
protected static long allocateHandle(ValueWrapper wrapper, RubyContext context, RubyLanguage language,

src/main/java/org/truffleruby/options/LanguageOptions.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ public class LanguageOptions {
9696
public final int POW_CACHE;
9797
/** --ruby-library-cache=DEFAULT_CACHE */
9898
public final int RUBY_LIBRARY_CACHE;
99-
/** --thread-cache=!singleContext ? 0 : 1 */
100-
public final int THREAD_CACHE;
10199
/** --identity-cache=1 */
102100
public final int IDENTITY_CACHE;
103101
/** --context-identity-cache=!singleContext ? 0 : IDENTITY_CACHE */
@@ -165,7 +163,6 @@ public LanguageOptions(Env env, OptionValues options, boolean singleContext) {
165163
TIME_FORMAT_CACHE = options.hasBeenSet(OptionsCatalog.TIME_FORMAT_CACHE_KEY) ? options.get(OptionsCatalog.TIME_FORMAT_CACHE_KEY) : DEFAULT_CACHE;
166164
POW_CACHE = options.hasBeenSet(OptionsCatalog.POW_CACHE_KEY) ? options.get(OptionsCatalog.POW_CACHE_KEY) : DEFAULT_CACHE;
167165
RUBY_LIBRARY_CACHE = options.hasBeenSet(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY) ? options.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY) : DEFAULT_CACHE;
168-
THREAD_CACHE = !singleContext ? 0 : (options.get(OptionsCatalog.THREAD_CACHE_KEY));
169166
IDENTITY_CACHE = options.get(OptionsCatalog.IDENTITY_CACHE_KEY);
170167
CONTEXT_SPECIFIC_IDENTITY_CACHE = !singleContext ? 0 : (options.hasBeenSet(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY) ? options.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY) : IDENTITY_CACHE);
171168
CLASS_CACHE = options.get(OptionsCatalog.CLASS_CACHE_KEY);
@@ -258,8 +255,6 @@ public Object fromDescriptor(OptionDescriptor descriptor) {
258255
return POW_CACHE;
259256
case "ruby.ruby-library-cache":
260257
return RUBY_LIBRARY_CACHE;
261-
case "ruby.thread-cache":
262-
return THREAD_CACHE;
263258
case "ruby.identity-cache":
264259
return IDENTITY_CACHE;
265260
case "ruby.context-identity-cache":
@@ -331,7 +326,6 @@ public static boolean areOptionsCompatible(OptionValues one, OptionValues two) {
331326
one.get(OptionsCatalog.TIME_FORMAT_CACHE_KEY).equals(two.get(OptionsCatalog.TIME_FORMAT_CACHE_KEY)) &&
332327
one.get(OptionsCatalog.POW_CACHE_KEY).equals(two.get(OptionsCatalog.POW_CACHE_KEY)) &&
333328
one.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY).equals(two.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY)) &&
334-
one.get(OptionsCatalog.THREAD_CACHE_KEY).equals(two.get(OptionsCatalog.THREAD_CACHE_KEY)) &&
335329
one.get(OptionsCatalog.IDENTITY_CACHE_KEY).equals(two.get(OptionsCatalog.IDENTITY_CACHE_KEY)) &&
336330
one.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY).equals(two.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY)) &&
337331
one.get(OptionsCatalog.CLASS_CACHE_KEY).equals(two.get(OptionsCatalog.CLASS_CACHE_KEY)) &&
@@ -611,13 +605,6 @@ public static boolean areOptionsCompatibleOrLog(TruffleLogger logger, LanguageOp
611605
return false;
612606
}
613607

614-
oldValue = oldOptions.THREAD_CACHE;
615-
newValue = newOptions.THREAD_CACHE;
616-
if (!newValue.equals(oldValue)) {
617-
logger.fine("not reusing pre-initialized context: --thread-cache differs, was: " + oldValue + " and is now: " + newValue);
618-
return false;
619-
}
620-
621608
oldValue = oldOptions.IDENTITY_CACHE;
622609
newValue = newOptions.IDENTITY_CACHE;
623610
if (!newValue.equals(oldValue)) {

src/options.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ LANGUAGE_OPTIONS:
4444
- TIME_FORMAT_CACHE
4545
- POW_CACHE
4646
- RUBY_LIBRARY_CACHE
47-
- THREAD_CACHE
4847
- CONTEXT_SPECIFIC_IDENTITY_CACHE
4948
- IDENTITY_CACHE
5049
- CLASS_CACHE
@@ -207,7 +206,6 @@ INTERNAL: # Options for debugging the TruffleRuby implementation
207206
RUBY_LIBRARY_CACHE: [ruby-library-cache, integer, DEFAULT_CACHE, Ruby Library cache size]
208207

209208
# Inline caches with a non-default size. When adding a new option here, update test/truffle/integration/limit-zero.sh
210-
THREAD_CACHE: [thread-cache, integer, ['!singleContext ? 0 : ', 1], Cache size of operations that depend on a particular thread]
211209
IDENTITY_CACHE: [identity-cache, integer, 1, Cache size for inline caches comparing by identity for context-independent objects]
212210
CONTEXT_SPECIFIC_IDENTITY_CACHE: [context-identity-cache, integer, ['!singleContext ? 0 : ', IDENTITY_CACHE], Cache size for inline caches comparing by identity for context-specific objects]
213211
CLASS_CACHE: [class-cache, integer, 3, .class and .metaclass cache size]

src/shared/java/org/truffleruby/shared/options/OptionsCatalog.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public class OptionsCatalog {
127127
public static final OptionKey<Integer> TIME_FORMAT_CACHE_KEY = new OptionKey<>(DEFAULT_CACHE_KEY.getDefaultValue());
128128
public static final OptionKey<Integer> POW_CACHE_KEY = new OptionKey<>(DEFAULT_CACHE_KEY.getDefaultValue());
129129
public static final OptionKey<Integer> RUBY_LIBRARY_CACHE_KEY = new OptionKey<>(DEFAULT_CACHE_KEY.getDefaultValue());
130-
public static final OptionKey<Integer> THREAD_CACHE_KEY = new OptionKey<>(1);
131130
public static final OptionKey<Integer> IDENTITY_CACHE_KEY = new OptionKey<>(1);
132131
public static final OptionKey<Integer> CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY = new OptionKey<>(IDENTITY_CACHE_KEY.getDefaultValue());
133132
public static final OptionKey<Integer> CLASS_CACHE_KEY = new OptionKey<>(3);
@@ -911,13 +910,6 @@ public class OptionsCatalog {
911910
.stability(OptionStability.EXPERIMENTAL)
912911
.build();
913912

914-
public static final OptionDescriptor THREAD_CACHE = OptionDescriptor
915-
.newBuilder(THREAD_CACHE_KEY, "ruby.thread-cache")
916-
.help("Cache size of operations that depend on a particular thread")
917-
.category(OptionCategory.INTERNAL)
918-
.stability(OptionStability.EXPERIMENTAL)
919-
.build();
920-
921913
public static final OptionDescriptor IDENTITY_CACHE = OptionDescriptor
922914
.newBuilder(IDENTITY_CACHE_KEY, "ruby.identity-cache")
923915
.help("Cache size for inline caches comparing by identity for context-independent objects")
@@ -1365,8 +1357,6 @@ public static OptionDescriptor fromName(String name) {
13651357
return POW_CACHE;
13661358
case "ruby.ruby-library-cache":
13671359
return RUBY_LIBRARY_CACHE;
1368-
case "ruby.thread-cache":
1369-
return THREAD_CACHE;
13701360
case "ruby.identity-cache":
13711361
return IDENTITY_CACHE;
13721362
case "ruby.context-identity-cache":
@@ -1547,7 +1537,6 @@ public static OptionDescriptor[] allDescriptors() {
15471537
TIME_FORMAT_CACHE,
15481538
POW_CACHE,
15491539
RUBY_LIBRARY_CACHE,
1550-
THREAD_CACHE,
15511540
IDENTITY_CACHE,
15521541
CONTEXT_SPECIFIC_IDENTITY_CACHE,
15531542
CLASS_CACHE,

0 commit comments

Comments
 (0)