Skip to content

Commit

Permalink
Merge branch 'develop' into wip/akirathan/enso-proj-suggestion-5050
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java
  • Loading branch information
Akirathan committed Apr 28, 2023
2 parents 5821133 + efe904c commit 7f700c9
Show file tree
Hide file tree
Showing 67 changed files with 511 additions and 276 deletions.
4 changes: 3 additions & 1 deletion app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,9 @@ impl GraphEditorModel {
self.breadcrumbs.set_x(x_offset);

self.scene().add_child(&self.tooltip);
self.add_child(&self.profiling_button);
if ARGS.groups.feature_preview.options.profiling.value {
self.add_child(&self.profiling_button);
}
self.add_child(&*self.add_node_button);
self
}
Expand Down
5 changes: 5 additions & 0 deletions app/ide-desktop/lib/content-config/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
"newDashboard": {
"value": false,
"description": "Determines whether the new dashboard with cloud integration is enabled."
},
"profiling": {
"value": false,
"description": "Enable the button to profile workflows.",
"primary": false
}
}
},
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ lazy val enso = (project in file("."))
.settings(version := "0.1")
.aggregate(
`interpreter-dsl`,
`interpreter-dsl-test`,
`json-rpc-server-test`,
`json-rpc-server`,
`language-server`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ final class InliningBuiltinsInNode extends Node {
long execute(long a, long b) {
return a + b;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.enso.interpreter.dsl.test;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import static org.junit.Assert.assertNotNull;

@BuiltinMethod(type = "InliningBuiltins", name = "need_not", inlineable = true)
final class InliningBuiltinsNeedNotNode extends Node {

long execute(VirtualFrame frame, long a, long b) {
assertNotNull("Some frame is still provided", frame);
return a + b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.enso.interpreter.dsl.test;

import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;

@BuiltinMethod(type = "InliningBuiltins", name = "needs", inlineable = false)
final class InliningBuiltinsNeedsNode extends Node {

long execute(long a, long b) {
return a + b;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ long execute(VirtualFrame frame, long a, long b) {
Assert.assertNotNull("VirtualFrame is always provided", frame);
return a + b;
}

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
package org.enso.interpreter.dsl.test;

import org.enso.interpreter.node.InlineableRootNode;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.RootNode;
import org.enso.interpreter.runtime.callable.function.Function;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.enso.interpreter.node.InlineableNode;

public class InliningBuiltinsTest {

/** @see InliningBuiltinsInNode#execute(long, long) */
@Test
public void executeWithoutVirtualFrame() {
var fn = InliningBuiltinsInMethodGen.makeFunction(null);
if (fn.getCallTarget().getRootNode() instanceof InlineableRootNode root) {
var call = root.createDirectCallNode();
var clazz = call.getClass().getSuperclass();
assertEquals("InlinedCallNode", clazz.getSimpleName());
assertEquals("BuiltinRootNode", clazz.getEnclosingClass().getSimpleName());
if (fn.getCallTarget().getRootNode() instanceof InlineableNode.Root root) {
var call = root.createInlineableNode();
var clazz = call.getClass();
assertEquals("InlineableNode", clazz.getSuperclass().getSimpleName());
assertEquals("org.enso.interpreter.node.InlineableNode$Root", clazz.getEnclosingClass().getInterfaces()[0].getName());

var res = call.call(Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 5L, 7L }));
var res = WithFrame.invoke((frame) -> {
return call.call(frame, Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 5L, 7L }));
});
assertEquals(12L, res);
} else {
fail("It is inlineable: " + fn.getCallTarget().getRootNode());
Expand All @@ -29,15 +34,73 @@ public void executeWithoutVirtualFrame() {
@Test
public void executeWithVirtualFrame() {
var fn = InliningBuiltinsOutMethodGen.makeFunction(null);
if (fn.getCallTarget().getRootNode() instanceof InlineableRootNode root) {
var call = root.createDirectCallNode();
if (fn.getCallTarget().getRootNode() instanceof InlineableNode.Root root) {
fail("The node isn't inlineable: " + fn.getCallTarget().getRootNode());
} else {
var call = DirectCallNode.create(fn.getCallTarget());
var clazz = call.getClass().getSuperclass();
assertEquals("com.oracle.truffle.api.nodes.DirectCallNode", clazz.getName());

var res = call.call(Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 3L, 9L }));
var res = WithFrame.invoke((frame) -> {
return call.call(Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 3L, 9L }));
});
assertEquals(12L, res);
}
}

/** @see InliningBuiltinsNeedsNode#execute(long, long) */
@Test
public void executeWhenNeedsVirtualFrame() {
var fn = InliningBuiltinsNeedsMethodGen.makeFunction(null);
if (fn.getCallTarget().getRootNode() instanceof InlineableNode.Root root) {
fail("The node isn't inlineable: " + fn.getCallTarget().getRootNode());
} else {
var call = DirectCallNode.create(fn.getCallTarget());
var clazz = call.getClass().getSuperclass();
assertEquals("com.oracle.truffle.api.nodes.DirectCallNode", clazz.getName());

var res = WithFrame.invoke((frame) -> {
return call.call(Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 3L, 9L }));
});
assertEquals(12L, res);
}
}

/** @see InliningBuiltinsNeedNotNode#execute(com.oracle.truffle.api.frame.VirtualFrame, long, long) */
@Test
public void executeWhenNeedNotVirtualFrame() {
var fn = InliningBuiltinsNeedNotMethodGen.makeFunction(null);
if (fn.getCallTarget().getRootNode() instanceof InlineableNode.Root root) {
var call = root.createInlineableNode();
var clazz = call.getClass();
assertEquals("InlineableNode", clazz.getSuperclass().getSimpleName());
assertEquals("org.enso.interpreter.node.InlineableNode$Root", clazz.getEnclosingClass().getInterfaces()[0].getName());

var res = WithFrame.invoke((frame) -> {
return call.call(frame, Function.ArgumentsHelper.buildArguments(null, null, new Object[] { null, 5L, 7L }));
});
assertEquals(12L, res);
} else {
fail("It is inlineable: " + fn.getCallTarget().getRootNode());
}
}

private static final class WithFrame<T> extends RootNode {
private final java.util.function.Function<VirtualFrame, T> fn;

private WithFrame(java.util.function.Function<VirtualFrame, T> fn) {
super(null);
this.fn = fn;
}

@Override
public Object execute(VirtualFrame frame) {
return fn.apply(frame);
}

@SuppressWarnings("unchecked")
static <T> T invoke(java.util.function.Function<VirtualFrame, T> fn, Object... args) {
return (T) new WithFrame<>(fn).getCallTarget().call(args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class EmptyUserConfigReader extends SystemReader {

/** @inheritdoc */
override def getHostname: String =
proxy.getHostname
"localhost"

/** @inheritdoc */
override def getenv(variable: String): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
.setAll(true)
.setMessage("Initial commit")
.setAuthor(AuthorName, AuthorEmail)
.setCommitter(AuthorName, AuthorEmail)
.setNoVerify(true)
.call()
()
Expand Down Expand Up @@ -166,6 +167,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
.commit()
.setMessage(commitName)
.setAuthor(AuthorName, AuthorEmail)
.setCommitter(AuthorName, AuthorEmail)
.call()
RepoCommit(revCommit.getName(), revCommit.getShortMessage())
}.mapError(errorHandling)
Expand Down Expand Up @@ -345,7 +347,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
object Git {
private val HeadRef = "HEAD"
private val AuthorName = "Enso VCS"
private val AuthorEmail = "vcs@enso.io"
private val AuthorEmail = "vcs@enso.org"

private class RepoExists extends Exception

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class GitSpec
.setAllowEmpty(true)
.setAll(true)
.setMessage("Initial commit")
.setAuthor("Enso VCS", "vcs@enso.io")
.setAuthor("Enso VCS", "vcs@enso.org")
.call()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@ class VcsManagerTest extends BaseServerTest with RetrySpec with FlakySpec {
.setAllowEmpty(true)
.setAll(true)
.setMessage("Initial commit")
.setAuthor("Enso VCS", "[email protected]")
.setAuthor("Enso VCS", "[email protected]")
.setCommitter("Enso VCS", "[email protected]")
.call()
test(client)
}
Expand Down Expand Up @@ -1491,7 +1492,11 @@ class VcsManagerTest extends BaseServerTest with RetrySpec with FlakySpec {

def commit(root: File, msg: String): RevCommit = {
val jgit = new JGit(repository(root.toPath))
jgit.commit.setMessage(msg).setAuthor("Enso VCS", "[email protected]").call()
jgit.commit
.setMessage(msg)
.setAuthor("Enso VCS", "[email protected]")
.setCommitter("Enso VCS", "[email protected]")
.call()
}

def add(root: File, paths: Path*): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ArrayProxyBenchmarks {
private final long length = 100000;

@Setup
public void initializeBenchmark(BenchmarkParams params) {
public void initializeBenchmark(BenchmarkParams params) throws Exception {
Engine eng =
Engine.newBuilder()
.allowExperimentalOptions(true)
Expand Down Expand Up @@ -59,13 +59,15 @@ Array_Proxy.new n (i -> 3 + 5*i)
make_delegating_vector n =
Vector.from_polyglot_array (make_delegating_proxy n)
""";
var module = ctx.eval("enso", code);
var benchmarkName = SrcUtil.findName(params);
var src = SrcUtil.source(benchmarkName, code);
var module = ctx.eval(src);

this.self = module.invokeMember("get_associated_type");
Function<String, Value> getMethod = (name) -> module.invokeMember("get_method", self, name);

String test_builder;
switch (params.getBenchmark().replaceFirst(".*\\.", "")) {
switch (benchmarkName) {
case "sumOverVector":
test_builder = "make_vector";
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();

var benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
var benchmarkName = SrcUtil.findName(params);
var code = """
avg fn len =
sum acc i = if i == len then acc else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();

var benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
var benchmarkName = SrcUtil.findName(params);
var codeBuilder = new StringBuilder("""
import Standard.Base.Data.Range.Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,8 @@ public void initializeBench(BenchmarkParams params) throws IOException {
""";

var file = File.createTempFile("if_case", ".enso");
try (var w = new FileWriter(file)) {
w.write(code);
}
var src = Source.newBuilder("enso", file).build();
var benchmarkName = SrcUtil.findName(params);
var src = SrcUtil.source(benchmarkName, code);
Value module = ctx.eval(src);
ifBench3 = Objects.requireNonNull(module.invokeMember(Module.EVAL_EXPRESSION, "if_bench_3"));
caseBench3 = Objects.requireNonNull(module.invokeMember(Module.EVAL_EXPRESSION, "case_bench_3"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();

var benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
var benchmarkName = SrcUtil.findName(params);
var code = """
from Standard.Base.Data.List.List import Cons, Nil
import Standard.Base.IO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();

benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
benchmarkName = SrcUtil.findName(params);
code = """
type List
Cons a b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import java.io.FileWriter;
import java.io.IOException;
import org.graalvm.polyglot.Source;
import org.openjdk.jmh.infra.BenchmarkParams;

final class SrcUtil {
private SrcUtil() {
}

static String findName(BenchmarkParams params) {
return params.getBenchmark().replaceFirst(".*\\.", "");
}

static Source source(String benchmarkName, String code) throws IOException {
var d = new File(new File(new File("."), "target"), "bench-data");
d.mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class StringBenchmarks {
private Value allLength;

@Setup
public void initializeBenchmark(BenchmarkParams params) {
public void initializeBenchmark(BenchmarkParams params) throws Exception {
var ctx = Context.newBuilder()
.allowExperimentalOptions(true)
.allowIO(true)
Expand All @@ -42,7 +42,8 @@ public void initializeBenchmark(BenchmarkParams params) {
"enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();
var module = ctx.eval("enso", """

var code ="""
from Standard.Base import all
all_length v = v.fold 0 (sum -> str -> sum + str.length)
Expand All @@ -51,7 +52,10 @@ public void initializeBenchmark(BenchmarkParams params) {
s = "Long string".repeat rep
v = Vector.new len (_ -> s)
v
""");
""";
var benchmarkName = SrcUtil.findName(params);
var src = SrcUtil.source(benchmarkName, code);
var module = ctx.eval(src);

this.self = module.invokeMember("get_associated_type");
Function<String,Value> getMethod = (name) -> module.invokeMember("get_method", self, name);
Expand Down
Loading

0 comments on commit 7f700c9

Please sign in to comment.