Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions annotations/annotations/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module com.dylibso.chicory.annotations {
exports com.dylibso.chicory.annotations;
}
8 changes: 8 additions & 0 deletions build-time-compiler/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module com.dylibso.chicory.build.time.compiler {
requires transitive com.dylibso.chicory.compiler;
requires com.dylibso.chicory.runtime;
requires com.dylibso.chicory.wasm;
requires com.github.javaparser.core;

exports com.dylibso.chicory.build.time.compiler;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dylibso.chicory.testing;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.ImportValues;
import com.dylibso.chicory.runtime.Instance;
import com.dylibso.chicory.runtime.Store;
Expand Down Expand Up @@ -40,7 +41,7 @@ public class TestModule {
+ "multiple start sections";

public static TestModule of(String classpath) {
try (var is = TestModule.class.getResourceAsStream(classpath)) {
try (var is = CorpusResources.getResource(classpath.substring(1))) {
if (classpath.endsWith(".wat")) {
byte[] parsed;
try {
Expand Down
19 changes: 19 additions & 0 deletions compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,23 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.sql</arg>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is surprising

</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public String map(String internalName) {

static byte[] getBytecode(Class<?> clazz) {
var name = getInternalName(clazz) + ".class";
// Okay when running with Java modules (JPMS), because .class are exempted from checks
try (var in = clazz.getClassLoader().getResourceAsStream(name)) {
if (in == null) {
throw new IOException("Resource not found: " + name);
Expand Down
11 changes: 11 additions & 0 deletions compiler/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module com.dylibso.chicory.compiler {
requires transitive com.dylibso.chicory.runtime;
requires transitive com.dylibso.chicory.wasm;
requires org.objectweb.asm;
requires org.objectweb.asm.commons;
requires org.objectweb.asm.util;

exports com.dylibso.chicory.compiler;
exports com.dylibso.chicory.compiler.internal;
exports com.dylibso.chicory.experimental.aot;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.dylibso.chicory.approvals;

import static com.dylibso.chicory.wasm.Parser.parse;
import static java.lang.ClassLoader.getSystemClassLoader;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.objectweb.asm.Type.getInternalName;

import com.dylibso.chicory.compiler.internal.Compiler;
import com.dylibso.chicory.compiler.internal.Shaded;
import com.dylibso.chicory.corpus.CorpusResources;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
Expand Down Expand Up @@ -68,7 +68,7 @@ public void verifyI32() {

@Test
public void verifyI32Renamed() {
var module = parse(getSystemClassLoader().getResourceAsStream("compiled/i32.wat.wasm"));
var module = parse(CorpusResources.getResource("compiled/i32.wat.wasm"));
var result = Compiler.builder(module).withClassName("FOO").build().compile();
verifyClass(result.classBytes(), (name) -> !name.equals("FOO"));
}
Expand Down Expand Up @@ -105,8 +105,7 @@ public void verifyExceptions() {

@Test
public void functions10() {
var module =
parse(getSystemClassLoader().getResourceAsStream("compiled/functions_10.wat.wasm"));
var module = parse(CorpusResources.getResource("compiled/functions_10.wat.wasm"));
var result = Compiler.builder(module).withMaxFunctionsPerClass(5).build().compile();
verifyClass(result.classBytes(), ApprovalTest::SKIP_Methods_CLASS);
}
Expand All @@ -117,7 +116,7 @@ private static void verifyGeneratedBytecode(String name) {

private static void verifyGeneratedBytecode(
String name, Function<String, Boolean> classSkipper) {
var module = parse(getSystemClassLoader().getResourceAsStream("compiled/" + name));
var module = parse(CorpusResources.getResource("compiled/" + name));
var result = Compiler.builder(module).build().compile();
verifyClass(result.classBytes(), classSkipper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.Instance;
import com.dylibso.chicory.wasm.Parser;
import org.junit.jupiter.api.Test;
Expand All @@ -11,8 +12,7 @@ public class CallTest {

@Test
public void callLotsOfArgs() throws InterruptedException {
var module =
Parser.parse(CallTest.class.getResourceAsStream("/compiled/lots-of-args.wat.wasm"));
var module = Parser.parse(CorpusResources.getResource("compiled/lots-of-args.wat.wasm"));
var instance =
Instance.builder(module)
.withMachineFactory(MachineFactoryCompiler::compile)
Expand All @@ -26,8 +26,7 @@ public void callLotsOfArgs() throws InterruptedException {
@Test
@SuppressWarnings("deprecation")
public void callLotsOfArgsOnDeprecatedAotMachine() throws InterruptedException {
var module =
Parser.parse(CallTest.class.getResourceAsStream("/compiled/lots-of-args.wat.wasm"));
var module = Parser.parse(CorpusResources.getResource("compiled/lots-of-args.wat.wasm"));
var instance =
Instance.builder(module)
.withMachineFactory(MachineFactoryCompiler::compile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.Instance;
import com.dylibso.chicory.wasm.Parser;
import com.dylibso.chicory.wasm.WasmModule;
Expand All @@ -13,7 +14,7 @@
public class ExceptionTest {

private static final WasmModule MODULE =
Parser.parse(ExceptionTest.class.getResourceAsStream("/compiled/exceptions.wat.wasm"));
Parser.parse(CorpusResources.getResource("compiled/exceptions.wat.wasm"));

private static int throwIfFn;
private static int catchlessTryFn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.Instance;
import com.dylibso.chicory.wasm.ChicoryException;
import com.dylibso.chicory.wasm.Parser;
Expand All @@ -18,10 +19,7 @@
public class InterruptionTest {
@Test
public void shouldInterruptLoop() throws InterruptedException {
var module =
Parser.parse(
InterruptionTest.class.getResourceAsStream(
"/compiled/infinite-loop.c.wasm"));
var module = Parser.parse(CorpusResources.getResource("compiled/infinite-loop.c.wasm"));
var instance =
Instance.builder(module)
.withMachineFactory(MachineFactoryCompiler::compile)
Expand All @@ -33,8 +31,7 @@ public void shouldInterruptLoop() throws InterruptedException {

@Test
public void shouldInterruptCall() throws InterruptedException {
var module =
Parser.parse(InterruptionTest.class.getResourceAsStream("/compiled/power.c.wasm"));
var module = Parser.parse(CorpusResources.getResource("compiled/power.c.wasm"));
var instance =
Instance.builder(module)
.withMachineFactory(MachineFactoryCompiler::compile)
Expand Down
6 changes: 6 additions & 0 deletions log/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module com.dylibso.chicory.log {
requires static com.google.errorprone.annotations;
requires static java.logging;

exports com.dylibso.chicory.log;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.ImportTable;
import com.dylibso.chicory.runtime.ImportValues;
import com.dylibso.chicory.runtime.Instance;
Expand Down Expand Up @@ -42,7 +43,7 @@
public final class MachinesTest {

private WasmModule loadModule(String fileName) {
return Parser.parse(getClass().getResourceAsStream("/" + fileName));
return Parser.parse(CorpusResources.getResource(fileName));
}

private Instance.Builder quickJsInstanceBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.dylibso.chicory.compiler.MachineFactoryCompiler;
import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.runtime.ByteArrayMemory;
import com.dylibso.chicory.runtime.ByteBufferMemory;
import com.dylibso.chicory.runtime.ImportMemory;
Expand All @@ -28,7 +29,7 @@
public class ThreadsProposalTest {

private static WasmModule loadModule(String fileName) {
return Parser.parse(ThreadsProposalTest.class.getResourceAsStream("/" + fileName));
return Parser.parse(CorpusResources.getResource(fileName));
}

@FunctionalInterface
Expand Down
76 changes: 48 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand Down Expand Up @@ -560,6 +565,10 @@
<excludeGeneratedSources>true</excludeGeneratedSources>
<checkstyleRules>
<module name="Checker">
<module name="BeforeExecutionExclusionFileFilter">
<!-- checkstyle does not support module-info files (checkstyle issue 8240) -->
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="FileTabCharacter">
<property name="fileExtensions" value="java,xml"/>
</module>
Expand Down Expand Up @@ -619,6 +628,13 @@
</module>
</checkstyleRules>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkstyle</id>
Expand Down Expand Up @@ -752,6 +768,23 @@
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>default-test</id>
<configuration>
<useModulePath>false</useModulePath>
</configuration>
</execution>
<execution>
<id>test-module-path</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<useModulePath>true</useModulePath>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -820,11 +853,23 @@
<activation>
<jdk>11</jdk>
</activation>
<properties>
<checkstyle.skip>true</checkstyle.skip>
</properties>
<build>
<plugins>
<!-- disable checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<dependencies/>
<executions>
<execution>
<id>checkstyle</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- disable Error Prone -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -837,31 +882,6 @@
</build>
</profile>

<profile>
<id>java17</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>

<profile>
<id>java21</id>
<activation>
Expand Down
7 changes: 7 additions & 0 deletions runtime/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module com.dylibso.chicory.runtime {
requires transitive com.dylibso.chicory.wasm;

exports com.dylibso.chicory.runtime;
exports com.dylibso.chicory.runtime.alloc;
exports com.dylibso.chicory.runtime.internal;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.dylibso.chicory.corpus.CorpusResources;
import com.dylibso.chicory.wasm.ChicoryException;
import com.dylibso.chicory.wasm.Parser;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -17,8 +18,8 @@ public void shouldInterruptLoop() throws InterruptedException {
var instance =
Instance.builder(
Parser.parse(
InterruptionTest.class.getResourceAsStream(
"/compiled/infinite-loop.c.wasm")))
CorpusResources.getResource(
"compiled/infinite-loop.c.wasm")))
.build();
var function = instance.export("run");
assertInterruption(function::apply);
Expand All @@ -27,10 +28,7 @@ public void shouldInterruptLoop() throws InterruptedException {
@Test
public void shouldInterruptCall() throws InterruptedException {
var instance =
Instance.builder(
Parser.parse(
InterruptionTest.class.getResourceAsStream(
"/compiled/power.c.wasm")))
Instance.builder(Parser.parse(CorpusResources.getResource("compiled/power.c.wasm")))
.build();
var function = instance.export("run");
assertInterruption(() -> function.apply(100));
Expand Down
Loading
Loading