222 }
223 Immutable immutable = new Immutable(options);
224 if (i < CACHE.length) {
225 CACHE[i] = immutable;
226 }
227 return immutable;
228 }
229
230 private static boolean isNotEmpty(OptionKey<String> option, OptionValues options) {
231 return option.getValue(options) != null && !option.getValue(options).isEmpty();
232 }
233
234 private Immutable(OptionValues options) {
235 this.options = options;
236 String timeValue = Time.getValue(options);
237 String trackMemUseValue = TrackMemUse.getValue(options);
238 this.unscopedCounters = parseUnscopedMetricSpec(Counters.getValue(options), "".equals(Count.getValue(options)), false);
239 this.unscopedTimers = parseUnscopedMetricSpec(Timers.getValue(options), "".equals(timeValue), true);
240 this.unscopedMemUseTrackers = parseUnscopedMetricSpec(MemUseTrackers.getValue(options), "".equals(trackMemUseValue), true);
241
242 if (unscopedTimers != null || timeValue != null) {
243 if (!GraalServices.isCurrentThreadCpuTimeSupported()) {
244 throw new IllegalArgumentException("Time and Timers options require VM support for querying CPU time");
245 }
246 }
247
248 if (unscopedMemUseTrackers != null || trackMemUseValue != null) {
249 if (!GraalServices.isThreadAllocatedMemorySupported()) {
250 throw new IllegalArgumentException("MemUseTrackers and TrackMemUse options require VM support for querying thread allocated memory");
251 }
252 }
253
254 this.scopesEnabled = DumpOnError.getValue(options) ||
255 Dump.getValue(options) != null ||
256 Log.getValue(options) != null ||
257 isNotEmpty(DebugOptions.Count, options) ||
258 isNotEmpty(DebugOptions.Time, options) ||
259 isNotEmpty(DebugOptions.TrackMemUse, options) ||
260 DumpOnPhaseChange.getValue(options) != null;
261 this.listMetrics = ListMetrics.getValue(options);
262 }
263
264 private Immutable() {
265 this.options = new OptionValues(EconomicMap.create());
266 this.unscopedCounters = null;
267 this.unscopedTimers = null;
268 this.unscopedMemUseTrackers = null;
269 this.scopesEnabled = false;
270 this.listMetrics = false;
|
222 }
223 Immutable immutable = new Immutable(options);
224 if (i < CACHE.length) {
225 CACHE[i] = immutable;
226 }
227 return immutable;
228 }
229
230 private static boolean isNotEmpty(OptionKey<String> option, OptionValues options) {
231 return option.getValue(options) != null && !option.getValue(options).isEmpty();
232 }
233
234 private Immutable(OptionValues options) {
235 this.options = options;
236 String timeValue = Time.getValue(options);
237 String trackMemUseValue = TrackMemUse.getValue(options);
238 this.unscopedCounters = parseUnscopedMetricSpec(Counters.getValue(options), "".equals(Count.getValue(options)), false);
239 this.unscopedTimers = parseUnscopedMetricSpec(Timers.getValue(options), "".equals(timeValue), true);
240 this.unscopedMemUseTrackers = parseUnscopedMetricSpec(MemUseTrackers.getValue(options), "".equals(trackMemUseValue), true);
241
242 if (unscopedMemUseTrackers != null || trackMemUseValue != null) {
243 if (!GraalServices.isThreadAllocatedMemorySupported()) {
244 TTY.println("WARNING: Missing VM support for MemUseTrackers and TrackMemUse options so all reported memory usage will be 0");
245 }
246 }
247
248 this.scopesEnabled = DumpOnError.getValue(options) ||
249 Dump.getValue(options) != null ||
250 Log.getValue(options) != null ||
251 isNotEmpty(DebugOptions.Count, options) ||
252 isNotEmpty(DebugOptions.Time, options) ||
253 isNotEmpty(DebugOptions.TrackMemUse, options) ||
254 DumpOnPhaseChange.getValue(options) != null;
255 this.listMetrics = ListMetrics.getValue(options);
256 }
257
258 private Immutable() {
259 this.options = new OptionValues(EconomicMap.create());
260 this.unscopedCounters = null;
261 this.unscopedTimers = null;
262 this.unscopedMemUseTrackers = null;
263 this.scopesEnabled = false;
264 this.listMetrics = false;
|