Skip to content

Commit 74099a5

Browse files
committed
Merge branch 'master' into graal
2 parents 3b5fdea + 1b3e83b commit 74099a5

File tree

131 files changed

+82
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+82
-32
lines changed

visualvm/host/src/org/graalvm/visualvm/host/model/HostOverview.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.graalvm.visualvm.core.model.Model;
2929

3030
/**
31-
* This class uses available JVM APIs to obtatin various information about operating system and host
31+
* This class uses available JVM APIs to obtain various information about operating system and host
3232
* on which the Java virtual machine is running.
3333
*
3434
* @author Tomas Hurka

visualvm/host/src/org/graalvm/visualvm/host/model/LocalHostOverview.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.net.InetAddress;
3232
import java.net.UnknownHostException;
3333
import org.openide.util.NbBundle;
34-
import org.openide.util.Utilities;
3534

3635

3736
/**

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/heap/ClassDump.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,25 @@ class ClassDump extends HprofObject implements JavaClass {
9393
//~ Methods ------------------------------------------------------------------------------------------------------------------
9494

9595
public long getAllInstancesSize() {
96-
if (isArray()) {
97-
return ((Long) classDumpSegment.arrayMap.get(this)).longValue();
96+
Long allInstancesSizeArr = (Long) classDumpSegment.arrayMap.get(this);
97+
98+
if (allInstancesSizeArr != null) {
99+
return allInstancesSizeArr.longValue();
98100
}
99101

100102
return ((long)getInstancesCount()) * getInstanceSize();
101103
}
102104

103105
public boolean isArray() {
104-
return classDumpSegment.arrayMap.get(this) != null;
106+
boolean isArrayWithInstances = classDumpSegment.arrayMap.get(this) != null;;
107+
108+
if (isArrayWithInstances) {
109+
return true;
110+
}
111+
if (instances != 0) {
112+
return false;
113+
}
114+
return getName().endsWith("[]");
105115
}
106116

107117
public Instance getClassLoader() {

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/CPUCallGraphBuilder.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ public CPUCCTContainer[] createPresentationCCTs(CPUResultsSnapshot cpuSnapshot)
160160

161161
// Fix the problem with inconsistent thread times that otherwise will occur for e.g. threads sitting in wait()
162162
// for long enough time when "get results" is pressed
163-
/* not in use any longer
164-
ti.applyDiffAtGetResultsMoment();
165-
*/
163+
applyDiffAtGetResultsMoment(ti);
166164
double[] activeTimes = calculateThreadActiveTimes(ti);
167165

168166
TimedCPUCCTNode rootNode = ti.stack[0];
@@ -173,6 +171,7 @@ public CPUCCTContainer[] createPresentationCCTs(CPUResultsSnapshot cpuSnapshot)
173171
if ((cct.rootNode != null) && (cct.rootNode.getNChildren() > 0)) {
174172
ccts.add(cct);
175173
}
174+
undoDiffAtGetResultsMoment(ti);
176175
}
177176

178177
return (CPUCCTContainer[]) ccts.toArray(new CPUCCTContainer[0]);
@@ -189,6 +188,17 @@ protected boolean isCollectingTwoTimeStamps() {
189188
return status.collectingTwoTimeStamps();
190189
}
191190

191+
/** See the comment to ThreadInfo.diffAtGetResultsMoment field. */
192+
protected void applyDiffAtGetResultsMoment(ThreadInfo ti) {
193+
}
194+
195+
/**
196+
* See the comment to ThreadInfo.diffAtGetResultsMoment field. When we resume data processing for the given thread,
197+
* we need to undo the effect of applyDiffAtGetResultsMoment.
198+
*/
199+
protected void undoDiffAtGetResultsMoment(ThreadInfo ti) {
200+
}
201+
192202
protected long getDumpAbsTimeStamp() {
193203
return status.dumpAbsTimeStamp;
194204
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/StackTraceSnapshotBuilder.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import org.graalvm.visualvm.lib.jfluid.global.CommonConstants;
5858
import org.graalvm.visualvm.lib.jfluid.global.ProfilingSessionStatus;
5959
import org.graalvm.visualvm.lib.jfluid.results.RuntimeCCTNode;
60+
import org.graalvm.visualvm.lib.jfluid.results.cpu.cct.nodes.MethodCPUCCTNode;
61+
import org.graalvm.visualvm.lib.jfluid.results.cpu.cct.nodes.TimedCPUCCTNode;
6062

6163
/**
6264
*
@@ -657,7 +659,6 @@ public final CPUResultsSnapshot createSnapshot(
657659
instrMethodSigs[counter] = "";
658660
counter++;
659661
}
660-
addStacktrace(new java.lang.management.ThreadInfo[0], currentDumpTimeStamp+1);
661662
return new CPUResultsSnapshot(since, System.currentTimeMillis(), ccgb, ccgb.isCollectingTwoTimeStamps(), instrMethodClasses, instrMethodNames, instrMethodSigs, miCount);
662663
}
663664
}
@@ -721,6 +722,36 @@ protected long getDumpAbsTimeStamp() {
721722
}
722723
}
723724

724-
}
725+
@Override
726+
protected void applyDiffAtGetResultsMoment(ThreadInfo ti) {
727+
long time0 = getDumpAbsTimeStamp();
728+
long diff = time0 - ti.topMethodEntryTime0;
729+
730+
applyDiffToTopNode(ti, diff);
731+
ti.diffAtGetResultsMoment = diff;
732+
}
733+
734+
@Override
735+
protected void undoDiffAtGetResultsMoment(ThreadInfo ti) {
736+
applyDiffToTopNode(ti, -ti.diffAtGetResultsMoment);
737+
ti.diffAtGetResultsMoment = 0;
738+
}
739+
740+
private void applyDiffToTopNode(ThreadInfo ti, long diff) {
741+
if (diff>0) {
742+
TimedCPUCCTNode top = ti.peek();
725743

744+
if (top instanceof MethodCPUCCTNode) {
745+
top.addNetTime0(diff);
746+
if (isCollectingTwoTimeStamps()) {
747+
SampledThreadInfo sti = lastStackTrace.get().get(Long.valueOf(ti.threadId));
748+
749+
if (sti!=null && sti.getThreadState() == Thread.State.RUNNABLE) {
750+
top.addNetTime1(diff);
751+
}
752+
}
753+
}
754+
}
755+
}
756+
}
726757
}

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/results/cpu/ThreadInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public class ThreadInfo {
5050
// moment user hits "get results" and the timestamp for the method entry into the top stack method. To present
5151
// results consistenly, we add this value to the TimedCPUCCTNode for the top-stack method. However, when
5252
// processing of data is resumed, we need to subtract this value back from that node.
53-
// this is effectively the self time for the last invocation of the top method on stack - if we would not keep
53+
// This is effectively the self time for the last invocation of the top method on stack - if we would not keep
5454
// it separately, it would not be reported
55-
// private long diffAtGetResultsMoment; // diff between last methodEntry and current moment timestamp -
55+
long diffAtGetResultsMoment; // diff between last methodEntry and current moment timestamp -
5656
// we will have to compensate for the processing time
5757

5858
//~ Instance fields ------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)