8255965: LogCompilation: add sort by nmethod code size
Reviewed-by: kvn, redestad
This commit is contained in:
parent
e42c134038
commit
57b98fa55a
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ test/nashorn/lib
|
|||||||
NashornProfile.txt
|
NashornProfile.txt
|
||||||
**/JTreport/**
|
**/JTreport/**
|
||||||
**/JTwork/**
|
**/JTwork/**
|
||||||
|
/src/utils/LogCompilation/target/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -221,8 +221,17 @@ public class Compilation implements LogEvent {
|
|||||||
stream.print(" " + nmethod.getLevel());
|
stream.print(" " + nmethod.getLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String codeSize = "";
|
||||||
|
if (nmethod != null) {
|
||||||
|
long nmethodSize = nmethod.getInstSize();
|
||||||
|
if (nmethodSize > 0) {
|
||||||
|
codeSize = "(code size: " + nmethodSize + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int bc = isOsr() ? getBCI() : -1;
|
int bc = isOsr() ? getBCI() : -1;
|
||||||
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc));
|
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc) + codeSize);
|
||||||
stream.println();
|
stream.println();
|
||||||
if (getFailureReason() != null) {
|
if (getFailureReason() != null) {
|
||||||
stream.println("COMPILE SKIPPED: " + getFailureReason() + " (not retryable)");
|
stream.println("COMPILE SKIPPED: " + getFailureReason() + " (not retryable)");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -95,6 +95,9 @@ public class LogCompilation extends DefaultHandler implements ErrorHandler {
|
|||||||
} else if (a.equals("-s")) {
|
} else if (a.equals("-s")) {
|
||||||
sort = LogParser.sortByStart;
|
sort = LogParser.sortByStart;
|
||||||
index++;
|
index++;
|
||||||
|
} else if (a.equals("-z")) {
|
||||||
|
sort = LogParser.sortByNMethodSize;
|
||||||
|
index++;
|
||||||
} else if (a.equals("-t")) {
|
} else if (a.equals("-t")) {
|
||||||
printTimeStamps = true;
|
printTimeStamps = true;
|
||||||
index++;
|
index++;
|
||||||
|
@ -381,6 +381,55 @@ public class LogParser extends DefaultHandler implements ErrorHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Comparator<LogEvent> sortByNMethodSize = new Comparator<LogEvent>() {
|
||||||
|
|
||||||
|
public int compare(LogEvent a, LogEvent b) {
|
||||||
|
Compilation c1 = a.getCompilation();
|
||||||
|
Compilation c2 = b.getCompilation();
|
||||||
|
if ((c1 != null && c2 == null)) {
|
||||||
|
return -1;
|
||||||
|
} else if (c1 == null && c2 != null) {
|
||||||
|
return 1;
|
||||||
|
} else if (c1 == null && c2 == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1.getNMethod() != null && c2.getNMethod() == null) {
|
||||||
|
return -1;
|
||||||
|
} else if (c1.getNMethod() == null && c2.getNMethod() != null) {
|
||||||
|
return 1;
|
||||||
|
} else if (c1.getNMethod() == null && c2.getNMethod() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert c1.getNMethod() != null && c2.getNMethod() != null : "Neither should be null here";
|
||||||
|
|
||||||
|
long c1Size = c1.getNMethod().getInstSize();
|
||||||
|
long c2Size = c2.getNMethod().getInstSize();
|
||||||
|
|
||||||
|
if (c1Size == 0 && c2Size == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1Size > c2Size) {
|
||||||
|
return -1;
|
||||||
|
} else if (c1Size < c2Size) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shrink-wrapped representation of a JVMState (tailored to meet this
|
* Shrink-wrapped representation of a JVMState (tailored to meet this
|
||||||
* tool's needs). It only records a method and bytecode instruction index.
|
* tool's needs). It only records a method and bytecode instruction index.
|
||||||
@ -1119,6 +1168,13 @@ public class LogParser extends DefaultHandler implements ErrorHandler {
|
|||||||
if (level != null) {
|
if (level != null) {
|
||||||
nm.setLevel(parseLong(level));
|
nm.setLevel(parseLong(level));
|
||||||
}
|
}
|
||||||
|
String iOffset = atts.getValue("insts_offset");
|
||||||
|
String sOffset = atts.getValue("stub_offset");
|
||||||
|
if (iOffset != null && sOffset != null) {
|
||||||
|
long insts_offset = parseLong(iOffset);
|
||||||
|
long stub_offset = parseLong(sOffset);
|
||||||
|
nm.setInstSize(stub_offset - insts_offset);
|
||||||
|
}
|
||||||
String compiler = search(atts, "compiler", "");
|
String compiler = search(atts, "compiler", "");
|
||||||
nm.setCompiler(compiler);
|
nm.setCompiler(compiler);
|
||||||
nmethods.put(id, nm);
|
nmethods.put(id, nm);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -42,6 +42,11 @@ public class NMethod extends BasicLogEvent {
|
|||||||
*/
|
*/
|
||||||
private long size;
|
private long size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The nmethod's insts size in bytes.
|
||||||
|
*/
|
||||||
|
private long instSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nmethod's compilation level.
|
* The nmethod's compilation level.
|
||||||
*/
|
*/
|
||||||
@ -79,6 +84,14 @@ public class NMethod extends BasicLogEvent {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getInstSize() {
|
||||||
|
return instSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstSize(long size) {
|
||||||
|
this.instSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the level
|
* @return the level
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -177,4 +177,13 @@ public class TestLogCompilation {
|
|||||||
|
|
||||||
LogCompilation.main(args);
|
LogCompilation.main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDashz() throws Exception {
|
||||||
|
String[] args = {"-z",
|
||||||
|
logFile
|
||||||
|
};
|
||||||
|
|
||||||
|
LogCompilation.main(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user