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

Base implementation of Dynamix, Tim #111

Open
wants to merge 88 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d499a77
Adapter/task compilation for Dynamix, depend on runtime package
molenzwiebel Mar 25, 2022
bb529aa
Namespace Dynamix files, cleanup
molenzwiebel Mar 25, 2022
0c9b662
Finalize signature generation for Dynamix
molenzwiebel Mar 25, 2022
75dd7ed
Add Tim language implementation and runtime
molenzwiebel Mar 25, 2022
f0d6a71
Add Dynamix Runtime implementation
molenzwiebel Mar 25, 2022
eae224f
Add support for constraint-analyzer property lookup and globals in Dy…
molenzwiebel Apr 3, 2022
ffb6955
Allow configuration of Dynamix entry-point rule
molenzwiebel Apr 21, 2022
a05839a
Minor fixes, include source location in rules for better stack traces
molenzwiebel Apr 21, 2022
9b39ebd
Consult rules in order of specificity during Dynamix evaluation
molenzwiebel Apr 21, 2022
1c7625d
Check for overlapping patterns in Statix, add support for concurrent …
molenzwiebel Apr 21, 2022
e4c6bfa
Add (untested) #array-write primitive to Tim
molenzwiebel Apr 21, 2022
40b2e2c
Merge from upstream
molenzwiebel Apr 21, 2022
389964a
Attempt at more efficiently comparing patterns in Statix
molenzwiebel Apr 21, 2022
83bce2e
Add some more tim primitives, make injected lists more ergonomic in D…
molenzwiebel Apr 28, 2022
81c2318
Make TFuns first-class values, do not generate signatures for bracket…
molenzwiebel May 9, 2022
1913616
Extract Tim runtime into separate project, depend on project
molenzwiebel May 12, 2022
bece936
Reorganize automatically generated Dynamix tasks
molenzwiebel May 12, 2022
ece00c1
An attempt at adding some native strategies to Tim
molenzwiebel May 12, 2022
0aa5a6c
Initial work on a closure conversion strategy
RvanBaarle Sep 10, 2022
22d12fa
Extract closures to outermost level. Fix mutually recursive closures.
RvanBaarle Sep 10, 2022
b2c6774
Add uniquify transform
RvanBaarle Sep 12, 2022
8400495
Inlining of functions
RvanBaarle Sep 20, 2022
37919bf
Support for integer operations
RvanBaarle Sep 20, 2022
a613e40
Add support for array operations
RvanBaarle Sep 21, 2022
a24f490
Add support for refs
RvanBaarle Sep 21, 2022
ca8fafc
Add support for strings
RvanBaarle Sep 22, 2022
4f283af
Add partial record support
RvanBaarle Sep 22, 2022
a063d14
Support for arguments to `#record-new`
RvanBaarle Sep 22, 2022
fae98ed
Add closure type to tim
RvanBaarle Sep 23, 2022
58352b5
Allow for negative indices in closure reads/offsets
RvanBaarle Sep 23, 2022
032df6f
Implement compilation of new closure primops
RvanBaarle Sep 23, 2022
e95a454
Combine closures for each fix expression
RvanBaarle Sep 23, 2022
b6c381b
WIP for closure conversion improvements
RvanBaarle Sep 27, 2022
ed26c61
Creation of project for LLVM IR
RvanBaarle Sep 27, 2022
424162e
Initial version of LLVM syntax
RvanBaarle Sep 27, 2022
07c6db9
Minor syntax fixes
RvanBaarle Sep 27, 2022
af1474a
Move around files and minor syntax changes
RvanBaarle Sep 28, 2022
e4722d0
Get rid of all string interpolation
RvanBaarle Sep 28, 2022
32c4752
C runtime library for Tim
RvanBaarle Sep 28, 2022
adc0604
Differentiate between printing ints and strings
RvanBaarle Sep 28, 2022
0994d8d
Fix statix type of string literal
RvanBaarle Sep 28, 2022
fc3edfc
Add array tail, length and concat operations
RvanBaarle Sep 28, 2022
fdeedb8
Minor fixes to syntax
RvanBaarle Sep 28, 2022
1fc296a
Implement the last missing features
RvanBaarle Sep 29, 2022
dd22445
Fix non-escaping closure optimizations
RvanBaarle Sep 30, 2022
d98d25c
Update compiler flags to emit bitcode
RvanBaarle Sep 30, 2022
3380018
Use static closure address if known at compile time
RvanBaarle Sep 30, 2022
94521ff
Let binding inlining
RvanBaarle Oct 4, 2022
21a43b7
Extend LLVM syntax for GC support
RvanBaarle Oct 4, 2022
3810581
WIP in explicating types further
RvanBaarle Oct 4, 2022
fa3ff44
More explicit typing
RvanBaarle Oct 4, 2022
a91464e
Explicitly typed, and progress towards GC
RvanBaarle Oct 5, 2022
8ca9b1f
quick fixes to correctly compile
RvanBaarle Oct 5, 2022
bdf90ee
Change what gets logged
RvanBaarle Oct 5, 2022
6923584
Fix incorrect base pointer
RvanBaarle Oct 6, 2022
439620e
Arrays start at one, fix tailcall issue
RvanBaarle Oct 6, 2022
e5b55ba
Array type consistency
RvanBaarle Oct 7, 2022
0d370cb
Add gc-leaf-function to function applications
RvanBaarle Oct 7, 2022
1ae60ad
Garbage collector
RvanBaarle Oct 7, 2022
81a4b6a
Remove all unused includes
RvanBaarle Oct 7, 2022
c49e60b
Scan heap for pointers as well
RvanBaarle Oct 11, 2022
20a1f7e
Support for finalizers
RvanBaarle Oct 11, 2022
cd946cd
Add [[maybe_unused]] attributes
RvanBaarle Oct 11, 2022
cd0b74e
Fix array and string operations using old references
RvanBaarle Oct 12, 2022
4c6a686
Garbage collection for closures
RvanBaarle Oct 12, 2022
a69a415
Add LLVM IR to Spoofax LWB
RvanBaarle Oct 13, 2022
246c729
Quick fix for emitting LLVM from Spoofax 3
RvanBaarle Oct 13, 2022
6b254ed
Fix a couple of bugs
RvanBaarle Oct 13, 2022
2edbd52
Change stratego provider to ctree in hopes of harmony between spoofax…
RvanBaarle Oct 14, 2022
8bf568f
Add explicit type annotations in preparation of more efficient types
RvanBaarle Oct 14, 2022
9b15144
Add type annotations to functions as well
RvanBaarle Oct 14, 2022
19ea985
Integer boxing
RvanBaarle Oct 19, 2022
e40cb02
Bitfield encoding and flag-related bugfixes
RvanBaarle Oct 19, 2022
76e1a10
Typed closures
RvanBaarle Oct 19, 2022
9343bf4
Struct type added
RvanBaarle Oct 20, 2022
b4487e5
Add typing additions to dynamix
RvanBaarle Oct 24, 2022
ff437c3
Implement tuples and fixes to types
RvanBaarle Oct 25, 2022
a532600
Rename holy to pluggable
RvanBaarle Oct 26, 2022
515e6bd
Refactor locations of ast.str, type.str and string.str
RvanBaarle Oct 26, 2022
fe20ccd
Struct inheritance
RvanBaarle Oct 26, 2022
a2ed622
Small fixes to Tim
RvanBaarle Nov 1, 2022
0292cc4
Improve performance issue, change names to match those used in Thijs'…
RvanBaarle Nov 2, 2022
a4558af
Fix closure conversion edgecase
RvanBaarle Nov 2, 2022
4409c2c
Fix recursive types and possibility for gc to encounter invalid pointers
RvanBaarle Nov 8, 2022
b06880b
Fix recursive types better
RvanBaarle Nov 8, 2022
6c8d609
Revert changes to tim type system
RvanBaarle Nov 10, 2022
d247dfa
Have structs contain scopes
RvanBaarle Nov 22, 2022
972acd3
Adding str-neq condition, slight LLVM syntax fixes, some other small …
RvanBaarle Dec 6, 2022
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 @@ -8,6 +8,7 @@
import mb.spoofax.compiler.adapter.AdapterProjectCompiler;
import mb.spoofax.compiler.adapter.CodeCompletionAdapterCompiler;
import mb.spoofax.compiler.adapter.ConstraintAnalyzerAdapterCompiler;
import mb.spoofax.compiler.adapter.DynamixAdapterCompiler;
import mb.spoofax.compiler.adapter.GetSourceFilesAdapterCompiler;
import mb.spoofax.compiler.adapter.HoverAdapterCompiler;
import mb.spoofax.compiler.adapter.MultilangAnalyzerAdapterCompiler;
Expand Down Expand Up @@ -78,6 +79,8 @@ public interface SpoofaxCompilerComponent extends TaskDefsProvider, AutoCloseabl

TegoRuntimeAdapterCompiler getTegoRuntimeAdapterCompiler();

DynamixAdapterCompiler getDynamixAdapterCompiler();


CliProjectCompiler getCliProjectCompiler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class AdapterProjectCompiler implements TaskDef<Supplier<Result<AdapterPr
private final CodeCompletionAdapterCompiler codeCompletionCompiler;
private final TegoRuntimeAdapterCompiler tegoRuntimeCompiler;
private final ReferenceResolutionAdapterCompiler referenceResolutionAdapterCompiler;
private final DynamixAdapterCompiler dynamixAdapterCompiler;
private final HoverAdapterCompiler hoverAdapterCompiler;
private final GetSourceFilesAdapterCompiler getSourceFilesAdapterCompiler;

Expand All @@ -87,6 +88,7 @@ public class AdapterProjectCompiler implements TaskDef<Supplier<Result<AdapterPr
CodeCompletionAdapterCompiler codeCompletionCompiler,
TegoRuntimeAdapterCompiler tegoRuntimeCompiler,
ReferenceResolutionAdapterCompiler referenceResolutionAdapterCompiler,
DynamixAdapterCompiler dynamixAdapterCompiler,
HoverAdapterCompiler hoverAdapterCompiler,
GetSourceFilesAdapterCompiler getSourceFilesAdapterCompiler
) {
Expand Down Expand Up @@ -117,6 +119,7 @@ public class AdapterProjectCompiler implements TaskDef<Supplier<Result<AdapterPr
this.codeCompletionCompiler = codeCompletionCompiler;
this.tegoRuntimeCompiler = tegoRuntimeCompiler;
this.referenceResolutionAdapterCompiler = referenceResolutionAdapterCompiler;
this.dynamixAdapterCompiler = dynamixAdapterCompiler;
this.hoverAdapterCompiler = hoverAdapterCompiler;
this.getSourceFilesAdapterCompiler = getSourceFilesAdapterCompiler;
}
Expand Down Expand Up @@ -147,6 +150,7 @@ public None compile(ExecContext context, Input input) throws IOException {
Option.ofOptional(input.tegoRuntime()).ifSomeThrowing((i) -> tegoRuntimeCompiler.compile(context, i));
Option.ofOptional(input.referenceResolution()).ifSomeThrowing((i) -> referenceResolutionAdapterCompiler.compile(context, i));
Option.ofOptional(input.hover()).ifSomeThrowing((i) -> hoverAdapterCompiler.compile(context, i));
Option.ofOptional(input.dynamix()).ifSomeThrowing((i) -> dynamixAdapterCompiler.compile(context, i));
getSourceFilesAdapterCompiler.compile(context, input.getSourceFiles());

if(input.classKind().isManual()) return None.instance; // Nothing to generate: return.
Expand Down Expand Up @@ -335,6 +339,7 @@ public None compile(ExecContext context, Input input) throws IOException {
final MenuItemCollection allMenuItems = new MenuItemCollection(input.mainMenuItems(), input.resourceContextMenuItems(), input.editorContextMenuItems());
input.parser().ifPresent(i -> i.collectMenus(allMenuItems));
input.constraintAnalyzer().ifPresent(i -> i.collectMenus(allMenuItems));
input.dynamix().ifPresent(i -> i.collectMenus(allMenuItems));
// Deduplicate menu items.
allMenuItems.deduplicateMenus();
// Then add to map.
Expand Down Expand Up @@ -373,6 +378,7 @@ public ArrayList<GradleConfiguredDependency> getDependencies(Input input) {
input.strategoRuntime().ifPresent((i) -> strategoRuntimeCompiler.getDependencies(i).addAllTo(dependencies));
input.tegoRuntime().ifPresent((i) -> tegoRuntimeCompiler.getDependencies(i).addAllTo(dependencies));
input.codeCompletion().ifPresent((i) -> codeCompletionCompiler.getDependencies(i).addAllTo(dependencies));
input.dynamix().ifPresent((i) -> dynamixAdapterCompiler.getDependencies(i).addAllTo(dependencies));
dependencies.add(GradleConfiguredDependency.api(shared.sptApiDep()));
if(input.dependOnRv32Im()) {
dependencies.add(GradleConfiguredDependency.api(shared.rv32ImDep()));
Expand All @@ -382,9 +388,12 @@ public ArrayList<GradleConfiguredDependency> getDependencies(Input input) {


@Value.Immutable public interface Input extends Serializable {
class Builder extends AdapterProjectCompilerData.Input.Builder {}
class Builder extends AdapterProjectCompilerData.Input.Builder {
}

static Builder builder() {return new Builder();}
static Builder builder() {
return new Builder();
}


/// Project
Expand Down Expand Up @@ -414,6 +423,8 @@ class Builder extends AdapterProjectCompilerData.Input.Builder {}

Optional<TegoRuntimeAdapterCompiler.Input> tegoRuntime();

Optional<DynamixAdapterCompiler.Input> dynamix();

Optional<HoverAdapterCompiler.Input> hover();

GetSourceFilesAdapterCompiler.Input getSourceFiles();
Expand Down Expand Up @@ -475,6 +486,9 @@ class Builder extends AdapterProjectCompilerData.Input.Builder {}
hover().ifPresent((i) -> {
taskDefs.add(i.hoverTaskDef(), i.baseHoverTaskDef());
});
dynamix().ifPresent((i) -> {
i.collectTaskDefs(taskDefs);
});
if(!hover().isPresent()) {
taskDefs.add(TypeInfo.of(NoneHoverTaskDef.class));
}
Expand All @@ -498,6 +512,7 @@ class Builder extends AdapterProjectCompilerData.Input.Builder {}
final ArrayList<CommandDefRepr> commandDefs = new ArrayList<>(commandDefs());
parser().ifPresent(i -> i.collectCommands(commandDefs));
constraintAnalyzer().ifPresent((i) -> i.collectCommands(commandDefs));
dynamix().ifPresent((i) -> i.collectCommands(commandDefs));
return commandDefs;
}

Expand Down Expand Up @@ -597,9 +612,13 @@ default TypeInfo packageInfo() {

// Dagger resources scope (passthrough from AdapterProject)

default TypeInfo baseResourcesScope() {return adapterProject().baseResourcesScope();}
default TypeInfo baseResourcesScope() {
return adapterProject().baseResourcesScope();
}

default TypeInfo resourcesScope() {return adapterProject().resourcesScope();}
default TypeInfo resourcesScope() {
return adapterProject().resourcesScope();
}

// Dagger resources component

Expand Down Expand Up @@ -631,15 +650,23 @@ default TypeInfo resourcesModule() {

// Dagger Scope (passthrough from AdapterProject)

default TypeInfo baseScope() {return adapterProject().baseScope();}
default TypeInfo baseScope() {
return adapterProject().baseScope();
}

default TypeInfo scope() {return adapterProject().scope();}
default TypeInfo scope() {
return adapterProject().scope();
}

// Dagger Qualifier (passthrough from AdapterProject)

default TypeInfo baseQualifier() {return adapterProject().baseQualifier();}
default TypeInfo baseQualifier() {
return adapterProject().baseQualifier();
}

default TypeInfo qualifier() {return adapterProject().qualifier();}
default TypeInfo qualifier() {
return adapterProject().qualifier();
}

// Dagger component

Expand Down Expand Up @@ -808,6 +835,7 @@ default ArrayList<ResourcePath> javaSourceFiles() {
multilangAnalyzer().ifPresent((i) -> i.javaSourceFiles().addAllTo(javaSourceFiles));
codeCompletion().ifPresent((i) -> i.javaSourceFiles().addAllTo(javaSourceFiles));
tegoRuntime().ifPresent((i) -> i.javaSourceFiles().addAllTo(javaSourceFiles));
dynamix().ifPresent((i) -> i.javaSourceFiles().addAllTo(javaSourceFiles));
hover().ifPresent((i) -> i.javaSourceFiles().addAllTo(javaSourceFiles));
getSourceFiles().javaSourceFiles().addAllTo(javaSourceFiles);
return javaSourceFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class AdapterProjectCompilerInputBuilder {
private boolean tegoRuntimeEnabled = false;
public final TegoRuntimeAdapterCompiler.Input.Builder tegoRuntime = TegoRuntimeAdapterCompiler.Input.builder();

private boolean dynamixEnabled = false;
public final DynamixAdapterCompiler.Input.Builder dynamix = DynamixAdapterCompiler.Input.builder();

private boolean referenceResolutionEnabled = false;
public final ReferenceResolutionAdapterCompiler.Input.Builder referenceResolution = ReferenceResolutionAdapterCompiler.Input.builder();

Expand Down Expand Up @@ -89,6 +92,11 @@ public TegoRuntimeAdapterCompiler.Input.Builder withTegoRuntime() {
return tegoRuntime;
}

public DynamixAdapterCompiler.Input.Builder withDynamix() {
dynamixEnabled = true;
return dynamix;
}

public CodeCompletionAdapterCompiler.Input.Builder withCodeCompletion() {
codeCompletionEnabled = true;
return codeCompletion;
Expand Down Expand Up @@ -135,6 +143,9 @@ public AdapterProjectCompiler.Input build(LanguageProjectCompiler.Input language
final TegoRuntimeAdapterCompiler.@Nullable Input tegoRuntime = buildTegoRuntime(shared, adapterProject, languageProjectInput, classLoaderResources);
if(tegoRuntime != null) project.tegoRuntime(tegoRuntime);

final DynamixAdapterCompiler.@Nullable Input dynamix = buildDynamix(shared, adapterProject, classLoaderResources, constraintAnalyzer);
if(dynamix != null) project.dynamix(dynamix);

final CodeCompletionAdapterCompiler.@Nullable Input codeCompletion = buildCodeCompletion(shared, adapterProject, languageProjectInput, parser, constraintAnalyzer, strategoRuntime, tegoRuntime, classLoaderResources);
if(codeCompletion != null) project.codeCompletion(codeCompletion);

Expand Down Expand Up @@ -283,6 +294,21 @@ private GetSourceFilesAdapterCompiler.Input buildGetSourceFiles(
.build();
}

private DynamixAdapterCompiler.@Nullable Input buildDynamix(
Shared shared,
AdapterProject adapterProject,
ClassLoaderResourcesCompiler.Input classloaderResources,
ConstraintAnalyzerAdapterCompiler.@Nullable Input constraintAnalyzerInput
) {
if(!dynamixEnabled) return null;
return dynamix
.shared(shared)
.adapterProject(adapterProject)
.classLoaderResourcesInput(classloaderResources)
.constraintAnalyzerInput(constraintAnalyzerInput)
.build();
}

private CodeCompletionAdapterCompiler.@Nullable Input buildCodeCompletion(
Shared shared,
AdapterProject adapterProject,
Expand Down
Loading