mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-21 16:04:09 -08:00
work on adding direct malloc support option to tooling
This commit is contained in:
parent
26df995f7c
commit
c630fae269
|
@ -119,6 +119,7 @@ public class TeaVMTool {
|
|||
private Set<File> generatedFiles = new HashSet<>();
|
||||
private int minHeapSize = 4 * (1 << 20);
|
||||
private int maxHeapSize = 128 * (1 << 20);
|
||||
private boolean directMallocSupport = false;
|
||||
private ReferenceCache referenceCache;
|
||||
private boolean heapDump;
|
||||
private boolean shortFileNames;
|
||||
|
@ -268,6 +269,10 @@ public class TeaVMTool {
|
|||
this.maxHeapSize = maxHeapSize;
|
||||
}
|
||||
|
||||
public void setDirectMallocSupport(boolean enableDirectMalloc) {
|
||||
this.directMallocSupport = enableDirectMalloc;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
|
@ -411,6 +416,11 @@ public class TeaVMTool {
|
|||
target.setSourceMapBuilder(wasmSourceMapWriter);
|
||||
target.setSourceMapLocation(getResolvedTargetFileName() + ".map");
|
||||
}
|
||||
if(directMallocSupport) {
|
||||
target.setEnableDirectMallocSupport(directMallocSupport);
|
||||
target.setDirectMallocMinHeapSize(minHeapSize);
|
||||
target.setDirectMallocMaxHeapSize(maxHeapSize);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ public interface BuildStrategy {
|
|||
|
||||
void setWasmDebugInfoLocation(WasmDebugInfoLocation wasmDebugInfoLocation);
|
||||
|
||||
void setDirectMallocSupport(boolean enable);
|
||||
|
||||
void setMinHeapSize(int minHeapSize);
|
||||
|
||||
void setMaxHeapSize(int maxHeapSize);
|
||||
|
|
|
@ -75,6 +75,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
private TeaVMToolLog log = new EmptyTeaVMToolLog();
|
||||
private boolean shortFileNames;
|
||||
private boolean assertionsRemoved;
|
||||
private boolean directMallocSupport;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -258,6 +259,11 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
this.assertionsRemoved = assertionsRemoved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirectMallocSupport(boolean enable) {
|
||||
this.directMallocSupport = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildResult build() throws BuildException {
|
||||
TeaVMTool tool = new TeaVMTool();
|
||||
|
@ -289,6 +295,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
tool.setWasmExceptionsUsed(wasmExceptionsUsed);
|
||||
tool.setWasmDebugInfoLevel(wasmDebugInfoLevel);
|
||||
tool.setWasmDebugInfoLocation(wasmDebugInfoLocation);
|
||||
tool.setDirectMallocSupport(directMallocSupport);
|
||||
tool.setMinHeapSize(minHeapSize);
|
||||
tool.setMaxHeapSize(maxHeapSize);
|
||||
tool.setHeapDump(heapDump);
|
||||
|
|
|
@ -214,6 +214,11 @@ public class RemoteBuildStrategy implements BuildStrategy {
|
|||
request.maxHeapSize = maxHeapSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirectMallocSupport(boolean enable) {
|
||||
request.directMallocSupport = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeapDump(boolean heapDump) {
|
||||
request.heapDump = heapDump;
|
||||
|
|
|
@ -59,4 +59,5 @@ public class RemoteBuildRequest implements Serializable {
|
|||
public boolean heapDump;
|
||||
public boolean shortFileNames;
|
||||
public boolean assertionsRemoved;
|
||||
public boolean directMallocSupport;
|
||||
}
|
||||
|
|
|
@ -231,6 +231,9 @@ public class TeaVMPlugin implements Plugin<Project> {
|
|||
task.getStrict().convention(wasmGC.getStrict());
|
||||
task.getSourceMap().convention(wasmGC.getSourceMap());
|
||||
task.getSourceFilePolicy().convention(wasmGC.getSourceFilePolicy());
|
||||
task.getDirectMallocSupport().convention(wasmGC.getDirectMallocSupport());
|
||||
task.getMinHeapSize().convention(wasmGC.getMinHeapSize());
|
||||
task.getMaxHeapSize().convention(wasmGC.getMaxHeapSize());
|
||||
setupSources(task.getSourceFiles(), project);
|
||||
buildTask.dependsOn(task);
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.teavm.gradle.api;
|
|||
|
||||
import org.gradle.api.provider.Property;
|
||||
|
||||
public interface TeaVMWasmGCConfiguration extends TeaVMCommonConfiguration, TeaVMWebConfiguration {
|
||||
public interface TeaVMWasmGCConfiguration extends TeaVMCommonConfiguration, TeaVMWebConfiguration, TeaVMNativeBaseConfiguration {
|
||||
Property<Boolean> getObfuscated();
|
||||
|
||||
Property<Boolean> getStrict();
|
||||
|
@ -37,4 +37,6 @@ public interface TeaVMWasmGCConfiguration extends TeaVMCommonConfiguration, TeaV
|
|||
Property<SourceFilePolicy> getSourceFilePolicy();
|
||||
|
||||
Property<Boolean> getModularRuntime();
|
||||
|
||||
Property<Boolean> getDirectMallocSupport();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.teavm.tooling.TeaVMTargetType;
|
|||
import org.teavm.tooling.builder.BuildStrategy;
|
||||
|
||||
public abstract class GenerateWasmGCTask extends TeaVMTask {
|
||||
private static final int MB = 1024 * 1024;
|
||||
|
||||
public GenerateWasmGCTask() {
|
||||
getStrict().convention(true);
|
||||
getObfuscated().convention(true);
|
||||
|
@ -58,6 +60,18 @@ public abstract class GenerateWasmGCTask extends TeaVMTask {
|
|||
@Optional
|
||||
public abstract Property<SourceFilePolicy> getSourceFilePolicy();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract Property<Boolean> getDirectMallocSupport();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract Property<Integer> getMinHeapSize();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract Property<Integer> getMaxHeapSize();
|
||||
|
||||
@Override
|
||||
protected void setupBuilder(BuildStrategy builder) {
|
||||
builder.setStrict(getStrict().get());
|
||||
|
@ -83,5 +97,8 @@ public abstract class GenerateWasmGCTask extends TeaVMTask {
|
|||
builder.setTargetType(TeaVMTargetType.WEBASSEMBLY_GC);
|
||||
TaskUtils.applySourceFiles(getSourceFiles(), builder);
|
||||
TaskUtils.applySourceFilePolicy(getSourceFilePolicy(), builder);
|
||||
builder.setDirectMallocSupport(getDirectMallocSupport().getOrElse(false));
|
||||
builder.setMinHeapSize(getMinHeapSize().getOrElse(0) * MB);
|
||||
builder.setMaxHeapSize(getMaxHeapSize().getOrElse(0) * MB);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user