-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e240852
commit 9c3ce34
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/main/java/org/adoptopenjdk/jitwatch/model/bytecode/UncommonTrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.adoptopenjdk.jitwatch.model.bytecode; | ||
|
||
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_ACTION; | ||
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_BCI; | ||
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_COMMENT; | ||
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_REASON; | ||
|
||
import org.adoptopenjdk.jitwatch.model.Tag; | ||
|
||
public class UncommonTrap | ||
{ | ||
private int bci; | ||
private String reason; | ||
private String action; | ||
private String comment; | ||
|
||
public int getBCI() | ||
{ | ||
return bci; | ||
} | ||
|
||
public String getReason() | ||
{ | ||
return reason; | ||
} | ||
|
||
public String getAction() | ||
{ | ||
return action; | ||
} | ||
|
||
public String getComment() | ||
{ | ||
return comment; | ||
} | ||
|
||
public UncommonTrap(int bci, String reason, String action, String comment) | ||
{ | ||
this.bci = bci; | ||
this.reason = reason; | ||
this.action = action; | ||
this.comment = comment; | ||
} | ||
|
||
public static UncommonTrap parse(Tag tag) | ||
{ | ||
UncommonTrap trap = null; | ||
|
||
String bci = tag.getAttribute(ATTR_BCI); | ||
String reason = tag.getAttribute(ATTR_REASON); | ||
String action = tag.getAttribute(ATTR_ACTION); | ||
String comment = tag.getAttribute(ATTR_COMMENT); | ||
|
||
if (bci != null) | ||
{ | ||
int bciValue = Integer.valueOf(bci); | ||
|
||
trap = new UncommonTrap(bciValue, reason, action, comment); | ||
} | ||
|
||
return trap; | ||
|
||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
StringBuilder builder = new StringBuilder(); | ||
|
||
builder.append("UncommonTrap"); | ||
builder.append("("); | ||
builder.append("reason:"); | ||
builder.append(reason); | ||
builder.append(" action:"); | ||
builder.append(action); | ||
|
||
if (comment != null) | ||
{ | ||
builder.append(" comment:"); | ||
builder.append(comment); | ||
} | ||
|
||
builder.append(")"); | ||
|
||
return builder.toString(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/org/adoptopenjdk/jitwatch/test/HelperMetaMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.adoptopenjdk.jitwatch.test; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.List; | ||
|
||
import org.adoptopenjdk.jitwatch.model.MetaClass; | ||
import org.adoptopenjdk.jitwatch.model.MetaMethod; | ||
import org.adoptopenjdk.jitwatch.model.bytecode.BytecodeInstruction; | ||
|
||
public class HelperMetaMethod extends MetaMethod | ||
{ | ||
public HelperMetaMethod(Method method, MetaClass methodClass) | ||
{ | ||
super(method, methodClass); | ||
} | ||
|
||
private List<BytecodeInstruction> instructions; | ||
|
||
public void setInstructions(List<BytecodeInstruction> instructions) | ||
{ | ||
this.instructions = instructions; | ||
} | ||
|
||
public List<BytecodeInstruction> getInstructions() | ||
{ | ||
return instructions; | ||
} | ||
} |