public class CanonicalStringGraphPrinter extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CONSTANT_TO_STRING_LENGTH |
static List<Class<?>> |
TRUSTED_CLASSES
Classes whose
#toString() method does not run any untrusted code. |
| Constructor and Description |
|---|
CanonicalStringGraphPrinter(SnippetReflectionProvider snippetReflection) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginGroup(DebugContext debug,
String name,
String shortName,
ResolvedJavaMethod method,
int bci,
Map<Object,Object> properties)
Starts a new group of graphs with the given name, short name and method byte code index (BCI)
as properties.
|
void |
close() |
static String |
constantArrayToString(Object array,
Set<Object> visited) |
static String |
constantToString(Object value,
Set<Object> visited) |
void |
endGroup()
Ends the current group.
|
default String |
format(JavaConstant constant)
Use the real
Object.toString() method for JavaConstants that are
wrapping trusted types, otherwise just return the result of JavaConstant#toString(). |
static String |
getCanonicalGraphString(StructuredGraph graph,
boolean excludeVirtual,
boolean checkConstants) |
protected static ControlFlowGraph |
getControlFlowGraph(StructuredGraph graph) |
static StructuredGraph.ScheduleResult |
getScheduleOrNull(Graph graph) |
SnippetReflectionProvider |
getSnippetReflectionProvider() |
static boolean |
isToStringTrusted(Class<?> c)
Determines if invoking
Object.toString() on an instance of c will only run
trusted code. |
void |
print(DebugContext debug,
Graph graph,
Map<Object,Object> properties,
int id,
String format,
Object... args)
Prints an entire
Graph with the specified title, optionally using short names for
nodes. |
default Object[] |
simplifyClassArgs(Object... args)
Replaces all
JavaType elements in args with the result of
JavaType.getUnqualifiedName(). |
static String |
truncate(String s) |
default void |
updateStringPropertiesForConstant(Map<Object,Object> props,
ConstantNode cn)
Sets or updates the
"rawvalue" and "toString" properties in props for
cn if it's a boxed Object value and snippetReflection can access the raw
value. |
protected static void |
writeCanonicalExpressionCFGString(StructuredGraph graph,
boolean checkConstants,
boolean removeIdentities,
PrintWriter writer) |
protected static void |
writeCanonicalGraphExpressionString(ValueNode node,
boolean checkConstants,
boolean removeIdentities,
PrintWriter writer) |
protected static void |
writeCanonicalGraphString(StructuredGraph graph,
boolean excludeVirtual,
boolean checkConstants,
PrintWriter writer) |
public static final List<Class<?>> TRUSTED_CLASSES
#toString() method does not run any untrusted code.public static final int MAX_CONSTANT_TO_STRING_LENGTH
public CanonicalStringGraphPrinter(SnippetReflectionProvider snippetReflection)
public SnippetReflectionProvider getSnippetReflectionProvider()
protected static void writeCanonicalGraphExpressionString(ValueNode node, boolean checkConstants, boolean removeIdentities, PrintWriter writer)
protected static void writeCanonicalExpressionCFGString(StructuredGraph graph, boolean checkConstants, boolean removeIdentities, PrintWriter writer)
protected static ControlFlowGraph getControlFlowGraph(StructuredGraph graph)
protected static void writeCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants, PrintWriter writer)
public static String getCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants)
public void beginGroup(DebugContext debug, String name, String shortName, ResolvedJavaMethod method, int bci, Map<Object,Object> properties) throws IOException
IOExceptionpublic void print(DebugContext debug, Graph graph, Map<Object,Object> properties, int id, String format, Object... args) throws IOException
Graph with the specified title, optionally using short names for
nodes.IOExceptionpublic void endGroup()
throws IOException
IOExceptionpublic void close()
public static boolean isToStringTrusted(Class<?> c)
Object.toString() on an instance of c will only run
trusted code.public String format(JavaConstant constant)
Object.toString() method for JavaConstants that are
wrapping trusted types, otherwise just return the result of JavaConstant#toString().format in interface JavaConstantFormatterpublic void updateStringPropertiesForConstant(Map<Object,Object> props, ConstantNode cn)
"rawvalue" and "toString" properties in props for
cn if it's a boxed Object value and snippetReflection can access the raw
value.public Object[] simplifyClassArgs(Object... args)
JavaType elements in args with the result of
JavaType.getUnqualifiedName().args with the above mentioned substitutions or args if no
substitutions were performedpublic static StructuredGraph.ScheduleResult getScheduleOrNull(Graph graph)