Skip to content

Commit

Permalink
Automatic merge of jdk:master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Nov 5, 2020
2 parents 5c073d9 + 57b98fa commit 6721c89
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test/nashorn/lib
NashornProfile.txt
**/JTreport/**
**/JTwork/**
/src/utils/LogCompilation/target/
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -221,8 +221,17 @@ public void print(PrintStream stream, int indent, boolean printID, boolean print
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;
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc));
stream.print(getMethod().decodeFlags(bc) + " " + getCompiler() + " " + getMethod().format(bc) + codeSize);
stream.println();
if (getFailureReason() != null) {
stream.println("COMPILE SKIPPED: " + getFailureReason() + " (not retryable)");
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,6 +95,9 @@ public static void main(String[] args) throws Exception {
} else if (a.equals("-s")) {
sort = LogParser.sortByStart;
index++;
} else if (a.equals("-z")) {
sort = LogParser.sortByNMethodSize;
index++;
} else if (a.equals("-t")) {
printTimeStamps = true;
index++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,55 @@ public int hashCode() {
}
};

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
* tool's needs). It only records a method and bytecode instruction index.
Expand Down Expand Up @@ -1119,6 +1168,13 @@ public void startElement(String uri, String localName, String qname, Attributes
if (level != null) {
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", "");
nm.setCompiler(compiler);
nmethods.put(id, nm);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -42,6 +42,11 @@ public class NMethod extends BasicLogEvent {
*/
private long size;

/**
* The nmethod's insts size in bytes.
*/
private long instSize;

/**
* The nmethod's compilation level.
*/
Expand Down Expand Up @@ -79,6 +84,14 @@ public void setSize(long size) {
this.size = size;
}

public long getInstSize() {
return instSize;
}

public void setInstSize(long size) {
this.instSize = size;
}

/**
* @return the level
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -177,4 +177,13 @@ public void testDashn() throws Exception {

LogCompilation.main(args);
}

@Test
public void testDashz() throws Exception {
String[] args = {"-z",
logFile
};

LogCompilation.main(args);
}
}

0 comments on commit 6721c89

Please sign in to comment.