Skip to content

Commit

Permalink
Renamed everything from polyllvm to jlang
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Zagieboylo committed Aug 22, 2018
1 parent 80d8457 commit d3171f2
Show file tree
Hide file tree
Showing 155 changed files with 862 additions and 795 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ POLYGLOT := lib/polyglot/
JAVACPP_PRESETS := lib/javacpp-presets/
SUBMODULES := $(addsuffix .git,$(POLYGLOT) $(JAVACPP_PRESETS))

# PolyLLVM.
export PLC := $(realpath bin/polyllvmc)
# JLang
export PLC := $(realpath bin/jlangc)

# Hack to allow dependency on PolyLLVM source.
export PLC_SRC := $(realpath $(shell find compiler/src -name "*.java"))
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PolyLLVM
JLang
========

PolyLLVM adds an LLVM back end to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java down to LLVM IR.
JLang adds an LLVM back end to the [Polyglot](https://www.cs.cornell.edu/projects/polyglot/) compiler, translating Java down to LLVM IR.

Since Polyglot already translates extended Java code into vanilla Java ASTs, PolyLLVM should be interoperable with other Polyglot extensions by default. However, PolyLLVM aims to be extensible itself, so that one can write optimized LLVM translations for language extensions when needed.
Since Polyglot already translates extended Java code into vanilla Java ASTs, JLang should be interoperable with other Polyglot extensions by default. However, JLang aims to be extensible itself, so that one can write optimized LLVM translations for language extensions when needed.

A user manual and developer guide can be found on the [PolyLLVM website](http://gharrma.github.io/polyllvm/).
A user manual and developer guide can be found on the [JLang website](http://dz333.github.io/JLang/).


Contributing
Expand All @@ -15,59 +15,59 @@ Before contributing, please do the following.

(1) Read through the rest of this README.<br>
(2) Read through all GitHub issues carefully, to get the most up-to-date picture of the current state of the project.<br>
(3) Read through the [developer guide](http://gharrma.github.io/polyllvm/developer-guide.html) on the website, to get technical details on the most critical subcomponents of PolyLLVM.<br>
(3) Read through the [developer guide](http://dz333.github.io/JLang/developer-guide.html) on the website, to get technical details on the most critical subcomponents of JLang.<br>
(4) If you need to work on compiler translations, get familiar with [LLVM IR](https://llvm.org/docs/LangRef.html).<br>
(5) If you need to work on native runtime code, get familiar with [JNI](https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html).


Quick start guide
-----------------

PolyLLVM has the following dependencies, which you will need to download and install prior to use.
JLang has the following dependencies, which you will need to download and install prior to use.

- [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html) and [Ant](http://ant.apache.org) are required to build the compiler. Ant is best installed through your preferred package manager. Be sure that the `JAVA_HOME` environment variable is defined and points to the JDK 8 installation (e.g., `/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/`).

- [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html) is required to compile programs with PolyLLVM, since we target Java 7. Be sure that the `JDK7` environment variable is defined and points to the JDK 7 home directory. When trying to run programs compiled with PolyLLVM you will need to set the `JAVA_HOME` environment variable to this value as well (see the test suite Makefile for an example of how to do execute PolyLLVM-compiled binaries).
- [JDK 7](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html) is required to compile programs with JLang, since we target Java 7. Be sure that the `JDK7` environment variable is defined and points to the JDK 7 home directory. When trying to run programs compiled with JLang you will need to set the `JAVA_HOME` environment variable to this value as well (see the test suite Makefile for an example of how to do execute JLang-compiled binaries).

- [LLVM](http://llvm.org) and [Clang](https://clang.llvm.org) are needed to build the runtime and create binaries from Java programs. PolyLLVM is tested with version 5.0.1, which you can download [here](http://releases.llvm.org/download.html#5.0.1). It may be possible to install through a package manager (e.g., `sudo apt install llvm && sudo apt install clang`). After installation be sure that `llc --version` (for example) and `clang++ --version` report consistent versions. You may have to alter your PATH to pick the right version, especially on a Mac for which a version of `Clang` comes bundled with the command line developer tools.
- [LLVM](http://llvm.org) and [Clang](https://clang.llvm.org) are needed to build the runtime and create binaries from Java programs. JLang is tested with version 5.0.1, which you can download [here](http://releases.llvm.org/download.html#5.0.1). It may be possible to install through a package manager (e.g., `sudo apt install llvm && sudo apt install clang`). After installation be sure that `llc --version` (for example) and `clang++ --version` report consistent versions. You may have to alter your PATH to pick the right version, especially on a Mac for which a version of `Clang` comes bundled with the command line developer tools.

- The [Boehm-Demers-Weiser garbage collector](http://www.hboehm.info/gc/) is also required for creating binaries. PolyLLVM is tested with version 7.6.4, which you can download [here](http://www.hboehm.info/gc/gc_source/) or install through a package manager (`brew install boehmgc`). A typical install from source looks like this: `./configure && make && make install`. Note that the garbage collector depends on [libatomic_ops](https://github.com/ivmai/libatomic_ops), which is often available through a package manager.
- The [Boehm-Demers-Weiser garbage collector](http://www.hboehm.info/gc/) is also required for creating binaries. JLang is tested with version 7.6.4, which you can download [here](http://www.hboehm.info/gc/gc_source/) or install through a package manager (`brew install boehmgc`). A typical install from source looks like this: `./configure && make && make install`. Note that the garbage collector depends on [libatomic_ops](https://github.com/ivmai/libatomic_ops), which is often available through a package manager.

- [Git LFS](https://git-lfs.github.com) is required to use PolyLLVM with OpenJDK 7. We use Git LFS to track a zip file containing all OpenJDK 7 Java source files. (The alternative is requiring a checkout and build of the full OpenJDK tree, which is notoriously difficult to configure.) Be sure to do a `git lfs pull` so that `jdk/src.zip` is downloaded; otherwise you will see strange error messages when trying to build.
- [Git LFS](https://git-lfs.github.com) is required to use JLang with OpenJDK 7. We use Git LFS to track a zip file containing all OpenJDK 7 Java source files. (The alternative is requiring a checkout and build of the full OpenJDK tree, which is notoriously difficult to configure.) Be sure to do a `git lfs pull` so that `jdk/src.zip` is downloaded; otherwise you will see strange error messages when trying to build.

Note that [Polyglot](https://github.com/polyglot-compiler/polyglot/) is also required, but is tracked as a git submodule and will be built automatically.

Finally, build PolyLLVM by running `make` at the top level of the repository. By default this will build only a "bare-bones" JDK, which is enough to run the [unit tests](tests/isolated). Note that PolyLLVM is usually tested on OS X; see issue #55 for updates on whether the build system supports Linux.
Finally, build JLang by running `make` at the top level of the repository. By default this will build only a "bare-bones" JDK, which is enough to run the [unit tests](tests/isolated). Note that JLang is usually tested on OS X; see issue #55 for updates on whether the build system supports Linux.

If you want to run unit tests from IntelliJ, run the `TestAll` class, using the top level of the repository as the working directory.


High-level project structure
----------------------------

- Compiler source files are in the [compiler/src/polyllvm](compiler/src/polyllvm) directory. Most translation code resides in the [extension](compiler/src/polyllvm/extension) subdirectory.
- Compiler source files are in the [compiler/src/jlang](compiler/src/jlang) directory. Most translation code resides in the [extension](compiler/src/jlang/extension) subdirectory.

- [runtime](runtime) contains [Java code](runtime/src) and [native code](runtime/native) needed to implement Java semantics at runtime (think: exceptions, JNI, reflection, etc.).

- [tests/isolated](tests/isolated) contains unit tests for translations from Java to LLVM IR. The JUnit test suite compiles and runs these programs with both `javac` and `polyllvm`, then compares the results.
- [tests/isolated](tests/isolated) contains unit tests for translations from Java to LLVM IR. The JUnit test suite compiles and runs these programs with both `javac` and `jlang`, then compares the results.

- [jdk](jdk) provides a way to compile and link OpenJDK 7 with PolyLLVM, and [jdk-lite](jdk-lite) provides a "bare-bones" JDK implementation used for unit testing.
- [jdk](jdk) provides a way to compile and link OpenJDK 7 with JLang, and [jdk-lite](jdk-lite) provides a "bare-bones" JDK implementation used for unit testing.

- [docs](docs) contains documentation for the various subcomponents of PolyLLVM, in the form of Markdown files. These files also provide the content for the [PolyLLVM website](http://gharrma.github.io/polyllvm/).
- [docs](docs) contains documentation for the various subcomponents of JLang, in the form of Markdown files. These files also provide the content for the [JLang website](http://dz333.github.io/jlang/).

- [lib](lib) contains Polyglot (the frontend for PolyLLVM); a fork of [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) to generate Java stubs from LLVM headers; and various supporting `.jar` files.
- [lib](lib) contains Polyglot (the frontend for JLang); a fork of [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) to generate Java stubs from LLVM headers; and various supporting `.jar` files.


Status (May 2018)
-----------------

All translations from Java to LLVM IR are complete, with the exception of the `synchronized` keyword (see below on concurrency support). This means that all Java 7 language features---expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc.---are translated robustly and as specified by the [JLS](https://docs.oracle.com/javase/specs/jls/se7/html/index.html). All of our [unit tests](tests/isolated) pass.

However, PolyLLVM is still a work in progress for two important reasons.
However, JLang is still a work in progress for two important reasons.

(1) JDK support. The JDK includes thousands of classes that are critical to the Java ecosystem, such as `java.lang.Class`, `java.util.ArrayList`, `java.io.File`, and `java.net.Socket`. Thus it is important to be able to compile programs that rely on the JDK. So far we can fully support a hand-written "bare-bones" JDK that includes only the JDK classes that are necessary for unit tests (`java.lang.Object`, `java.lang.Class`, `java.lang.System`, etc.). This has allowed us to test the compiler before trying to compile the entire JDK. Support for the full JDK is close, but not finished. Please see [issue #54](https://github.com/gharrma/polyllvm/issues/54) for more information.
(1) JDK support. The JDK includes thousands of classes that are critical to the Java ecosystem, such as `java.lang.Class`, `java.util.ArrayList`, `java.io.File`, and `java.net.Socket`. Thus it is important to be able to compile programs that rely on the JDK. So far we can fully support a hand-written "bare-bones" JDK that includes only the JDK classes that are necessary for unit tests (`java.lang.Object`, `java.lang.Class`, `java.lang.System`, etc.). This has allowed us to test the compiler before trying to compile the entire JDK. Support for the full JDK is close, but not finished. Please see [issue #54](https://github.com/dz333/JLang/issues/54) for more information.

(2) Concurrency support. Support for multiple threads and synchronization has not been started, as JDK support took priority. PolyLLVM will ignore the Java `synchronized` keyword, and the [native runtime code](runtime/native) is generally not thread-safe. Please see [issue #5](https://github.com/gharrma/polyllvm/issues/5) for more information.
(2) Concurrency support. Support for multiple threads and synchronization has not been started, as JDK support took priority. JLang will ignore the Java `synchronized` keyword, and the [native runtime code](runtime/native) is generally not thread-safe. Please see [issue #5](https://github.com/dz333/JLang/issues/5) for more information.

All other loose ends (minor bugs, build system issues, etc.) are tracked as GitHub issues as well. If you would like to contribute, please read through all of these tracked issues carefully!

4 changes: 2 additions & 2 deletions bin/polyllvmc → bin/jlangc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extra_cp=
args=
vmargs=
java=java
ext=polyllvm
ext=jlang

while true; do
case "$1" in
Expand Down Expand Up @@ -73,7 +73,7 @@ runtime_classpath="$dir/runtime/out/classes"
runtime_classpath="$runtime_classpath:$extra_cp"

command="$java -ea $vmargs -classpath \"$(fixpath ${compiler_classpath})\" \
polyllvm.Main \
jlang.Main \
-classpath \"$(fixpath ${runtime_classpath})\" \
$args"

Expand Down
2 changes: 1 addition & 1 deletion bin/plc
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ for d in $directories; do
done


$DIR/polyllvmc -d "$outdir" $files && \
$DIR/jlangc -d "$outdir" $files && \
clang++ -Wno-override-module -L/usr/local/lib/ -lgc -O1 -o "$out" $clangflags "$RUNTIME"/runtime.o `find "$outdir" -name *.ll`
8 changes: 4 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project name="polyllvm" default="compile-all" basedir=".">
<project name="jlang" default="compile-all" basedir=".">
<description>
PolyLLVM build file
JLang build file
</description>


Expand All @@ -9,10 +9,10 @@
**************************************** -->

<!-- extension package name -->
<property name="package.dir" value="polyllvm"/>
<property name="package.dir" value="jlang"/>

<!-- extension language name -->
<property name="name" value="polyllvm"/>
<property name="name" value="jlang"/>

<!-- extension compiler script name -->
<property name="compiler.name" value="${name}c"/>
Expand Down
4 changes: 2 additions & 2 deletions compiler/compiler.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="polyllvm" level="project" />
<orderEntry type="library" name="jlang" level="project" />
<orderEntry type="library" name="polyglot" level="project" />
<orderEntry type="module" module-name="runtime" />
<orderEntry type="module" module-name="polyglot" />
</component>
</module>
</module>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package polyllvm;
package jlang;

import polyglot.ast.NodeFactory;
import polyglot.ext.jl5.ast.JL5ExtFactory_c;
Expand All @@ -11,19 +11,21 @@
import polyglot.main.Version;
import polyglot.types.TypeSystem;
import polyglot.util.StringUtil;
import polyllvm.ast.PolyLLVMExtFactory_c;
import polyllvm.ast.PolyLLVMLang_c;
import polyllvm.ast.PolyLLVMNodeFactory_c;
import polyllvm.types.PolyLLVMTypeSystem_c;

import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;

import jlang.ast.JLangExtFactory_c;
import jlang.ast.JLangLang_c;
import jlang.ast.JLangNodeFactory_c;
import jlang.types.JLangTypeSystem_c;

import java.io.IOException;

/**
* Extension information for polyllvm extension.
* Extension information for JLang extension.
*/
public class PolyLLVMExtensionInfo extends JL7ExtensionInfo {
public class JLangExtensionInfo extends JL7ExtensionInfo {
static {
// force Topics to load
@SuppressWarnings("unused")
Expand All @@ -43,35 +45,35 @@ public String[] defaultFileExtensions() {

@Override
public String compilerName() {
return "polyllvmc";
return "jlangc";
}

@Override
protected NodeFactory createNodeFactory() {
return new PolyLLVMNodeFactory_c(PolyLLVMLang_c.instance,
new PolyLLVMExtFactory_c(
return new JLangNodeFactory_c(JLangLang_c.instance,
new JLangExtFactory_c(
new JL7ExtFactory_c(
new JL5ExtFactory_c())));
}

@Override
protected TypeSystem createTypeSystem() {
return new PolyLLVMTypeSystem_c();
return new JLangTypeSystem_c();
}

@Override
public Scheduler createScheduler() {
return new PolyLLVMScheduler(this);
return new JLangScheduler(this);
}

@Override
protected Options createOptions() {
return new PolyLLVMOptions(this);
return new JLangOptions(this);
}

@Override
public Version version() {
return new polyllvm.Version();
return new jlang.Version();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package polyllvm;
package jlang;

import polyglot.ext.jl5.JL5Options;
import polyglot.main.OptFlag;
import polyglot.main.UsageError;

import java.util.Set;

public class PolyLLVMOptions extends JL5Options {
public class JLangOptions extends JL5Options {

public String entryPointClass;
public boolean entryPointEmitted;
public boolean printDesugar;
public int maxPasses;

public PolyLLVMOptions(PolyLLVMExtensionInfo extension) {
public JLangOptions(JLangExtensionInfo extension) {
super(extension);
this.setOutputExtension("ll");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package polyllvm;
package jlang;

import jlang.util.DesugarBarrier;
import jlang.util.JLangDesugared;
import polyglot.ast.ClassDecl;
import polyglot.ast.Lang;
import polyglot.ast.Node;
Expand All @@ -15,21 +17,19 @@
import polyglot.types.ParsedClassType;
import polyglot.util.InternalCompilerError;
import polyglot.visit.NodeVisitor;
import polyllvm.util.DesugarBarrier;
import polyllvm.util.PolyLLVMDesugared;

/**
* Schedules the passes necessary to translate Java down to LLVM IR.
*/
public class PolyLLVMScheduler extends JL7Scheduler {
public class JLangScheduler extends JL7Scheduler {

public PolyLLVMScheduler(JLExtensionInfo extInfo) {
public JLangScheduler(JLExtensionInfo extInfo) {
super(extInfo);
}

@Override
protected int maxRunCount() {
PolyLLVMOptions options = (PolyLLVMOptions) Options.global;
JLangOptions options = (JLangOptions) Options.global;
return (options.maxPasses > 0) ? options.maxPasses : super.maxRunCount();
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public Node leave(Node old, Node n, NodeVisitor v) {

/** Desugar passes which simplify LLVM translation. */
public Goal LLVMDesugared(Job job) {
Goal desugar = new PolyLLVMDesugared(job);
Goal desugar = new JLangDesugared(job);
try {
desugar.addPrerequisiteGoal(AllSignaturesResolved(job), this);
} catch (CyclicDependencyException e) {
Expand Down
Loading

0 comments on commit d3171f2

Please sign in to comment.