1 /*
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
82 this.entryBCI = entryBCI;
83
84 start = System.nanoTime();
85 allocatedBytesBefore = isThreadAllocatedMemorySupported() ? getCurrentThreadAllocatedBytes() : -1;
86 }
87
88 private String getMethodDescription() {
89 return String.format("%-30s %-70s %-45s %-50s %s", id.toString(CompilationIdentifier.Verbosity.ID),
90 method.getDeclaringClass().getName(), method.getName(),
91 method.getSignature().toMethodDescriptor(),
92 entryBCI == JVMCICompiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");
93 }
94
95 /**
96 * Notifies this object that the compilation finished and the informational line should be
97 * printed to {@link TTY}.
98 */
99 public void finish(CompilationResult result) {
100 if (id != null) {
101 final long stop = System.nanoTime();
102 final long duration = (stop - start) / 1000000;
103 final int targetCodeSize = result != null ? result.getTargetCodeSize() : -1;
104 final int bytecodeSize = result != null ? result.getBytecodeSize() : 0;
105 if (allocatedBytesBefore == -1) {
106 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dB", duration, bytecodeSize, targetCodeSize));
107 } else {
108 final long allocatedBytesAfter = getCurrentThreadAllocatedBytes();
109 final long allocatedKBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
110 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dB %5dkB", duration, bytecodeSize, targetCodeSize, allocatedKBytes));
111 }
112 }
113 }
114 }
|
1 /*
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
82 this.entryBCI = entryBCI;
83
84 start = System.nanoTime();
85 allocatedBytesBefore = isThreadAllocatedMemorySupported() ? getCurrentThreadAllocatedBytes() : -1;
86 }
87
88 private String getMethodDescription() {
89 return String.format("%-30s %-70s %-45s %-50s %s", id.toString(CompilationIdentifier.Verbosity.ID),
90 method.getDeclaringClass().getName(), method.getName(),
91 method.getSignature().toMethodDescriptor(),
92 entryBCI == JVMCICompiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");
93 }
94
95 /**
96 * Notifies this object that the compilation finished and the informational line should be
97 * printed to {@link TTY}.
98 */
99 public void finish(CompilationResult result) {
100 if (id != null) {
101 final long stop = System.nanoTime();
102 final long duration = (stop - start) / 1000;
103 final int targetCodeSize = result != null ? result.getTargetCodeSize() : -1;
104 final int bytecodeSize = result != null ? result.getBytecodeSize() : 0;
105 if (allocatedBytesBefore == -1) {
106 TTY.println(getMethodDescription() + String.format(" | %4dus %5dB bytecodes %5dB codesize", duration, bytecodeSize, targetCodeSize));
107 } else {
108 final long allocatedBytesAfter = getCurrentThreadAllocatedBytes();
109 final long allocatedKBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
110 TTY.println(getMethodDescription() + String.format(" | %4dus %5dB bytecodes %5dB codesize %5dkB allocated", duration, bytecodeSize, targetCodeSize, allocatedKBytes));
111 }
112 }
113 }
114 }
|