Skip to content
Snippets Groups Projects
Commit f5014483 authored by Stepan Sindelar's avatar Stepan Sindelar
Browse files

[GR-2798] Avoid memory leak in tests.

parents eb61b6be 9db8d239
No related branches found
No related tags found
No related merge requests found
......@@ -533,7 +533,7 @@ final class REngine implements Engine, Engine.Timings {
*/
@TruffleBoundary
private RootCallTarget doMakeCallTarget(RNode body, String description, boolean printResult, boolean topLevel) {
return Truffle.getRuntime().createCallTarget(new AnonymousRootNode(body, description, printResult, topLevel));
return Truffle.getRuntime().createCallTarget(new AnonymousRootNode(this, body, description, printResult, topLevel));
}
/**
......@@ -544,7 +544,7 @@ final class REngine implements Engine, Engine.Timings {
* context of that frame. Note that passing only this one frame argument, strictly spoken,
* violates the frame layout as set forth in {@link RArguments}. This is for internal use only.
*/
private final class AnonymousRootNode extends RootNode implements RootWithBody {
private static final class AnonymousRootNode extends RootNode implements RootWithBody {
private final ValueProfile frameTypeProfile = ValueProfile.createClassProfile();
private final ConditionProfile isVirtualFrameProfile = ConditionProfile.createBinaryProfile();
......@@ -552,13 +552,15 @@ final class REngine implements Engine, Engine.Timings {
private final String description;
private final boolean printResult;
private final boolean topLevel;
private final boolean suppressWarnings;
@Child private RNode body;
@Child private GetVisibilityNode visibility = GetVisibilityNode.create();
@Child private SetVisibilityNode setVisibility = SetVisibilityNode.create();
protected AnonymousRootNode(RNode body, String description, boolean printResult, boolean topLevel) {
super(context.getLanguage());
protected AnonymousRootNode(REngine engine, RNode body, String description, boolean printResult, boolean topLevel) {
super(engine.context.getLanguage());
this.suppressWarnings = engine.suppressWarnings;
this.body = body;
this.description = description;
this.printResult = printResult;
......@@ -597,7 +599,7 @@ final class REngine implements Engine, Engine.Timings {
if (printResult && result != null) {
assert topLevel;
if (visibility.execute(vf)) {
printResult(result);
printResultImpl(result);
}
}
if (topLevel) {
......@@ -665,8 +667,12 @@ final class REngine implements Engine, Engine.Timings {
}
@Override
@TruffleBoundary
public void printResult(Object originalResult) {
printResultImpl(originalResult);
}
@TruffleBoundary
static void printResultImpl(Object originalResult) {
Object result = evaluatePromise(originalResult);
result = RRuntime.asAbstractVector(result);
if (result instanceof RTypedValue || result instanceof TruffleObject) {
......
......@@ -29,7 +29,7 @@ suite = {
{
"name" : "truffle",
"subdir" : True,
"version" : "05b61f9fa9dceebec447f3ec3656c8cc5be215dd",
"version" : "b29a94a6738f96c33be981681b69216a1664eb8a",
"urls" : [
{"url" : "https://github.com/graalvm/graal", "kind" : "git"},
{"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment