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

Initial benchmarks for intersection types + a bit of speedup #11924

Merged
merged 29 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
086d024
Ensure isAllTypes is compilation constant
JaroslavTulach Dec 19, 2024
a33965d
Using internal MultiType to represent Type[] but with guaranteed ==
JaroslavTulach Dec 19, 2024
171c799
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MultiT…
JaroslavTulach Dec 19, 2024
775595c
Prefer partialEvaluationConstant assert
JaroslavTulach Dec 19, 2024
e2760ff
Benchmarks for intersection types
JaroslavTulach Dec 20, 2024
630ec62
Usage of Map & co. must be behind @TruffleBoundary
JaroslavTulach Dec 20, 2024
8defcfe
Unify findInteropTypeValue
JaroslavTulach Dec 20, 2024
d44d30e
Inline cache to find index of a type
JaroslavTulach Dec 20, 2024
7b6d364
Use EnsoMultiValue.NewNode to allocate new instances of EnsoMultiValue
JaroslavTulach Dec 20, 2024
bda398a
Basic specializations for NewNode
JaroslavTulach Dec 20, 2024
56b24aa
Splitting the FindIndexNode and caching requests for newNode
JaroslavTulach Dec 20, 2024
2dcc2c4
Just ask only for types the value 'has been cast to'
JaroslavTulach Dec 20, 2024
ee080a3
Provide cachedTypes as the first argument to activate the caches
JaroslavTulach Dec 20, 2024
53c2222
AllOfTypesCheckNode needs cached EnsoMultiValue.NewNode to allocate E…
JaroslavTulach Dec 20, 2024
9567257
Moving EnsoMultiType into outer scope
JaroslavTulach Dec 20, 2024
6bfdbf9
Sum re field of a Complex object in a Vector is the base benchmark
JaroslavTulach Dec 21, 2024
4dacf53
Cache dispatch on EnsoMultiValue.getDispatchId
JaroslavTulach Dec 21, 2024
ebe0553
Turing allTypesWith method into EnsoMultiType.AllTypesWith node
JaroslavTulach Dec 28, 2024
2301f9b
Only assert valid payload
JaroslavTulach Dec 30, 2024
8d5452c
Speeding up non-reordering reorderOnly case twice
JaroslavTulach Dec 30, 2024
ed8799c
Merging with develop and resolving conflicts
JaroslavTulach Dec 30, 2024
615b600
Don't use keyword as variable name
JaroslavTulach Dec 30, 2024
a68db22
Assert there is no intersection between dispatch and extra types
JaroslavTulach Dec 30, 2024
98ebc39
Merge remote-tracking branch 'origin/develop' into wip/jtulach/MultiT…
JaroslavTulach Jan 4, 2025
a9f57f0
Avoiding duplications when Number & Integer & Float and co.
JaroslavTulach Jan 4, 2025
035b2be
Merge branch 'develop' into wip/jtulach/MultiType11846
mergify[bot] Jan 4, 2025
3f0a3e3
Merge branch 'develop' into wip/jtulach/MultiType11846
mergify[bot] Jan 6, 2025
9503f79
Merge branch 'develop' into wip/jtulach/MultiType11846
mergify[bot] Jan 7, 2025
f515d8a
Merge branch 'develop' into wip/jtulach/MultiType11846
mergify[bot] Jan 7, 2025
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
@@ -1,10 +1,12 @@
package org.enso.interpreter.node.typecheck;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.enso.interpreter.node.ExpressionNode;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.data.EnsoMultiValue;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
Expand Down Expand Up @@ -37,12 +39,26 @@ Object executeCheckOrConversion(VirtualFrame frame, Object value, ExpressionNode
var values = new Object[checks.length];
var valueTypes = new Type[checks.length];
var at = 0;
var integers = 0;
var floats = 0;
for (var n : checks) {
var result = n.executeCheckOrConversion(frame, value, expr);
if (result == null) {
return null;
}
valueTypes[at] = types.getType(result);
var t = types.getType(result);
var ctx = EnsoContext.get(this);
if (ctx.getBuiltins().number().getInteger() == t) {
if (++integers > 1) {
continue;
}
}
if (ctx.getBuiltins().number().getFloat() == t) {
if (++floats > 1) {
continue;
}
}
valueTypes[at] = t;
if (result instanceof EnsoMultiValue emv) {
result =
EnsoMultiValue.CastToNode.getUncached()
Expand All @@ -54,6 +70,17 @@ Object executeCheckOrConversion(VirtualFrame frame, Object value, ExpressionNode
values[at] = result;
at++;
}
if (at != checks.length) {
// request for Number & Integer may yield two integers collision
// request for Number & Float may yield two floats collision
// request for Number & Integer & Float must yield one collision
Copy link
Member Author

Choose a reason for hiding this comment

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

There are tests in Conversion_Spec that combine these types. Thus such a combination must be supported (and it clashes with assert checking each type is in multi value only once) - but it doesn't have to be fast. Thus transferToInterpreter().

//
// people shouldn't be doing such things but the code must be
// ready for that - switching to interpreter without optimization
CompilerDirectives.transferToInterpreter();
values = Arrays.copyOf(values, at);
valueTypes = Arrays.copyOf(valueTypes, at);
}
return newNode.newValue(valueTypes, valueTypes.length, values);
}

Expand Down
Loading