Skip to content

Commit 6721c89

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 5c073d9 + 57b98fa commit 6721c89

File tree

6 files changed

+96
-5
lines changed

6 files changed

+96
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test/nashorn/lib
1414
NashornProfile.txt
1515
**/JTreport/**
1616
**/JTwork/**
17+
/src/utils/LogCompilation/target/

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/Compilation.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -221,8 +221,17 @@ public void print(PrintStream stream, int indent, boolean printID, boolean print
221221
stream.print(" " + nmethod.getLevel());
222222
}
223223
}
224+
225+
String codeSize = "";
226+
if (nmethod != null) {
227+
long nmethodSize = nmethod.getInstSize();
228+
if (nmethodSize > 0) {
229+
codeSize = "(code size: " + nmethodSize + ")";
230+
}
231+
}
232+
224233
int bc = isOsr() ? getBCI() : -1;
225-
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc));
234+
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc) + codeSize);
226235
stream.println();
227236
if (getFailureReason() != null) {
228237
stream.println("COMPILE SKIPPED: " + getFailureReason() + " (not retryable)");

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogCompilation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,6 +95,9 @@ public static void main(String[] args) throws Exception {
9595
} else if (a.equals("-s")) {
9696
sort = LogParser.sortByStart;
9797
index++;
98+
} else if (a.equals("-z")) {
99+
sort = LogParser.sortByNMethodSize;
100+
index++;
98101
} else if (a.equals("-t")) {
99102
printTimeStamps = true;
100103
index++;

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,55 @@ public int hashCode() {
381381
}
382382
};
383383

384+
static Comparator<LogEvent> sortByNMethodSize = new Comparator<LogEvent>() {
385+
386+
public int compare(LogEvent a, LogEvent b) {
387+
Compilation c1 = a.getCompilation();
388+
Compilation c2 = b.getCompilation();
389+
if ((c1 != null && c2 == null)) {
390+
return -1;
391+
} else if (c1 == null && c2 != null) {
392+
return 1;
393+
} else if (c1 == null && c2 == null) {
394+
return 0;
395+
}
396+
397+
if (c1.getNMethod() != null && c2.getNMethod() == null) {
398+
return -1;
399+
} else if (c1.getNMethod() == null && c2.getNMethod() != null) {
400+
return 1;
401+
} else if (c1.getNMethod() == null && c2.getNMethod() == null) {
402+
return 0;
403+
}
404+
405+
assert c1.getNMethod() != null && c2.getNMethod() != null : "Neither should be null here";
406+
407+
long c1Size = c1.getNMethod().getInstSize();
408+
long c2Size = c2.getNMethod().getInstSize();
409+
410+
if (c1Size == 0 && c2Size == 0) {
411+
return 0;
412+
}
413+
414+
if (c1Size > c2Size) {
415+
return -1;
416+
} else if (c1Size < c2Size) {
417+
return 1;
418+
}
419+
420+
return 0;
421+
}
422+
423+
public boolean equals(Object other) {
424+
return false;
425+
}
426+
427+
@Override
428+
public int hashCode() {
429+
return 7;
430+
}
431+
};
432+
384433
/**
385434
* Shrink-wrapped representation of a JVMState (tailored to meet this
386435
* tool's needs). It only records a method and bytecode instruction index.
@@ -1119,6 +1168,13 @@ public void startElement(String uri, String localName, String qname, Attributes
11191168
if (level != null) {
11201169
nm.setLevel(parseLong(level));
11211170
}
1171+
String iOffset = atts.getValue("insts_offset");
1172+
String sOffset = atts.getValue("stub_offset");
1173+
if (iOffset != null && sOffset != null) {
1174+
long insts_offset = parseLong(iOffset);
1175+
long stub_offset = parseLong(sOffset);
1176+
nm.setInstSize(stub_offset - insts_offset);
1177+
}
11221178
String compiler = search(atts, "compiler", "");
11231179
nm.setCompiler(compiler);
11241180
nmethods.put(id, nm);

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/NMethod.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,11 @@ public class NMethod extends BasicLogEvent {
4242
*/
4343
private long size;
4444

45+
/**
46+
* The nmethod's insts size in bytes.
47+
*/
48+
private long instSize;
49+
4550
/**
4651
* The nmethod's compilation level.
4752
*/
@@ -79,6 +84,14 @@ public void setSize(long size) {
7984
this.size = size;
8085
}
8186

87+
public long getInstSize() {
88+
return instSize;
89+
}
90+
91+
public void setInstSize(long size) {
92+
this.instSize = size;
93+
}
94+
8295
/**
8396
* @return the level
8497
*/

src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -177,4 +177,13 @@ public void testDashn() throws Exception {
177177

178178
LogCompilation.main(args);
179179
}
180+
181+
@Test
182+
public void testDashz() throws Exception {
183+
String[] args = {"-z",
184+
logFile
185+
};
186+
187+
LogCompilation.main(args);
188+
}
180189
}

0 commit comments

Comments
 (0)