author | egahlin |
Mon, 08 Jul 2019 23:08:05 +0200 | |
branch | JEP-349-branch |
changeset 57460 | bcbc53560c77 |
parent 50113 | caf115bb98ad |
child 58112 | e7754025004b |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
2 |
* Copyright (c) 2016, 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.jfr.consumer; |
|
27 |
||
28 |
import java.lang.reflect.Modifier; |
|
29 |
||
30 |
import jdk.jfr.internal.Type; |
|
31 |
||
32 |
/** |
|
33 |
* A recorded frame in a stack trace. |
|
34 |
* |
|
35 |
* @since 9 |
|
36 |
*/ |
|
37 |
public final class RecordedFrame extends RecordedObject { |
|
38 |
||
39 |
static ObjectFactory<RecordedFrame> createFactory(Type type, TimeConverter timeConverter) { |
|
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
40 |
return new ObjectFactory<RecordedFrame>(type, timeConverter) { |
50113 | 41 |
@Override |
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
42 |
RecordedFrame createTyped(ObjectContext objectContext, long id, Object[] values) { |
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
43 |
return new RecordedFrame(objectContext, values); |
50113 | 44 |
} |
45 |
}; |
|
46 |
} |
|
47 |
||
48 |
// package private |
|
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
49 |
RecordedFrame(ObjectContext objectContext, Object[] objects) { |
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
50 |
super(objectContext, objects); |
50113 | 51 |
} |
52 |
||
53 |
/** |
|
54 |
* Returns {@code true} if this is a Java frame, {@code false} otherwise. |
|
55 |
* <p> |
|
56 |
* A Java method that has a native modifier is considered a Java frame. |
|
57 |
* |
|
58 |
* @return {@code true} if this is a Java frame, {@code false} otherwise |
|
59 |
* |
|
60 |
* @see Modifier#isNative(int) |
|
61 |
*/ |
|
62 |
public boolean isJavaFrame() { |
|
63 |
// Only Java frames exist today, but this allows |
|
64 |
// API to be extended for native frame in the future. |
|
65 |
if (hasField("javaFrame")) { |
|
66 |
return getTyped("javaFrame", Boolean.class, Boolean.TRUE); |
|
67 |
} |
|
68 |
return true; |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* Returns the bytecode index for the execution point that is represented by |
|
73 |
* this recorded frame. |
|
74 |
* |
|
75 |
* @return byte code index, or {@code -1} if doesn't exist |
|
76 |
*/ |
|
77 |
public int getBytecodeIndex() { |
|
78 |
return getTyped("bytecodeIndex", Integer.class, Integer.valueOf(-1)); |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Returns the line number for the execution point that is represented by this |
|
83 |
* recorded frame, or {@code -1} if doesn't exist |
|
84 |
* |
|
85 |
* @return the line number, or {@code -1} if doesn't exist |
|
86 |
*/ |
|
87 |
public int getLineNumber() { |
|
88 |
return getTyped("lineNumber", Integer.class, Integer.valueOf(-1)); |
|
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* Returns the frame type for the execution point that is represented by this |
|
93 |
* recorded frame (for example, {@code "Interpreted"}, {@code "JIT compiled"} or |
|
94 |
* {@code "Inlined"}). |
|
95 |
* |
|
96 |
* @return the frame type, or {@code null} if doesn't exist |
|
97 |
*/ |
|
98 |
public String getType() { |
|
99 |
return getTyped("type", String.class, null); |
|
100 |
} |
|
101 |
||
102 |
/** |
|
103 |
* Returns the method for the execution point that is represented by this |
|
104 |
* recorded frame. |
|
105 |
* |
|
106 |
* @return the method, not {@code null} |
|
107 |
*/ |
|
108 |
public RecordedMethod getMethod() { |
|
109 |
return getTyped("method", RecordedMethod.class, null); |
|
110 |
} |
|
111 |
} |