Skip to content

Commit

Permalink
2020-12-01
Browse files Browse the repository at this point in the history
* Renamed wasmMinimumPages to wasmInitialPages
* Added llvmOptimizationLevel and escapeAnalysis
  • Loading branch information
ogrammer committed Dec 20, 2020
1 parent 355813c commit 8b9d0bf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,57 @@

```groovy
buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2019-11-25'
classpath group: 'com.github.objectprogrammer', name: 'bytecodergradle', version: '2019-11-25'
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2020-12-01'
classpath group: 'com.github.objectprogrammer', name: 'bytecodergradle', version: '2020-12-01'
}
}
apply plugin: 'java'
apply plugin: 'com.github.objectprogrammer.bytecodergradle'
bytecoder {
mainClass = 'com.example.Main'
backend = 'wasm'
mainClass = 'com.example.Main'
backend = 'wasm'
}
group 'com.example'
version '1.0.0'
repositories {
mavenCentral()
mavenCentral()
}
dependencies {
compile group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2019-11-25'
compile group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2020-12-01'
}
```

## All options with their default values

mainClass (String) is the only required option.
**mainClass** (String) is the only required option.

```groovy
bytecoder {
buildDirectory = 'bytecoder'
backend = 'js' // or 'wasm'
debugOutput = false
exceptionHandling = false
optimizer = 'ALL'
filenamePrefix = 'bytecoder'
wasmMinimumPages = 512
wasmMaximumPages = 1024
minify = true
preferStackifier = false
registerAllocator = 'linear' // or 'passthru'
additionalClassesToLink = []
additionalResources = []
mainClass = 'com.example.Main'
buildDirectory = 'bytecoder'
backend = 'js' // or 'wasm' or 'wasm_llvm'
debugOutput = false
exceptionHandling = false
optimizer = 'ALL'
filenamePrefix = 'bytecoder'
wasmInitialPages = 512
wasmMaximumPages = 1024
minify = true
preferStackifier = false
registerAllocator = 'linear' // or 'passthru'
additionalClassesToLink = []
additionalResources = []
llvmOptimizationLevel = 'O2'
escapeAnalysis = false
}
```
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
plugins {
id 'java'
id 'java'
}

group 'com.github.objectprogrammer.bytecodergradle'
version '2019-11-25'
version '2020-12-01'

sourceCompatibility = 1.8

tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
preserveFileTimestamps = false
reproducibleFileOrder = true
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2019-11-25'
implementation gradleApi()
implementation group: 'de.mirkosertic.bytecoder', name: 'bytecoder-core', version: '2020-12-01'
implementation gradleApi()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.mirkosertic.bytecoder.allocator.Allocator;
import de.mirkosertic.bytecoder.backend.CompileOptions;
import de.mirkosertic.bytecoder.backend.CompileTarget;
import de.mirkosertic.bytecoder.backend.LLVMOptimizationLevel;
import de.mirkosertic.bytecoder.optimizer.KnownOptimizer;
import de.mirkosertic.bytecoder.unittest.Slf4JLogger;

Expand All @@ -16,15 +17,17 @@ public class Extension {
public boolean exceptionHandling = false;
public KnownOptimizer optimizer = KnownOptimizer.ALL;
public String filenamePrefix = "bytecoder";
public int wasmMinimumPages = 512;
public int wasmInitialPages = 512;
public int wasmMaximumPages = 1024;
public boolean minify = true;
public boolean preferStackifier = false;
public Allocator registerAllocator = Allocator.linear;
public String[] additionalClassesToLink = {};
public String[] additionalResources = {};
public LLVMOptimizationLevel llvmOptimizationLevel = LLVMOptimizationLevel.defaultValue();
public boolean escapeAnalysis = false;

public CompileOptions toCompileOptions() {
return new CompileOptions(new Slf4JLogger(), debugOutput, optimizer, exceptionHandling, filenamePrefix, wasmMinimumPages, wasmMaximumPages, minify, preferStackifier, registerAllocator, additionalClassesToLink, additionalResources);
return new CompileOptions(new Slf4JLogger(), debugOutput, optimizer, exceptionHandling, filenamePrefix, wasmInitialPages, wasmMaximumPages, minify, preferStackifier, registerAllocator, additionalClassesToLink, additionalResources, llvmOptimizationLevel, escapeAnalysis);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public void execute() throws TaskExecutionException {
bytecoderDir.mkdirs();
try {
ClassLoader loader = createClassLoader();
Class mainClass = loader.loadClass(extension.mainClass);
Class<?> mainClass = loader.loadClass(extension.mainClass);
CompileTarget compileTarget = new CompileTarget(loader, extension.backend);
BytecodeMethodSignature signature = new BytecodeMethodSignature(BytecodePrimitiveTypeRef.VOID,
new BytecodeTypeRef[] { new BytecodeArrayTypeRef(BytecodeObjectTypeRef.fromRuntimeClass(String.class), 1) });
CompileResult code = compileTarget.compile(extension.toCompileOptions(), mainClass, "main", signature);
CompileResult<?> code = compileTarget.compile(extension.toCompileOptions(), mainClass, "main", signature);
for (CompileResult.Content content : code.getContent()) {
File fileName = new File(bytecoderDir, content.getFileName());
try (FileOutputStream fos = new FileOutputStream(fileName)) {
Expand Down

0 comments on commit 8b9d0bf

Please sign in to comment.