Skip to content

Commit 31290b1

Browse files
committed
Let CONTEXT_SPECIFIC_IDENTITY_CACHE default to IDENTITY_CACHE
1 parent 6064e31 commit 31290b1

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ public class LanguageOptions {
9696
public final int RUBY_LIBRARY_CACHE;
9797
/** --thread-cache=!singleContext ? 0 : 1 */
9898
public final int THREAD_CACHE;
99-
/** --context-identity-cache=!singleContext ? 0 : 1 */
100-
public final int CONTEXT_SPECIFIC_IDENTITY_CACHE;
10199
/** --identity-cache=1 */
102100
public final int IDENTITY_CACHE;
101+
/** --context-identity-cache=!singleContext ? 0 : IDENTITY_CACHE */
102+
public final int CONTEXT_SPECIFIC_IDENTITY_CACHE;
103103
/** --class-cache=3 */
104104
public final int CLASS_CACHE;
105105
/** --array-dup-cache=3 */
@@ -161,8 +161,8 @@ public LanguageOptions(Env env, OptionValues options, boolean singleContext) {
161161
POW_CACHE = options.hasBeenSet(OptionsCatalog.POW_CACHE_KEY) ? options.get(OptionsCatalog.POW_CACHE_KEY) : DEFAULT_CACHE;
162162
RUBY_LIBRARY_CACHE = options.hasBeenSet(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY) ? options.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY) : DEFAULT_CACHE;
163163
THREAD_CACHE = !singleContext ? 0 : (options.get(OptionsCatalog.THREAD_CACHE_KEY));
164-
CONTEXT_SPECIFIC_IDENTITY_CACHE = !singleContext ? 0 : (options.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY));
165164
IDENTITY_CACHE = options.get(OptionsCatalog.IDENTITY_CACHE_KEY);
165+
CONTEXT_SPECIFIC_IDENTITY_CACHE = !singleContext ? 0 : (options.hasBeenSet(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY) ? options.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY) : IDENTITY_CACHE);
166166
CLASS_CACHE = options.get(OptionsCatalog.CLASS_CACHE_KEY);
167167
ARRAY_DUP_CACHE = options.get(OptionsCatalog.ARRAY_DUP_CACHE_KEY);
168168
ARRAY_STRATEGY_CACHE = options.get(OptionsCatalog.ARRAY_STRATEGY_CACHE_KEY);
@@ -252,10 +252,10 @@ public Object fromDescriptor(OptionDescriptor descriptor) {
252252
return RUBY_LIBRARY_CACHE;
253253
case "ruby.thread-cache":
254254
return THREAD_CACHE;
255-
case "ruby.context-identity-cache":
256-
return CONTEXT_SPECIFIC_IDENTITY_CACHE;
257255
case "ruby.identity-cache":
258256
return IDENTITY_CACHE;
257+
case "ruby.context-identity-cache":
258+
return CONTEXT_SPECIFIC_IDENTITY_CACHE;
259259
case "ruby.class-cache":
260260
return CLASS_CACHE;
261261
case "ruby.array-dup-cache":
@@ -321,8 +321,8 @@ public static boolean areOptionsCompatible(OptionValues one, OptionValues two) {
321321
one.get(OptionsCatalog.POW_CACHE_KEY).equals(two.get(OptionsCatalog.POW_CACHE_KEY)) &&
322322
one.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY).equals(two.get(OptionsCatalog.RUBY_LIBRARY_CACHE_KEY)) &&
323323
one.get(OptionsCatalog.THREAD_CACHE_KEY).equals(two.get(OptionsCatalog.THREAD_CACHE_KEY)) &&
324-
one.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY).equals(two.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY)) &&
325324
one.get(OptionsCatalog.IDENTITY_CACHE_KEY).equals(two.get(OptionsCatalog.IDENTITY_CACHE_KEY)) &&
325+
one.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY).equals(two.get(OptionsCatalog.CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY)) &&
326326
one.get(OptionsCatalog.CLASS_CACHE_KEY).equals(two.get(OptionsCatalog.CLASS_CACHE_KEY)) &&
327327
one.get(OptionsCatalog.ARRAY_DUP_CACHE_KEY).equals(two.get(OptionsCatalog.ARRAY_DUP_CACHE_KEY)) &&
328328
one.get(OptionsCatalog.ARRAY_STRATEGY_CACHE_KEY).equals(two.get(OptionsCatalog.ARRAY_STRATEGY_CACHE_KEY)) &&
@@ -599,17 +599,17 @@ public static boolean areOptionsCompatibleOrLog(TruffleLogger logger, LanguageOp
599599
return false;
600600
}
601601

602-
oldValue = oldOptions.CONTEXT_SPECIFIC_IDENTITY_CACHE;
603-
newValue = newOptions.CONTEXT_SPECIFIC_IDENTITY_CACHE;
602+
oldValue = oldOptions.IDENTITY_CACHE;
603+
newValue = newOptions.IDENTITY_CACHE;
604604
if (!newValue.equals(oldValue)) {
605-
logger.fine("not reusing pre-initialized context: --context-identity-cache differs, was: " + oldValue + " and is now: " + newValue);
605+
logger.fine("not reusing pre-initialized context: --identity-cache differs, was: " + oldValue + " and is now: " + newValue);
606606
return false;
607607
}
608608

609-
oldValue = oldOptions.IDENTITY_CACHE;
610-
newValue = newOptions.IDENTITY_CACHE;
609+
oldValue = oldOptions.CONTEXT_SPECIFIC_IDENTITY_CACHE;
610+
newValue = newOptions.CONTEXT_SPECIFIC_IDENTITY_CACHE;
611611
if (!newValue.equals(oldValue)) {
612-
logger.fine("not reusing pre-initialized context: --identity-cache differs, was: " + oldValue + " and is now: " + newValue);
612+
logger.fine("not reusing pre-initialized context: --context-identity-cache differs, was: " + oldValue + " and is now: " + newValue);
613613
return false;
614614
}
615615

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ public class Options {
153153
public final boolean LOG_PENDING_INTERRUPTS;
154154
/** --rope-print-intern-stats=false */
155155
public final boolean ROPE_PRINT_INTERN_STATS;
156+
/** --cexts-tonative-stats=false */
157+
public final boolean CEXTS_TONATIVE_STATS;
156158
/** --array-small=3 */
157159
public final int ARRAY_SMALL;
158160
/** --cexts-marking-cache=100 */
159161
public final int CEXTS_MARKING_CACHE;
160-
/** --cexts-tonative-stats=false */
161-
public final boolean CEXTS_TONATIVE_STATS;
162162
/** --global-variable-max-invalidations=1 */
163163
public final int GLOBAL_VARIABLE_MAX_INVALIDATIONS;
164164
/** --clone-default=true */
@@ -258,9 +258,9 @@ public Options(Env env, OptionValues options, LanguageOptions languageOptions) {
258258
BUILDING_CORE_CEXTS = options.get(OptionsCatalog.BUILDING_CORE_CEXTS_KEY);
259259
LOG_PENDING_INTERRUPTS = options.get(OptionsCatalog.LOG_PENDING_INTERRUPTS_KEY);
260260
ROPE_PRINT_INTERN_STATS = options.get(OptionsCatalog.ROPE_PRINT_INTERN_STATS_KEY);
261+
CEXTS_TONATIVE_STATS = options.get(OptionsCatalog.CEXTS_TONATIVE_STATS_KEY);
261262
ARRAY_SMALL = options.get(OptionsCatalog.ARRAY_SMALL_KEY);
262263
CEXTS_MARKING_CACHE = options.get(OptionsCatalog.CEXTS_MARKING_CACHE_KEY);
263-
CEXTS_TONATIVE_STATS = options.get(OptionsCatalog.CEXTS_TONATIVE_STATS_KEY);
264264
GLOBAL_VARIABLE_MAX_INVALIDATIONS = options.get(OptionsCatalog.GLOBAL_VARIABLE_MAX_INVALIDATIONS_KEY);
265265
CLONE_DEFAULT = options.get(OptionsCatalog.CLONE_DEFAULT_KEY);
266266
INLINE_DEFAULT = options.get(OptionsCatalog.INLINE_DEFAULT_KEY);
@@ -411,12 +411,12 @@ public Object fromDescriptor(OptionDescriptor descriptor) {
411411
return LOG_PENDING_INTERRUPTS;
412412
case "ruby.rope-print-intern-stats":
413413
return ROPE_PRINT_INTERN_STATS;
414+
case "ruby.cexts-tonative-stats":
415+
return CEXTS_TONATIVE_STATS;
414416
case "ruby.array-small":
415417
return ARRAY_SMALL;
416418
case "ruby.cexts-marking-cache":
417419
return CEXTS_MARKING_CACHE;
418-
case "ruby.cexts-tonative-stats":
419-
return CEXTS_TONATIVE_STATS;
420420
case "ruby.global-variable-max-invalidations":
421421
return GLOBAL_VARIABLE_MAX_INVALIDATIONS;
422422
case "ruby.clone-default":

src/options.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ INTERNAL: # Options for debugging the TruffleRuby implementation
166166
LOG_DYNAMIC_CONSTANT_LOOKUP: [constant-dynamic-lookup-log, boolean, false, Log source code positions where dynamic constant lookup is performed]
167167
LOG_PENDING_INTERRUPTS: [log-pending-interrupts, boolean, false, Log when executing pending interrupts]
168168
ROPE_PRINT_INTERN_STATS: [rope-print-intern-stats, boolean, false, Print interned rope stats at application exit]
169+
CEXTS_TONATIVE_STATS: [cexts-tonative-stats, boolean, false, Track the number of conversions of VALUEs to native and print the stats at application exit]
169170

170171
# Options to debug the implementation
171172
LAZY_BUILTINS: [lazy-builtins, boolean, LAZY_CALLTARGETS, Load builtin classes (core methods & primitives) lazily on first use]
@@ -200,8 +201,8 @@ INTERNAL: # Options for debugging the TruffleRuby implementation
200201

201202
# Inline caches with a non-default size
202203
THREAD_CACHE: [thread-cache, integer, ['!singleContext ? 0 : ', 1], Cache size of operations that depend on a particular thread]
203-
CONTEXT_SPECIFIC_IDENTITY_CACHE: [context-identity-cache, integer, ['!singleContext ? 0 : ', 1], Cache size for inline caches comparing by identity for context-specific objects]
204204
IDENTITY_CACHE: [identity-cache, integer, 1, Cache size for inline caches comparing by identity for context-independent objects]
205+
CONTEXT_SPECIFIC_IDENTITY_CACHE: [context-identity-cache, integer, ['!singleContext ? 0 : ', IDENTITY_CACHE], Cache size for inline caches comparing by identity for context-specific objects]
205206
CLASS_CACHE: [class-cache, integer, 3, .class and .metaclass cache size]
206207
ARRAY_DUP_CACHE: [array-dup-cache, integer, 3, Cache size for copying small arrays]
207208
ARRAY_STRATEGY_CACHE: [array-strategy-cache, integer, 4, Cache size for array strategies]
@@ -213,7 +214,6 @@ INTERNAL: # Options for debugging the TruffleRuby implementation
213214
PACK_UNROLL_LIMIT: [pack-unroll, integer, 4, 'If a pack or unpack expression has a loop less than this many iterations, unroll it']
214215
PACK_RECOVER_LOOP_MIN: [pack-recover, integer, 32, 'If a pack or unpack expression is longer than this, attempt to recover loops']
215216
CEXTS_MARKING_CACHE: [cexts-marking-cache, integer, 100, 'Number of objects converted to native handles before the marking service is run']
216-
CEXTS_TONATIVE_STATS: [cexts-tonative-stats, boolean, false, Track the number of conversions of VALUEs to native and print the stats at application exit]
217217
GLOBAL_VARIABLE_MAX_INVALIDATIONS: [global-variable-max-invalidations, integer, 1, Maximum number of times a global variable can be changed to be considered constant]
218218

219219
# Splitting and cloning, useful for debugging cloning

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public class OptionsCatalog {
9797
public static final OptionKey<Boolean> LOG_DYNAMIC_CONSTANT_LOOKUP_KEY = new OptionKey<>(false);
9898
public static final OptionKey<Boolean> LOG_PENDING_INTERRUPTS_KEY = new OptionKey<>(false);
9999
public static final OptionKey<Boolean> ROPE_PRINT_INTERN_STATS_KEY = new OptionKey<>(false);
100+
public static final OptionKey<Boolean> CEXTS_TONATIVE_STATS_KEY = new OptionKey<>(false);
100101
public static final OptionKey<Boolean> LAZY_BUILTINS_KEY = new OptionKey<>(LAZY_CALLTARGETS_KEY.getDefaultValue());
101102
public static final OptionKey<Boolean> LAZY_TRANSLATION_CORE_KEY = new OptionKey<>(LAZY_CALLTARGETS_KEY.getDefaultValue());
102103
public static final OptionKey<Boolean> BASICOPS_INLINE_KEY = new OptionKey<>(true);
@@ -122,8 +123,8 @@ public class OptionsCatalog {
122123
public static final OptionKey<Integer> POW_CACHE_KEY = new OptionKey<>(DEFAULT_CACHE_KEY.getDefaultValue());
123124
public static final OptionKey<Integer> RUBY_LIBRARY_CACHE_KEY = new OptionKey<>(DEFAULT_CACHE_KEY.getDefaultValue());
124125
public static final OptionKey<Integer> THREAD_CACHE_KEY = new OptionKey<>(1);
125-
public static final OptionKey<Integer> CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY = new OptionKey<>(1);
126126
public static final OptionKey<Integer> IDENTITY_CACHE_KEY = new OptionKey<>(1);
127+
public static final OptionKey<Integer> CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY = new OptionKey<>(IDENTITY_CACHE_KEY.getDefaultValue());
127128
public static final OptionKey<Integer> CLASS_CACHE_KEY = new OptionKey<>(3);
128129
public static final OptionKey<Integer> ARRAY_DUP_CACHE_KEY = new OptionKey<>(3);
129130
public static final OptionKey<Integer> ARRAY_STRATEGY_CACHE_KEY = new OptionKey<>(4);
@@ -133,7 +134,6 @@ public class OptionsCatalog {
133134
public static final OptionKey<Integer> PACK_UNROLL_LIMIT_KEY = new OptionKey<>(4);
134135
public static final OptionKey<Integer> PACK_RECOVER_LOOP_MIN_KEY = new OptionKey<>(32);
135136
public static final OptionKey<Integer> CEXTS_MARKING_CACHE_KEY = new OptionKey<>(100);
136-
public static final OptionKey<Boolean> CEXTS_TONATIVE_STATS_KEY = new OptionKey<>(false);
137137
public static final OptionKey<Integer> GLOBAL_VARIABLE_MAX_INVALIDATIONS_KEY = new OptionKey<>(1);
138138
public static final OptionKey<Boolean> CLONE_DEFAULT_KEY = new OptionKey<>(true);
139139
public static final OptionKey<Boolean> INLINE_DEFAULT_KEY = new OptionKey<>(true);
@@ -694,6 +694,13 @@ public class OptionsCatalog {
694694
.stability(OptionStability.EXPERIMENTAL)
695695
.build();
696696

697+
public static final OptionDescriptor CEXTS_TONATIVE_STATS = OptionDescriptor
698+
.newBuilder(CEXTS_TONATIVE_STATS_KEY, "ruby.cexts-tonative-stats")
699+
.help("Track the number of conversions of VALUEs to native and print the stats at application exit")
700+
.category(OptionCategory.INTERNAL)
701+
.stability(OptionStability.EXPERIMENTAL)
702+
.build();
703+
697704
public static final OptionDescriptor LAZY_BUILTINS = OptionDescriptor
698705
.newBuilder(LAZY_BUILTINS_KEY, "ruby.lazy-builtins")
699706
.help("Load builtin classes (core methods & primitives) lazily on first use")
@@ -869,16 +876,16 @@ public class OptionsCatalog {
869876
.stability(OptionStability.EXPERIMENTAL)
870877
.build();
871878

872-
public static final OptionDescriptor CONTEXT_SPECIFIC_IDENTITY_CACHE = OptionDescriptor
873-
.newBuilder(CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY, "ruby.context-identity-cache")
874-
.help("Cache size for inline caches comparing by identity for context-specific objects")
879+
public static final OptionDescriptor IDENTITY_CACHE = OptionDescriptor
880+
.newBuilder(IDENTITY_CACHE_KEY, "ruby.identity-cache")
881+
.help("Cache size for inline caches comparing by identity for context-independent objects")
875882
.category(OptionCategory.INTERNAL)
876883
.stability(OptionStability.EXPERIMENTAL)
877884
.build();
878885

879-
public static final OptionDescriptor IDENTITY_CACHE = OptionDescriptor
880-
.newBuilder(IDENTITY_CACHE_KEY, "ruby.identity-cache")
881-
.help("Cache size for inline caches comparing by identity for context-independent objects")
886+
public static final OptionDescriptor CONTEXT_SPECIFIC_IDENTITY_CACHE = OptionDescriptor
887+
.newBuilder(CONTEXT_SPECIFIC_IDENTITY_CACHE_KEY, "ruby.context-identity-cache")
888+
.help("Cache size for inline caches comparing by identity for context-specific objects")
882889
.category(OptionCategory.INTERNAL)
883890
.stability(OptionStability.EXPERIMENTAL)
884891
.build();
@@ -946,13 +953,6 @@ public class OptionsCatalog {
946953
.stability(OptionStability.EXPERIMENTAL)
947954
.build();
948955

949-
public static final OptionDescriptor CEXTS_TONATIVE_STATS = OptionDescriptor
950-
.newBuilder(CEXTS_TONATIVE_STATS_KEY, "ruby.cexts-tonative-stats")
951-
.help("Track the number of conversions of VALUEs to native and print the stats at application exit")
952-
.category(OptionCategory.INTERNAL)
953-
.stability(OptionStability.EXPERIMENTAL)
954-
.build();
955-
956956
public static final OptionDescriptor GLOBAL_VARIABLE_MAX_INVALIDATIONS = OptionDescriptor
957957
.newBuilder(GLOBAL_VARIABLE_MAX_INVALIDATIONS_KEY, "ruby.global-variable-max-invalidations")
958958
.help("Maximum number of times a global variable can be changed to be considered constant")
@@ -1249,6 +1249,8 @@ public static OptionDescriptor fromName(String name) {
12491249
return LOG_PENDING_INTERRUPTS;
12501250
case "ruby.rope-print-intern-stats":
12511251
return ROPE_PRINT_INTERN_STATS;
1252+
case "ruby.cexts-tonative-stats":
1253+
return CEXTS_TONATIVE_STATS;
12521254
case "ruby.lazy-builtins":
12531255
return LAZY_BUILTINS;
12541256
case "ruby.lazy-translation-core":
@@ -1299,10 +1301,10 @@ public static OptionDescriptor fromName(String name) {
12991301
return RUBY_LIBRARY_CACHE;
13001302
case "ruby.thread-cache":
13011303
return THREAD_CACHE;
1302-
case "ruby.context-identity-cache":
1303-
return CONTEXT_SPECIFIC_IDENTITY_CACHE;
13041304
case "ruby.identity-cache":
13051305
return IDENTITY_CACHE;
1306+
case "ruby.context-identity-cache":
1307+
return CONTEXT_SPECIFIC_IDENTITY_CACHE;
13061308
case "ruby.class-cache":
13071309
return CLASS_CACHE;
13081310
case "ruby.array-dup-cache":
@@ -1321,8 +1323,6 @@ public static OptionDescriptor fromName(String name) {
13211323
return PACK_RECOVER_LOOP_MIN;
13221324
case "ruby.cexts-marking-cache":
13231325
return CEXTS_MARKING_CACHE;
1324-
case "ruby.cexts-tonative-stats":
1325-
return CEXTS_TONATIVE_STATS;
13261326
case "ruby.global-variable-max-invalidations":
13271327
return GLOBAL_VARIABLE_MAX_INVALIDATIONS;
13281328
case "ruby.clone-default":
@@ -1447,6 +1447,7 @@ public static OptionDescriptor[] allDescriptors() {
14471447
LOG_DYNAMIC_CONSTANT_LOOKUP,
14481448
LOG_PENDING_INTERRUPTS,
14491449
ROPE_PRINT_INTERN_STATS,
1450+
CEXTS_TONATIVE_STATS,
14501451
LAZY_BUILTINS,
14511452
LAZY_TRANSLATION_CORE,
14521453
BASICOPS_INLINE,
@@ -1472,8 +1473,8 @@ public static OptionDescriptor[] allDescriptors() {
14721473
POW_CACHE,
14731474
RUBY_LIBRARY_CACHE,
14741475
THREAD_CACHE,
1475-
CONTEXT_SPECIFIC_IDENTITY_CACHE,
14761476
IDENTITY_CACHE,
1477+
CONTEXT_SPECIFIC_IDENTITY_CACHE,
14771478
CLASS_CACHE,
14781479
ARRAY_DUP_CACHE,
14791480
ARRAY_STRATEGY_CACHE,
@@ -1483,7 +1484,6 @@ public static OptionDescriptor[] allDescriptors() {
14831484
PACK_UNROLL_LIMIT,
14841485
PACK_RECOVER_LOOP_MIN,
14851486
CEXTS_MARKING_CACHE,
1486-
CEXTS_TONATIVE_STATS,
14871487
GLOBAL_VARIABLE_MAX_INVALIDATIONS,
14881488
CLONE_DEFAULT,
14891489
INLINE_DEFAULT,

0 commit comments

Comments
 (0)