-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated uq interpreter #4115
base: master
Are you sure you want to change the base?
Updated uq interpreter #4115
Conversation
… in the interpreter.
…not implemented yet.
…he correct value()
…ic fields including private ones.
…with java.lang.reflect.InaccessibleObjectException issues.
…taFlow(_) to interpretExpr(_). And FixedNode provides a useful default implementation of the latter.
…. Make Node lookups total. Tag thrown exceptions with an unwinding flag to distinguish them from Exception objects returned normally.
…supporting constant real Java objects.
Add IR Interpreter, with support for simple objects.
We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address k -(dot)- thomassen -(at)- uq -(dot)- edu -(dot)- au. You can sign it at that link. If you think you've already signed it, please comment below and we'll check.
We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address m -(dot)- utting -(at)- uq -(dot)- edu -(dot)- au. You can sign it at that link. If you think you've already signed it, please comment below and we'll check.
We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address bm -(dot)- utting -(at)- gmail -(dot)- com. You can sign it at that link. If you think you've already signed it, please comment below and we'll check. |
This is brilliant! |
Hello Brae Webb, thanks for contributing a PR to our project! We use the Oracle Contributor Agreement to make the copyright of contributions clear. We don't have a record of you having signed this yet, based on your email address email -(at)- braewebb -(dot)- com. You can sign it at that link. If you think you've already signed it, please comment below and we'll check. |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a cursory review of this PR and left a few comments.
While it's a good start, it will need substantial work before it might be integrated. Namely, all the TODO's should be addressed and other unimplemented functionality should be completed.
return test(getInitialOptions(), name, args); | ||
// return test(getInitialOptions(), name, args); | ||
Result result = test(getInitialOptions(), name, args); | ||
String interpret = System.getProperty("graal.Interpreter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be test.graal.Interpreter
to avoid clashing with the Graal options system which "owns" the graal.
system property namespace.
return; | ||
} | ||
StructuredGraph methodGraph = parseForCompile(method, getOrCreateCompilationId(method, null), getInitialOptions()); | ||
// System.out.println("Method: " method.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete all commented out code.
@@ -0,0 1,80 @@ | |||
/* | |||
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix copyright to be 2021
here and in all other new files.
/** | ||
* Interpreter for Graal Intermediate Representation (IR) graphs. | ||
* | ||
* The main method is <code>executeGraph(g,args...)</code>, which interprets the graph <code>g</code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use {@link ...}
instead of <code>
tags as the former will survive refactoring. Also, Use {@code ...}
instead of <code>...</code>
.
throw new UnsupportedOperationException("asPrimitiveConstant called on non primitive value"); | ||
} | ||
|
||
public ResolvedJavaType getObjectType() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every method in this fundamental base class needs javadoc. Same goes for all other classes in this package.
@Override | ||
public void setUnwindException() { | ||
try { | ||
if (!Exception.class.isAssignableFrom(Class.forName(type.toClassName()))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwable
is the base exception class, not Exception
.
Instead of Class.forName
, you should resolve Throwable.class
to a ResolvedJavaType
, caches it in a static, and use ResolvedJavaType.isAssignableFrom
instead.
public abstract InterpreterValue getFieldValue(ResolvedJavaField field); | ||
|
||
@Override | ||
public boolean isUnwindException() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just throw an exception in the interpreter to model exception throwing?
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA). To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When singing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. |
3818dce
to
8c47dee
Compare
Added a getTypeClass() method used by InterpreterValueMutableObject and InterpreterValueArray
Support primitive array. When accessing array elements, convert elements from native objects into InterpreterValue back and forth.
Use native objects to implement interpreter objects. Use reflection to construct native object, and VarHandles to access fields.
same with the orginal format
Added some static methods to convert primitive values into InterpreterValuePrimitive
Added this interface to support cross-module class loading and VarHandle use for InterpreterValueMutableObject.
Support null constant.
Support null constant.
Support null constant.
Removed getHeapValue() and setHeapValue().
Added this exception to distinguish interpretation exception and exception caused by interpreter malfunctioning.
Throws exception if the object is null in interpreter
Throws exception if the array is null in interpreter
setHeapValue() -> setNodeLookupValue()
setHeapValue() -> setNodeLookupValue()
setHeapValue() -> setNodeLookupValue()
Throws exception if the object is null in interpreter
Throws exception if the array is null in interpreter
Fixed object equality testing in interpreter.
An interpreter for GraalVM IR graphs.
This can be useful for evaluating IR graphs during testing.
This implements 'interpret(InterpreterState)' methods in 30 of the most common subclasses of FixedNode in order to interpret those control-flow nodes, and 'interpretExpr(InterpreterState)' methods in most of the common data flow nodes in order to interpret expressions. The main entry point for the interpreter is the GraalInterpreter class and its executeGraph method.
The interpreter is based on a 2020-2021 UQ honours project by Leon Karstens plus further contributions by Kristian Thomassen and Mark Utting (UQ). Some current limitations are that it focusses mostly on high-level nodes rather than lowered nodes, supports only simple objects whose fields are primitive values, it attempts to interpret methods in ALL classes that are called (an alternative might be to treat some java.lang.* classes as pre-defined), and uses reflection to initialize static fields (which means that it cannot find some private fields).