in analysis/gc-log/src/main/java/org/eclipse/jifa/gclog/parser/AbstractPreUnifiedGCLogParser.java [237:293]
private void doParseSentence(List<GCLogToken> line) {
try {
GCEvent event = new GCEvent();
String title = null;
String referenceGC = null;
String datestamp = null;
for (GCLogToken token : line) {
if (token.getType() == TOKEN_LINE_FULL_SENTENCE || token.getType() == TOKEN_EMBEDDED_SENTENCE) {
doParseFullSentence(token.getValue());
return;
} else if (token.getType() == TOKEN_DATESTAMP) {
datestamp = token.getValue();
} else if (token.getType() == TOKEN_UPTIME) {
event.setStartTime(MS2S * Double.parseDouble(token.getValue()));
} else if (token.getType() == TOKEN_GCID) {
event.setGcid(Integer.parseInt(token.getValue()));
} else if (token.getType() == TOKEN_GC_TRACETIME_TITLE) {
// title is complex, it may include event name, gc cause, generation or something else.
// let subclass parse it
title = token.getValue();
} else if (token.getType() == TOKEN_SAFEPOINT) {
if (doBeforeParsingGCTraceTime(event, datestamp)) {
doParseSafePoint(event, token.getValue());
}
return;
} else if (token.getType() == TOKEN_MEMORY_CHANGE) {
long[] memories = GCLogUtil.parseMemorySizeFromTo(token.getValue(), (int) KB2MB);
GCMemoryItem item = new GCMemoryItem(MemoryArea.HEAP, memories);
event.setMemoryItem(item);
} else if (token.getType() == TOKEN_REFERENCE_GC) {
referenceGC = token.getValue();
} else if (token.getType() == TOKEN_DURATION) {
event.setDuration(MS2S * Double.parseDouble(token.getValue()));
} else if (token.getType() == TOKEN_METASPACE) {
long[] memories = GCLogUtil.parseMemorySizeFromTo(token.getValue(), (int) KB2MB);
GCMemoryItem item = new GCMemoryItem(MemoryArea.METASPACE, memories);
event.setMemoryItem(item);
} else if (token.getType() == TOKEN_RIGHT_BRACKET) {
// do nothing
} else {
throw new ShouldNotReachHereException();
}
}
// jni weak does not print reference count
if (referenceGC != null || "JNI Weak Reference".equals(title)) {
if (doBeforeParsingGCTraceTime(event, datestamp)) {
doParseReferenceGC(event, title, referenceGC);
}
} else if (title != null) {
if (doBeforeParsingGCTraceTime(event, datestamp)) {
doParseGCTraceTime(event, title);
}
}
} catch (Exception e) {
log.debug(e.getMessage());
}
}