Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d754beb
Showing
160 changed files
with
9,402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
.idea | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017, Ragnar Dahlén | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# shen-truffle | ||
|
||
shen-truffle is a port of the [Shen programming | ||
language](http://www.shenlanguage.org/) to the [Graal | ||
runtime](https://github.com/graalvm/graal). | ||
|
||
### Acknowledgments | ||
|
||
Thanks to [Dr Mark Tarver](http://marktarver.com) for his work in | ||
science and philosophy in general, and Shen in particular. | ||
|
||
|
||
## Usage | ||
|
||
Not yet | ||
|
||
|
||
## References | ||
|
||
### Shen | ||
|
||
- http://www.shenlanguage.org/ | ||
- http://www.shenlanguage.org/learn-shen/shendoc.htm | ||
- [Shen Sources](https://github.com/shen-Language/shen-sources) | ||
|
||
### Other Shen ports | ||
- [Shen Common Lisp](https://github.com/shen-Language/shen-cl) | ||
- [Shen.java](https://github.com/hraberg/Shen.java) | ||
- [ShenSharp](https://github.com/rkoeninger/ShenSharp) | ||
|
||
### General | ||
|
||
- http://matt.might.net/articles/closure-conversion/ | ||
|
||
|
||
### Truffle | ||
- [Graal/truffle](https://github.com/graalvm/graal/truffle) | ||
- [Truffle Javadoc](https://graalvm.github.io/graal/truffle/javadoc/) | ||
|
||
### Other truffle languages | ||
- [TruffleRuby](https://github.com/graalvm/truffleruby) | ||
- [An Oz Implementation using Truffle and Graal](https://dial.uclouvain.be/memoire/ucl/en/object/thesis%3A10657/datastream/PDF_01/view) | ||
- [TruffleClojure](http://ssw.jku.at/Teaching/MasterTheses/Graal/TruffleClojure.pdf) | ||
- [Mumbler](http://cesquivias.github.io/tags/truffle.html) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.ragnard</groupId> | ||
<artifactId>shen-truffle</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oracle.truffle</groupId> | ||
<artifactId>truffle-api</artifactId> | ||
<version>0.25</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.truffle</groupId> | ||
<artifactId>truffle-dsl-processor</artifactId> | ||
<version>0.25</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<version>1.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<profiles> | ||
<profile> | ||
<id>unit</id> | ||
<properties> | ||
<testcase.groups>Unit</testcase.groups> | ||
</properties> | ||
</profile> | ||
<profile> | ||
<id>shen</id> | ||
<properties> | ||
<testcase.groups>com.github.ragnar.shen.tests.Shen</testcase.groups> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.20</version> | ||
<!--<configuration> | ||
<groups>com.github.ragnard.shen.tests.categories.Unit</groups> | ||
</configuration>--> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
ROOT="$DIR/.." | ||
|
||
GRAAL_HOME=/Users/ragnardahlen/projects/graalvm/graalvm-0.24 | ||
|
||
JAVACMD=${JAVACMD:=$GRAAL_HOME/bin/java} | ||
|
||
PROGRAM_ARGS="" | ||
JAVA_ARGS="-Dgraal.TruffleCompilationExceptionsAreFatal=true" | ||
|
||
for opt in "$@" | ||
do | ||
case $opt in | ||
--dump) | ||
JAVA_ARGS="$JAVA_ARGS -Dgraal.Dump= -Dgraal.MethodFilter=Truffle.* -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true" ;; | ||
--trace-deopt) | ||
JAVA_ARGS="$JAVA_ARGS -XX:+TraceDeoptimization" ;; | ||
--disassemble) | ||
JAVA_ARGS="$JAVA_ARGS -XX:CompileCommand=print,*OptimizedCallTarget.callRoot -XX:CompileCommand=exclude,*OptimizedCallTarget.callRoot -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true" ;; | ||
-J*) | ||
opt=${opt:2} | ||
JAVA_ARGS="$JAVA_ARGS $opt" ;; | ||
*) | ||
PROGRAM_ARGS="$PROGRAM_ARGS $opt" ;; | ||
esac | ||
done | ||
|
||
|
||
$JAVACMD $JAVA_ARGS \ | ||
-cp "$ROOT/target/classes" \ | ||
com.github.ragnard.shen.KLambda "$PROGRAM_ARGS" | ||
|
||
# # -Dgraal.Dump= -Dgraal.MethodFilter=Truffle.* -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true \ | ||
|
||
#JAVA=/Users/ragnardahlen/projects/graalvm/labsjdk1.8.0_121-jvmci-0.26/bin/java | ||
|
||
# "$JAVA" -server \ | ||
# -XX:+UnlockExperimentalVMOptions \ | ||
# -XX:+EnableJVMCI \ | ||
# -d64 \ | ||
# -Djvmci.class.path.append=$GRAAL_HOME/lib/graal/graal.jar \ | ||
# -Xbootclasspath/a:$GRAAL_HOME/lib/truffle/truffle-api.jar \ | ||
# -Dgraal.Dump= -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true \ | ||
# -Dgraal.TruffleCompilationExceptionsAreFatal=true \ | ||
# -cp target/classes \ | ||
# com.github.ragnard.shen.KLambda "$@" | ||
|
||
# -XX:CompileCommand=print,*OptimizedCallTarget.callRoot -XX:CompileCommand=exclude,*OptimizedCallTarget.callRoot -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true \ | ||
# -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 \ | ||
# -agentpath:'/Applications/YourKit Java Profiler.app/Contents/Resources/bin/mac/libyjpagent.jnilib' \ | ||
|
||
|
||
# -XX:+TraceDeoptimization \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
ROOT="$DIR/.." | ||
|
||
JAVA=/Users/ragnardahlen/projects/graalvm/labsjdk1.8.0_121-jvmci-0.26/bin/java | ||
#JAVA=/Users/ragnardahlen/projects/graalvm/labsjdk1.8.0_121-jvmci-0.29/bin/java | ||
GRAAL_HOME=/Users/ragnardahlen/projects/graalvm/graalvm-0.24 | ||
|
||
"$JAVA" -server \ | ||
-Xss16M \ | ||
-XX:+UnlockExperimentalVMOptions \ | ||
-XX:+EnableJVMCI \ | ||
-d64 \ | ||
-Djvmci.class.path.append=$GRAAL_HOME/lib/graal/graal.jar \ | ||
-Xbootclasspath/a:$GRAAL_HOME/lib/truffle/truffle-api.jar \ | ||
-Dgraal.TruffleCompilationExceptionsAreFatal=true \ | ||
-cp $ROOT/target/classes \ | ||
com.github.ragnard.shen.Shen "$@" | ||
|
||
|
||
GRAAL_HOME=/Users/ragnardahlen/projects/graalvm/graalvm-0.24 | ||
|
||
JAVACMD=${JAVACMD:=$GRAAL_HOME/bin/java} | ||
|
||
PROGRAM_ARGS="" | ||
JAVA_ARGS="-Dgraal.TruffleCompilationExceptionsAreFatal=true" | ||
|
||
|
||
|
||
# -Dgraal.Dump= -Dgraal.MethodFilter=Truffle.* -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true \ | ||
# -Dgraal.Dump= -Dgraal.MethodFilter=Truffle.* -Dgraal.TruffleBackgroundCompilation=false -Dgraal.TraceTruffleCompilation=true -Dgraal.TraceTruffleCompilationDetails=true \ | ||
|
||
|
||
# "$GRAAL_HOME"/bin/java \ | ||
# -Xss16M \ | ||
# -Dgraal.TruffleBackgroundCompilation=true \ | ||
# -cp target/classes \ | ||
# com.github.ragnard.shen.Shen "$@" | ||
|
||
# "$GRAAL_HOME"/bin/java \ | ||
# -server \ | ||
# -Xss16M \ | ||
# -cp target/classes \ | ||
# -Dgraal.TruffleCompilationExceptionsAreFatal=true \ | ||
# com.github.ragnard.shen.Shen "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="graalvm-0.24" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: com.oracle.truffle:truffle-api:0.25" level="project" /> | ||
<orderEntry type="library" name="Maven: com.oracle.truffle:truffle-dsl-processor:0.25" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.github.ragnard.shen; | ||
|
||
import com.github.ragnard.shen.klambda.Language; | ||
import com.github.ragnard.shen.klambda.TraceInstrument; | ||
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; | ||
import com.oracle.truffle.api.source.Source; | ||
import com.oracle.truffle.api.vm.PolyglotEngine; | ||
import com.oracle.truffle.api.vm.PolyglotRuntime; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStream; | ||
|
||
public class KLambda { | ||
|
||
private final PolyglotEngine engine; | ||
|
||
public KLambda() { | ||
this(System.in, System.out); | ||
} | ||
|
||
public KLambda(InputStream in, OutputStream out) { | ||
this.engine = PolyglotEngine.newBuilder().setIn(in).setOut(out).build(); | ||
PolyglotRuntime.Instrument traceInstrument = this.engine.getRuntime().getInstruments().get(TraceInstrument.ID); | ||
//traceInstrument.setEnabled(true); | ||
} | ||
|
||
public Object eval(String s) { | ||
Source code = Source.newBuilder(s) | ||
.name("<eval>") | ||
.interactive() | ||
.mimeType(Language.MIME_TYPE) | ||
.build(); | ||
|
||
return eval(code); | ||
} | ||
|
||
public Object eval(InputStream s) throws IOException { | ||
Source code = Source.newBuilder(new InputStreamReader(s)) | ||
.name("<eval>") | ||
.interactive() | ||
.mimeType(Language.MIME_TYPE) | ||
.build(); | ||
|
||
return eval(code); | ||
} | ||
|
||
public Object eval(Source source) { | ||
try { | ||
PolyglotEngine.Value result = engine.eval(source); | ||
|
||
return result.get(); | ||
|
||
} catch (UnsupportedSpecializationException e) { | ||
throw e; | ||
//throw new RuntimeException(e.getNode().getEncapsulatingSourceSection().toString(), e); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
KLambda kl = new KLambda(); | ||
|
||
kl.eval(System.in); | ||
} | ||
} |
Oops, something went wrong.