< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinter.java
Print this page
*** 33,42 ****
--- 33,43 ----
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugContext.Scope;
import org.graalvm.compiler.graph.Graph;
import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.StructuredGraph;
+ import org.graalvm.compiler.nodes.util.JavaConstantFormatter;
import org.graalvm.compiler.phases.schedule.SchedulePhase;
import org.graalvm.compiler.serviceprovider.JDK9Method;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
*** 44,54 ****
import jdk.vm.ci.meta.MetaUtil;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.runtime.JVMCI;
import jdk.vm.ci.services.Services;
! interface GraphPrinter extends Closeable {
/**
* Starts a new group of graphs with the given name, short name and method byte code index (BCI)
* as properties.
*/
--- 45,55 ----
import jdk.vm.ci.meta.MetaUtil;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.runtime.JVMCI;
import jdk.vm.ci.services.Services;
! interface GraphPrinter extends Closeable, JavaConstantFormatter {
/**
* Starts a new group of graphs with the given name, short name and method byte code index (BCI)
* as properties.
*/
*** 114,150 ****
if (JVMCI_MODULE == module || (Boolean) JDK9Method.isOpenTo.invoke(JVMCI_MODULE, JVMCI_RUNTIME_PACKAGE, module)) {
// Can access non-statically-exported package in JVMCI
return true;
}
}
return false;
}
/**
! * Sets or updates the {@code "rawvalue"} and {@code "toString"} properties in {@code props} for
! * {@code cn} if it's a boxed Object value and {@code snippetReflection} can access the raw
! * value.
*/
! default void updateStringPropertiesForConstant(Map<Object, Object> props, ConstantNode cn) {
SnippetReflectionProvider snippetReflection = getSnippetReflectionProvider();
! if (snippetReflection != null && cn.getValue() instanceof JavaConstant) {
! JavaConstant constant = (JavaConstant) cn.getValue();
if (constant.getJavaKind() == JavaKind.Object) {
Object obj = snippetReflection.asObject(Object.class, constant);
if (obj != null) {
! String toString = GraphPrinter.constantToString(obj);
String rawvalue = GraphPrinter.truncate(toString);
// Overwrite the value inserted by
// ConstantNode.getDebugProperties()
props.put("rawvalue", rawvalue);
if (!rawvalue.equals(toString)) {
props.put("toString", toString);
}
}
}
- }
- }
/**
* Replaces all {@link JavaType} elements in {@code args} with the result of
* {@link JavaType#getUnqualifiedName()}.
*
--- 115,165 ----
if (JVMCI_MODULE == module || (Boolean) JDK9Method.isOpenTo.invoke(JVMCI_MODULE, JVMCI_RUNTIME_PACKAGE, module)) {
// Can access non-statically-exported package in JVMCI
return true;
}
}
+ if (c.getClassLoader() == GraphPrinter.class.getClassLoader()) {
+ return true;
+ }
return false;
}
/**
! * Use the real {@link Object#toString()} method for {@link JavaConstant JavaConstants} that are
! * wrapping trusted types, other just return the results of {@link JavaConstant#toString()}.
*/
! @Override
! default String format(JavaConstant constant) {
SnippetReflectionProvider snippetReflection = getSnippetReflectionProvider();
! if (snippetReflection != null) {
if (constant.getJavaKind() == JavaKind.Object) {
Object obj = snippetReflection.asObject(Object.class, constant);
if (obj != null) {
! return GraphPrinter.constantToString(obj);
! }
! }
! }
! return constant.toString();
! }
!
! /**
! * Sets or updates the {@code "rawvalue"} and {@code "toString"} properties in {@code props} for
! * {@code cn} if it's a boxed Object value and {@code snippetReflection} can access the raw
! * value.
! */
! default void updateStringPropertiesForConstant(Map<Object, Object> props, ConstantNode cn) {
! if (cn.isJavaConstant() && cn.getStackKind().isObject()) {
! String toString = format(cn.asJavaConstant());
String rawvalue = GraphPrinter.truncate(toString);
// Overwrite the value inserted by
// ConstantNode.getDebugProperties()
props.put("rawvalue", rawvalue);
if (!rawvalue.equals(toString)) {
props.put("toString", toString);
}
}
}
/**
* Replaces all {@link JavaType} elements in {@code args} with the result of
* {@link JavaType#getUnqualifiedName()}.
*
< prev index next >