Skip to content
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

RD-10562 Implement OSR for iterators #352

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0c55576
updated aggregations
alexzerntev Feb 4, 2024
5046dfd
Headers
alexzerntev Feb 4, 2024
d04e19d
Finished joins
alexzerntev Feb 4, 2024
e5f17f0
Fixed tests
alexzerntev Feb 4, 2024
b6b4a35
Finished List OSR
alexzerntev Feb 4, 2024
bddc1cf
Added compilation finals
alexzerntev Feb 4, 2024
1fa3144
Finished iterables
alexzerntev Feb 5, 2024
f0d0335
Finished json reader
alexzerntev Feb 5, 2024
7131a7c
Merge remote-tracking branch 'origin/main' into RD-10562-implement-os…
alexzerntev Feb 15, 2024
4e3d069
Updated some OSR nodes according to comments
alexzerntev Feb 15, 2024
0efd125
finished list OSR
alexzerntev Feb 16, 2024
e376168
Updated compute next
alexzerntev Feb 16, 2024
4325af9
format
alexzerntev Feb 16, 2024
e6ea58c
Updated compute next
alexzerntev Feb 16, 2024
4db112c
Fix
alexzerntev Feb 16, 2024
bae21c9
Fix
alexzerntev Feb 16, 2024
6827dc0
Fix
alexzerntev Feb 16, 2024
61863b9
Fix
alexzerntev Feb 16, 2024
66ff36b
fixes
alexzerntev Feb 16, 2024
a471176
test
alexzerntev Feb 17, 2024
e54533e
fix
alexzerntev Feb 17, 2024
a9f0673
fix
alexzerntev Feb 17, 2024
a82c9fc
wip
alexzerntev Feb 17, 2024
637cbb4
wip
alexzerntev Feb 17, 2024
41d966b
added std deviation to metrics
alexzerntev Feb 18, 2024
8a05a1d
Added multirun
alexzerntev Feb 20, 2024
cd384cf
fixed filter OSR to use frame
alexzerntev Feb 20, 2024
499dca6
added osr Auxiliary slots
alexzerntev Feb 21, 2024
c72a0a2
Applied frame changes
alexzerntev Feb 21, 2024
bf96ff7
wip
alexzerntev Feb 24, 2024
d7b1dbc
finished lists
alexzerntev Feb 25, 2024
bddc147
wip
alexzerntev Feb 25, 2024
39922d6
finished OSR
alexzerntev Feb 26, 2024
f7ba5b4
fixed test
alexzerntev Feb 27, 2024
f3b117e
updated slots
alexzerntev Feb 27, 2024
c74d453
metrics
alexzerntev Mar 3, 2024
98e5020
Merge remote-tracking branch 'origin/main' into RD-10562-implement-os…
alexzerntev Mar 4, 2024
ac9af7e
metrics
alexzerntev Mar 4, 2024
e9d6a13
improvement
alexzerntev Mar 5, 2024
a62e98b
metrics
alexzerntev Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import java.util.ArrayList;
import raw.compiler.rql2.source.Rql2Type;
import raw.runtime.truffle.ExpressionNode;
import raw.runtime.truffle.ast.TypeGuards;
import raw.runtime.truffle.ast.expressions.iterable.list.osr.OSRListFilterNode;
import raw.runtime.truffle.ast.expressions.iterable.list.osr.OSRToArrayNode;
import raw.runtime.truffle.ast.osr.OSRGeneratorNode;
import raw.runtime.truffle.ast.osr.filter.OSRListFilterBodyNode;
import raw.runtime.truffle.ast.osr.filter.OSRListFilterConditionNode;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodes;
import raw.runtime.truffle.runtime.iterable.IterableNodes;
import raw.runtime.truffle.runtime.list.*;

import java.util.ArrayList;

@ImportStatic(value = TypeGuards.class)
@NodeInfo(shortName = "List.Filter")
@NodeChild("list")
Expand All @@ -52,7 +53,11 @@ public static int[] getSlots(VirtualFrame frame) {
}

public static LoopNode getFilterLoopNode(int[] slots) {
return Truffle.getRuntime().createLoopNode(new OSRListFilterNode(slots[0], slots[1], slots[2]));
return Truffle.getRuntime()
.createLoopNode(
new OSRGeneratorNode(
new OSRListFilterConditionNode(slots[0]),
new OSRListFilterBodyNode(slots[0], slots[1], slots[2])));
}

public static LoopNode getToArrayLoopNode(Rql2Type resultType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@

package raw.runtime.truffle.ast.expressions.iterable.list.osr;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RepeatingNode;
import java.util.ArrayList;

import raw.runtime.truffle.runtime.function.Function;
import raw.runtime.truffle.runtime.function.FunctionExecuteNodes;
import raw.runtime.truffle.runtime.function.FunctionExecuteNodesFactory;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodes;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2023 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package raw.runtime.truffle.ast.osr;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RepeatingNode;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import raw.runtime.truffle.ExpressionNode;
import raw.runtime.truffle.runtime.exceptions.RawTruffleInternalErrorException;

public class OSRGeneratorNode extends Node implements RepeatingNode {

@Child private ExpressionNode conditionNode;

@Child private ExpressionNode bodyNode;

public OSRGeneratorNode(ExpressionNode conditionNode, ExpressionNode bodyNode) {
this.conditionNode = conditionNode;
this.bodyNode = bodyNode;
}

public boolean executeRepeating(VirtualFrame frame) {
try {
if (conditionNode.executeBoolean(frame)) {
bodyNode.executeVoid(frame);
return true;
}
return false;
} catch (UnexpectedResultException e) {
throw new RawTruffleInternalErrorException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2023 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package raw.runtime.truffle.ast.osr.filter;

import com.oracle.truffle.api.frame.VirtualFrame;
import java.util.ArrayList;
import raw.runtime.truffle.ExpressionNode;
import raw.runtime.truffle.runtime.function.FunctionExecuteNodes;
import raw.runtime.truffle.runtime.function.FunctionExecuteNodesFactory;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodes;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodesFactory;
import raw.runtime.truffle.tryable_nullable.TryableNullable;

public class OSRListFilterBodyNode extends ExpressionNode {

@Child
private GeneratorNodes.GeneratorNextNode nextNode =
GeneratorNodesFactory.GeneratorNextNodeGen.create();

@Child
FunctionExecuteNodes.FunctionExecuteOne functionExecuteOneNode =
FunctionExecuteNodesFactory.FunctionExecuteOneNodeGen.create();

private final int generatorSlot;
private final int functionSlot;
private final int llistSlot;

public OSRListFilterBodyNode(int generatorSlot, int functionSlot, int llistSlot) {
this.generatorSlot = generatorSlot;
this.functionSlot = functionSlot;
this.llistSlot = llistSlot;
}

@Override
public Object executeGeneric(VirtualFrame frame) {
Object generator = frame.getAuxiliarySlot(generatorSlot);
Object v = nextNode.execute(this, generator);
Boolean predicate = null;
Object function = frame.getAuxiliarySlot(functionSlot);
predicate =
TryableNullable.handlePredicate(functionExecuteOneNode.execute(this, function, v), false);
if (predicate) {
@SuppressWarnings("unchecked")
ArrayList<Object> llist = (ArrayList<Object>) frame.getAuxiliarySlot(llistSlot);
llist.add(v);
}
return null;
}

@Override
public void executeVoid(VirtualFrame virtualFrame) {
executeGeneric(virtualFrame);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2023 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package raw.runtime.truffle.ast.osr.filter;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import raw.runtime.truffle.ExpressionNode;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodes;
import raw.runtime.truffle.runtime.generator.collection.GeneratorNodesFactory;

public class OSRListFilterConditionNode extends ExpressionNode {

@Child
private GeneratorNodes.GeneratorHasNextNode hasNextNode =
GeneratorNodesFactory.GeneratorHasNextNodeGen.create();

private final int generatorSlot;

public OSRListFilterConditionNode(int generatorSlot) {
this.generatorSlot = generatorSlot;
}

@Override
public Object executeGeneric(VirtualFrame frame) {
Object generator = frame.getAuxiliarySlot(generatorSlot);
if (!hasNextNode.execute(this, generator)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo, remove the if

return false;
}
return true;
}

@Override
public boolean executeBoolean(VirtualFrame virtualFrame) throws UnexpectedResultException {
return (boolean) executeGeneric(virtualFrame);
}
}
Loading