diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..34f2848bb --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# Endive Code Owners +# These users will be automatically requested for review on PRs. + +* @andreaTP @evacchi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c7fb05606..931767d7c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,7 +72,7 @@ jobs: uses: actions/setup-node@v6 with: node-version: '22' - - name: Build Chicory + - name: Build Endive run: ./mvnw -B -Dquickly - name: Test Docs working-directory: docs diff --git a/.github/workflows/dependency-check.yaml b/.github/workflows/dependency-check.yaml new file mode 100644 index 000000000..bde84f8d6 --- /dev/null +++ b/.github/workflows/dependency-check.yaml @@ -0,0 +1,41 @@ +name: Dependency Check + +on: + schedule: + - cron: "30 2 * * *" # every day at 2:30 AM + workflow_dispatch: # allow manual triggering + +permissions: + contents: read + +jobs: + dependency-check: + name: OWASP Dependency Check + runs-on: ubuntu-latest + if: github.repository_owner == 'bytecodealliance' + steps: + - name: Checkout sources + uses: actions/checkout@v6 + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + cache: maven + - name: Build + run: mvn -B -Dquickly + - name: Run OWASP Dependency Check + run: | + mvn -B org.owasp:dependency-check-maven:check \ + -DfailBuildOnCVSS=7 \ + -DsuppressedPaths=./dependency-check-suppressions.xml \ + -Dformats=HTML,JSON \ + -Danalyzer.ossindexAnalyzerEnabled=true + - name: Upload report + uses: actions/upload-artifact@v7 + if: always() + with: + name: dependency-check-report + path: target/dependency-check-report.* + retention-days: 30 + if-no-files-found: ignore diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 000000000..76dbe6ea1 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,65 @@ +name: Deploy Docs + +on: + push: + branches: [main] + paths: + - 'docs/**' + - 'docs-lib/**' + - 'wasm-corpus/**' + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' + cache: maven + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + + - name: Build Endive + run: ./mvnw -B -Dquickly + + - name: Install docs dependencies + working-directory: docs + run: npm ci + + - name: Build Docusaurus site + working-directory: docs + run: npm run build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v5 + with: + path: docs/build + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index a1e19aa52..c45c9a199 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -22,7 +22,7 @@ jobs: java-version: '21' cache: maven - name: Fuzz Test - if: github.repository_owner == 'dylibso' + if: github.repository_owner == 'bytecodealliance' run: | # Build everything mvn -B -Dquickly diff --git a/.github/workflows/perf.yaml b/.github/workflows/perf.yaml index bf8f53c28..91700370e 100644 --- a/.github/workflows/perf.yaml +++ b/.github/workflows/perf.yaml @@ -14,7 +14,7 @@ jobs: name: JMH tests on baseline runs-on: ubuntu-latest outputs: - result-link: "https://nightly.link/dylibso/chicory/actions/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}.zip" + result-link: "https://nightly.link/bytecodealliance/endive/actions/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}.zip" steps: - name: Checkout sources for this branch uses: actions/checkout@v6 @@ -41,7 +41,7 @@ jobs: name: JMH tests on current branch runs-on: ubuntu-latest outputs: - result-link: "https://nightly.link/dylibso/chicory/actions/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}.zip" + result-link: "https://nightly.link/bytecodealliance/endive/actions/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}.zip" steps: - name: Checkout sources for this branch uses: actions/checkout@v6 @@ -76,4 +76,4 @@ jobs: echo "Visualize JMH results using this script from the project root:" >> $GITHUB_STEP_SUMMARY echo -e '
./scripts/show-results.sh ci ${{ needs.perf-main.outputs.result-link }} ${{ needs.perf-current.outputs.result-link }}
' >> $GITHUB_STEP_SUMMARY echo "Or use a pre-built container image:" >> $GITHUB_STEP_SUMMARY - echo -e '
docker run --rm -it -p 3000:3000 docker.io/andreatp/chicory-show-jmh ci ${{ needs.perf-main.outputs.result-link }} ${{ needs.perf-current.outputs.result-link }}
' >> $GITHUB_STEP_SUMMARY + echo -e '
docker run --rm -it -p 3000:3000 docker.io/andreatp/endive-show-jmh ci ${{ needs.perf-main.outputs.result-link }} ${{ needs.perf-current.outputs.result-link }}
' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e93340eaa..cabebe80b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,8 +47,8 @@ jobs: - name: Setup Git run: | - git config user.name "Chicory BOT" - git config user.email "chicory@dylibso.com" + git config user.name "Endive BOT" + git config user.email "endive@bytecodealliance.org" - name: Set the version run: | diff --git a/.github/workflows/zig-testsuite.yaml b/.github/workflows/zig-testsuite.yaml index 230cac1ef..5a3df406e 100644 --- a/.github/workflows/zig-testsuite.yaml +++ b/.github/workflows/zig-testsuite.yaml @@ -21,10 +21,10 @@ jobs: java-version: '21' cache: maven - name: Compile the Zig testsuite - if: github.repository_owner == 'dylibso' + if: github.repository_owner == 'bytecodealliance' run: ./scripts/build-zig-testsuite.sh - name: Nightly Test - if: github.repository_owner == 'dylibso' + if: github.repository_owner == 'bytecodealliance' run: | # Build everything mvn -B -Dquickly diff --git a/ADOPTERS.md b/ADOPTERS.md new file mode 100644 index 000000000..41eff7da6 --- /dev/null +++ b/ADOPTERS.md @@ -0,0 +1,22 @@ +# Endive Adopters + +Organizations and projects using Endive (formerly Chicory) in production: + +* [sqlite4j](https://github.com/roastedroot/sqlite4j) - Pure Java SQLite JDBC driver +* [pglite4j](https://github.com/roastedroot/pglite4j) - Embedded PostgreSQL 17 in pure Java +* [Quickjs4J](https://github.com/roastedroot/quickjs4j) - Sandboxed runtime for JavaScript (used by [Microcks](https://github.com/microcks/microcks) and [Apicurio Registry](https://github.com/Apicurio/apicurio-registry)) +* [jq4j](https://github.com/roastedroot/jq4j) - jq JSON processor as pure Java bytecode +* [protobuf4j](https://github.com/roastedroot/protobuf4j) - protoc compiler as pure Java bytecode +* [lumis4j](https://github.com/roastedroot/lumis4j) - Pure Java syntax highlighter powered by Tree-sitter +* [Proxy-Wasm Java Host](https://github.com/roastedroot/proxy-wasm-java-host) +* [Apache Camel - Wasm component](https://camel.apache.org/components/4.8.x/wasm-component.html) +* [JRuby](https://github.com/jruby/jruby) - Ruby Prism parser +* [Debezium](https://github.com/debezium/debezium) - Pluggable Go Single Message Transformations +* [OPA Java Wasm SDK](https://github.com/StyraInc/opa-java-wasm) - Open Policy Agent WebAssembly Java SDK +* [Trino](https://trino.io/docs/current/udf/python.html) - Python user-defined functions +* [Extism Chicory SDK](https://github.com/extism/chicory-sdk) +* [OpenFeature Go Feature Flag provider](https://github.com/open-feature/java-sdk-contrib) - local feature flag evaluation +* [Spotify Confidence resolver](https://github.com/spotify/confidence-resolver) - local feature flag evaluation +* [Bazel](https://github.com/bazelbuild/bazel) - WebAssembly execution in repo rules +* [WildFly AI Feature Pack](https://github.com/wildfly-extras/wildfly-ai-feature-pack) +* Quarkus extensions: [quarkus-chicory](https://github.com/quarkiverse/quarkus-chicory), [quarkus-proxy-wasm](https://github.com/quarkiverse/quarkus-proxy-wasm), [quarkus-quickjs4j](https://github.com/quarkiverse/quarkus-quickjs4j), [quarkus-grpc-zero](https://github.com/quarkiverse/quarkus-grpc-zero) diff --git a/AGENT.md b/AGENT.md index 4b69874f8..120a3e16b 100644 --- a/AGENT.md +++ b/AGENT.md @@ -1,6 +1,6 @@ # Working with this repository -Chicory is a WebAssembly runtime written in Java. This document captures practical knowledge for working in the codebase. +Endive is a WebAssembly runtime written in Java. This document captures practical knowledge for working in the codebase. ## Prerequisites diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..f84fd18db --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,49 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Code of Conduct Team + +The Organization’s Code of Conduct Team is responsible for ensuring that all Code of Conduct complaints are investigated and resolved. It consists of the members of the Technical Steering Commmittee along with the Executive Director acting as Compliance Officer. The Compliance Officer, on behalf of the Code of Conduct Team, will advise the Board of all complaints and their resolution and will report at least annually to the Board on compliance activity relating to the organizational Code of Conduct. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Bytecode Alliance CoC Team at [report@bytecodealliance.org](mailto:report@bytecodealliance.org). The CoC Team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The CoC Team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the Bytecode Alliance's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at http://contributor-covenant.org/version/1/4. + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f307fb32..4d5e22047 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ But first, read this page (including the small print at the end). ## Coding Philosophy -Writing a runtime is a big challenge. We want Chicory to always be a solid foundation +Writing a runtime is a big challenge. We want Endive to always be a solid foundation for running Wasm in Java. In order to accomplish this, it's going to take a large team of diverse contributors. That's why our goal up front is to aim for writing simple code that's easy to understand and is as backwards compatible as possible. @@ -92,7 +92,7 @@ Our priority is to focus on implementing [proposals](https://github.com/WebAssem ### Continuous Integration -Because we are all humans, and to ensure Chicory evolves in the right direction, all changes must pass continuous integration before being merged. The CI is based on GitHub Actions, which means that pull requests will receive automatic feedback. Please watch out for the results of these workflows to see if your PR passes all tests. +Because we are all humans, and to ensure Endive evolves in the right direction, all changes must pass continuous integration before being merged. The CI is based on GitHub Actions, which means that pull requests will receive automatic feedback. Please watch out for the results of these workflows to see if your PR passes all tests. ### IntelliJ default limits @@ -125,7 +125,7 @@ If you believe you found a bug, and it's likely possible, please indicate a way ## Legal -All original contributions to Chicory projects are licensed under the +All original contributions to Endive projects are licensed under the [ASL - Apache License](https://www.apache.org/licenses/LICENSE-2.0), version 2.0 or later, or, if another license is specified as governing the file or directory being modified, such other license. diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..4cb5b84e3 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Endive +Copyright 2026 The Bytecode Alliance + +This project is based on Chicory, originally created by Dylibso, Inc. +Original source: https://github.com/dylibso/chicory diff --git a/README.md b/README.md index c44f0d4ed..700c7e5c1 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,35 @@ -# Chicory +# Endive

- +
- Website | - Getting started | - Blog | + A Bytecode Alliance hosted project +

+ Website | + Getting started | + Blog | Contributing

- [![Interpreter Test Results](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-interpreter.svg)](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-interpreter.svg) [![Compiler Test Results](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-compiler.svg)](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-compiler.svg) [![WASI Test Results](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-wasi.svg)](https://gist.githubusercontent.com/andreaTP/69354d1cc6cf23e4c3c4a9a8daf7ea15/raw/badge-wasi.svg) -[![Zulip](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://chicory.zulipchat.com/join/g4gqsxoys6orfxlrk6hn4cyp/) +[![Zulip](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://bytecodealliance.zulipchat.com/#narrow/stream/endive) -Chicory is a JVM native WebAssembly runtime. It allows you to run WebAssembly programs with -zero native dependencies or JNI. Chicory can run Wasm anywhere that the JVM can go. It is designed with +Endive is a JVM native WebAssembly runtime. It allows you to run WebAssembly programs with +zero native dependencies or JNI. Endive can run Wasm anywhere that the JVM can go. It is designed with simplicity and safety in mind. -> *Reach out to us*: let us know what you are building with Chicory. -> [Join our team Zulip chat with this invite link](https://chicory.zulipchat.com/join/g4gqsxoys6orfxlrk6hn4cyp/). +Endive is a fork of [Chicory](https://github.com/dylibso/chicory) by Dylibso, Inc. +We thank Dylibso for the incubation period and their foundational work on this project. + +> *Reach out to us*: let us know what you are building with Endive. +> [Join our Zulip chat](https://bytecodealliance.zulipchat.com/#narrow/stream/endive). -Get started now with the [official documentation](https://chicory.dev/docs/) +Get started now with the [official documentation](https://endive.run/docs/) ## Why? @@ -43,65 +47,46 @@ architecture and operating system. This matrix can become quite large. This elim ### 2. Runtime -At runtime, you must use FFI to execute the module. While there might be performance benefits to doing this for some modules, -when you do, you're effectively escaping the safety and observability of the JVM. Having a pure JVM runtime means all your +At runtime, you must use FFI to execute the module. When you do, you're effectively escaping the safety and observability of the JVM. Having a pure JVM runtime means all your security and memory guarantees, and your tools, can stay in place. ## Goals +* Be the default runtime for Wasm on the JVM * Be as safe as possible - * In that we are willing to sacrifice things like performance for safety and simplicity -* Make it easy to run Wasm in any JVM environment without native code, including very restrictive environments. +* Make it easy to run Wasm in any JVM environment without native code, including very restrictive environments * Fully support the core Wasm spec -* Make integration with Java (and other host languages) easy and idiomatic. - -## Non-Goals: - -* Be a standalone runtime -* Be the fastest runtime -* Be the right choice for every JVM project +* Make integration with Java (and other host languages) easy and idiomatic ## Roadmap -Chicory development was started in September 2023. The following are the milestones we're aiming for. These -are subject to change but represent our best guesses with current information. These are not necessarily sequential -and some may be happening in parallel. Unless specified, any unchecked box is still not planned or started. +Endive development builds on years of work started in September 2023 as Chicory. If you have an interest in working on any of these please reach out in Zulip! -### 2023 +### Completed * [x] Wasm binary parser * [x] Simple bytecode interpreter -* [x] Establish basic coding and testing patterns * [x] Generate JUnit tests from wasm test suite - -### 2024 - -* [x] Make all tests green with the interpreter (important for correctness) -* [x] Implement validation logic (important for safety) -* [x] Draft of the v1.0 API (important for stability and dx) -* [x] Decouple interpreter and create separate compiler and interpreter "engines" -* [x] Proof of concept AOT compiler (run some subset of modules) -* [x] AOT engine passes all the same specs as interpreter (stretch goal) +* [x] All tests green with the interpreter (correctness) +* [x] Validation logic (safety) +* [x] v1.0 API (stability and dx) +* [x] Decoupled interpreter and compiler "engines" +* [x] Build-time compiler passes all the same specs as interpreter * [x] WASIp1 Support (including test gen) - * [Read more details in the documentation](https://chicory.dev/docs/usage/wasi/) - -### 2025 - * [x] SIMD Support - * in the interpreter -* [x] Tail Call - * in the interpreter(and compiler**) +* [x] Tail Call (interpreter and compiler) * [x] Compiler out of experimental * [x] Exception Handling * [x] Threads Support * [x] Extended Constant Expressions - -### 2026 - * [x] GC support * [x] Multi-Memory Support + +### Ongoing + * [ ] Performance +* [ ] WASIp2 Support ## On the press @@ -127,28 +112,6 @@ If you have an interest in working on any of these please reach out in Zulip! * [kwasm](https://github.com/jasonwyatt/KWasm) * [wazero](https://wazero.io/) -## Who uses Chicory? - -* [sqlite4j - Pure Java SQLite JDBC driver](https://github.com/roastedroot/sqlite4j) -* [pglite4j - Embedded PostgreSQL 17 in pure Java](https://github.com/roastedroot/pglite4j) -* [Quickjs4J - Sandboxed runtime for JavaScript](https://github.com/roastedroot/quickjs4j) (used by [Microcks](https://github.com/microcks/microcks) and [Apicurio Registry](https://github.com/Apicurio/apicurio-registry)) -* [jq4j - jq JSON processor as pure Java bytecode](https://github.com/roastedroot/jq4j) -* [protobuf4j - protoc compiler as pure Java bytecode](https://github.com/roastedroot/protobuf4j) -* [lumis4j - Pure Java syntax highlighter powered by Tree-sitter](https://github.com/roastedroot/lumis4j) -* [Proxy-Wasm - Java Host](https://github.com/roastedroot/proxy-wasm-java-host) -* Quarkus extensions: [quarkus-chicory](https://github.com/quarkiverse/quarkus-chicory), [quarkus-proxy-wasm](https://github.com/quarkiverse/quarkus-proxy-wasm), [quarkus-quickjs4j](https://github.com/quarkiverse/quarkus-quickjs4j), [quarkus-grpc-zero](https://github.com/quarkiverse/quarkus-grpc-zero) -* [Apache Camel - Wasm component](https://camel.apache.org/components/4.8.x/wasm-component.html) -* [JRuby - Ruby Prism parser](https://github.com/jruby/jruby) -* [Debezium - Pluggable Go Single Message Transformations](https://github.com/debezium/debezium) -* [OPA - Open Policy Agent - WebAssembly Java SDK](https://github.com/StyraInc/opa-java-wasm) -* [Trino - Python user-defined functions](https://trino.io/docs/current/udf/python.html) [(Trino plugin source)](https://github.com/trinodb/trino/tree/master/plugin/trino-functions-python) [(Python host source)](https://github.com/trinodb/trino-wasm-python) -* [Extism Chicory SDK](https://github.com/extism/chicory-sdk) -* [OpenFeature Go Feature Flag provider - local feature flag evaluation](https://github.com/open-feature/java-sdk-contrib) -* [Spotify Confidence resolver - local feature flag evaluation](https://github.com/spotify/confidence-resolver) -* [Bazel - WebAssembly execution in repo rules](https://github.com/bazelbuild/bazel) -* [WildFly - AI Feature Pack](https://github.com/wildfly-extras/wildfly-ai-feature-pack) - -## Meet the Team - -📅 Chicory Office Hours, every Tuesdays, 16:00–16:30 UTC (09:00–09:30 PT · 12:00–12:30 ET · 18:00–18:30 CET). -The link will be shared in the Zulip chat each week. Let’s talk Chicory! +## Who uses Endive? + +See [ADOPTERS.md](ADOPTERS.md) for the full list of organizations and projects using Endive. diff --git a/SECURITY.md b/SECURITY.md index 67cf632f4..df4123765 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,9 +1,13 @@ -# Reporting Security Issues +# Security Policy -The Chicory team and community take security bugs in Chicory seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions. +Please refer to the [Bytecode Alliance security policy](https://bytecodealliance.org/security) for details on our disclosure policy and how to receive notifications about security issues. -To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/dylibso/chicory/security/advisories/new) tab. +## Reporting a Vulnerability -The Chicory team will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance. +To report a vulnerability, navigate to the [security](https://github.com/bytecodealliance/endive/security) tab and click the green `Report a Vulnerability` button, or use [this direct link](https://github.com/bytecodealliance/endive/security/advisories/new) to the reporting form. -Report security bugs in third-party modules to the person or team maintaining the module when applicable. +The Endive team will send a response indicating the next steps in handling your report. After the initial reply, we will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance. + +Security patches are handled as priority releases. We recommend that CVE numbers are requested for discovered vulnerabilities following the [Bytecode Alliance security policy](https://bytecodealliance.org/security). + +Report security bugs in third-party dependencies to the person or team maintaining them when applicable. diff --git a/android-tests/README.md b/android-tests/README.md index c2ed575cc..368e8eb1b 100644 --- a/android-tests/README.md +++ b/android-tests/README.md @@ -1,8 +1,8 @@ -# Running Chicory tests on Android +# Running Endive tests on Android -This is an Android project designed to run Chicory tests on device. +This is an Android project designed to run Endive tests on device. -Since Chicory uses maven and Android doesn't have official maven +Since Endive uses maven and Android doesn't have official maven support, we cannot make Android testing part of the main build. Instead, we use this project where it uses the outputs of the @@ -10,10 +10,10 @@ main maven build to run those tests as Android instrumentation tests. Inside the `device-tests` folder, there is an Android library project setup. It doesn't have any code, except for declaring product flavors -for each main chicory project and setting up its dependencies to run +for each main endive project and setting up its dependencies to run tests. -To run the tests on Android you need first to build a local `CHICORY_REPO`: +To run the tests on Android you need first to build a local `ENDIVE_REPO`: ```bash mvn -Dandroid-prepare @@ -30,12 +30,12 @@ Finally you can run the tests from the gradle project: ./android-tests/gradlew -p android-tests cC ``` -You can override the repository location by setting the `CHICORY_REPO` environment variable. -It can either be an absolute path, or relative to the Chicory checkout directory. +You can override the repository location by setting the `ENDIVE_REPO` environment variable. +It can either be an absolute path, or relative to the Endive checkout directory. ```base # mv local-repo my-repo -CHICORY_REPO=my-repo ./android-tests/gradlew -p android-tests cC +ENDIVE_REPO=my-repo ./android-tests/gradlew -p android-tests cC ``` ## Environment Setup diff --git a/android-tests/device-tests/build.gradle.kts b/android-tests/device-tests/build.gradle.kts index f275a1b30..d399365a1 100644 --- a/android-tests/device-tests/build.gradle.kts +++ b/android-tests/device-tests/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } android { - namespace = "com.dylibso.runtimeTests" + namespace = "run.endive.runtimeTests" compileSdk = 35 defaultConfig { @@ -12,10 +12,10 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - val chicoryDimension = "chicoryDimension" - flavorDimensions += chicoryDimension + val endiveDimension = "endiveDimension" + flavorDimensions += endiveDimension productFlavors { - create("runtime") { dimension = chicoryDimension } + create("runtime") { dimension = endiveDimension } // add future modules similar to the runtime configuration above. } @@ -42,11 +42,11 @@ dependencies { // if you need to add a dependency on a specific module, you can use // "androidTestImplementation"() // e.g. - // "androidTestRuntimeImplementation"(libs.chicory.runtime) - androidTestImplementation(libs.chicory.wasi) - androidTestImplementation(libs.chicory.runtime) - androidTestImplementation(libs.chicory.wasm) - androidTestImplementation(libs.chicory.wasmCorpus) + // "androidTestRuntimeImplementation"(libs.endive.runtime) + androidTestImplementation(libs.endive.wasi) + androidTestImplementation(libs.endive.runtime) + androidTestImplementation(libs.endive.wasm) + androidTestImplementation(libs.endive.wasmCorpus) androidTestImplementation(libs.junit.jupiter.api) } @@ -57,7 +57,7 @@ dependencies { * the target maven project. See the pom file for runtime project for a sample setup. * * @param configurationName Target Gradle configuration name - * @param libraryPath Library path relative to the main chicory maven project + * @param libraryPath Library path relative to the main endive maven project */ fun addLibraryTests(configurationName: String, libraryPath: String) { // Add the jar task's output as a dependency. diff --git a/android-tests/device-tests/src/androidTest/java/com/dylibso/runtimeTests/Placeholder.kt b/android-tests/device-tests/src/androidTest/java/run/endive/runtimeTests/Placeholder.kt similarity index 75% rename from android-tests/device-tests/src/androidTest/java/com/dylibso/runtimeTests/Placeholder.kt rename to android-tests/device-tests/src/androidTest/java/run/endive/runtimeTests/Placeholder.kt index d6c4ce900..07306968a 100644 --- a/android-tests/device-tests/src/androidTest/java/com/dylibso/runtimeTests/Placeholder.kt +++ b/android-tests/device-tests/src/androidTest/java/run/endive/runtimeTests/Placeholder.kt @@ -1,4 +1,4 @@ -package com.dylibso.runtimeTests +package run.endive.runtimeTests // we need a file here to prevent gradle from skipping tests due to no inputs. object Placeholder diff --git a/android-tests/gradle/libs.versions.toml b/android-tests/gradle/libs.versions.toml index 7cf94de56..8ff8f9924 100644 --- a/android-tests/gradle/libs.versions.toml +++ b/android-tests/gradle/libs.versions.toml @@ -2,14 +2,14 @@ agp = "9.1.0" junitJupiterApi = "5.14.3" kotlin = "2.3.20" -chicory = "999-SNAPSHOT" +endive = "999-SNAPSHOT" [libraries] junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiterApi" } -chicory-wasi = { module = "com.dylibso.chicory:wasi", version.ref = "chicory"} -chicory-runtime = { module = "com.dylibso.chicory:runtime", version.ref = "chicory"} -chicory-wasm = { module = "com.dylibso.chicory:wasm", version.ref = "chicory"} -chicory-wasmCorpus = { module = "com.dylibso.chicory:wasm-corpus", version.ref = "chicory"} +endive-wasi = { module = "run.endive:wasi", version.ref = "endive"} +endive-runtime = { module = "run.endive:runtime", version.ref = "endive"} +endive-wasm = { module = "run.endive:wasm", version.ref = "endive"} +endive-wasmCorpus = { module = "run.endive:wasm-corpus", version.ref = "endive"} android-gradle-plugin-api = { module = "com.android.tools.build:gradle-api", version.ref = "agp"} [plugins] kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/android-tests/settings.gradle.kts b/android-tests/settings.gradle.kts index 5339c8ac3..d1ccf19ce 100644 --- a/android-tests/settings.gradle.kts +++ b/android-tests/settings.gradle.kts @@ -16,7 +16,7 @@ dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenLocal { - val repoOverride = settings.providers.environmentVariable("CHICORY_REPO") + val repoOverride = settings.providers.environmentVariable("ENDIVE_REPO") val relativePath = if (repoOverride.isPresent) { repoOverride.get() diff --git a/annotations/annotations/pom.xml b/annotations/annotations/pom.xml index 4308addc6..97c9f7ab9 100644 --- a/annotations/annotations/pom.xml +++ b/annotations/annotations/pom.xml @@ -3,14 +3,14 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../../pom.xml annotations jar - Chicory - Annotations + Endive - Annotations Annotations for easy interoperability with Wasm modules diff --git a/annotations/annotations/src/main/java/module-info.java b/annotations/annotations/src/main/java/module-info.java index 9ac617bed..059577dec 100644 --- a/annotations/annotations/src/main/java/module-info.java +++ b/annotations/annotations/src/main/java/module-info.java @@ -1,3 +1,3 @@ -module com.dylibso.chicory.annotations { - exports com.dylibso.chicory.annotations; +module run.endive.annotations { + exports run.endive.annotations; } diff --git a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/Buffer.java b/annotations/annotations/src/main/java/run/endive/annotations/Buffer.java similarity index 86% rename from annotations/annotations/src/main/java/com/dylibso/chicory/annotations/Buffer.java rename to annotations/annotations/src/main/java/run/endive/annotations/Buffer.java index 2cbb306ed..7336d1453 100644 --- a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/Buffer.java +++ b/annotations/annotations/src/main/java/run/endive/annotations/Buffer.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations; +package run.endive.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/CString.java b/annotations/annotations/src/main/java/run/endive/annotations/CString.java similarity index 86% rename from annotations/annotations/src/main/java/com/dylibso/chicory/annotations/CString.java rename to annotations/annotations/src/main/java/run/endive/annotations/CString.java index eba26052a..450c51d39 100644 --- a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/CString.java +++ b/annotations/annotations/src/main/java/run/endive/annotations/CString.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations; +package run.endive.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/HostModule.java b/annotations/annotations/src/main/java/run/endive/annotations/HostModule.java similarity index 87% rename from annotations/annotations/src/main/java/com/dylibso/chicory/annotations/HostModule.java rename to annotations/annotations/src/main/java/run/endive/annotations/HostModule.java index d0b6e3ca2..9d84ce11f 100644 --- a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/HostModule.java +++ b/annotations/annotations/src/main/java/run/endive/annotations/HostModule.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations; +package run.endive.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmExport.java b/annotations/annotations/src/main/java/run/endive/annotations/WasmExport.java similarity index 87% rename from annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmExport.java rename to annotations/annotations/src/main/java/run/endive/annotations/WasmExport.java index 001f809f1..d62e6a166 100644 --- a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmExport.java +++ b/annotations/annotations/src/main/java/run/endive/annotations/WasmExport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations; +package run.endive.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmModuleInterface.java b/annotations/annotations/src/main/java/run/endive/annotations/WasmModuleInterface.java similarity index 92% rename from annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmModuleInterface.java rename to annotations/annotations/src/main/java/run/endive/annotations/WasmModuleInterface.java index fa83ffc5d..0aa7bef32 100644 --- a/annotations/annotations/src/main/java/com/dylibso/chicory/annotations/WasmModuleInterface.java +++ b/annotations/annotations/src/main/java/run/endive/annotations/WasmModuleInterface.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations; +package run.endive.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/annotations/it/pom.xml b/annotations/it/pom.xml index 4c9c5730e..4ec656013 100644 --- a/annotations/it/pom.xml +++ b/annotations/it/pom.xml @@ -3,29 +3,29 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../../pom.xml annotations-it jar - Chicory - Annotations - IT - Integration tests for the Chicory annotations + Endive - Annotations - IT + Integration tests for the Endive annotations - com.dylibso.chicory + run.endive annotations-processor - com.dylibso.chicory - chicory-compiler-maven-plugin + run.endive + endive-compiler-maven-plugin - com.dylibso.chicory + run.endive wasi @@ -38,9 +38,9 @@ maven-dependency-plugin - com.dylibso.chicory:annotations-processor - com.dylibso.chicory:chicory-compiler-maven-plugin - com.dylibso.chicory:wasi + run.endive:annotations-processor + run.endive:endive-compiler-maven-plugin + run.endive:wasi @@ -50,7 +50,7 @@ ${project.basedir} - ${project.version} + ${project.version} diff --git a/annotations/it/src/it/all-exports/pom.xml b/annotations/it/src/it/all-exports/pom.xml index 40ef8f1e0..a76537041 100644 --- a/annotations/it/src/it/all-exports/pom.xml +++ b/annotations/it/src/it/all-exports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - all-exports-chicory-it + all-exports-endive-it 0.0-SNAPSHOT jar @@ -14,27 +14,21 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -48,6 +42,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -61,7 +61,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/all-exports/src/test/java/chicory/test/AllExportsTest.java b/annotations/it/src/it/all-exports/src/test/java/endive/test/AllExportsTest.java similarity index 90% rename from annotations/it/src/it/all-exports/src/test/java/chicory/test/AllExportsTest.java rename to annotations/it/src/it/all-exports/src/test/java/endive/test/AllExportsTest.java index 1165f71af..e8f8e6bd6 100644 --- a/annotations/it/src/it/all-exports/src/test/java/chicory/test/AllExportsTest.java +++ b/annotations/it/src/it/all-exports/src/test/java/endive/test/AllExportsTest.java @@ -1,13 +1,13 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.types.Value; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.types.Value; class AllExportsTest { diff --git a/annotations/it/src/it/all-imports/pom.xml b/annotations/it/src/it/all-imports/pom.xml index fdcfe072d..4c0113129 100644 --- a/annotations/it/src/it/all-imports/pom.xml +++ b/annotations/it/src/it/all-imports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - all-imports-chicory-it + all-imports-endive-it 0.0-SNAPSHOT jar @@ -14,27 +14,21 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -48,6 +42,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -61,7 +61,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/all-imports/src/test/java/chicory/test/AllImportsTest.java b/annotations/it/src/it/all-imports/src/test/java/endive/test/AllImportsTest.java similarity index 86% rename from annotations/it/src/it/all-imports/src/test/java/chicory/test/AllImportsTest.java rename to annotations/it/src/it/all-imports/src/test/java/endive/test/AllImportsTest.java index 18767488e..e67876fdb 100644 --- a/annotations/it/src/it/all-imports/src/test/java/chicory/test/AllImportsTest.java +++ b/annotations/it/src/it/all-imports/src/test/java/endive/test/AllImportsTest.java @@ -1,24 +1,24 @@ -package chicory.test; +package endive.test; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.runtime.GlobalInstance; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.ValueType; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.GlobalInstance; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.runtime.TableInstance; +import run.endive.wasm.Parser; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.ValueType; class AllImportsTest { diff --git a/annotations/it/src/it/colliding-exports/pom.xml b/annotations/it/src/it/colliding-exports/pom.xml index e06f38cc5..46341cc56 100644 --- a/annotations/it/src/it/colliding-exports/pom.xml +++ b/annotations/it/src/it/colliding-exports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - colliding-imports-chicory-it + colliding-imports-endive-it 0.0-SNAPSHOT jar @@ -14,32 +14,26 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive wasi @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -53,6 +47,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -66,7 +66,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/colliding-exports/src/test/java/chicory/test/CollidingExportsTest.java b/annotations/it/src/it/colliding-exports/src/test/java/endive/test/CollidingExportsTest.java similarity index 85% rename from annotations/it/src/it/colliding-exports/src/test/java/chicory/test/CollidingExportsTest.java rename to annotations/it/src/it/colliding-exports/src/test/java/endive/test/CollidingExportsTest.java index b8c24dbbf..755c71811 100644 --- a/annotations/it/src/it/colliding-exports/src/test/java/chicory/test/CollidingExportsTest.java +++ b/annotations/it/src/it/colliding-exports/src/test/java/endive/test/CollidingExportsTest.java @@ -1,14 +1,14 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; import java.io.ByteArrayOutputStream; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; class CollidingExportsTest { diff --git a/annotations/it/src/it/externref-base/pom.xml b/annotations/it/src/it/externref-base/pom.xml index 3f982e462..2698bd9bf 100644 --- a/annotations/it/src/it/externref-base/pom.xml +++ b/annotations/it/src/it/externref-base/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - externref-base-chicory-it + externref-base-endive-it 0.0-SNAPSHOT jar @@ -14,32 +14,26 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive wasi @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -53,6 +47,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -66,7 +66,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/externref-base/src/test/java/chicory/test/ExternRefExampleTest.java b/annotations/it/src/it/externref-base/src/test/java/endive/test/ExternRefExampleTest.java similarity index 90% rename from annotations/it/src/it/externref-base/src/test/java/chicory/test/ExternRefExampleTest.java rename to annotations/it/src/it/externref-base/src/test/java/endive/test/ExternRefExampleTest.java index 845913657..49b57d3c2 100644 --- a/annotations/it/src/it/externref-base/src/test/java/chicory/test/ExternRefExampleTest.java +++ b/annotations/it/src/it/externref-base/src/test/java/endive/test/ExternRefExampleTest.java @@ -1,11 +1,11 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; class ExternRefExampleTest { diff --git a/annotations/it/src/it/hello-wasi/pom.xml b/annotations/it/src/it/hello-wasi/pom.xml index 8cff4ac4f..5735418d5 100644 --- a/annotations/it/src/it/hello-wasi/pom.xml +++ b/annotations/it/src/it/hello-wasi/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - hello-wasi-chicory-it + hello-wasi-endive-it 0.0-SNAPSHOT jar @@ -14,32 +14,26 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive wasi @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -53,6 +47,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -66,7 +66,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/hello-wasi/src/test/java/chicory/test/HelloWasiTest.java b/annotations/it/src/it/hello-wasi/src/test/java/endive/test/HelloWasiTest.java similarity index 88% rename from annotations/it/src/it/hello-wasi/src/test/java/chicory/test/HelloWasiTest.java rename to annotations/it/src/it/hello-wasi/src/test/java/endive/test/HelloWasiTest.java index 1133546a3..208f5c80f 100644 --- a/annotations/it/src/it/hello-wasi/src/test/java/chicory/test/HelloWasiTest.java +++ b/annotations/it/src/it/hello-wasi/src/test/java/endive/test/HelloWasiTest.java @@ -1,15 +1,15 @@ -package chicory.test; +package endive.test; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; import java.io.ByteArrayOutputStream; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; class HelloWasiTest { diff --git a/annotations/it/src/it/import-exports/pom.xml b/annotations/it/src/it/import-exports/pom.xml index 464831e6e..82303d28d 100644 --- a/annotations/it/src/it/import-exports/pom.xml +++ b/annotations/it/src/it/import-exports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - import-exports-chicory-it + import-exports-endive-it 0.0-SNAPSHOT jar @@ -14,27 +14,21 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -48,6 +42,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -61,7 +61,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/import-exports/src/test/java/chicory/test/ImportExportsTest.java b/annotations/it/src/it/import-exports/src/test/java/endive/test/ImportExportsTest.java similarity index 90% rename from annotations/it/src/it/import-exports/src/test/java/chicory/test/ImportExportsTest.java rename to annotations/it/src/it/import-exports/src/test/java/endive/test/ImportExportsTest.java index a5cc22c08..acfb9e12a 100644 --- a/annotations/it/src/it/import-exports/src/test/java/chicory/test/ImportExportsTest.java +++ b/annotations/it/src/it/import-exports/src/test/java/endive/test/ImportExportsTest.java @@ -1,12 +1,12 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; class ImportExportsTest { public final AtomicInteger count = new AtomicInteger(); diff --git a/annotations/it/src/it/mixed-imports/pom.xml b/annotations/it/src/it/mixed-imports/pom.xml index a5205e6fb..7831026ae 100644 --- a/annotations/it/src/it/mixed-imports/pom.xml +++ b/annotations/it/src/it/mixed-imports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - mixed-imports-chicory-it + mixed-imports-endive-it 0.0-SNAPSHOT jar @@ -14,27 +14,21 @@ - com.dylibso.chicory + run.endive annotations @project.version@ - com.dylibso.chicory + run.endive runtime @project.version@ - com.dylibso.chicory + run.endive annotations-processor @project.version@ provided - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -48,6 +42,12 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + @@ -61,7 +61,7 @@ ${maven.compiler.release} - com.dylibso.chicory + run.endive annotations-processor @project.version@ diff --git a/annotations/it/src/it/mixed-imports/src/test/java/chicory/test/MixedImportsTest.java b/annotations/it/src/it/mixed-imports/src/test/java/endive/test/MixedImportsTest.java similarity index 84% rename from annotations/it/src/it/mixed-imports/src/test/java/chicory/test/MixedImportsTest.java rename to annotations/it/src/it/mixed-imports/src/test/java/endive/test/MixedImportsTest.java index a84788a25..8331bafa2 100644 --- a/annotations/it/src/it/mixed-imports/src/test/java/chicory/test/MixedImportsTest.java +++ b/annotations/it/src/it/mixed-imports/src/test/java/endive/test/MixedImportsTest.java @@ -1,15 +1,15 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.types.MemoryLimits; import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Test; +import run.endive.annotations.WasmModuleInterface; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.wasm.Parser; +import run.endive.wasm.types.MemoryLimits; class MixedImportsTest { diff --git a/annotations/it/src/it/plugin-only-exports/pom.xml b/annotations/it/src/it/plugin-only-exports/pom.xml index 1ff062c64..02eb2b3bb 100644 --- a/annotations/it/src/it/plugin-only-exports/pom.xml +++ b/annotations/it/src/it/plugin-only-exports/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.dylibso.chicory + run.endive - plugin-only-exports-chicory-it + plugin-only-exports-endive-it 0.0-SNAPSHOT jar @@ -14,16 +14,10 @@ - com.dylibso.chicory + run.endive runtime @project.version@ - - com.dylibso.chicory - wasm-corpus - @project.version@ - test - org.junit.jupiter @@ -37,28 +31,16 @@ @junit.version@ test + + run.endive + wasm-corpus + @project.version@ + test + - - com.dylibso.chicory - chicory-compiler-maven-plugin - @project.version@ - - - compile-all-exports - - compile - - - chicory.test.AllExportsModule - src/test/resources/all-exports.wat.wasm - chicory.test.AllExportsWrapper - - - - org.apache.maven.plugins maven-compiler-plugin @@ -91,6 +73,24 @@ + + run.endive + endive-compiler-maven-plugin + @project.version@ + + + compile-all-exports + + compile + + + endive.test.AllExportsModule + src/test/resources/all-exports.wat.wasm + endive.test.AllExportsWrapper + + + + diff --git a/annotations/it/src/it/plugin-only-exports/src/test/java/chicory/test/PluginOnlyExportsTest.java b/annotations/it/src/it/plugin-only-exports/src/test/java/endive/test/PluginOnlyExportsTest.java similarity index 93% rename from annotations/it/src/it/plugin-only-exports/src/test/java/chicory/test/PluginOnlyExportsTest.java rename to annotations/it/src/it/plugin-only-exports/src/test/java/endive/test/PluginOnlyExportsTest.java index 1dfc6f830..6035392d0 100644 --- a/annotations/it/src/it/plugin-only-exports/src/test/java/chicory/test/PluginOnlyExportsTest.java +++ b/annotations/it/src/it/plugin-only-exports/src/test/java/endive/test/PluginOnlyExportsTest.java @@ -1,11 +1,11 @@ -package chicory.test; +package endive.test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.types.Value; import org.junit.jupiter.api.Test; +import run.endive.runtime.Instance; +import run.endive.wasm.types.Value; class PluginOnlyExportsTest { diff --git a/annotations/processor/pom.xml b/annotations/processor/pom.xml index 39d85ac32..0966cba80 100644 --- a/annotations/processor/pom.xml +++ b/annotations/processor/pom.xml @@ -3,38 +3,33 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../../pom.xml annotations-processor jar - Chicory - Annotations Processor + Endive - Annotations Processor Annotation processors for easy interoperability with Wasm modules - com.dylibso.chicory + com.github.javaparser + javaparser-core + + + run.endive annotations - com.dylibso.chicory + run.endive codegen - com.dylibso.chicory + run.endive wasm - - com.github.javaparser - javaparser-core - - - com.dylibso.chicory - runtime - test - com.google.testing.compile compile-testing @@ -50,6 +45,11 @@ junit-jupiter-engine test + + run.endive + runtime + test + @@ -66,8 +66,8 @@ maven-dependency-plugin - com.dylibso.chicory:runtime - com.dylibso.chicory:wasm + run.endive:runtime + run.endive:wasm diff --git a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/AbstractModuleProcessor.java b/annotations/processor/src/main/java/run/endive/annotations/processor/AbstractModuleProcessor.java similarity index 94% rename from annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/AbstractModuleProcessor.java rename to annotations/processor/src/main/java/run/endive/annotations/processor/AbstractModuleProcessor.java index 4149d6e9d..d6e427cf3 100644 --- a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/AbstractModuleProcessor.java +++ b/annotations/processor/src/main/java/run/endive/annotations/processor/AbstractModuleProcessor.java @@ -1,6 +1,5 @@ -package com.dylibso.chicory.annotations.processor; +package run.endive.annotations.processor; -import com.dylibso.chicory.codegen.CodegenUtils; import com.github.javaparser.printer.DefaultPrettyPrinter; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; @@ -10,6 +9,7 @@ import javax.lang.model.element.PackageElement; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; +import run.endive.codegen.CodegenUtils; public abstract class AbstractModuleProcessor extends AbstractProcessor { diff --git a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/HostModuleProcessor.java b/annotations/processor/src/main/java/run/endive/annotations/processor/HostModuleProcessor.java similarity index 95% rename from annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/HostModuleProcessor.java rename to annotations/processor/src/main/java/run/endive/annotations/processor/HostModuleProcessor.java index 61b18cf17..8400db446 100644 --- a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/HostModuleProcessor.java +++ b/annotations/processor/src/main/java/run/endive/annotations/processor/HostModuleProcessor.java @@ -1,14 +1,10 @@ -package com.dylibso.chicory.annotations.processor; +package run.endive.annotations.processor; import static com.github.javaparser.StaticJavaParser.parseType; import static java.lang.String.format; import static javax.tools.Diagnostic.Kind.ERROR; import static javax.tools.Diagnostic.Kind.NOTE; -import com.dylibso.chicory.annotations.Buffer; -import com.dylibso.chicory.annotations.CString; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; import com.github.javaparser.ast.ArrayCreationLevel; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.NodeList; @@ -43,6 +39,10 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; +import run.endive.annotations.Buffer; +import run.endive.annotations.CString; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; public final class HostModuleProcessor extends AbstractModuleProcessor { @@ -81,11 +81,11 @@ private void processModule(TypeElement type) { cu.setPackageDeclaration(packageName); cu.addImport(type.getQualifiedName().toString()); } - cu.addImport("com.dylibso.chicory.runtime.HostFunction"); - cu.addImport("com.dylibso.chicory.runtime.Instance"); - cu.addImport("com.dylibso.chicory.wasm.types.Value"); - cu.addImport("com.dylibso.chicory.wasm.types.FunctionType"); - cu.addImport("com.dylibso.chicory.wasm.types.ValType"); + cu.addImport("run.endive.runtime.HostFunction"); + cu.addImport("run.endive.runtime.Instance"); + cu.addImport("run.endive.wasm.types.Value"); + cu.addImport("run.endive.wasm.types.FunctionType"); + cu.addImport("run.endive.wasm.types.ValType"); cu.addImport("java.util.List"); var typeName = type.getSimpleName().toString(); @@ -193,10 +193,10 @@ private Expression processMethod(Element member, ExecutableElement executable) { throw new AbortProcessingException(); } break; - case "com.dylibso.chicory.runtime.Instance": + case "run.endive.runtime.Instance": arguments.add(new NameExpr("instance")); break; - case "com.dylibso.chicory.runtime.Memory": + case "run.endive.runtime.Memory": arguments.add(new MethodCallExpr(new NameExpr("instance"), "memory")); break; default: diff --git a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/WasmModuleProcessor.java b/annotations/processor/src/main/java/run/endive/annotations/processor/WasmModuleProcessor.java similarity index 92% rename from annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/WasmModuleProcessor.java rename to annotations/processor/src/main/java/run/endive/annotations/processor/WasmModuleProcessor.java index 6dcbe971c..b3cd46cd9 100644 --- a/annotations/processor/src/main/java/com/dylibso/chicory/annotations/processor/WasmModuleProcessor.java +++ b/annotations/processor/src/main/java/run/endive/annotations/processor/WasmModuleProcessor.java @@ -1,13 +1,9 @@ -package com.dylibso.chicory.annotations.processor; +package run.endive.annotations.processor; import static java.lang.String.format; import static javax.tools.Diagnostic.Kind.ERROR; import static javax.tools.Diagnostic.Kind.NOTE; -import com.dylibso.chicory.annotations.WasmModuleInterface; -import com.dylibso.chicory.codegen.ModuleInterfaceCodegen; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import com.github.javaparser.ast.CompilationUnit; import java.io.IOException; import java.io.Writer; @@ -20,6 +16,10 @@ import javax.lang.model.element.TypeElement; import javax.tools.FileObject; import javax.tools.StandardLocation; +import run.endive.annotations.WasmModuleInterface; +import run.endive.codegen.ModuleInterfaceCodegen; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; public final class WasmModuleProcessor extends AbstractModuleProcessor { diff --git a/annotations/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/annotations/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor index 65c82face..f19a2fd34 100644 --- a/annotations/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/annotations/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -1,2 +1,2 @@ -com.dylibso.chicory.annotations.processor.HostModuleProcessor -com.dylibso.chicory.annotations.processor.WasmModuleProcessor +run.endive.annotations.processor.HostModuleProcessor +run.endive.annotations.processor.WasmModuleProcessor diff --git a/annotations/processor/src/test/java/com/dylibso/chicory/annotations/processor/HostModuleProcessorTest.java b/annotations/processor/src/test/java/run/endive/annotations/processor/HostModuleProcessorTest.java similarity index 91% rename from annotations/processor/src/test/java/com/dylibso/chicory/annotations/processor/HostModuleProcessorTest.java rename to annotations/processor/src/test/java/run/endive/annotations/processor/HostModuleProcessorTest.java index cd92f9a60..63bef61e3 100644 --- a/annotations/processor/src/test/java/com/dylibso/chicory/annotations/processor/HostModuleProcessorTest.java +++ b/annotations/processor/src/test/java/run/endive/annotations/processor/HostModuleProcessorTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.annotations.processor; +package run.endive.annotations.processor; import static com.google.testing.compile.CompilationSubject.assertThat; import static com.google.testing.compile.Compiler.javac; @@ -22,15 +22,15 @@ void generateModules() { assertThat(compilation).succeededWithoutWarnings(); assertThat(compilation) - .generatedSourceFile("chicory.testing.BasicMath_ModuleFactory") + .generatedSourceFile("endive.testing.BasicMath_ModuleFactory") .hasSourceEquivalentTo(JavaFileObjects.forResource("BasicMathGenerated.java")); assertThat(compilation) - .generatedSourceFile("chicory.testing.Simple_ModuleFactory") + .generatedSourceFile("endive.testing.Simple_ModuleFactory") .hasSourceEquivalentTo(JavaFileObjects.forResource("SimpleGenerated.java")); assertThat(compilation) - .generatedSourceFile("chicory.testing.Nested_ModuleFactory") + .generatedSourceFile("endive.testing.Nested_ModuleFactory") .hasSourceEquivalentTo(JavaFileObjects.forResource("NestedGenerated.java")); assertThat(compilation) diff --git a/annotations/processor/src/test/resources/BasicMath.java b/annotations/processor/src/test/resources/BasicMath.java index 64b294bcc..cfd1196b8 100644 --- a/annotations/processor/src/test/resources/BasicMath.java +++ b/annotations/processor/src/test/resources/BasicMath.java @@ -1,8 +1,8 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; -import com.dylibso.chicory.runtime.HostFunction; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; +import run.endive.runtime.HostFunction; @HostModule("math") public final class BasicMath { diff --git a/annotations/processor/src/test/resources/BasicMathGenerated.java b/annotations/processor/src/test/resources/BasicMathGenerated.java index 35ba6eb97..8bb955770 100644 --- a/annotations/processor/src/test/resources/BasicMathGenerated.java +++ b/annotations/processor/src/test/resources/BasicMathGenerated.java @@ -1,15 +1,15 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Instance; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; import java.util.List; import javax.annotation.processing.Generated; -@Generated("com.dylibso.chicory.annotations.processor.HostModuleProcessor") +@Generated("run.endive.annotations.processor.HostModuleProcessor") public final class BasicMath_ModuleFactory { private BasicMath_ModuleFactory() { diff --git a/annotations/processor/src/test/resources/Box.java b/annotations/processor/src/test/resources/Box.java index defdc0ae4..63d75e495 100644 --- a/annotations/processor/src/test/resources/Box.java +++ b/annotations/processor/src/test/resources/Box.java @@ -1,10 +1,10 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Memory; +import run.endive.wasm.WasmEngineException; public class Box { @@ -18,7 +18,7 @@ public void print(Memory memory, int ptr, int len) { @WasmExport public void exit() { - throw new ChicoryException("exit"); + throw new WasmEngineException("exit"); } public HostFunction[] toHostFunctions() { diff --git a/annotations/processor/src/test/resources/InvalidParameterString.java b/annotations/processor/src/test/resources/InvalidParameterString.java index aac34d35d..13fd61bf2 100644 --- a/annotations/processor/src/test/resources/InvalidParameterString.java +++ b/annotations/processor/src/test/resources/InvalidParameterString.java @@ -1,7 +1,7 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; @HostModule("bad_param") public final class InvalidParameterString { diff --git a/annotations/processor/src/test/resources/InvalidParameterUnsupported.java b/annotations/processor/src/test/resources/InvalidParameterUnsupported.java index c1697fbab..877e37068 100644 --- a/annotations/processor/src/test/resources/InvalidParameterUnsupported.java +++ b/annotations/processor/src/test/resources/InvalidParameterUnsupported.java @@ -1,7 +1,7 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; import java.math.BigDecimal; @HostModule("bad_param") diff --git a/annotations/processor/src/test/resources/InvalidReturn.java b/annotations/processor/src/test/resources/InvalidReturn.java index fa0d42f4e..21a6660e1 100644 --- a/annotations/processor/src/test/resources/InvalidReturn.java +++ b/annotations/processor/src/test/resources/InvalidReturn.java @@ -1,7 +1,7 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; @HostModule("bad_return") public final class InvalidReturn { diff --git a/annotations/processor/src/test/resources/NestedGenerated.java b/annotations/processor/src/test/resources/NestedGenerated.java index 539dbe579..1e07ef69d 100644 --- a/annotations/processor/src/test/resources/NestedGenerated.java +++ b/annotations/processor/src/test/resources/NestedGenerated.java @@ -1,16 +1,16 @@ -package chicory.testing; +package endive.testing; -import chicory.testing.Box.Nested; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; +import endive.testing.Box.Nested; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Instance; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; import java.util.List; import javax.annotation.processing.Generated; -@Generated("com.dylibso.chicory.annotations.processor.HostModuleProcessor") +@Generated("run.endive.annotations.processor.HostModuleProcessor") public final class Nested_ModuleFactory { private Nested_ModuleFactory() { diff --git a/annotations/processor/src/test/resources/NoPackage.java b/annotations/processor/src/test/resources/NoPackage.java index 4f09c14dc..d068a522a 100644 --- a/annotations/processor/src/test/resources/NoPackage.java +++ b/annotations/processor/src/test/resources/NoPackage.java @@ -1,8 +1,8 @@ -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; +import run.endive.runtime.Memory; +import run.endive.runtime.HostFunction; +import run.endive.wasm.WasmEngineException; @HostModule("nopackage") public final class NoPackage { @@ -14,7 +14,7 @@ public void print(Memory memory, int ptr, int len) { @WasmExport public void exit() { - throw new ChicoryException("exit"); + throw new WasmEngineException("exit"); } public HostFunction[] toHostFunctions() { diff --git a/annotations/processor/src/test/resources/NoPackageGenerated.java b/annotations/processor/src/test/resources/NoPackageGenerated.java index 1c84c7246..1462685ae 100644 --- a/annotations/processor/src/test/resources/NoPackageGenerated.java +++ b/annotations/processor/src/test/resources/NoPackageGenerated.java @@ -1,13 +1,13 @@ -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Instance; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; import java.util.List; import javax.annotation.processing.Generated; -@Generated("com.dylibso.chicory.annotations.processor.HostModuleProcessor") +@Generated("run.endive.annotations.processor.HostModuleProcessor") public final class NoPackage_ModuleFactory { private NoPackage_ModuleFactory() { diff --git a/annotations/processor/src/test/resources/Simple.java b/annotations/processor/src/test/resources/Simple.java index fe25fd675..c968746ac 100644 --- a/annotations/processor/src/test/resources/Simple.java +++ b/annotations/processor/src/test/resources/Simple.java @@ -1,14 +1,14 @@ -package chicory.testing; +package endive.testing; import static java.util.Objects.requireNonNull; -import com.dylibso.chicory.annotations.Buffer; -import com.dylibso.chicory.annotations.CString; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.annotations.Buffer; +import run.endive.annotations.CString; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; +import run.endive.runtime.Memory; +import run.endive.runtime.HostFunction; +import run.endive.wasm.WasmEngineException; import java.util.Random; @HostModule("simple") @@ -39,7 +39,7 @@ public void randomGet(Memory memory, int ptr, int len) { @WasmExport public void exit() { - throw new ChicoryException("exit"); + throw new WasmEngineException("exit"); } public HostFunction[] toHostFunctions() { diff --git a/annotations/processor/src/test/resources/SimpleGenerated.java b/annotations/processor/src/test/resources/SimpleGenerated.java index 8f2707cca..055839733 100644 --- a/annotations/processor/src/test/resources/SimpleGenerated.java +++ b/annotations/processor/src/test/resources/SimpleGenerated.java @@ -1,15 +1,15 @@ -package chicory.testing; +package endive.testing; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Instance; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; import java.util.List; import javax.annotation.processing.Generated; -@Generated("com.dylibso.chicory.annotations.processor.HostModuleProcessor") +@Generated("run.endive.annotations.processor.HostModuleProcessor") public final class Simple_ModuleFactory { private Simple_ModuleFactory() { diff --git a/bom/pom.xml b/bom/pom.xml index 2e54a0461..0eeac4dae 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -3,94 +3,94 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT bom pom - Chicory - BOM + Endive - BOM Bill of Materials (BOM) - com.dylibso.chicory + run.endive annotations ${project.version} - com.dylibso.chicory + run.endive annotations-processor ${project.version} - com.dylibso.chicory + run.endive build-time-compiler ${project.version} - com.dylibso.chicory + run.endive build-time-compiler-cli-experimental ${project.version} - com.dylibso.chicory - chicory-compiler-maven-plugin - ${project.version} - - - com.dylibso.chicory + run.endive cli-experimental ${project.version} - com.dylibso.chicory + run.endive codegen ${project.version} - com.dylibso.chicory + run.endive compiler ${project.version} - com.dylibso.chicory + run.endive dircache-experimental ${project.version} - com.dylibso.chicory + run.endive + endive-compiler-maven-plugin + ${project.version} + + + run.endive log ${project.version} - com.dylibso.chicory + run.endive runtime ${project.version} - com.dylibso.chicory + run.endive simd ${project.version} - com.dylibso.chicory + run.endive wabt ${project.version} - com.dylibso.chicory + run.endive wasi ${project.version} - com.dylibso.chicory + run.endive wasm ${project.version} - com.dylibso.chicory + run.endive wasm-tools ${project.version} diff --git a/build-time-compiler-cli/pom.xml b/build-time-compiler-cli/pom.xml index 96af13f04..4c4fb01b3 100644 --- a/build-time-compiler-cli/pom.xml +++ b/build-time-compiler-cli/pom.xml @@ -3,33 +3,33 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT build-time-compiler-cli-experimental jar - Chicory - Build Time Compiler Cli - Chicory Build Time Compiler CLI + Endive - Build Time Compiler Cli + Endive Build Time Compiler CLI - com.dylibso.chicory + info.picocli + picocli + + + run.endive build-time-compiler - com.dylibso.chicory + run.endive compiler - com.dylibso.chicory + run.endive wasm - - info.picocli - picocli - @@ -79,7 +79,7 @@ - com.dylibso.chicory.experimental.compiler.cli.Cli + run.endive.experimental.compiler.cli.Cli false @@ -105,7 +105,7 @@ 2.1.1 -Xmx1G - chicory-compiler + endive-compiler true diff --git a/build-time-compiler-cli/src/main/java/com/dylibso/chicory/experimental/compiler/cli/Cli.java b/build-time-compiler-cli/src/main/java/run/endive/experimental/compiler/cli/Cli.java similarity index 87% rename from build-time-compiler-cli/src/main/java/com/dylibso/chicory/experimental/compiler/cli/Cli.java rename to build-time-compiler-cli/src/main/java/run/endive/experimental/compiler/cli/Cli.java index 8b6b6b00d..9e4245caa 100644 --- a/build-time-compiler-cli/src/main/java/com/dylibso/chicory/experimental/compiler/cli/Cli.java +++ b/build-time-compiler-cli/src/main/java/run/endive/experimental/compiler/cli/Cli.java @@ -1,20 +1,20 @@ -package com.dylibso.chicory.experimental.compiler.cli; +package run.endive.experimental.compiler.cli; -import com.dylibso.chicory.build.time.compiler.Config; -import com.dylibso.chicory.build.time.compiler.Generator; -import com.dylibso.chicory.compiler.InterpreterFallback; -import com.dylibso.chicory.wasm.Version; import java.io.IOException; import java.nio.file.Path; import java.util.Set; import picocli.CommandLine; +import run.endive.build.time.compiler.Config; +import run.endive.build.time.compiler.Generator; +import run.endive.compiler.InterpreterFallback; +import run.endive.wasm.Version; @CommandLine.Command( - name = "chicory-compiler", + name = "endive-compiler", versionProvider = Cli.VersionProvider.class, mixinStandardHelpOptions = true, helpCommand = true, - header = "A CLI to generate resources using the Chicory build-time compiler") + header = "A CLI to generate resources using the Endive build-time compiler") public class Cli implements Runnable { static final class VersionProvider implements CommandLine.IVersionProvider { @Override @@ -30,7 +30,7 @@ public String[] getVersion() { order = 1, names = "--prefix", description = "The prefix to be used to generate resources", - defaultValue = "com.dylibso.chicory.Wasm") + defaultValue = "run.endive.Wasm") String prefix; @CommandLine.Option( diff --git a/build-time-compiler/pom.xml b/build-time-compiler/pom.xml index cdb10da1e..89bf66cef 100644 --- a/build-time-compiler/pom.xml +++ b/build-time-compiler/pom.xml @@ -3,38 +3,38 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml build-time-compiler jar - Chicory - Build Time Compiler - Chicory Build Time Compiler + Endive - Build Time Compiler + Endive Build Time Compiler - com.dylibso.chicory + com.github.javaparser + javaparser-core + + + run.endive codegen - com.dylibso.chicory + run.endive compiler - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - - com.github.javaparser - javaparser-core - diff --git a/build-time-compiler/src/main/java/module-info.java b/build-time-compiler/src/main/java/module-info.java index fb1e96328..aeae8a7ee 100644 --- a/build-time-compiler/src/main/java/module-info.java +++ b/build-time-compiler/src/main/java/module-info.java @@ -1,9 +1,9 @@ -module com.dylibso.chicory.build.time.compiler { - requires transitive com.dylibso.chicory.compiler; - requires com.dylibso.chicory.codegen; - requires com.dylibso.chicory.runtime; - requires com.dylibso.chicory.wasm; +module run.endive.build.time.compiler { + requires transitive run.endive.compiler; + requires run.endive.codegen; + requires run.endive.runtime; + requires run.endive.wasm; requires com.github.javaparser.core; - exports com.dylibso.chicory.build.time.compiler; + exports run.endive.build.time.compiler; } diff --git a/build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Config.java b/build-time-compiler/src/main/java/run/endive/build/time/compiler/Config.java similarity index 97% rename from build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Config.java rename to build-time-compiler/src/main/java/run/endive/build/time/compiler/Config.java index 661ca846e..1aba2b9b9 100644 --- a/build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Config.java +++ b/build-time-compiler/src/main/java/run/endive/build/time/compiler/Config.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.build.time.compiler; +package run.endive.build.time.compiler; -import com.dylibso.chicory.compiler.InterpreterFallback; import java.nio.file.Path; import java.util.Set; import java.util.StringJoiner; +import run.endive.compiler.InterpreterFallback; public final class Config { /** diff --git a/build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Generator.java b/build-time-compiler/src/main/java/run/endive/build/time/compiler/Generator.java similarity index 94% rename from build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Generator.java rename to build-time-compiler/src/main/java/run/endive/build/time/compiler/Generator.java index 53df0c5f9..d0a79f1c3 100644 --- a/build-time-compiler/src/main/java/com/dylibso/chicory/build/time/compiler/Generator.java +++ b/build-time-compiler/src/main/java/run/endive/build/time/compiler/Generator.java @@ -1,23 +1,10 @@ -package com.dylibso.chicory.build.time.compiler; +package run.endive.build.time.compiler; -import static com.dylibso.chicory.wasm.Encoding.readVarUInt32; -import static com.dylibso.chicory.wasm.WasmWriter.writeVarUInt32; import static com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType; import static com.github.javaparser.StaticJavaParser.parseType; +import static run.endive.wasm.Encoding.readVarUInt32; +import static run.endive.wasm.WasmWriter.writeVarUInt32; -import com.dylibso.chicory.codegen.CodegenUtils; -import com.dylibso.chicory.codegen.ModuleInterfaceCodegen; -import com.dylibso.chicory.compiler.internal.ByteClassCollector; -import com.dylibso.chicory.compiler.internal.Compiler; -import com.dylibso.chicory.runtime.CompiledModule; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.WasmWriter; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.RawSection; -import com.dylibso.chicory.wasm.types.SectionId; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; @@ -46,6 +33,19 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; +import run.endive.codegen.CodegenUtils; +import run.endive.codegen.ModuleInterfaceCodegen; +import run.endive.compiler.internal.ByteClassCollector; +import run.endive.compiler.internal.Compiler; +import run.endive.runtime.CompiledModule; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.WasmWriter; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.RawSection; +import run.endive.wasm.types.SectionId; public class Generator { @@ -124,7 +124,7 @@ public void generateModuleInterface(String moduleInterfaceName) throws IOExcepti ModuleInterfaceCodegen.builder(module) .withPackageName(packageName) .withTypeName(typeName) - .withGeneratorName("com.dylibso.chicory.build.time.compiler.Generator") + .withGeneratorName("run.endive.build.time.compiler.Generator") .build(); var classes = codegen.generate(); diff --git a/chicory1.png b/chicory1.png deleted file mode 100644 index c876b8c59..000000000 Binary files a/chicory1.png and /dev/null differ diff --git a/cli/README.md b/cli/README.md index 99b78c24c..2d0cd0f4c 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,3 +1,3 @@ # Cli -This produces a CLI for executing Chicory on the command line. +This produces a CLI for executing Endive on the command line. diff --git a/cli/pom.xml b/cli/pom.xml index 09ec2fc06..75fa48fd6 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -3,33 +3,33 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT cli-experimental jar - Chicory - Cli - Experimental - A Chicory CLI + Endive - Cli - Experimental + A Endive CLI - com.dylibso.chicory + info.picocli + picocli + + + run.endive runtime - com.dylibso.chicory + run.endive wasi - com.dylibso.chicory + run.endive wasm - - info.picocli - picocli - @@ -64,7 +64,7 @@ - com.dylibso.chicory.experimental.cli.Cli + run.endive.experimental.cli.Cli false @@ -90,7 +90,7 @@ 2.1.1 -Xmx1G - chicory + endive true diff --git a/cli/src/main/java/com/dylibso/chicory/experimental/cli/Cli.java b/cli/src/main/java/run/endive/experimental/cli/Cli.java similarity index 92% rename from cli/src/main/java/com/dylibso/chicory/experimental/cli/Cli.java rename to cli/src/main/java/run/endive/experimental/cli/Cli.java index 02fb10954..c0012cd13 100644 --- a/cli/src/main/java/com/dylibso/chicory/experimental/cli/Cli.java +++ b/cli/src/main/java/run/endive/experimental/cli/Cli.java @@ -1,19 +1,19 @@ -package com.dylibso.chicory.experimental.cli; +package run.endive.experimental.cli; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.logging.LogManager; import picocli.CommandLine; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; @CommandLine.Command( - name = "chicory", + name = "endive", mixinStandardHelpOptions = true, helpCommand = true, header = "A pure Java WASM runtime available as a CLI.") diff --git a/codegen/pom.xml b/codegen/pom.xml index 838f47458..721667b6d 100644 --- a/codegen/pom.xml +++ b/codegen/pom.xml @@ -3,26 +3,26 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml codegen jar - Chicory - Codegen - Shared code generation utilities for Chicory annotation processor and build-time compiler + Endive - Codegen + Shared code generation utilities for Endive annotation processor and build-time compiler - - com.dylibso.chicory - wasm - com.github.javaparser javaparser-core + + run.endive + wasm + diff --git a/codegen/src/main/java/module-info.java b/codegen/src/main/java/module-info.java index b6d84f953..25a995b21 100644 --- a/codegen/src/main/java/module-info.java +++ b/codegen/src/main/java/module-info.java @@ -1,7 +1,7 @@ -module com.dylibso.chicory.codegen { +module run.endive.codegen { requires java.compiler; - requires com.dylibso.chicory.wasm; + requires run.endive.wasm; requires com.github.javaparser.core; - exports com.dylibso.chicory.codegen; + exports run.endive.codegen; } diff --git a/codegen/src/main/java/com/dylibso/chicory/codegen/CodegenUtils.java b/codegen/src/main/java/run/endive/codegen/CodegenUtils.java similarity index 97% rename from codegen/src/main/java/com/dylibso/chicory/codegen/CodegenUtils.java rename to codegen/src/main/java/run/endive/codegen/CodegenUtils.java index cc91d154b..38186d038 100644 --- a/codegen/src/main/java/com/dylibso/chicory/codegen/CodegenUtils.java +++ b/codegen/src/main/java/run/endive/codegen/CodegenUtils.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.codegen; +package run.endive.codegen; import static com.github.javaparser.printer.configuration.DefaultPrinterConfiguration.ConfigOption.COLUMN_ALIGN_PARAMETERS; diff --git a/codegen/src/main/java/com/dylibso/chicory/codegen/ModuleInterfaceCodegen.java b/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java similarity index 94% rename from codegen/src/main/java/com/dylibso/chicory/codegen/ModuleInterfaceCodegen.java rename to codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java index 57e0fb2ef..b9c41c04a 100644 --- a/codegen/src/main/java/com/dylibso/chicory/codegen/ModuleInterfaceCodegen.java +++ b/codegen/src/main/java/run/endive/codegen/ModuleInterfaceCodegen.java @@ -1,14 +1,8 @@ -package com.dylibso.chicory.codegen; +package run.endive.codegen; import static com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType; import static com.github.javaparser.StaticJavaParser.parseType; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionImport; -import com.dylibso.chicory.wasm.types.Import; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import com.github.javaparser.ast.ArrayCreationLevel; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; @@ -40,6 +34,12 @@ import java.util.Map; import java.util.stream.Collectors; import javax.annotation.processing.Generated; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionImport; +import run.endive.wasm.types.Import; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; public final class ModuleInterfaceCodegen { @@ -103,7 +103,7 @@ public Map generate() { String prefix = packageName.isEmpty() ? "" : packageName + "."; var exportsCu = newCu(); - exportsCu.addImport("com.dylibso.chicory.runtime.Instance"); + exportsCu.addImport("run.endive.runtime.Instance"); var processorName = new StringLiteralExpr(generatorName); var exportsClass = @@ -162,7 +162,7 @@ public Map generate() { var exportMethodBodyGen = exportMethodBodyGen(exportCallHandle, export.name()); if (export.exportType() == ExternalType.MEMORY) { - exportsCu.addImport("com.dylibso.chicory.runtime.Memory"); + exportsCu.addImport("run.endive.runtime.Memory"); exportsConstructor .getBody() @@ -176,7 +176,7 @@ public Map generate() { exportMethod.createBody().addStatement(new ReturnStmt(exportFieldName)); continue; } else if (export.exportType() == ExternalType.GLOBAL) { - exportsCu.addImport("com.dylibso.chicory.runtime.GlobalInstance"); + exportsCu.addImport("run.endive.runtime.GlobalInstance"); exportsConstructor .getBody() @@ -190,7 +190,7 @@ public Map generate() { exportMethod.createBody().addStatement(new ReturnStmt(exportFieldName)); continue; } else if (export.exportType() == ExternalType.TABLE) { - exportsCu.addImport("com.dylibso.chicory.runtime.TableInstance"); + exportsCu.addImport("run.endive.runtime.TableInstance"); exportsConstructor .getBody() @@ -206,7 +206,7 @@ public Map generate() { } // it should be a function here assert (export.exportType() == ExternalType.FUNCTION); - exportsCu.addImport("com.dylibso.chicory.runtime.ExportFunction"); + exportsCu.addImport("run.endive.runtime.ExportFunction"); var funcType = (export.index() >= functionImports.length) @@ -337,11 +337,11 @@ public Map generate() { importFunctionCall)); if (importedFun.importType() == ExternalType.MEMORY) { - cu.addImport("com.dylibso.chicory.runtime.Memory"); + cu.addImport("run.endive.runtime.Memory"); importMethod.setType("Memory"); importMethod.removeBody(); - importsCu.addImport("com.dylibso.chicory.runtime.ImportMemory"); + importsCu.addImport("run.endive.runtime.ImportMemory"); toImportValuesBody.addStatement( new MethodCallExpr( new NameExpr("imports"), @@ -349,11 +349,11 @@ public Map generate() { NodeList.nodeList(importObj.apply("ImportMemory")))); continue; } else if (importedFun.importType() == ExternalType.GLOBAL) { - cu.addImport("com.dylibso.chicory.runtime.GlobalInstance"); + cu.addImport("run.endive.runtime.GlobalInstance"); importMethod.setType("GlobalInstance"); importMethod.removeBody(); - importsCu.addImport("com.dylibso.chicory.runtime.ImportGlobal"); + importsCu.addImport("run.endive.runtime.ImportGlobal"); toImportValuesBody.addStatement( new MethodCallExpr( new NameExpr("imports"), @@ -361,11 +361,11 @@ public Map generate() { NodeList.nodeList(importObj.apply("ImportGlobal")))); continue; } else if (importedFun.importType() == ExternalType.TABLE) { - cu.addImport("com.dylibso.chicory.runtime.TableInstance"); + cu.addImport("run.endive.runtime.TableInstance"); importMethod.setType("TableInstance"); importMethod.removeBody(); - importsCu.addImport("com.dylibso.chicory.runtime.ImportTable"); + importsCu.addImport("run.endive.runtime.ImportTable"); toImportValuesBody.addStatement( new MethodCallExpr( new NameExpr("imports"), @@ -378,8 +378,8 @@ public Map generate() { // needed to generate the functions signatures importsCu.addImport(List.class); importsCu.addImport(ValType.class); - importsCu.addImport("com.dylibso.chicory.runtime.Instance"); - importsCu.addImport("com.dylibso.chicory.runtime.HostFunction"); + importsCu.addImport("run.endive.runtime.Instance"); + importsCu.addImport("run.endive.runtime.HostFunction"); var importType = module.typeSection() @@ -478,7 +478,7 @@ public Map generate() { var toImportValuesMethod = importsInterface.addMethod("toImportValues", Modifier.Keyword.DEFAULT); - importsCu.addImport("com.dylibso.chicory.runtime.ImportValues"); + importsCu.addImport("run.endive.runtime.ImportValues"); toImportValuesMethod.setType("ImportValues"); toImportValuesMethod.setBody(toImportValuesBody); } diff --git a/compiler-maven-plugin/pom.xml b/compiler-maven-plugin/pom.xml index 9a875bc30..223b8df00 100644 --- a/compiler-maven-plugin/pom.xml +++ b/compiler-maven-plugin/pom.xml @@ -3,23 +3,23 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml - chicory-compiler-maven-plugin + endive-compiler-maven-plugin maven-plugin - Chicory - Compiler Maven Plugin + Endive - Compiler Maven Plugin A Maven Plugin to compile at build time WASM to Java bytecode - com.dylibso.chicory + run.endive build-time-compiler - com.dylibso.chicory + run.endive compiler @@ -51,7 +51,7 @@ org.apache.maven.plugins maven-plugin-plugin - chicory + endive diff --git a/compiler-maven-plugin/src/main/java/com/dylibso/chicory/build/time/maven/ChicoryCompilerGenMojo.java b/compiler-maven-plugin/src/main/java/run/endive/build/time/maven/EndiveCompilerGenMojo.java similarity index 92% rename from compiler-maven-plugin/src/main/java/com/dylibso/chicory/build/time/maven/ChicoryCompilerGenMojo.java rename to compiler-maven-plugin/src/main/java/run/endive/build/time/maven/EndiveCompilerGenMojo.java index ba279c2df..5866a32ed 100644 --- a/compiler-maven-plugin/src/main/java/com/dylibso/chicory/build/time/maven/ChicoryCompilerGenMojo.java +++ b/compiler-maven-plugin/src/main/java/run/endive/build/time/maven/EndiveCompilerGenMojo.java @@ -1,8 +1,5 @@ -package com.dylibso.chicory.build.time.maven; +package run.endive.build.time.maven; -import com.dylibso.chicory.build.time.compiler.Config; -import com.dylibso.chicory.build.time.compiler.Generator; -import com.dylibso.chicory.compiler.InterpreterFallback; import java.io.File; import java.io.IOException; import java.util.Set; @@ -14,12 +11,15 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import run.endive.build.time.compiler.Config; +import run.endive.build.time.compiler.Generator; +import run.endive.compiler.InterpreterFallback; /** * This plugin generates an invokable library from the compiled Wasm */ @Mojo(name = "compile", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -public class ChicoryCompilerGenMojo extends AbstractMojo { +public class EndiveCompilerGenMojo extends AbstractMojo { /** * the wasm module to be used @@ -38,7 +38,7 @@ public class ChicoryCompilerGenMojo extends AbstractMojo { */ @Parameter( required = true, - defaultValue = "${project.build.directory}/generated-resources/chicory-compiler") + defaultValue = "${project.build.directory}/generated-resources/endive-compiler") private File targetClassFolder; /** @@ -46,7 +46,7 @@ public class ChicoryCompilerGenMojo extends AbstractMojo { */ @Parameter( required = true, - defaultValue = "${project.build.directory}/generated-sources/chicory-compiler") + defaultValue = "${project.build.directory}/generated-sources/endive-compiler") private File targetSourceFolder; /** @@ -54,7 +54,7 @@ public class ChicoryCompilerGenMojo extends AbstractMojo { */ @Parameter( required = true, - defaultValue = "${project.build.directory}/generated-resources/chicory-compiler") + defaultValue = "${project.build.directory}/generated-resources/endive-compiler") private File targetWasmFolder; /** diff --git a/compiler-tests/pom.xml b/compiler-tests/pom.xml index bb2fe7752..bb109d798 100644 --- a/compiler-tests/pom.xml +++ b/compiler-tests/pom.xml @@ -3,15 +3,15 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml compiler-tests jar - Chicory - Compiler tests + Endive - Compiler tests Spec tests for the compiler @@ -21,61 +21,71 @@ test - com.dylibso.chicory - build-time-compiler + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - compiler + org.junit.jupiter + junit-jupiter-engine test - com.dylibso.chicory - runtime + org.ow2.asm + asm test - com.dylibso.chicory - wabt + org.ow2.asm + asm-util test - com.dylibso.chicory - wasm + run.endive + build-time-compiler test - com.dylibso.chicory - wasm-corpus + run.endive + compiler test - org.junit.jupiter - junit-jupiter-api + run.endive + runtime test - org.junit.jupiter - junit-jupiter-engine + run.endive + wabt test - org.ow2.asm - asm + run.endive + wasm test - org.ow2.asm - asm-util + run.endive + wasm-corpus test + - com.dylibso.chicory + org.apache.maven.plugins + maven-surefire-plugin + + + true + + + + + run.endive test-gen-plugin ${project.version} @@ -429,16 +439,6 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - - - true - - - diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java b/compiler-tests/src/test/java/run/endive/testing/ArgsAdapter.java similarity index 95% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java rename to compiler-tests/src/test/java/run/endive/testing/ArgsAdapter.java index cfb01e5b5..dae93f93d 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java +++ b/compiler-tests/src/test/java/run/endive/testing/ArgsAdapter.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import java.util.ArrayDeque; diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ClassTooLargeTest.java b/compiler-tests/src/test/java/run/endive/testing/ClassTooLargeTest.java similarity index 91% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/ClassTooLargeTest.java rename to compiler-tests/src/test/java/run/endive/testing/ClassTooLargeTest.java index 9136048c2..66e24bfdf 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ClassTooLargeTest.java +++ b/compiler-tests/src/test/java/run/endive/testing/ClassTooLargeTest.java @@ -1,16 +1,16 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.corpus.WatGenerator.bigWat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.corpus.WatGenerator.bigWat; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.compiler.internal.Compiler; -import com.dylibso.chicory.runtime.ExportFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasm.Parser; import org.junit.jupiter.api.Test; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.compiler.internal.Compiler; +import run.endive.runtime.ExportFunction; +import run.endive.runtime.Instance; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasm.Parser; public class ClassTooLargeTest { diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ImplementsCompiledModuleTest.java b/compiler-tests/src/test/java/run/endive/testing/ImplementsCompiledModuleTest.java similarity index 72% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/ImplementsCompiledModuleTest.java rename to compiler-tests/src/test/java/run/endive/testing/ImplementsCompiledModuleTest.java index 5b3fefd54..ebd3cd065 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/ImplementsCompiledModuleTest.java +++ b/compiler-tests/src/test/java/run/endive/testing/ImplementsCompiledModuleTest.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.dylibso.chicory.runtime.CompiledModule; -import com.dylibso.chicory.wabt.Wat2WasmModule; import org.junit.jupiter.api.Test; +import run.endive.runtime.CompiledModule; +import run.endive.wabt.Wat2WasmModule; public class ImplementsCompiledModuleTest { diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/InterpreterFallbackTest.java b/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java similarity index 86% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/InterpreterFallbackTest.java rename to compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java index 64862808b..52db9cf82 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/InterpreterFallbackTest.java +++ b/compiler-tests/src/test/java/run/endive/testing/InterpreterFallbackTest.java @@ -1,26 +1,13 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.corpus.WatGenerator.methodTooLarge; import static java.lang.invoke.MethodHandleProxies.asInterfaceInstance; import static java.lang.invoke.MethodHandles.publicLookup; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.corpus.WatGenerator.methodTooLarge; -import com.dylibso.chicory.build.time.compiler.Config; -import com.dylibso.chicory.build.time.compiler.Generator; -import com.dylibso.chicory.compiler.InterpreterFallback; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -38,6 +25,19 @@ import org.approvaltests.core.Options; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import run.endive.build.time.compiler.Config; +import run.endive.build.time.compiler.Generator; +import run.endive.compiler.InterpreterFallback; +import run.endive.runtime.HostFunction; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; public class InterpreterFallbackTest { @@ -78,12 +78,12 @@ private void generateAll(Generator generator) throws IOException { public void testDefaultInterpreterFallback() throws IOException { var config = defaultConfig() - .withName("com.dylibso.chicory.testing.Test1") + .withName("run.endive.testing.Test1") // .withInterpreterFallback(InterpreterFallback.FAIL) .build(); var generator = new Generator(config); - var exception = assertThrows(ChicoryException.class, () -> generateAll(generator)); + var exception = assertThrows(WasmEngineException.class, () -> generateAll(generator)); assertTrue( exception.getMessage().contains(expectedMessageContent), @@ -94,7 +94,7 @@ public void testDefaultInterpreterFallback() throws IOException { public void testWarnInterpreterFallback() throws IOException { var config = defaultConfig() - .withName("com.dylibso.chicory.testing.Test2") + .withName("run.endive.testing.Test2") .withInterpreterFallback(InterpreterFallback.WARN) .build(); var generator = new Generator(config); @@ -108,7 +108,7 @@ public void testWarnInterpreterFallback() throws IOException { public void testSilentInterpreterFallback() throws IOException, ClassNotFoundException { var config = defaultConfig() - .withName("com.dylibso.chicory.testing.Test3") + .withName("run.endive.testing.Test3") .withInterpreterFallback(InterpreterFallback.SILENT) .build(); var generator = new Generator(config); @@ -122,7 +122,7 @@ public void testSilentInterpreterFallback() throws IOException, ClassNotFoundExc var url = classDir.toUri().toURL(); var cl = new URLClassLoader(new URL[] {url}); - var machineClass = cl.loadClass("com.dylibso.chicory.testing.Test3Machine"); + var machineClass = cl.loadClass("run.endive.testing.Test3Machine"); Function machineFactory = createMachineFactory(machineClass); var hostStackTrace = new ArrayList(); @@ -191,12 +191,12 @@ private boolean containsInOrder(List expected, List actual) { public void testFailWithInterpretedFunctions() throws IOException { var config = defaultConfig() - .withName("com.dylibso.chicory.testing.Test3") + .withName("run.endive.testing.Test3") .withInterpretedFunctions(Set.of(1)) .build(); var generator = new Generator(config); - var exception = assertThrows(ChicoryException.class, () -> generateAll(generator)); + var exception = assertThrows(WasmEngineException.class, () -> generateAll(generator)); assertTrue( exception.getMessage().contains(expectedMessageContent), @@ -207,7 +207,7 @@ public void testFailWithInterpretedFunctions() throws IOException { public void testWithInterpretedFunctionsOk() throws IOException { var config = defaultConfig() - .withName("com.dylibso.chicory.testing.Test3") + .withName("run.endive.testing.Test3") .withInterpretedFunctions(Set.of(1, 2)) .build(); var generator = new Generator(config); @@ -245,7 +245,7 @@ private Function createMachineFactory(Class machineClass) Function function = asInterfaceInstance(Function.class, handle); return function; } catch (ReflectiveOperationException e) { - throw new ChicoryException(e); + throw new WasmEngineException(e); } } diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/MethodTooLargeTest.java b/compiler-tests/src/test/java/run/endive/testing/MethodTooLargeTest.java similarity index 91% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/MethodTooLargeTest.java rename to compiler-tests/src/test/java/run/endive/testing/MethodTooLargeTest.java index 8fc975a2a..c29ef1611 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/MethodTooLargeTest.java +++ b/compiler-tests/src/test/java/run/endive/testing/MethodTooLargeTest.java @@ -1,13 +1,9 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.corpus.WatGenerator.methodTooLarge; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.objectweb.asm.Type.getInternalName; +import static run.endive.corpus.WatGenerator.methodTooLarge; -import com.dylibso.chicory.compiler.internal.Compiler; -import com.dylibso.chicory.compiler.internal.Shaded; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasm.Parser; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Map; @@ -18,6 +14,10 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.util.TraceClassVisitor; +import run.endive.compiler.internal.Compiler; +import run.endive.compiler.internal.Shaded; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasm.Parser; public class MethodTooLargeTest { diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/PackageSettings.java b/compiler-tests/src/test/java/run/endive/testing/PackageSettings.java similarity index 71% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/PackageSettings.java rename to compiler-tests/src/test/java/run/endive/testing/PackageSettings.java index 01770e325..14ba80062 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/PackageSettings.java +++ b/compiler-tests/src/test/java/run/endive/testing/PackageSettings.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; public class PackageSettings { public String ApprovalBaseDirectory = "../resources"; diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java b/compiler-tests/src/test/java/run/endive/testing/Spectest.java similarity index 84% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java rename to compiler-tests/src/test/java/run/endive/testing/Spectest.java index 9d89548c3..be3aca5da 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java +++ b/compiler-tests/src/test/java/run/endive/testing/Spectest.java @@ -1,24 +1,24 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.runtime.GlobalInstance; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.ImportGlobal; -import com.dylibso.chicory.runtime.ImportMemory; -import com.dylibso.chicory.runtime.ImportTable; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.runtime.WasmFunctionHandle; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.List; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.GlobalInstance; +import run.endive.runtime.HostFunction; +import run.endive.runtime.ImportGlobal; +import run.endive.runtime.ImportMemory; +import run.endive.runtime.ImportTable; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.TableInstance; +import run.endive.runtime.WasmFunctionHandle; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; // https://github.com/WebAssembly/spec/blob/ee82c8e50c5106e0cedada0a083d4cc4129034a2/interpreter/host/spectest.ml public final class Spectest { diff --git a/compiler-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java b/compiler-tests/src/test/java/run/endive/testing/TestModule.java similarity index 83% rename from compiler-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java rename to compiler-tests/src/test/java/run/endive/testing/TestModule.java index 181f3ea27..167043bb9 100644 --- a/compiler-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java +++ b/compiler-tests/src/test/java/run/endive/testing/TestModule.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.testing; +package run.endive.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; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasm.MalformedException; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import java.io.IOException; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Store; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasm.MalformedException; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; public class TestModule { diff --git a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt b/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt deleted file mode 100644 index 769db7dc7..000000000 --- a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt +++ /dev/null @@ -1,19 +0,0 @@ -com.dylibso.chicory.testing.Test3MachineShaded.callHostFunction -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_0 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_1 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.call_1 -com.dylibso.chicory.testing.Test3MachineMachineCall.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.runtime.InterpreterMachine.CALL_INDIRECT -com.dylibso.chicory.runtime.InterpreterMachine.eval -com.dylibso.chicory.runtime.InterpreterMachine.call -com.dylibso.chicory.runtime.internal.CompilerInterpreterMachine.call -com.dylibso.chicory.runtime.InterpreterMachine.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.testing.Test3MachineShaded.callIndirect -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_2 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_3 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.call_3 -com.dylibso.chicory.testing.Test3MachineMachineCall.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.runtime.Instance$Exports.lambda$function$0 \ No newline at end of file diff --git a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt b/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt deleted file mode 100644 index b01c5440e..000000000 --- a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt +++ /dev/null @@ -1,19 +0,0 @@ -com.dylibso.chicory.testing.Test3MachineShaded.callHostFunction -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_0 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_1 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.call_1 -com.dylibso.chicory.testing.Test3MachineMachineCall.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.runtime.internal.CompilerInterpreterMachine.CALL -com.dylibso.chicory.runtime.InterpreterMachine.eval -com.dylibso.chicory.runtime.InterpreterMachine.call -com.dylibso.chicory.runtime.internal.CompilerInterpreterMachine.call -com.dylibso.chicory.runtime.InterpreterMachine.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.testing.Test3MachineShaded.callIndirect -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_2 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.func_3 -com.dylibso.chicory.testing.Test3MachineFuncGroup_0.call_3 -com.dylibso.chicory.testing.Test3MachineMachineCall.call -com.dylibso.chicory.testing.Test3Machine.call -com.dylibso.chicory.runtime.Instance$Exports.lambda$function$0 \ No newline at end of file diff --git a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/MethodTooLargeTest.testBigFunc.approved.txt b/compiler-tests/src/test/resources/com/dylibso/chicory/testing/MethodTooLargeTest.testBigFunc.approved.txt deleted file mode 100644 index 9d155aa8a..000000000 --- a/compiler-tests/src/test/resources/com/dylibso/chicory/testing/MethodTooLargeTest.testBigFunc.approved.txt +++ /dev/null @@ -1,28 +0,0 @@ -private final Lcom/dylibso/chicory/runtime/Instance; instance - - private final Lcom/dylibso/chicory/runtime/internal/CompilerInterpreterMachine; compilerInterpreterMachine -} - - private final static Z memCopyWorkaround -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_2(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_2 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -} diff --git a/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt b/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt new file mode 100644 index 000000000..e378ab761 --- /dev/null +++ b/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback-indirect.approved.txt @@ -0,0 +1,19 @@ +run.endive.testing.Test3MachineShaded.callHostFunction +run.endive.testing.Test3MachineFuncGroup_0.func_0 +run.endive.testing.Test3MachineFuncGroup_0.func_1 +run.endive.testing.Test3MachineFuncGroup_0.call_1 +run.endive.testing.Test3MachineMachineCall.call +run.endive.testing.Test3Machine.call +run.endive.runtime.InterpreterMachine.CALL_INDIRECT +run.endive.runtime.InterpreterMachine.eval +run.endive.runtime.InterpreterMachine.call +run.endive.runtime.internal.CompilerInterpreterMachine.call +run.endive.runtime.InterpreterMachine.call +run.endive.testing.Test3Machine.call +run.endive.testing.Test3MachineShaded.callIndirect +run.endive.testing.Test3MachineFuncGroup_0.func_2 +run.endive.testing.Test3MachineFuncGroup_0.func_3 +run.endive.testing.Test3MachineFuncGroup_0.call_3 +run.endive.testing.Test3MachineMachineCall.call +run.endive.testing.Test3Machine.call +run.endive.runtime.Instance$Exports.lambda$function$0 \ No newline at end of file diff --git a/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt b/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt new file mode 100644 index 000000000..a68c3e51e --- /dev/null +++ b/compiler-tests/src/test/resources/run/endive/testing/InterpreterFallbackTest.testSilentInterpreterFallback.approved.txt @@ -0,0 +1,19 @@ +run.endive.testing.Test3MachineShaded.callHostFunction +run.endive.testing.Test3MachineFuncGroup_0.func_0 +run.endive.testing.Test3MachineFuncGroup_0.func_1 +run.endive.testing.Test3MachineFuncGroup_0.call_1 +run.endive.testing.Test3MachineMachineCall.call +run.endive.testing.Test3Machine.call +run.endive.runtime.internal.CompilerInterpreterMachine.CALL +run.endive.runtime.InterpreterMachine.eval +run.endive.runtime.InterpreterMachine.call +run.endive.runtime.internal.CompilerInterpreterMachine.call +run.endive.runtime.InterpreterMachine.call +run.endive.testing.Test3Machine.call +run.endive.testing.Test3MachineShaded.callIndirect +run.endive.testing.Test3MachineFuncGroup_0.func_2 +run.endive.testing.Test3MachineFuncGroup_0.func_3 +run.endive.testing.Test3MachineFuncGroup_0.call_3 +run.endive.testing.Test3MachineMachineCall.call +run.endive.testing.Test3Machine.call +run.endive.runtime.Instance$Exports.lambda$function$0 \ No newline at end of file diff --git a/compiler-tests/src/test/resources/run/endive/testing/MethodTooLargeTest.testBigFunc.approved.txt b/compiler-tests/src/test/resources/run/endive/testing/MethodTooLargeTest.testBigFunc.approved.txt new file mode 100644 index 000000000..58922d89c --- /dev/null +++ b/compiler-tests/src/test/resources/run/endive/testing/MethodTooLargeTest.testBigFunc.approved.txt @@ -0,0 +1,28 @@ +private final Lrun/endive/runtime/Instance; instance + + private final Lrun/endive/runtime/internal/CompilerInterpreterMachine; compilerInterpreterMachine +} + + private final static Z memCopyWorkaround +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_2(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_2 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +} diff --git a/compiler/pom.xml b/compiler/pom.xml index fe3c70a1f..f59d81546 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -3,26 +3,18 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml compiler jar - Chicory - Compiler + Endive - Compiler Wasm to Java bytecode compiler - - com.dylibso.chicory - runtime - - - com.dylibso.chicory - wasm - org.ow2.asm asm @@ -36,13 +28,16 @@ asm-util - com.approvaltests - approvaltests - test + run.endive + runtime - com.dylibso.chicory - wasm-corpus + run.endive + wasm + + + com.approvaltests + approvaltests test @@ -60,6 +55,11 @@ junit-jupiter-engine test + + run.endive + wasm-corpus + test + diff --git a/compiler/src/main/java/module-info.java b/compiler/src/main/java/module-info.java index 5946b91fc..98a1059d2 100644 --- a/compiler/src/main/java/module-info.java +++ b/compiler/src/main/java/module-info.java @@ -1,11 +1,11 @@ -module com.dylibso.chicory.compiler { - requires transitive com.dylibso.chicory.runtime; - requires transitive com.dylibso.chicory.wasm; +module run.endive.compiler { + requires transitive run.endive.runtime; + requires transitive run.endive.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; + exports run.endive.compiler; + exports run.endive.compiler.internal; + exports run.endive.experimental.aot; } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/Cache.java b/compiler/src/main/java/run/endive/compiler/Cache.java similarity index 93% rename from compiler/src/main/java/com/dylibso/chicory/compiler/Cache.java rename to compiler/src/main/java/run/endive/compiler/Cache.java index 75e47793d..efc44fdaf 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/Cache.java +++ b/compiler/src/main/java/run/endive/compiler/Cache.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler; +package run.endive.compiler; import java.io.IOException; diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/InterpreterFallback.java b/compiler/src/main/java/run/endive/compiler/InterpreterFallback.java similarity index 93% rename from compiler/src/main/java/com/dylibso/chicory/compiler/InterpreterFallback.java rename to compiler/src/main/java/run/endive/compiler/InterpreterFallback.java index 79a046117..e0445c64f 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/InterpreterFallback.java +++ b/compiler/src/main/java/run/endive/compiler/InterpreterFallback.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler; +package run.endive.compiler; /** * Enum representing the fallback behavior for when the compiler needs to fallback to using diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/MachineFactoryCompiler.java b/compiler/src/main/java/run/endive/compiler/MachineFactoryCompiler.java similarity index 93% rename from compiler/src/main/java/com/dylibso/chicory/compiler/MachineFactoryCompiler.java rename to compiler/src/main/java/run/endive/compiler/MachineFactoryCompiler.java index a1adc17d3..1fb842dc9 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/MachineFactoryCompiler.java +++ b/compiler/src/main/java/run/endive/compiler/MachineFactoryCompiler.java @@ -1,11 +1,5 @@ -package com.dylibso.chicory.compiler; - -import com.dylibso.chicory.compiler.internal.ClassLoadingCollector; -import com.dylibso.chicory.compiler.internal.MachineFactory; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.WasmModule; +package run.endive.compiler; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -18,6 +12,12 @@ import java.util.jar.JarEntry; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; +import run.endive.compiler.internal.ClassLoadingCollector; +import run.endive.compiler.internal.MachineFactory; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; /** * Compiles WASM function bodies to JVM byte code that can be used as a machine factory for {@link Instance}'s. @@ -84,12 +84,12 @@ public static Builder builder(WasmModule module) { public static final class Builder { private final WasmModule module; - private final com.dylibso.chicory.compiler.internal.Compiler.Builder compilerBuilder; + private final run.endive.compiler.internal.Compiler.Builder compilerBuilder; private Cache cache; private Builder(WasmModule module) { this.module = module; - this.compilerBuilder = com.dylibso.chicory.compiler.internal.Compiler.builder(module); + this.compilerBuilder = run.endive.compiler.internal.Compiler.builder(module); } public Builder withClassName(String className) { @@ -145,7 +145,7 @@ public Function compile() { return new MachineFactory(module, collector.machineFactory()); } catch (IOException e) { - throw new ChicoryException(e); + throw new WasmEngineException(e); } } } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ByteClassCollector.java b/compiler/src/main/java/run/endive/compiler/internal/ByteClassCollector.java similarity index 96% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/ByteClassCollector.java rename to compiler/src/main/java/run/endive/compiler/internal/ByteClassCollector.java index 592deb568..213c65555 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ByteClassCollector.java +++ b/compiler/src/main/java/run/endive/compiler/internal/ByteClassCollector.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import java.util.Collections; import java.util.HashMap; diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassCollector.java b/compiler/src/main/java/run/endive/compiler/internal/ClassCollector.java similarity index 92% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassCollector.java rename to compiler/src/main/java/run/endive/compiler/internal/ClassCollector.java index 249be60e7..335a7bf37 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassCollector.java +++ b/compiler/src/main/java/run/endive/compiler/internal/ClassCollector.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import java.util.Map; diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassLoadingCollector.java b/compiler/src/main/java/run/endive/compiler/internal/ClassLoadingCollector.java similarity index 94% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassLoadingCollector.java rename to compiler/src/main/java/run/endive/compiler/internal/ClassLoadingCollector.java index be07824a7..e593d382c 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ClassLoadingCollector.java +++ b/compiler/src/main/java/run/endive/compiler/internal/ClassLoadingCollector.java @@ -1,11 +1,8 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import static java.lang.invoke.MethodHandleProxies.asInterfaceInstance; import static java.lang.invoke.MethodHandles.publicLookup; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.ChicoryException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collections; @@ -15,6 +12,9 @@ import java.util.function.Function; import org.objectweb.asm.ClassReader; import org.objectweb.asm.util.CheckClassAdapter; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wasm.WasmEngineException; /** * A {@link ClassCollector} that stores the classes in an ordered map. @@ -103,7 +103,7 @@ private Function createMachineFactory(String name) { Function function = asInterfaceInstance(Function.class, handle); return function; } catch (ReflectiveOperationException e) { - throw new ChicoryException(e); + throw new WasmEngineException(e); } } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Compiler.java b/compiler/src/main/java/run/endive/compiler/internal/Compiler.java similarity index 92% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/Compiler.java rename to compiler/src/main/java/run/endive/compiler/internal/Compiler.java index 6420a5139..f3d3f4696 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Compiler.java +++ b/compiler/src/main/java/run/endive/compiler/internal/Compiler.java @@ -1,43 +1,5 @@ -package com.dylibso.chicory.compiler.internal; - -import static com.dylibso.chicory.compiler.internal.CompilerUtil.asmType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callDispatchMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callIndirectMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callIndirectMethodType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.classNameForCallIndirect; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.classNameForDispatch; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.defaultValue; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeFunction; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeStatic; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeVirtual; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitJvmToLong; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitLongToJvm; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.hasTooManyParameters; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.internalClassName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.jvmReturnType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.localType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.methodNameForFunc; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.methodTypeFor; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.rawMethodTypeFor; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.slotCount; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.valueMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.valueMethodType; -import static com.dylibso.chicory.compiler.internal.EmitterMap.EMITTERS; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.AOT_INTERPRETER_MACHINE_CALL; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.CALL_HOST_FUNCTION; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.CALL_INDIRECT; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.CALL_INDIRECT_ON_INTERPRETER; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.CHECK_INTERRUPTION; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.INSTANCE_MEMORY; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.INSTANCE_TABLE; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.TABLE_INSTANCE; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.TABLE_REQUIRED_REF; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.THROW_CALL_STACK_EXHAUSTED; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.THROW_INDIRECT_CALL_TYPE_MISMATCH; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.THROW_UNKNOWN_FUNCTION; -import static com.dylibso.chicory.compiler.internal.Shader.createShadedClass; -import static com.dylibso.chicory.compiler.internal.Shader.shadedClassRemapper; +package run.endive.compiler.internal; + import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.invoke.MethodType.methodType; @@ -52,20 +14,45 @@ import static org.objectweb.asm.Type.getMethodDescriptor; import static org.objectweb.asm.Type.getType; import static org.objectweb.asm.commons.InstructionAdapter.OBJECT_TYPE; +import static run.endive.compiler.internal.CompilerUtil.asmType; +import static run.endive.compiler.internal.CompilerUtil.callDispatchMethodName; +import static run.endive.compiler.internal.CompilerUtil.callIndirectMethodName; +import static run.endive.compiler.internal.CompilerUtil.callIndirectMethodType; +import static run.endive.compiler.internal.CompilerUtil.callMethodName; +import static run.endive.compiler.internal.CompilerUtil.classNameForCallIndirect; +import static run.endive.compiler.internal.CompilerUtil.classNameForDispatch; +import static run.endive.compiler.internal.CompilerUtil.defaultValue; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeFunction; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeStatic; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeVirtual; +import static run.endive.compiler.internal.CompilerUtil.emitJvmToLong; +import static run.endive.compiler.internal.CompilerUtil.emitLongToJvm; +import static run.endive.compiler.internal.CompilerUtil.hasTooManyParameters; +import static run.endive.compiler.internal.CompilerUtil.internalClassName; +import static run.endive.compiler.internal.CompilerUtil.jvmReturnType; +import static run.endive.compiler.internal.CompilerUtil.localType; +import static run.endive.compiler.internal.CompilerUtil.methodNameForFunc; +import static run.endive.compiler.internal.CompilerUtil.methodTypeFor; +import static run.endive.compiler.internal.CompilerUtil.rawMethodTypeFor; +import static run.endive.compiler.internal.CompilerUtil.slotCount; +import static run.endive.compiler.internal.CompilerUtil.valueMethodName; +import static run.endive.compiler.internal.CompilerUtil.valueMethodType; +import static run.endive.compiler.internal.EmitterMap.EMITTERS; +import static run.endive.compiler.internal.ShadedRefs.AOT_INTERPRETER_MACHINE_CALL; +import static run.endive.compiler.internal.ShadedRefs.CALL_HOST_FUNCTION; +import static run.endive.compiler.internal.ShadedRefs.CALL_INDIRECT; +import static run.endive.compiler.internal.ShadedRefs.CALL_INDIRECT_ON_INTERPRETER; +import static run.endive.compiler.internal.ShadedRefs.CHECK_INTERRUPTION; +import static run.endive.compiler.internal.ShadedRefs.INSTANCE_MEMORY; +import static run.endive.compiler.internal.ShadedRefs.INSTANCE_TABLE; +import static run.endive.compiler.internal.ShadedRefs.TABLE_INSTANCE; +import static run.endive.compiler.internal.ShadedRefs.TABLE_REQUIRED_REF; +import static run.endive.compiler.internal.ShadedRefs.THROW_CALL_STACK_EXHAUSTED; +import static run.endive.compiler.internal.ShadedRefs.THROW_INDIRECT_CALL_TYPE_MISMATCH; +import static run.endive.compiler.internal.ShadedRefs.THROW_UNKNOWN_FUNCTION; +import static run.endive.compiler.internal.Shader.createShadedClass; +import static run.endive.compiler.internal.Shader.shadedClassRemapper; -import com.dylibso.chicory.compiler.InterpreterFallback; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.WasmException; -import com.dylibso.chicory.runtime.internal.CompilerInterpreterMachine; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.ValType; import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.HashMap; @@ -84,10 +71,23 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; +import run.endive.compiler.InterpreterFallback; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.runtime.Memory; +import run.endive.runtime.WasmException; +import run.endive.runtime.internal.CompilerInterpreterMachine; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.ValType; public final class Compiler { - public static final String DEFAULT_CLASS_NAME = "com.dylibso.chicory.$gen.CompiledMachine"; + public static final String DEFAULT_CLASS_NAME = "run.endive.$gen.CompiledMachine"; private static final Type LONG_ARRAY_TYPE = Type.getType(long[].class); private static final Type INT_ARRAY_TYPE = Type.getType(int[].class); private static final Type AOT_INTERPRETER_MACHINE_TYPE = @@ -102,8 +102,7 @@ public final class Compiler { // C2 JIT's HugeMethodLimit (default 8KB) — methods exceeding this get degraded optimization. // Dispatch chunks are sized to stay under this limit for full C2 compilation. - private static final int HUGE_METHOD_LIMIT = - Integer.getInteger("chicory.hugeMethodLimit", 8000); + private static final int HUGE_METHOD_LIMIT = Integer.getInteger("endive.hugeMethodLimit", 8000); // Estimated upper bound: tableswitch offset (4) + label + invokestatic (~5) + areturn (1) + // overhead private static final int ESTIMATED_BYTES_PER_DISPATCH_ENTRY = 40; @@ -337,7 +336,7 @@ private void compileExtraClasses() { "Warning: using interpreted mode for " + functionDescription); break; case FAIL: - throw new ChicoryException( + throw new WasmEngineException( "WASM function size exceeds the Java method size limits and" + " cannot be compiled to Java bytecode. It can only be run" + " in the interpreter. Either reduce the size of the" @@ -623,7 +622,7 @@ private static RuntimeException handleMethodTooLarge( name += " (" + function + ")"; } } - return new ChicoryException( + return new WasmEngineException( String.format( "JVM bytecode too large for WASM method: %s size=%d", name, e.getCodeSize()), @@ -1442,7 +1441,7 @@ private void compileFunction( break; case IFEQ: if (visitedTargets.contains(ins.operand(0))) { - throw new ChicoryException("Unexpected backward jump"); + throw new WasmEngineException("Unexpected backward jump"); } asm.ifeq(labels.get(ins.operand(0))); break; @@ -1480,7 +1479,7 @@ private void compileFunction( default: var emitter = EMITTERS.get(ins.opcode()); if (emitter == null) { - throw new ChicoryException("Unhandled opcode: " + ins.opcode()); + throw new WasmEngineException("Unhandled opcode: " + ins.opcode()); } emitter.emit(ctx, ins, asm); } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerInstruction.java b/compiler/src/main/java/run/endive/compiler/internal/CompilerInstruction.java similarity index 96% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerInstruction.java rename to compiler/src/main/java/run/endive/compiler/internal/CompilerInstruction.java index e8a62e331..382b78c65 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerInstruction.java +++ b/compiler/src/main/java/run/endive/compiler/internal/CompilerInstruction.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import java.util.Arrays; import java.util.stream.LongStream; diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerOpCode.java b/compiler/src/main/java/run/endive/compiler/internal/CompilerOpCode.java similarity index 99% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerOpCode.java rename to compiler/src/main/java/run/endive/compiler/internal/CompilerOpCode.java index 63f4f1920..77193307e 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerOpCode.java +++ b/compiler/src/main/java/run/endive/compiler/internal/CompilerOpCode.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import com.dylibso.chicory.wasm.types.OpCode; import java.util.EnumMap; import java.util.Map; import java.util.Optional; +import run.endive.wasm.types.OpCode; enum CompilerOpCode { LABEL, diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerResult.java b/compiler/src/main/java/run/endive/compiler/internal/CompilerResult.java similarity index 93% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerResult.java rename to compiler/src/main/java/run/endive/compiler/internal/CompilerResult.java index 72bd975d9..680fa4763 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerResult.java +++ b/compiler/src/main/java/run/endive/compiler/internal/CompilerResult.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import java.util.Map; import java.util.Set; diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerUtil.java b/compiler/src/main/java/run/endive/compiler/internal/CompilerUtil.java similarity index 96% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerUtil.java rename to compiler/src/main/java/run/endive/compiler/internal/CompilerUtil.java index ade8cdd7e..ef6f8d878 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/CompilerUtil.java +++ b/compiler/src/main/java/run/endive/compiler/internal/CompilerUtil.java @@ -1,6 +1,5 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; import static java.lang.invoke.MethodType.methodType; import static java.util.stream.Collectors.joining; import static org.objectweb.asm.Type.DOUBLE_TYPE; @@ -9,13 +8,8 @@ import static org.objectweb.asm.Type.LONG_TYPE; import static org.objectweb.asm.Type.getInternalName; import static org.objectweb.asm.Type.getMethodDescriptor; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -24,6 +18,12 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; final class CompilerUtil { diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Context.java b/compiler/src/main/java/run/endive/compiler/internal/Context.java similarity index 90% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/Context.java rename to compiler/src/main/java/run/endive/compiler/internal/Context.java index 90ca45e7f..465fd5e1f 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Context.java +++ b/compiler/src/main/java/run/endive/compiler/internal/Context.java @@ -1,19 +1,19 @@ -package com.dylibso.chicory.compiler.internal; - -import static com.dylibso.chicory.compiler.internal.CompilerUtil.hasTooManyParameters; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.slotCount; - -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.TagImport; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.ValType; +package run.endive.compiler.internal; + +import static run.endive.compiler.internal.CompilerUtil.hasTooManyParameters; +import static run.endive.compiler.internal.CompilerUtil.slotCount; + import java.util.ArrayList; import java.util.List; import java.util.function.IntFunction; import java.util.stream.Collectors; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.TagImport; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.ValType; /** * Class for tracking context relevant to compiling a single function diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/EmitterMap.java b/compiler/src/main/java/run/endive/compiler/internal/EmitterMap.java similarity index 99% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/EmitterMap.java rename to compiler/src/main/java/run/endive/compiler/internal/EmitterMap.java index b7c6bb189..dc14c99b2 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/EmitterMap.java +++ b/compiler/src/main/java/run/endive/compiler/internal/EmitterMap.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import com.dylibso.chicory.runtime.OpcodeImpl; import java.util.Map; +import run.endive.runtime.OpcodeImpl; final class EmitterMap { diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Emitters.java b/compiler/src/main/java/run/endive/compiler/internal/Emitters.java similarity index 97% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/Emitters.java rename to compiler/src/main/java/run/endive/compiler/internal/Emitters.java index f50fd098b..40e768259 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Emitters.java +++ b/compiler/src/main/java/run/endive/compiler/internal/Emitters.java @@ -1,22 +1,5 @@ -package com.dylibso.chicory.compiler.internal; - -import static com.dylibso.chicory.compiler.internal.CompilerUtil.asmType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callIndirectMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.callIndirectMethodType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeFunction; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeStatic; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitInvokeVirtual; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitJvmToLong; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitLongToJvm; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.emitPop; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.hasTooManyParameters; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.jvmReturnType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.localType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.slotCount; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.valueMethodName; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.valueMethodType; -import static com.dylibso.chicory.compiler.internal.ShadedRefs.EXCEPTION_MATCHES; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; +package run.endive.compiler.internal; + import static java.lang.Double.longBitsToDouble; import static java.lang.Float.intBitsToFloat; import static org.objectweb.asm.Type.INT_TYPE; @@ -25,12 +8,24 @@ import static org.objectweb.asm.Type.getMethodDescriptor; import static org.objectweb.asm.Type.getType; import static org.objectweb.asm.commons.InstructionAdapter.OBJECT_TYPE; +import static run.endive.compiler.internal.CompilerUtil.asmType; +import static run.endive.compiler.internal.CompilerUtil.callIndirectMethodName; +import static run.endive.compiler.internal.CompilerUtil.callIndirectMethodType; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeFunction; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeStatic; +import static run.endive.compiler.internal.CompilerUtil.emitInvokeVirtual; +import static run.endive.compiler.internal.CompilerUtil.emitJvmToLong; +import static run.endive.compiler.internal.CompilerUtil.emitLongToJvm; +import static run.endive.compiler.internal.CompilerUtil.emitPop; +import static run.endive.compiler.internal.CompilerUtil.hasTooManyParameters; +import static run.endive.compiler.internal.CompilerUtil.jvmReturnType; +import static run.endive.compiler.internal.CompilerUtil.localType; +import static run.endive.compiler.internal.CompilerUtil.slotCount; +import static run.endive.compiler.internal.CompilerUtil.valueMethodName; +import static run.endive.compiler.internal.CompilerUtil.valueMethodType; +import static run.endive.compiler.internal.ShadedRefs.EXCEPTION_MATCHES; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.OpCodeIdentifier; -import com.dylibso.chicory.runtime.WasmException; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.EnumMap; @@ -40,6 +35,11 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.commons.InstructionAdapter; +import run.endive.runtime.Instance; +import run.endive.runtime.OpCodeIdentifier; +import run.endive.runtime.WasmException; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; final class Emitters { diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/MachineFactory.java b/compiler/src/main/java/run/endive/compiler/internal/MachineFactory.java similarity index 86% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/MachineFactory.java rename to compiler/src/main/java/run/endive/compiler/internal/MachineFactory.java index ebbb6364c..532699694 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/MachineFactory.java +++ b/compiler/src/main/java/run/endive/compiler/internal/MachineFactory.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import com.dylibso.chicory.runtime.CompiledModule; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.WasmModule; import java.util.function.Function; +import run.endive.runtime.CompiledModule; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wasm.WasmModule; /** * Machine factory implementation that AOT compiles function bodies. diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shaded.java b/compiler/src/main/java/run/endive/compiler/internal/Shaded.java similarity index 97% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shaded.java rename to compiler/src/main/java/run/endive/compiler/internal/Shaded.java index 6738ae857..38107d097 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shaded.java +++ b/compiler/src/main/java/run/endive/compiler/internal/Shaded.java @@ -1,26 +1,26 @@ -package com.dylibso.chicory.compiler.internal; - -import static com.dylibso.chicory.runtime.MemCopyWorkaround.shouldUseMemWorkaround; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; - -import com.dylibso.chicory.runtime.ChicoryInterruptedException; -import com.dylibso.chicory.runtime.ConstantEvaluators; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.MemCopyWorkaround; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.OpcodeImpl; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.runtime.TrapException; -import com.dylibso.chicory.runtime.WasmArray; -import com.dylibso.chicory.runtime.WasmException; -import com.dylibso.chicory.runtime.WasmI31Ref; -import com.dylibso.chicory.runtime.WasmRuntimeException; -import com.dylibso.chicory.runtime.WasmStruct; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.InvalidException; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; +package run.endive.compiler.internal; + +import static run.endive.runtime.MemCopyWorkaround.shouldUseMemWorkaround; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; + import java.util.Arrays; +import run.endive.runtime.ConstantEvaluators; +import run.endive.runtime.Instance; +import run.endive.runtime.MemCopyWorkaround; +import run.endive.runtime.Memory; +import run.endive.runtime.OpcodeImpl; +import run.endive.runtime.TableInstance; +import run.endive.runtime.TrapException; +import run.endive.runtime.WasmArray; +import run.endive.runtime.WasmException; +import run.endive.runtime.WasmI31Ref; +import run.endive.runtime.WasmInterruptedException; +import run.endive.runtime.WasmRuntimeException; +import run.endive.runtime.WasmStruct; +import run.endive.wasm.InvalidException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; /** * This class will get shaded into the compiled code. @@ -58,7 +58,7 @@ public static void setTailCallIndirect( int funcId = table.requiredRef(funcTableIdx); Instance refInstance = table.instance(funcTableIdx); if (refInstance != null && refInstance != instance) { - throw new ChicoryException( + throw new WasmEngineException( "Indirect tail-call to a different Machine implementation is not supported"); } int actualTypeIdx = instance.functionType(funcId); @@ -136,7 +136,7 @@ public static int i32_ge_u(int a, int b) { private static final boolean memCopyWorkaround; static { - var prop = System.getProperty("chicory.memCopyWorkaround"); + var prop = System.getProperty("endive.memCopyWorkaround"); if (prop != null) { memCopyWorkaround = Boolean.valueOf(prop); @@ -341,11 +341,11 @@ public static int getAddr(int base, int offset) { } public static RuntimeException throwCallStackExhausted(StackOverflowError e) { - throw new ChicoryException("call stack exhausted", e); + throw new WasmEngineException("call stack exhausted", e); } public static RuntimeException throwIndirectCallTypeMismatch() { - return new ChicoryException("indirect call type mismatch"); + return new WasmEngineException("indirect call type mismatch"); } public static RuntimeException throwOutOfBoundsMemoryAccess() { @@ -366,7 +366,7 @@ public static RuntimeException throwUnknownFunction(int index) { public static void checkInterruption() { if (Thread.currentThread().isInterrupted()) { - throw new ChicoryInterruptedException("Thread interrupted"); + throw new WasmInterruptedException("Thread interrupted"); } } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ShadedRefs.java b/compiler/src/main/java/run/endive/compiler/internal/ShadedRefs.java similarity index 99% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/ShadedRefs.java rename to compiler/src/main/java/run/endive/compiler/internal/ShadedRefs.java index e5a6ffa58..89b5420b0 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/ShadedRefs.java +++ b/compiler/src/main/java/run/endive/compiler/internal/ShadedRefs.java @@ -1,12 +1,12 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.runtime.WasmException; -import com.dylibso.chicory.runtime.internal.CompilerInterpreterMachine; -import com.dylibso.chicory.wasm.types.Element; import java.lang.reflect.Method; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.runtime.TableInstance; +import run.endive.runtime.WasmException; +import run.endive.runtime.internal.CompilerInterpreterMachine; +import run.endive.wasm.types.Element; public final class ShadedRefs { diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shader.java b/compiler/src/main/java/run/endive/compiler/internal/Shader.java similarity index 91% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shader.java rename to compiler/src/main/java/run/endive/compiler/internal/Shader.java index c52113b7d..7bdede4d1 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/Shader.java +++ b/compiler/src/main/java/run/endive/compiler/internal/Shader.java @@ -1,9 +1,8 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.internalClassName; import static org.objectweb.asm.Type.getInternalName; +import static run.endive.compiler.internal.CompilerUtil.internalClassName; -import com.dylibso.chicory.wasm.ChicoryException; import java.io.IOException; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; @@ -11,6 +10,7 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.commons.ClassRemapper; import org.objectweb.asm.commons.Remapper; +import run.endive.wasm.WasmEngineException; /** * The Shader class is responsible for creating a shaded version of the Shaded class. @@ -75,7 +75,7 @@ static byte[] getBytecode(Class clazz) { } return in.readAllBytes(); } catch (IOException e) { - throw new ChicoryException("Could not load bytecode for " + clazz, e); + throw new WasmEngineException("Could not load bytecode for " + clazz, e); } } } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/TypeStack.java b/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java similarity index 87% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/TypeStack.java rename to compiler/src/main/java/run/endive/compiler/internal/TypeStack.java index 60bb8d390..f5fc264bd 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/TypeStack.java +++ b/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java @@ -1,16 +1,16 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import static com.dylibso.chicory.wasm.types.Instruction.EMPTY_OPERANDS; +import static run.endive.wasm.types.Instruction.EMPTY_OPERANDS; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.ValType; import java.util.ArrayDeque; import java.util.Deque; import java.util.HashMap; import java.util.Map; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.ValType; final class TypeStack { diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmAnalyzer.java b/compiler/src/main/java/run/endive/compiler/internal/WasmAnalyzer.java similarity index 98% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmAnalyzer.java rename to compiler/src/main/java/run/endive/compiler/internal/WasmAnalyzer.java index 15b42c196..6c8522384 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmAnalyzer.java +++ b/compiler/src/main/java/run/endive/compiler/internal/WasmAnalyzer.java @@ -1,29 +1,13 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.hasTooManyParameters; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.localType; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.slotCount; -import static com.dylibso.chicory.compiler.internal.TypeStack.FUNCTION_SCOPE; import static java.util.Collections.reverse; import static java.util.stream.Collectors.toCollection; import static java.util.stream.Collectors.toUnmodifiableList; +import static run.endive.compiler.internal.CompilerUtil.hasTooManyParameters; +import static run.endive.compiler.internal.CompilerUtil.localType; +import static run.endive.compiler.internal.CompilerUtil.slotCount; +import static run.endive.compiler.internal.TypeStack.FUNCTION_SCOPE; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.CatchOpCode; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FieldType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionImport; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Global; -import com.dylibso.chicory.wasm.types.GlobalImport; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableImport; -import com.dylibso.chicory.wasm.types.ValType; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -35,6 +19,22 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.CatchOpCode; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FieldType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionImport; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Global; +import run.endive.wasm.types.GlobalImport; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableImport; +import run.endive.wasm.types.ValType; final class WasmAnalyzer { @@ -1595,7 +1595,7 @@ private void analyzeSimple( .build()); break; default: - throw new ChicoryException("Unhandled opcode: " + ins.opcode()); + throw new WasmEngineException("Unhandled opcode: " + ins.opcode()); } out.add(new CompilerInstruction(CompilerOpCode.of(ins.opcode()), ins.operands())); } diff --git a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmClassLoader.java b/compiler/src/main/java/run/endive/compiler/internal/WasmClassLoader.java similarity index 88% rename from compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmClassLoader.java rename to compiler/src/main/java/run/endive/compiler/internal/WasmClassLoader.java index 831974486..a9cade21a 100644 --- a/compiler/src/main/java/com/dylibso/chicory/compiler/internal/WasmClassLoader.java +++ b/compiler/src/main/java/run/endive/compiler/internal/WasmClassLoader.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import org.objectweb.asm.ClassReader; diff --git a/compiler/src/main/java/com/dylibso/chicory/experimental/aot/AotMachine.java b/compiler/src/main/java/run/endive/experimental/aot/AotMachine.java similarity index 58% rename from compiler/src/main/java/com/dylibso/chicory/experimental/aot/AotMachine.java rename to compiler/src/main/java/run/endive/experimental/aot/AotMachine.java index e88e53adf..a473a7bb0 100644 --- a/compiler/src/main/java/com/dylibso/chicory/experimental/aot/AotMachine.java +++ b/compiler/src/main/java/run/endive/experimental/aot/AotMachine.java @@ -1,16 +1,16 @@ -package com.dylibso.chicory.experimental.aot; +package run.endive.experimental.aot; -import com.dylibso.chicory.compiler.internal.MachineFactory; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.compiler.internal.MachineFactory; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.wasm.WasmEngineException; /** * Machine implementation that compiles WASM function bodies to JVM byte code. * All compilation is done in a single compile phase during instantiation. *

* This class is deprecated and will be removed in a future version. Please use - * the {@link com.dylibso.chicory.compiler.MachineFactoryCompiler} instead. + * the {@link run.endive.compiler.MachineFactoryCompiler} instead. */ @Deprecated(since = "1.4.0") public final class AotMachine implements Machine { @@ -20,7 +20,7 @@ public final class AotMachine implements Machine { /** * Creates a new AOT machine instance. *

- * Please use the {@link com.dylibso.chicory.compiler.MachineFactoryCompiler#compile(Instance)} method instead. + * Please use the {@link run.endive.compiler.MachineFactoryCompiler#compile(Instance)} method instead. * * @param instance the instance to use for the machine */ @@ -30,7 +30,7 @@ public AotMachine(Instance instance) { } @Override - public long[] call(int funcId, long[] args) throws ChicoryException { + public long[] call(int funcId, long[] args) throws WasmEngineException { return machine.call(funcId, args); } } diff --git a/compiler/src/test/java/com/dylibso/chicory/approvals/ApprovalTest.java b/compiler/src/test/java/run/endive/approvals/ApprovalTest.java similarity index 94% rename from compiler/src/test/java/com/dylibso/chicory/approvals/ApprovalTest.java rename to compiler/src/test/java/run/endive/approvals/ApprovalTest.java index 85a247b96..2db71273f 100644 --- a/compiler/src/test/java/com/dylibso/chicory/approvals/ApprovalTest.java +++ b/compiler/src/test/java/run/endive/approvals/ApprovalTest.java @@ -1,12 +1,9 @@ -package com.dylibso.chicory.approvals; +package run.endive.approvals; -import static com.dylibso.chicory.wasm.Parser.parse; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.objectweb.asm.Type.getInternalName; +import static run.endive.wasm.Parser.parse; -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; @@ -24,6 +21,9 @@ import org.junit.jupiter.api.Test; import org.objectweb.asm.ClassReader; import org.objectweb.asm.util.TraceClassVisitor; +import run.endive.compiler.internal.Compiler; +import run.endive.compiler.internal.Shaded; +import run.endive.corpus.CorpusResources; // To approve everything use the env var: `APPROVAL_TESTS_USE_REPORTER=AutoApproveReporter` public class ApprovalTest { @@ -42,7 +42,7 @@ public void verifyBrTable() { public void verifyLotsOfArgs() throws Exception { var destPath = Path.of( - "src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyLotsOfArgs.approved.txt"); + "src/test/resources/run/endive/approvals/ApprovalTest.verifyLotsOfArgs.approved.txt"); if (!Files.exists(destPath)) { Files.writeString(destPath, renderLotsOfArgs(), StandardOpenOption.CREATE_NEW); diff --git a/compiler/src/test/java/com/dylibso/chicory/approvals/PackageSettings.java b/compiler/src/test/java/run/endive/approvals/PackageSettings.java similarity index 70% rename from compiler/src/test/java/com/dylibso/chicory/approvals/PackageSettings.java rename to compiler/src/test/java/run/endive/approvals/PackageSettings.java index 584ae9e5d..f06274b3d 100644 --- a/compiler/src/test/java/com/dylibso/chicory/approvals/PackageSettings.java +++ b/compiler/src/test/java/run/endive/approvals/PackageSettings.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.approvals; +package run.endive.approvals; public class PackageSettings { public String ApprovalBaseDirectory = "../resources"; diff --git a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/CacheTest.java b/compiler/src/test/java/run/endive/compiler/internal/CacheTest.java similarity index 90% rename from compiler/src/test/java/com/dylibso/chicory/compiler/internal/CacheTest.java rename to compiler/src/test/java/run/endive/compiler/internal/CacheTest.java index 41dee9062..313d77a7c 100644 --- a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/CacheTest.java +++ b/compiler/src/test/java/run/endive/compiler/internal/CacheTest.java @@ -1,17 +1,17 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.compiler.Cache; -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 java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; +import run.endive.compiler.Cache; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class CacheTest { diff --git a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/CallTest.java b/compiler/src/test/java/run/endive/compiler/internal/CallTest.java similarity index 83% rename from compiler/src/test/java/com/dylibso/chicory/compiler/internal/CallTest.java rename to compiler/src/test/java/run/endive/compiler/internal/CallTest.java index 00c86c4f2..8787ac472 100644 --- a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/CallTest.java +++ b/compiler/src/test/java/run/endive/compiler/internal/CallTest.java @@ -1,12 +1,12 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; 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; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class CallTest { diff --git a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/ExceptionTest.java b/compiler/src/test/java/run/endive/compiler/internal/ExceptionTest.java similarity index 90% rename from compiler/src/test/java/com/dylibso/chicory/compiler/internal/ExceptionTest.java rename to compiler/src/test/java/run/endive/compiler/internal/ExceptionTest.java index 03ceb7e74..7972cc60b 100644 --- a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/ExceptionTest.java +++ b/compiler/src/test/java/run/endive/compiler/internal/ExceptionTest.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; 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; import java.util.HashMap; import java.util.Set; import org.junit.jupiter.api.Test; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; public class ExceptionTest { diff --git a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/InterruptionTest.java b/compiler/src/test/java/run/endive/compiler/internal/InterruptionTest.java similarity index 86% rename from compiler/src/test/java/com/dylibso/chicory/compiler/internal/InterruptionTest.java rename to compiler/src/test/java/run/endive/compiler/internal/InterruptionTest.java index b69cfe3f5..e1bec61fc 100644 --- a/compiler/src/test/java/com/dylibso/chicory/compiler/internal/InterruptionTest.java +++ b/compiler/src/test/java/run/endive/compiler/internal/InterruptionTest.java @@ -1,20 +1,20 @@ -package com.dylibso.chicory.compiler.internal; +package run.endive.compiler.internal; -import static com.dylibso.chicory.compiler.internal.CompilerUtil.methodNameForFunc; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.compiler.internal.CompilerUtil.methodNameForFunc; -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; -import com.dylibso.chicory.wasm.WasmModule; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Test; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; public class InterruptionTest { @Test @@ -55,7 +55,7 @@ private static void assertInterruption(Runnable function, int funcIdx) AtomicBoolean interrupted = new AtomicBoolean(); Runnable runnable = () -> { - var e = assertThrows(ChicoryException.class, function::run); + var e = assertThrows(WasmEngineException.class, function::run); assertEquals("Thread interrupted", e.getMessage()); interrupted.set(true); }; diff --git a/compiler/src/test/resources/ApprovalTest.verifyLotsOfArgs.approved.template b/compiler/src/test/resources/ApprovalTest.verifyLotsOfArgs.approved.template index c68a0d712..ea06e41f9 100644 --- a/compiler/src/test/resources/ApprovalTest.verifyLotsOfArgs.approved.template +++ b/compiler/src/test/resources/ApprovalTest.verifyLotsOfArgs.approved.template @@ -1,43 +1,43 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { - private final Lcom/dylibso/chicory/runtime/Instance; instance + private final Lrun/endive/runtime/Instance; instance - public (Lcom/dylibso/chicory/runtime/Instance;)V + public (Lrun/endive/runtime/Instance;)V ALOAD 0 INVOKESPECIAL java/lang/Object. ()V ALOAD 0 ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; RETURN public call(I[J)[J TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError L0 ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; ILOAD 1 ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J ARETURN L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; ATHROW - public static call_indirect_0(IIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V + public static call_indirect_0(IIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V ALOAD 5 ILOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; ASTORE 6 ALOAD 6 ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I ISTORE 7 ALOAD 6 ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; ASTORE 8 ALOAD 8 IFNULL L0 @@ -54,10 +54,10 @@ public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylib 0: L2 default: L3 L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I IRETURN L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; ATHROW L1 ICONST_2 @@ -75,25 +75,25 @@ public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylib ICONST_0 ILOAD 7 ALOAD 8 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J ICONST_0 LALOAD L2I IRETURN - public static call_indirect_1([JIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V + public static call_indirect_1([JIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V ALOAD 4 ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; ASTORE 5 ALOAD 5 ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I ISTORE 6 ALOAD 5 ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; ASTORE 7 ALOAD 7 IFNULL L0 @@ -109,26 +109,26 @@ public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylib 1: L2 default: L3 L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 ([JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 ([JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I IRETURN L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; ATHROW L1 ALOAD 0 ICONST_1 ILOAD 6 ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J ICONST_0 LALOAD L2I IRETURN } -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { +final class run/endive/$gen/CompiledMachineFuncGroup_0 { - public static func_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + public static func_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I ILOAD 0 LCONST_0 FCONST_0 @@ -139,7 +139,7 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { ICONST_0 #end ILOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V #foreach ($store in $istore) #set($store = 305 - $store) ISTORE $store @@ -162,12 +162,12 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { DUP ICONST_2 FLOAD 7 - INVOKESTATIC com/dylibso/chicory/wasm/types/Value.floatToLong (F)J + INVOKESTATIC run/endive/wasm/types/Value.floatToLong (F)J LASTORE DUP ICONST_3 DLOAD 8 - INVOKESTATIC com/dylibso/chicory/wasm/types/Value.doubleToLong (D)J + INVOKESTATIC run/endive/wasm/types/Value.doubleToLong (D)J LASTORE DUP ICONST_4 @@ -199,10 +199,10 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { #end ALOAD 2 ALOAD 3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 ([JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 ([JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I IRETURN - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J ALOAD 2 ICONST_0 LALOAD @@ -213,7 +213,7 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { L2I ALOAD 1 ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I I2L LSTORE 3 ICONST_1 @@ -224,7 +224,7 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { LASTORE ARETURN - public static func_1([JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + public static func_1([JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I ALOAD 0 ICONST_0 LALOAD @@ -237,12 +237,12 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { ALOAD 0 ICONST_2 LALOAD - INVOKESTATIC com/dylibso/chicory/wasm/types/Value.longToFloat (J)F + INVOKESTATIC run/endive/wasm/types/Value.longToFloat (J)F FSTORE 6 ALOAD 0 ICONST_3 LALOAD - INVOKESTATIC com/dylibso/chicory/wasm/types/Value.longToDouble (J)D + INVOKESTATIC run/endive/wasm/types/Value.longToDouble (J)D DSTORE 7 ALOAD 0 ICONST_4 @@ -277,11 +277,11 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { IADD IRETURN - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J ALOAD 2 ALOAD 1 ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 ([JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 ([JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I I2L LSTORE 3 ICONST_1 @@ -293,14 +293,14 @@ final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { ARETURN } -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { +final class run/endive/$gen/CompiledMachineMachineCall { public ()V ALOAD 0 INVOKESPECIAL java/lang/Object. ()V RETURN - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J ALOAD 0 ALOAD 1 ALOAD 3 @@ -310,13 +310,13 @@ final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { 1: L1 default: L2 L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J ARETURN L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J ARETURN L2 ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; ATHROW } diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.functions10.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.functions10.approved.txt deleted file mode 100644 index ef2b9723c..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.functions10.approved.txt +++ /dev/null @@ -1,455 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - 1: L3 - 2: L4 - 3: L5 - 4: L6 - 5: L7 - 6: L8 - 7: L9 - 8: L10 - 9: L11 - default: L12 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L4 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L5 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_3 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_4 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_5 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L8 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_6 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L9 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_7 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L10 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_8 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L11 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_9 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L12 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_1 - IADD - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_1(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_2 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_2(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_3 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_2(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_3(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_4 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_3(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_3 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_4(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_5 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_3 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_4(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_4 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1 { - - public static func_5(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 6 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_4 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_5(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_5 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_6(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 7 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_5 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_6(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_6 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_7(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 8 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_6 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_7(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_7 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_8(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 9 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_7 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_8(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_8 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_9(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 10 - IADD - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_8 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_9(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.func_9 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - 1: L1 - 2: L2 - 3: L3 - 4: L4 - 5: L5 - 6: L6 - 7: L7 - 8: L8 - 9: L9 - default: L10 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_2 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_3 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L4 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_4 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L5 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.call_5 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.call_6 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.call_7 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L8 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.call_8 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L9 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_1.call_9 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L10 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBrTable.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBrTable.approved.txt deleted file mode 100644 index dacc3ea0c..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBrTable.approved.txt +++ /dev/null @@ -1,144 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - TABLESWITCH - 0: L0 - 1: L1 - 2: L2 - default: L3 - L2 - BIPUSH 100 - IRETURN - L1 - BIPUSH 101 - IRETURN - L0 - BIPUSH 102 - IRETURN - L3 - BIPUSH 103 - IRETURN - L4 - ATHROW - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBranching.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBranching.approved.txt deleted file mode 100644 index b4b221598..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyBranching.approved.txt +++ /dev/null @@ -1,146 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ICONST_0 - ISTORE 3 - ILOAD 0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQZ (I)I - IFNE L0 - ILOAD 0 - ICONST_1 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQ (II)I - IFNE L1 - BIPUSH 7 - ISTORE 3 - GOTO L2 - L0 - BIPUSH 42 - ISTORE 3 - GOTO L2 - L1 - BIPUSH 99 - ISTORE 3 - L2 - ILOAD 3 - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyExceptions.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyExceptions.approved.txt deleted file mode 100644 index 74443839a..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyExceptions.approved.txt +++ /dev/null @@ -1,192 +0,0 @@ -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - TRYCATCHBLOCK L0 L1 L2 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L3 L4 L2 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L5 L6 L2 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L0 L1 L7 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L3 L4 L7 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L5 L6 L7 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L2 L8 L7 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L9 L10 L7 com/dylibso/chicory/runtime/WasmException - L0 - ILOAD 0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQZ (I)I - IFEQ L3 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.createWasmException ([JILcom/dylibso/chicory/runtime/Instance;)Lcom/dylibso/chicory/runtime/WasmException; - ATHROW - L1 - NOP - NOP - ATHROW - L3 - ILOAD 0 - ICONST_1 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQ (II)I - IFEQ L5 - ICONST_0 - NEWARRAY T_LONG - ICONST_1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.createWasmException ([JILcom/dylibso/chicory/runtime/Instance;)Lcom/dylibso/chicory/runtime/WasmException; - ATHROW - L4 - NOP - NOP - ATHROW - L5 - ICONST_0 - NEWARRAY T_LONG - ICONST_2 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.createWasmException ([JILcom/dylibso/chicory/runtime/Instance;)Lcom/dylibso/chicory/runtime/WasmException; - ATHROW - L6 - ATHROW - L11 - NOP - NOP - ATHROW - L2 - ASTORE 3 - ALOAD 3 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.exceptionMatches (Lcom/dylibso/chicory/runtime/WasmException;ILcom/dylibso/chicory/runtime/Instance;)Z - IFEQ L12 - GOTO L9 - L12 - ALOAD 3 - ATHROW - L8 - NOP - NOP - ATHROW - L9 - ICONST_3 - L10 - GOTO L13 - L7 - ASTORE 3 - ALOAD 3 - ICONST_1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.exceptionMatches (Lcom/dylibso/chicory/runtime/WasmException;ILcom/dylibso/chicory/runtime/Instance;)Z - IFEQ L14 - GOTO L15 - L14 - ALOAD 3 - ATHROW - L13 - IRETURN - L15 - ICONST_4 - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_1(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_NE (II)I - IFEQ L0 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.createWasmException ([JILcom/dylibso/chicory/runtime/Instance;)Lcom/dylibso/chicory/runtime/WasmException; - ATHROW - L0 - ICONST_0 - IRETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_2(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - TRYCATCHBLOCK L0 L1 L2 com/dylibso/chicory/runtime/WasmException - TRYCATCHBLOCK L0 L3 L4 com/dylibso/chicory/runtime/WasmException - L0 - ILOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - L1 - GOTO L3 - L2 - ASTORE 3 - ALOAD 3 - ATHROW - L3 - GOTO L5 - L4 - ASTORE 3 - ALOAD 3 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.exceptionMatches (Lcom/dylibso/chicory/runtime/WasmException;ILcom/dylibso/chicory/runtime/Instance;)Z - IFEQ L6 - GOTO L7 - L6 - ALOAD 3 - ATHROW - L5 - IRETURN - L7 - ICONST_1 - IRETURN - - public static call_2(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyFloat.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyFloat.approved.txt deleted file mode 100644 index 649dd6b4f..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyFloat.approved.txt +++ /dev/null @@ -1,109 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ILOAD 5 - ALOAD 6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - LDC 0.12345678F - LDC 0.123456789012345D - POP2 - POP - RETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyGc.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyGc.approved.txt deleted file mode 100644 index 6da85edf5..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyGc.approved.txt +++ /dev/null @@ -1,107 +0,0 @@ -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ILOAD 1 - ISTORE 5 - ISTORE 4 - ICONST_2 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 4 - I2L - LASTORE - DUP - ICONST_1 - ILOAD 5 - I2L - LASTORE - ICONST_0 - ALOAD 3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.structNew ([JILcom/dylibso/chicory/runtime/Instance;)I - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 2 - ICONST_1 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_1(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_0 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.structGet (IIILcom/dylibso/chicory/runtime/Instance;)J - L2I - IRETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_2(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - ICONST_0 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.structGet (IIILcom/dylibso/chicory/runtime/Instance;)J - L2I - ILOAD 0 - ICONST_0 - ICONST_1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.structGet (IIILcom/dylibso/chicory/runtime/Instance;)J - L2I - IADD - IRETURN - - public static call_2(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyHelloWasi.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyHelloWasi.approved.txt deleted file mode 100644 index f6273d905..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyHelloWasi.approved.txt +++ /dev/null @@ -1,231 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIIIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 7 - ILOAD 5 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 8 - ALOAD 8 - ILOAD 4 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 9 - ALOAD 8 - ILOAD 4 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 10 - ALOAD 10 - IFNULL L0 - ALOAD 10 - ALOAD 7 - IF_ACMPNE L1 - L0 - ILOAD 0 - ILOAD 1 - ILOAD 2 - ILOAD 3 - ALOAD 6 - ALOAD 7 - ILOAD 9 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_4 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - DUP - ICONST_1 - ILOAD 1 - I2L - LASTORE - DUP - ICONST_2 - ILOAD 2 - I2L - LASTORE - DUP - ICONST_3 - ILOAD 3 - I2L - LASTORE - ICONST_0 - ILOAD 9 - ALOAD 10 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN - - public static call_indirect_1(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 1: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_1 - ILOAD 5 - ALOAD 6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(IIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ALOAD 5 - ICONST_0 - ICONST_4 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - DUP - ICONST_1 - ILOAD 1 - I2L - LASTORE - DUP - ICONST_2 - ILOAD 2 - I2L - LASTORE - DUP - ICONST_3 - ILOAD 3 - I2L - LASTORE - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callHostFunction (Lcom/dylibso/chicory/runtime/Instance;I[J)[J - ICONST_0 - LALOAD - L2I - IRETURN - - public static func_1(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ICONST_0 - BIPUSH 8 - ICONST_0 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryWriteInt (IIILcom/dylibso/chicory/runtime/Memory;)V - ICONST_4 - BIPUSH 12 - ICONST_0 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryWriteInt (IIILcom/dylibso/chicory/runtime/Memory;)V - ICONST_1 - ICONST_0 - ICONST_1 - BIPUSH 20 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - POP - RETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - 1: L1 - default: L2 - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L0 - POP - POP - ILOAD 2 - ALOAD 3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callHostFunction (Lcom/dylibso/chicory/runtime/Instance;I[J)[J - ARETURN - L2 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32.approved.txt deleted file mode 100644 index 9f4134aba..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32.approved.txt +++ /dev/null @@ -1,133 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ILOAD 5 - ALOAD 6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - LDC -2147483648 - POP - ICONST_0 - POP - LDC 2147483647 - POP - LDC -9223372036854775808L - POP2 - LCONST_0 - POP2 - LDC 9223372036854775807L - POP2 - LDC -2147483647 - POP - LDC 2147483646 - POP - LDC -9223372036854775807L - POP2 - LDC 9223372036854775806L - POP2 - ICONST_M1 - POP - ICONST_1 - POP - LDC -1L - POP2 - LCONST_1 - POP2 - RETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32Renamed.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32Renamed.approved.txt deleted file mode 100644 index a8d904d8c..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyI32Renamed.approved.txt +++ /dev/null @@ -1,68 +0,0 @@ -public final class FOO implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD FOO.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD FOO.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC FOOMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC FOOShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC FOOShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC FOOFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC FOOShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ILOAD 5 - ALOAD 6 - INVOKESTATIC FOOShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyIterFact.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyIterFact.approved.txt deleted file mode 100644 index 157f882c0..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyIterFact.approved.txt +++ /dev/null @@ -1,148 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ICONST_0 - ISTORE 3 - ICONST_1 - ISTORE 3 - ILOAD 0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQZ (I)I - IFNE L0 - L1 - ILOAD 3 - ILOAD 0 - IMUL - ISTORE 3 - ILOAD 0 - ICONST_M1 - IADD - DUP - ISTORE 0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQZ (I)I - IFNE L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - GOTO L1 - L0 - ILOAD 3 - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyKitchenSink.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyKitchenSink.approved.txt deleted file mode 100644 index 60064cbcc..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyKitchenSink.approved.txt +++ /dev/null @@ -1,149 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - BIPUSH 10 - IADD - ICONST_1 - ISUB - BIPUSH 6 - IMUL - ICONST_2 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_DIV_S (II)I - BIPUSH 40 - IAND - BIPUSH 33 - IOR - BIPUSH 22 - IXOR - ICONST_2 - ISHL - ICONST_3 - ISHR - ICONST_4 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_ROTL (II)I - BIPUSH 6 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_ROTR (II)I - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EXTEND_8_S (I)I - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyMemory.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyMemory.approved.txt deleted file mode 100644 index 2941c3f66..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyMemory.approved.txt +++ /dev/null @@ -1,218 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN - - public static call_indirect_1(JIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)J - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 5 - ILOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 6 - ALOAD 6 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 7 - ALOAD 6 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 8 - ALOAD 8 - IFNULL L0 - ALOAD 8 - ALOAD 5 - IF_ACMPNE L1 - L0 - LLOAD 0 - ALOAD 4 - ALOAD 5 - ILOAD 7 - LOOKUPSWITCH - 1: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)J - LRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 0 - LASTORE - ICONST_1 - ILOAD 7 - ALOAD 8 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - LRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ICONST_0 - ILOAD 0 - ICONST_0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryWriteInt (IIILcom/dylibso/chicory/runtime/Memory;)V - ICONST_0 - ICONST_0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryReadInt (IILcom/dylibso/chicory/runtime/Memory;)I - IRETURN - L0 - ATHROW - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN - - public static func_1(JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)J - ICONST_0 - LLOAD 0 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryWriteLong (IJILcom/dylibso/chicory/runtime/Memory;)V - ICONST_0 - ICONST_0 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.memoryReadLong (IILcom/dylibso/chicory/runtime/Memory;)J - LRETURN - L0 - ATHROW - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (JLcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)J - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - 1: L1 - default: L2 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L2 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyStart.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyStart.approved.txt deleted file mode 100644 index fc203df52..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyStart.approved.txt +++ /dev/null @@ -1,178 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 4 - ILOAD 2 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 5 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 6 - ALOAD 5 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 7 - ALOAD 7 - IFNULL L0 - ALOAD 7 - ALOAD 4 - IF_ACMPNE L1 - L0 - ILOAD 0 - ALOAD 3 - ALOAD 4 - ILOAD 6 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - ICONST_0 - ILOAD 6 - ALOAD 7 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN - - public static call_indirect_1(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 1: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_1 - ILOAD 5 - ALOAD 6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 2 - ICONST_0 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callHostFunction (Lcom/dylibso/chicory/runtime/Instance;I[J)[J - RETURN - - public static func_1(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - BIPUSH 42 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (ILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - 1: L1 - default: L2 - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L0 - POP - POP - ILOAD 2 - ALOAD 3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callHostFunction (Lcom/dylibso/chicory/runtime/Instance;I[J)[J - ARETURN - L2 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTailCall.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTailCall.approved.txt deleted file mode 100644 index cb72e1104..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTailCall.approved.txt +++ /dev/null @@ -1,209 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L2 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - ASTORE 3 - L3 - ALOAD 3 - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.isTailCallPending ()Z - IFEQ L1 - POP - ALOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.tailCallFuncId ()I - ISTORE 1 - ALOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.tailCallArgs ()[J - ASTORE 2 - ALOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.clearTailCall ()V - GOTO L3 - L1 - ARETURN - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IIIIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 6 - ILOAD 4 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 7 - ALOAD 7 - ILOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 8 - ALOAD 7 - ILOAD 3 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 9 - ALOAD 9 - IFNULL L0 - ALOAD 9 - ALOAD 6 - IF_ACMPNE L1 - L0 - ILOAD 0 - ILOAD 1 - ILOAD 2 - ALOAD 5 - ALOAD 6 - ILOAD 8 - LOOKUPSWITCH - 0: L2 - default: L3 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - IRETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_3 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 0 - I2L - LASTORE - DUP - ICONST_1 - ILOAD 1 - I2L - LASTORE - DUP - ICONST_2 - ILOAD 2 - I2L - LASTORE - ICONST_0 - ILOAD 8 - ALOAD 9 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - ICONST_0 - LALOAD - L2I - IRETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - ILOAD 0 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQZ (I)I - IFEQ L0 - ILOAD 1 - GOTO L1 - L0 - ILOAD 0 - ICONST_1 - INVOKESTATIC com/dylibso/chicory/runtime/OpcodeImpl.I32_EQ (II)I - IFEQ L2 - ILOAD 2 - GOTO L1 - L2 - ILOAD 0 - ICONST_1 - ISUB - ILOAD 2 - ILOAD 1 - ILOAD 2 - IADD - ISTORE 7 - ISTORE 6 - ISTORE 5 - ICONST_3 - NEWARRAY T_LONG - DUP - ICONST_0 - ILOAD 5 - I2L - LASTORE - DUP - ICONST_1 - ILOAD 6 - I2L - LASTORE - DUP - ICONST_2 - ILOAD 7 - I2L - LASTORE - ICONST_0 - SWAP - ALOAD 4 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.setTailCall (I[JLcom/dylibso/chicory/runtime/Instance;)V - ICONST_0 - IRETURN - L1 - IRETURN - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 2 - ICONST_0 - LALOAD - L2I - ALOAD 2 - ICONST_1 - LALOAD - L2I - ALOAD 2 - ICONST_2 - LALOAD - L2I - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (IIILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)I - I2L - LSTORE 3 - ICONST_1 - NEWARRAY T_LONG - DUP - ICONST_0 - LLOAD 3 - LASTORE - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - default: L1 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTrap.approved.txt b/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTrap.approved.txt deleted file mode 100644 index 9eeb822f4..000000000 --- a/compiler/src/test/resources/com/dylibso/chicory/approvals/ApprovalTest.verifyTrap.approved.txt +++ /dev/null @@ -1,152 +0,0 @@ -public final class com/dylibso/chicory/$gen/CompiledMachine implements com/dylibso/chicory/runtime/Machine { - - private final Lcom/dylibso/chicory/runtime/Instance; instance - - public (Lcom/dylibso/chicory/runtime/Instance;)V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - ALOAD 0 - ALOAD 1 - PUTFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - RETURN - - public call(I[J)[J - TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError - L0 - ALOAD 0 - GETFIELD com/dylibso/chicory/$gen/CompiledMachine.instance : Lcom/dylibso/chicory/runtime/Instance; - DUP - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.memory ()Lcom/dylibso/chicory/runtime/Memory; - ILOAD 1 - ALOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineMachineCall.call (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; - ATHROW - - public static call_indirect_0(IILcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 3 - ILOAD 1 - INVOKEVIRTUAL com/dylibso/chicory/runtime/Instance.table (I)Lcom/dylibso/chicory/runtime/TableInstance; - ASTORE 4 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.requiredRef (I)I - ISTORE 5 - ALOAD 4 - ILOAD 0 - INVOKEVIRTUAL com/dylibso/chicory/runtime/TableInstance.instance (I)Lcom/dylibso/chicory/runtime/Instance; - ASTORE 6 - ALOAD 6 - IFNULL L0 - ALOAD 6 - ALOAD 3 - IF_ACMPNE L1 - L0 - ALOAD 2 - ALOAD 3 - ILOAD 5 - LOOKUPSWITCH - 0: L2 - 1: L3 - 2: L4 - default: L5 - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L3 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L4 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - L5 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; - ATHROW - L1 - ICONST_0 - NEWARRAY T_LONG - ICONST_0 - ILOAD 5 - ALOAD 6 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.callIndirect ([JIILcom/dylibso/chicory/runtime/Instance;)[J - RETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0 { - - public static func_0(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwTrapException ()Ljava/lang/RuntimeException; - ATHROW - L0 - ATHROW - - public static call_0(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN - - public static func_1(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_0 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - - public static call_1(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN - - public static func_2(Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.checkInterruption ()V - ALOAD 0 - ALOAD 1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_1 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - RETURN - - public static call_2(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ALOAD 1 - ALOAD 0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.func_2 (Lcom/dylibso/chicory/runtime/Memory;Lcom/dylibso/chicory/runtime/Instance;)V - ACONST_NULL - ARETURN -} - -final class com/dylibso/chicory/$gen/CompiledMachineMachineCall { - - public ()V - ALOAD 0 - INVOKESPECIAL java/lang/Object. ()V - RETURN - - public static call(Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;I[J)[J - ALOAD 0 - ALOAD 1 - ALOAD 3 - ILOAD 2 - TABLESWITCH - 0: L0 - 1: L1 - 2: L2 - default: L3 - L0 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_0 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L1 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_1 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineFuncGroup_0.call_2 (Lcom/dylibso/chicory/runtime/Instance;Lcom/dylibso/chicory/runtime/Memory;[J)[J - ARETURN - L3 - ILOAD 2 - INVOKESTATIC com/dylibso/chicory/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; - ATHROW -} diff --git a/compiler/src/test/resources/com/dylibso/chicory/approvals/.gitignore b/compiler/src/test/resources/run/endive/approvals/.gitignore similarity index 100% rename from compiler/src/test/resources/com/dylibso/chicory/approvals/.gitignore rename to compiler/src/test/resources/run/endive/approvals/.gitignore diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.functions10.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.functions10.approved.txt new file mode 100644 index 000000000..776e13b08 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.functions10.approved.txt @@ -0,0 +1,455 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + 1: L3 + 2: L4 + 3: L5 + 4: L6 + 5: L7 + 6: L8 + 7: L9 + 8: L10 + 9: L11 + default: L12 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L4 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L5 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_3 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L6 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_4 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L7 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_5 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L8 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_6 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L9 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_7 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L10 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_8 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L11 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_9 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L12 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_1 + IADD + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_1(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_2 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_2(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_3 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_2(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_3(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_4 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_3(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_3 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_4(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_5 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_3 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_4(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_4 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_1 { + + public static func_5(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 6 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_4 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_5(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_5 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_6(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 7 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_5 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_6(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_6 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_7(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 8 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_6 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_7(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_7 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_8(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 9 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_7 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_8(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_8 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_9(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 10 + IADD + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_8 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + + public static call_9(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.func_9 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + 1: L1 + 2: L2 + 3: L3 + 4: L4 + 5: L5 + 6: L6 + 7: L7 + 8: L8 + 9: L9 + default: L10 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_2 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_3 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L4 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_4 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L5 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.call_5 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L6 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.call_6 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L7 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.call_7 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L8 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.call_8 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L9 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_1.call_9 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L10 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBrTable.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBrTable.approved.txt new file mode 100644 index 000000000..65c1516f8 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBrTable.approved.txt @@ -0,0 +1,144 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + TABLESWITCH + 0: L0 + 1: L1 + 2: L2 + default: L3 + L2 + BIPUSH 100 + IRETURN + L1 + BIPUSH 101 + IRETURN + L0 + BIPUSH 102 + IRETURN + L3 + BIPUSH 103 + IRETURN + L4 + ATHROW + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBranching.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBranching.approved.txt new file mode 100644 index 000000000..3ddbf9272 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyBranching.approved.txt @@ -0,0 +1,146 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ICONST_0 + ISTORE 3 + ILOAD 0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQZ (I)I + IFNE L0 + ILOAD 0 + ICONST_1 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQ (II)I + IFNE L1 + BIPUSH 7 + ISTORE 3 + GOTO L2 + L0 + BIPUSH 42 + ISTORE 3 + GOTO L2 + L1 + BIPUSH 99 + ISTORE 3 + L2 + ILOAD 3 + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyExceptions.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyExceptions.approved.txt new file mode 100644 index 000000000..77e775c09 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyExceptions.approved.txt @@ -0,0 +1,192 @@ +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + TRYCATCHBLOCK L0 L1 L2 run/endive/runtime/WasmException + TRYCATCHBLOCK L3 L4 L2 run/endive/runtime/WasmException + TRYCATCHBLOCK L5 L6 L2 run/endive/runtime/WasmException + TRYCATCHBLOCK L0 L1 L7 run/endive/runtime/WasmException + TRYCATCHBLOCK L3 L4 L7 run/endive/runtime/WasmException + TRYCATCHBLOCK L5 L6 L7 run/endive/runtime/WasmException + TRYCATCHBLOCK L2 L8 L7 run/endive/runtime/WasmException + TRYCATCHBLOCK L9 L10 L7 run/endive/runtime/WasmException + L0 + ILOAD 0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQZ (I)I + IFEQ L3 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.createWasmException ([JILrun/endive/runtime/Instance;)Lrun/endive/runtime/WasmException; + ATHROW + L1 + NOP + NOP + ATHROW + L3 + ILOAD 0 + ICONST_1 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQ (II)I + IFEQ L5 + ICONST_0 + NEWARRAY T_LONG + ICONST_1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.createWasmException ([JILrun/endive/runtime/Instance;)Lrun/endive/runtime/WasmException; + ATHROW + L4 + NOP + NOP + ATHROW + L5 + ICONST_0 + NEWARRAY T_LONG + ICONST_2 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.createWasmException ([JILrun/endive/runtime/Instance;)Lrun/endive/runtime/WasmException; + ATHROW + L6 + ATHROW + L11 + NOP + NOP + ATHROW + L2 + ASTORE 3 + ALOAD 3 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.exceptionMatches (Lrun/endive/runtime/WasmException;ILrun/endive/runtime/Instance;)Z + IFEQ L12 + GOTO L9 + L12 + ALOAD 3 + ATHROW + L8 + NOP + NOP + ATHROW + L9 + ICONST_3 + L10 + GOTO L13 + L7 + ASTORE 3 + ALOAD 3 + ICONST_1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.exceptionMatches (Lrun/endive/runtime/WasmException;ILrun/endive/runtime/Instance;)Z + IFEQ L14 + GOTO L15 + L14 + ALOAD 3 + ATHROW + L13 + IRETURN + L15 + ICONST_4 + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_1(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_NE (II)I + IFEQ L0 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.createWasmException ([JILrun/endive/runtime/Instance;)Lrun/endive/runtime/WasmException; + ATHROW + L0 + ICONST_0 + IRETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_2(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + TRYCATCHBLOCK L0 L1 L2 run/endive/runtime/WasmException + TRYCATCHBLOCK L0 L3 L4 run/endive/runtime/WasmException + L0 + ILOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + L1 + GOTO L3 + L2 + ASTORE 3 + ALOAD 3 + ATHROW + L3 + GOTO L5 + L4 + ASTORE 3 + ALOAD 3 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.exceptionMatches (Lrun/endive/runtime/WasmException;ILrun/endive/runtime/Instance;)Z + IFEQ L6 + GOTO L7 + L6 + ALOAD 3 + ATHROW + L5 + IRETURN + L7 + ICONST_1 + IRETURN + + public static call_2(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyFloat.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyFloat.approved.txt new file mode 100644 index 000000000..b2426373d --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyFloat.approved.txt @@ -0,0 +1,109 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ILOAD 5 + ALOAD 6 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + LDC 0.12345678F + LDC 0.123456789012345D + POP2 + POP + RETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyGc.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyGc.approved.txt new file mode 100644 index 000000000..926ddb655 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyGc.approved.txt @@ -0,0 +1,107 @@ +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ILOAD 1 + ISTORE 5 + ISTORE 4 + ICONST_2 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 4 + I2L + LASTORE + DUP + ICONST_1 + ILOAD 5 + I2L + LASTORE + ICONST_0 + ALOAD 3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.structNew ([JILrun/endive/runtime/Instance;)I + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 2 + ICONST_1 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_1(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_0 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.structGet (IIILrun/endive/runtime/Instance;)J + L2I + IRETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_2(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + ICONST_0 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.structGet (IIILrun/endive/runtime/Instance;)J + L2I + ILOAD 0 + ICONST_0 + ICONST_1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.structGet (IIILrun/endive/runtime/Instance;)J + L2I + IADD + IRETURN + + public static call_2(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyHelloWasi.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyHelloWasi.approved.txt new file mode 100644 index 000000000..0bf4dd66e --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyHelloWasi.approved.txt @@ -0,0 +1,231 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIIIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 7 + ILOAD 5 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 8 + ALOAD 8 + ILOAD 4 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 9 + ALOAD 8 + ILOAD 4 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 10 + ALOAD 10 + IFNULL L0 + ALOAD 10 + ALOAD 7 + IF_ACMPNE L1 + L0 + ILOAD 0 + ILOAD 1 + ILOAD 2 + ILOAD 3 + ALOAD 6 + ALOAD 7 + ILOAD 9 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_4 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + DUP + ICONST_1 + ILOAD 1 + I2L + LASTORE + DUP + ICONST_2 + ILOAD 2 + I2L + LASTORE + DUP + ICONST_3 + ILOAD 3 + I2L + LASTORE + ICONST_0 + ILOAD 9 + ALOAD 10 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN + + public static call_indirect_1(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 1: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_1 + ILOAD 5 + ALOAD 6 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(IIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ALOAD 5 + ICONST_0 + ICONST_4 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + DUP + ICONST_1 + ILOAD 1 + I2L + LASTORE + DUP + ICONST_2 + ILOAD 2 + I2L + LASTORE + DUP + ICONST_3 + ILOAD 3 + I2L + LASTORE + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callHostFunction (Lrun/endive/runtime/Instance;I[J)[J + ICONST_0 + LALOAD + L2I + IRETURN + + public static func_1(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ICONST_0 + BIPUSH 8 + ICONST_0 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryWriteInt (IIILrun/endive/runtime/Memory;)V + ICONST_4 + BIPUSH 12 + ICONST_0 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryWriteInt (IIILrun/endive/runtime/Memory;)V + ICONST_1 + ICONST_0 + ICONST_1 + BIPUSH 20 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + POP + RETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + 1: L1 + default: L2 + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L0 + POP + POP + ILOAD 2 + ALOAD 3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callHostFunction (Lrun/endive/runtime/Instance;I[J)[J + ARETURN + L2 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32.approved.txt new file mode 100644 index 000000000..6a5ef2a4b --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32.approved.txt @@ -0,0 +1,133 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ILOAD 5 + ALOAD 6 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + LDC -2147483648 + POP + ICONST_0 + POP + LDC 2147483647 + POP + LDC -9223372036854775808L + POP2 + LCONST_0 + POP2 + LDC 9223372036854775807L + POP2 + LDC -2147483647 + POP + LDC 2147483646 + POP + LDC -9223372036854775807L + POP2 + LDC 9223372036854775806L + POP2 + ICONST_M1 + POP + ICONST_1 + POP + LDC -1L + POP2 + LCONST_1 + POP2 + RETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32Renamed.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32Renamed.approved.txt new file mode 100644 index 000000000..469719821 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyI32Renamed.approved.txt @@ -0,0 +1,68 @@ +public final class FOO implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD FOO.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD FOO.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC FOOMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC FOOShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC FOOShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC FOOFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC FOOShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ILOAD 5 + ALOAD 6 + INVOKESTATIC FOOShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyIterFact.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyIterFact.approved.txt new file mode 100644 index 000000000..29484bd45 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyIterFact.approved.txt @@ -0,0 +1,148 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ICONST_0 + ISTORE 3 + ICONST_1 + ISTORE 3 + ILOAD 0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQZ (I)I + IFNE L0 + L1 + ILOAD 3 + ILOAD 0 + IMUL + ISTORE 3 + ILOAD 0 + ICONST_M1 + IADD + DUP + ISTORE 0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQZ (I)I + IFNE L0 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + GOTO L1 + L0 + ILOAD 3 + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyKitchenSink.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyKitchenSink.approved.txt new file mode 100644 index 000000000..c2aa894fc --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyKitchenSink.approved.txt @@ -0,0 +1,149 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + BIPUSH 10 + IADD + ICONST_1 + ISUB + BIPUSH 6 + IMUL + ICONST_2 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_DIV_S (II)I + BIPUSH 40 + IAND + BIPUSH 33 + IOR + BIPUSH 22 + IXOR + ICONST_2 + ISHL + ICONST_3 + ISHR + ICONST_4 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_ROTL (II)I + BIPUSH 6 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_ROTR (II)I + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EXTEND_8_S (I)I + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyMemory.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyMemory.approved.txt new file mode 100644 index 000000000..8b24e2d46 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyMemory.approved.txt @@ -0,0 +1,218 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN + + public static call_indirect_1(JIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)J + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 5 + ILOAD 3 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 6 + ALOAD 6 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 7 + ALOAD 6 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 8 + ALOAD 8 + IFNULL L0 + ALOAD 8 + ALOAD 5 + IF_ACMPNE L1 + L0 + LLOAD 0 + ALOAD 4 + ALOAD 5 + ILOAD 7 + LOOKUPSWITCH + 1: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)J + LRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 0 + LASTORE + ICONST_1 + ILOAD 7 + ALOAD 8 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + LRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ICONST_0 + ILOAD 0 + ICONST_0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryWriteInt (IIILrun/endive/runtime/Memory;)V + ICONST_0 + ICONST_0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryReadInt (IILrun/endive/runtime/Memory;)I + IRETURN + L0 + ATHROW + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN + + public static func_1(JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)J + ICONST_0 + LLOAD 0 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryWriteLong (IJILrun/endive/runtime/Memory;)V + ICONST_0 + ICONST_0 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.memoryReadLong (IILrun/endive/runtime/Memory;)J + LRETURN + L0 + ATHROW + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (JLrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)J + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + 1: L1 + default: L2 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L2 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyStart.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyStart.approved.txt new file mode 100644 index 000000000..b2d2bcfcc --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyStart.approved.txt @@ -0,0 +1,178 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 4 + ILOAD 2 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 5 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 6 + ALOAD 5 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 7 + ALOAD 7 + IFNULL L0 + ALOAD 7 + ALOAD 4 + IF_ACMPNE L1 + L0 + ILOAD 0 + ALOAD 3 + ALOAD 4 + ILOAD 6 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + ICONST_0 + ILOAD 6 + ALOAD 7 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN + + public static call_indirect_1(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 1: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_1 + ILOAD 5 + ALOAD 6 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ALOAD 2 + ICONST_0 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callHostFunction (Lrun/endive/runtime/Instance;I[J)[J + RETURN + + public static func_1(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + BIPUSH 42 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (ILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + 1: L1 + default: L2 + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L0 + POP + POP + ILOAD 2 + ALOAD 3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callHostFunction (Lrun/endive/runtime/Instance;I[J)[J + ARETURN + L2 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTailCall.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTailCall.approved.txt new file mode 100644 index 000000000..a0379e79c --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTailCall.approved.txt @@ -0,0 +1,209 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L2 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + ASTORE 3 + L3 + ALOAD 3 + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 3 + INVOKEVIRTUAL run/endive/runtime/Instance.isTailCallPending ()Z + IFEQ L1 + POP + ALOAD 3 + INVOKEVIRTUAL run/endive/runtime/Instance.tailCallFuncId ()I + ISTORE 1 + ALOAD 3 + INVOKEVIRTUAL run/endive/runtime/Instance.tailCallArgs ()[J + ASTORE 2 + ALOAD 3 + INVOKEVIRTUAL run/endive/runtime/Instance.clearTailCall ()V + GOTO L3 + L1 + ARETURN + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IIIIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 6 + ILOAD 4 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 7 + ALOAD 7 + ILOAD 3 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 8 + ALOAD 7 + ILOAD 3 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 9 + ALOAD 9 + IFNULL L0 + ALOAD 9 + ALOAD 6 + IF_ACMPNE L1 + L0 + ILOAD 0 + ILOAD 1 + ILOAD 2 + ALOAD 5 + ALOAD 6 + ILOAD 8 + LOOKUPSWITCH + 0: L2 + default: L3 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + IRETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_3 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 0 + I2L + LASTORE + DUP + ICONST_1 + ILOAD 1 + I2L + LASTORE + DUP + ICONST_2 + ILOAD 2 + I2L + LASTORE + ICONST_0 + ILOAD 8 + ALOAD 9 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + ICONST_0 + LALOAD + L2I + IRETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + ILOAD 0 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQZ (I)I + IFEQ L0 + ILOAD 1 + GOTO L1 + L0 + ILOAD 0 + ICONST_1 + INVOKESTATIC run/endive/runtime/OpcodeImpl.I32_EQ (II)I + IFEQ L2 + ILOAD 2 + GOTO L1 + L2 + ILOAD 0 + ICONST_1 + ISUB + ILOAD 2 + ILOAD 1 + ILOAD 2 + IADD + ISTORE 7 + ISTORE 6 + ISTORE 5 + ICONST_3 + NEWARRAY T_LONG + DUP + ICONST_0 + ILOAD 5 + I2L + LASTORE + DUP + ICONST_1 + ILOAD 6 + I2L + LASTORE + DUP + ICONST_2 + ILOAD 7 + I2L + LASTORE + ICONST_0 + SWAP + ALOAD 4 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.setTailCall (I[JLrun/endive/runtime/Instance;)V + ICONST_0 + IRETURN + L1 + IRETURN + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 2 + ICONST_0 + LALOAD + L2I + ALOAD 2 + ICONST_1 + LALOAD + L2I + ALOAD 2 + ICONST_2 + LALOAD + L2I + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (IIILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)I + I2L + LSTORE 3 + ICONST_1 + NEWARRAY T_LONG + DUP + ICONST_0 + LLOAD 3 + LASTORE + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + default: L1 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTrap.approved.txt b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTrap.approved.txt new file mode 100644 index 000000000..9e1c20b63 --- /dev/null +++ b/compiler/src/test/resources/run/endive/approvals/ApprovalTest.verifyTrap.approved.txt @@ -0,0 +1,152 @@ +public final class run/endive/$gen/CompiledMachine implements run/endive/runtime/Machine { + + private final Lrun/endive/runtime/Instance; instance + + public (Lrun/endive/runtime/Instance;)V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + ALOAD 0 + ALOAD 1 + PUTFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + RETURN + + public call(I[J)[J + TRYCATCHBLOCK L0 L1 L1 java/lang/StackOverflowError + L0 + ALOAD 0 + GETFIELD run/endive/$gen/CompiledMachine.instance : Lrun/endive/runtime/Instance; + DUP + INVOKEVIRTUAL run/endive/runtime/Instance.memory ()Lrun/endive/runtime/Memory; + ILOAD 1 + ALOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineMachineCall.call (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwCallStackExhausted (Ljava/lang/StackOverflowError;)Ljava/lang/RuntimeException; + ATHROW + + public static call_indirect_0(IILrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 3 + ILOAD 1 + INVOKEVIRTUAL run/endive/runtime/Instance.table (I)Lrun/endive/runtime/TableInstance; + ASTORE 4 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.requiredRef (I)I + ISTORE 5 + ALOAD 4 + ILOAD 0 + INVOKEVIRTUAL run/endive/runtime/TableInstance.instance (I)Lrun/endive/runtime/Instance; + ASTORE 6 + ALOAD 6 + IFNULL L0 + ALOAD 6 + ALOAD 3 + IF_ACMPNE L1 + L0 + ALOAD 2 + ALOAD 3 + ILOAD 5 + LOOKUPSWITCH + 0: L2 + 1: L3 + 2: L4 + default: L5 + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L3 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L4 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + L5 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwIndirectCallTypeMismatch ()Ljava/lang/RuntimeException; + ATHROW + L1 + ICONST_0 + NEWARRAY T_LONG + ICONST_0 + ILOAD 5 + ALOAD 6 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.callIndirect ([JIILrun/endive/runtime/Instance;)[J + RETURN +} + +final class run/endive/$gen/CompiledMachineFuncGroup_0 { + + public static func_0(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwTrapException ()Ljava/lang/RuntimeException; + ATHROW + L0 + ATHROW + + public static call_0(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN + + public static func_1(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_0 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + + public static call_1(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN + + public static func_2(Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.checkInterruption ()V + ALOAD 0 + ALOAD 1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_1 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + RETURN + + public static call_2(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ALOAD 1 + ALOAD 0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.func_2 (Lrun/endive/runtime/Memory;Lrun/endive/runtime/Instance;)V + ACONST_NULL + ARETURN +} + +final class run/endive/$gen/CompiledMachineMachineCall { + + public ()V + ALOAD 0 + INVOKESPECIAL java/lang/Object. ()V + RETURN + + public static call(Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;I[J)[J + ALOAD 0 + ALOAD 1 + ALOAD 3 + ILOAD 2 + TABLESWITCH + 0: L0 + 1: L1 + 2: L2 + default: L3 + L0 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_0 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L1 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_1 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L2 + INVOKESTATIC run/endive/$gen/CompiledMachineFuncGroup_0.call_2 (Lrun/endive/runtime/Instance;Lrun/endive/runtime/Memory;[J)[J + ARETURN + L3 + ILOAD 2 + INVOKESTATIC run/endive/$gen/CompiledMachineShaded.throwUnknownFunction (I)Ljava/lang/RuntimeException; + ATHROW +} diff --git a/dircache/pom.xml b/dircache/pom.xml index 490c4c260..af43833e0 100644 --- a/dircache/pom.xml +++ b/dircache/pom.xml @@ -3,49 +3,49 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT dircache-experimental jar - Chicory - Dircache - Experimental - Chicory directory based Cache + Endive - Dircache - Experimental + Endive directory based Cache - com.dylibso.chicory + run.endive compiler - com.dylibso.chicory - runtime + io.roastedroot + zerofs test - com.dylibso.chicory - wasm + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - wasm-corpus + org.junit.jupiter + junit-jupiter-engine test - io.roastedroot - zerofs + run.endive + runtime test - org.junit.jupiter - junit-jupiter-api + run.endive + wasm test - org.junit.jupiter - junit-jupiter-engine + run.endive + wasm-corpus test diff --git a/dircache/src/main/java/com/dylibso/chicory/experimental/dircache/DirectoryCache.java b/dircache/src/main/java/run/endive/experimental/dircache/DirectoryCache.java similarity index 96% rename from dircache/src/main/java/com/dylibso/chicory/experimental/dircache/DirectoryCache.java rename to dircache/src/main/java/run/endive/experimental/dircache/DirectoryCache.java index 9f6d552d9..1032080c9 100644 --- a/dircache/src/main/java/com/dylibso/chicory/experimental/dircache/DirectoryCache.java +++ b/dircache/src/main/java/run/endive/experimental/dircache/DirectoryCache.java @@ -1,9 +1,7 @@ -package com.dylibso.chicory.experimental.dircache; +package run.endive.experimental.dircache; import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; -import com.dylibso.chicory.compiler.Cache; -import com.dylibso.chicory.experimental.dircache.internal.PathUtils; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.FileSystemException; @@ -12,6 +10,8 @@ import java.util.Locale; import java.util.Objects; import java.util.regex.Pattern; +import run.endive.compiler.Cache; +import run.endive.experimental.dircache.internal.PathUtils; /** * Disk-backed sharded file cache. diff --git a/dircache/src/main/java/com/dylibso/chicory/experimental/dircache/internal/PathUtils.java b/dircache/src/main/java/run/endive/experimental/dircache/internal/PathUtils.java similarity index 95% rename from dircache/src/main/java/com/dylibso/chicory/experimental/dircache/internal/PathUtils.java rename to dircache/src/main/java/run/endive/experimental/dircache/internal/PathUtils.java index 2561450f2..26b179fb5 100644 --- a/dircache/src/main/java/com/dylibso/chicory/experimental/dircache/internal/PathUtils.java +++ b/dircache/src/main/java/run/endive/experimental/dircache/internal/PathUtils.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.experimental.dircache.internal; +package run.endive.experimental.dircache.internal; import java.io.IOException; import java.nio.file.FileVisitResult; diff --git a/dircache/src/test/java/com/dylibso/chicory/experimental/dircache/DirectoryCacheTest.java b/dircache/src/test/java/run/endive/experimental/dircache/DirectoryCacheTest.java similarity index 96% rename from dircache/src/test/java/com/dylibso/chicory/experimental/dircache/DirectoryCacheTest.java rename to dircache/src/test/java/run/endive/experimental/dircache/DirectoryCacheTest.java index a3a783abe..803b46aa3 100644 --- a/dircache/src/test/java/com/dylibso/chicory/experimental/dircache/DirectoryCacheTest.java +++ b/dircache/src/test/java/run/endive/experimental/dircache/DirectoryCacheTest.java @@ -1,13 +1,9 @@ -package com.dylibso.chicory.experimental.dircache; +package run.endive.experimental.dircache; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.compiler.Cache; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.IOException; @@ -20,6 +16,10 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import run.endive.compiler.Cache; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class DirectoryCacheTest { diff --git a/docs-lib/pom.xml b/docs-lib/pom.xml index 4fa25f6fa..ad325ccf9 100644 --- a/docs-lib/pom.xml +++ b/docs-lib/pom.xml @@ -3,14 +3,14 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml docs-lib jar - Chicory - Docs Lib + Endive - Docs Lib INTERNAL USAGE ONLY - utils to verify the docs diff --git a/docs/blog/2023-12-25-chicory-first.md b/docs/blog/2023-12-25-chicory-first.md index d5dc1be5a..f053e93e3 100644 --- a/docs/blog/2023-12-25-chicory-first.md +++ b/docs/blog/2023-12-25-chicory-first.md @@ -3,6 +3,7 @@ slug: first-announcement title: A zero dependency Wasm runtime for the JVM authors: [andreaTP, bhelx] tags: [wasm, chicory] +unlisted: true --- # A zero dependency Wasm runtime for the JVM diff --git a/docs/blog/2024-11-08-chicory-1.0.0-M1.md b/docs/blog/2024-11-08-chicory-1.0.0-M1.md index af49b167c..e3994c536 100644 --- a/docs/blog/2024-11-08-chicory-1.0.0-M1.md +++ b/docs/blog/2024-11-08-chicory-1.0.0-M1.md @@ -3,6 +3,7 @@ slug: chicory-1.0.0-M1 title: 'Announcing Chicory 1.0.0-M1: First Milestone Release' authors: [evacchi] tags: [wasm, chicory, release] +unlisted: true --- It's been a while since our **pure-Java WebAssembly runtime** released version [0.0.12][0.0.12], @@ -314,8 +315,8 @@ Check out Chicory 1.0.0-M1 right now and let us know what you think! [0.0.12]: https://github.com/dylibso/chicory/releases/tag/0.0.12 [docs]: /docs/ -[store]: /docs/usage/linking -[wasi]: /docs/usage/wasi +[store]: /docs/core/linking +[wasi]: /docs/wasi [value-convert]: https://github.com/dylibso/chicory/blob/c369d287f724b2297211c6dd02e7bbaeaaed321a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Value.java#L26-L44 [aot-maven-plugin]: https://github.com/dylibso/chicory/tree/16c7fe4d5cd3d7365b8bc78425d968af12f61dba/aot-maven-plugin [chicory-wabt]: https://github.com/dylibso/chicory/tree/16c7fe4d5cd3d7365b8bc78425d968af12f61dba/wabt diff --git a/docs/blog/2024-11-26-chicory-1.0.0-M2.md b/docs/blog/2024-11-26-chicory-1.0.0-M2.md index 73a14a950..f2f6dacc4 100644 --- a/docs/blog/2024-11-26-chicory-1.0.0-M2.md +++ b/docs/blog/2024-11-26-chicory-1.0.0-M2.md @@ -3,6 +3,7 @@ slug: chicory-1.0.0-M2 title: 'Announcing Chicory 1.0.0-M2: Second Milestone Release' authors: [andreaTP, electrum] tags: [wasm, chicory, release] +unlisted: true --- @@ -24,7 +25,7 @@ There is a lot of work that can be easily parallelized here, come and join the e ## AOT improvements -We finished making modules compiled at build time with the `aot-maven-plugin-experimental` completely self-contained! You can now emit a binary that runs pure Java Bytecode and only depends on the Chicory runtime library: the original WASM file is not needed. The `WasmModule` is now provided by the compiled code. Additionally, we changed the Maven configuration so that you now specify the class name prefix rather than the `Machine` class name. See the documentation for [Build-time AOT](/docs/usage/build-time-compiler) for more details. +We finished making modules compiled at build time with the `aot-maven-plugin-experimental` completely self-contained! You can now emit a binary that runs pure Java Bytecode and only depends on the Chicory runtime library: the original WASM file is not needed. The `WasmModule` is now provided by the compiled code. Additionally, we changed the Maven configuration so that you now specify the class name prefix rather than the `Machine` class name. See the documentation for [Build-time AOT](/docs/execution/build-time-compiler) for more details. ## Documentation diff --git a/docs/blog/2024-12-25-chicory-1.0.0.md b/docs/blog/2024-12-25-chicory-1.0.0.md index 598127591..037c238d4 100644 --- a/docs/blog/2024-12-25-chicory-1.0.0.md +++ b/docs/blog/2024-12-25-chicory-1.0.0.md @@ -3,6 +3,7 @@ slug: chicory-1.0.0 title: 'The Chicory Photo Album: Celebrating 1.0.0 and a Year of Wasm' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2025-02-20-chicory-1.1.0.md b/docs/blog/2025-02-20-chicory-1.1.0.md index 71a0221fd..b06301415 100644 --- a/docs/blog/2025-02-20-chicory-1.1.0.md +++ b/docs/blog/2025-02-20-chicory-1.1.0.md @@ -3,6 +3,7 @@ slug: chicory-1.1.0 title: 'Announcing Chicory 1.1.0: Faster and More Compliant' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- @@ -32,5 +33,5 @@ With this release, we’re introducing a **“Who Uses Chicory?”** section in Try out **Chicory 1.1.0** today, and let us know what you think! -[simd]: /docs/usage/simd -[memory]: /docs/advanced/memory +[simd]: /docs/advanced/simd +[memory]: /docs/advanced/memory-customization diff --git a/docs/blog/2025-03-21-chicory-1.2.0.md b/docs/blog/2025-03-21-chicory-1.2.0.md index 8fd1fe08f..0baf89623 100644 --- a/docs/blog/2025-03-21-chicory-1.2.0.md +++ b/docs/blog/2025-03-21-chicory-1.2.0.md @@ -3,6 +3,7 @@ slug: chicory-1.2.0 title: 'Announcing an `Exception`al Chicory 1.2.0' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2025-04-24-chicory-1.3.0.md b/docs/blog/2025-04-24-chicory-1.3.0.md index 064a5fea6..810ec9edb 100644 --- a/docs/blog/2025-04-24-chicory-1.3.0.md +++ b/docs/blog/2025-04-24-chicory-1.3.0.md @@ -3,6 +3,7 @@ slug: chicory-1.3.0 title: 'Closing the Gap – Chicory 1.3.0 is Here!' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2025-05-30-chicory-1.4.0.md b/docs/blog/2025-05-30-chicory-1.4.0.md index 7cf49ac30..4531d6808 100644 --- a/docs/blog/2025-05-30-chicory-1.4.0.md +++ b/docs/blog/2025-05-30-chicory-1.4.0.md @@ -3,6 +3,7 @@ slug: chicory-1.4.0 title: 'Chicory 1.4.0 – Compiler Graduates, Annotations Stabilize, and WasmGC Advances' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2025-07-04-chicory-1.5.0.md b/docs/blog/2025-07-04-chicory-1.5.0.md index 2b3151366..3169a5ded 100644 --- a/docs/blog/2025-07-04-chicory-1.5.0.md +++ b/docs/blog/2025-07-04-chicory-1.5.0.md @@ -3,6 +3,7 @@ slug: chicory-1.5.0 title: 'Chicory 1.5.0 – EH and Threads, Across the Board' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2025-11-10-chicory-1.6.0.md b/docs/blog/2025-11-10-chicory-1.6.0.md index 823a7275e..656612fd6 100644 --- a/docs/blog/2025-11-10-chicory-1.6.0.md +++ b/docs/blog/2025-11-10-chicory-1.6.0.md @@ -3,6 +3,7 @@ slug: chicory-1.6.0 title: 'Chicory 1.6.0 – Java Modules, Performance, and Enhanced Proposals' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2026-02-25-chicory-1.7.0.md b/docs/blog/2026-02-25-chicory-1.7.0.md index 89980202e..c38ce06df 100644 --- a/docs/blog/2026-02-25-chicory-1.7.0.md +++ b/docs/blog/2026-02-25-chicory-1.7.0.md @@ -3,6 +3,7 @@ slug: chicory-1.7.0 title: 'Chicory 1.7.0 – WasmGC, Multi-Memory, and Threads Improvements' authors: [andreaTP] tags: [wasm, chicory, release] +unlisted: true --- diff --git a/docs/blog/2026-04-16-chicory-redline.md b/docs/blog/2026-04-16-chicory-redline.md index 58dbba3d8..475f18145 100644 --- a/docs/blog/2026-04-16-chicory-redline.md +++ b/docs/blog/2026-04-16-chicory-redline.md @@ -3,6 +3,7 @@ slug: chicory-redline title: 'Introducing Chicory Redline: Native Speed for Wasm on the JVM' authors: [andreaTP] tags: [wasm, chicory, redline] +unlisted: true --- ![Chicory Redline](chicory-redline.png) diff --git a/docs/blog/authors.yml b/docs/blog/authors.yml index 403142757..a9de396ec 100644 --- a/docs/blog/authors.yml +++ b/docs/blog/authors.yml @@ -1,6 +1,5 @@ bhelx: name: Benjamin Eckel - title: CTO @ Dylibso url: https://github.com/bhelx image_url: https://avatars.githubusercontent.com/u/185919 page: true @@ -19,7 +18,7 @@ andreaTP: evacchi: name: Edoardo Vacchi - title: Staff Software Engineer @ Dylibso + title: Staff Software Engineer @ Red Hat url: https://github.com/evacchi image_url: https://avatars.githubusercontent.com/u/380791?v=4 socials: diff --git a/docs/blog/tags.yml b/docs/blog/tags.yml index 5ceca2ad5..f23d398a9 100644 --- a/docs/blog/tags.yml +++ b/docs/blog/tags.yml @@ -1,18 +1,18 @@ +endive: + label: Endive + permalink: /endive + description: Endive tag description + chicory: label: Chicory permalink: /chicory - description: Chicory tag description + description: Historical Chicory posts wasm: label: Wasm permalink: /wasm description: Wasm tag description -dylibso: - label: Dylibso - permalink: /dylibso - description: Dylibso - release: label: Release permalink: /release @@ -21,4 +21,14 @@ release: redline: label: Redline permalink: /redline - description: Chicory Redline + description: Endive Redline + +highlight: + label: Syntax Highlight + permalink: /highlight + description: Syntax highlighting + +treesitter: + label: Tree-sitter + permalink: /treesitter + description: Tree-sitter integration diff --git a/docs/docs/advanced/_category_.yml b/docs/docs/advanced/_category_.yml index bb285f4dd..759467147 100644 --- a/docs/docs/advanced/_category_.yml +++ b/docs/docs/advanced/_category_.yml @@ -1,2 +1,2 @@ label: Advanced -position: 40 +position: 50 diff --git a/docs/docs/usage/cpu.md b/docs/docs/advanced/cpu-limits.md similarity index 61% rename from docs/docs/usage/cpu.md rename to docs/docs/advanced/cpu-limits.md index e6bcb2c75..c1f08ec3c 100644 --- a/docs/docs/usage/cpu.md +++ b/docs/docs/advanced/cpu-limits.md @@ -1,26 +1,30 @@ --- -sidebar_position: 30 +sidebar_position: 1 sidebar_label: CPU title: CPU --- # Limiting CPU usage +:::warning[Security Consideration] +Wasm modules can contain infinite loops. When running untrusted code, always set execution timeouts via thread interruption or an ExecutorService with a deadline. Without timeouts, a malicious module can consume 100% CPU indefinitely. +::: + Often, when running untrusted user code in our infrastructure, we want to have strong guarantees around the termination of the program. -To achieve this result there are, currently, two mechanisms in Chicory: +To achieve this result there are, currently, two mechanisms in Endive: ## Interrupts -Wasm modules executed using Chicory honour the carrier thread interruption mechanism, thus you can leverage it to implement absolute timeouts: +Wasm modules executed using Endive honour the carrier thread interruption mechanism, thus you can leverage it to implement absolute timeouts: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/infinite-loop.c.wasm > infinite-loop.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/infinite-loop.c.wasm > infinite-loop.wasm ``` diff --git a/docs/docs/usage/logging.md b/docs/docs/advanced/logging.md similarity index 70% rename from docs/docs/usage/logging.md rename to docs/docs/advanced/logging.md index df1d14534..8d0f73861 100644 --- a/docs/docs/usage/logging.md +++ b/docs/docs/advanced/logging.md @@ -1,5 +1,5 @@ --- -sidebar_position: 80 +sidebar_position: 4 sidebar_label: Logging title: Logging --- @@ -13,12 +13,12 @@ For more advanced configuration scenarios we encourage you to provide an alterna - [slf4j](https://www.slf4j.org/manual.html#jep264) - [log4j2](https://logging.apache.org/log4j/2.x/log4j-jpl.html) -It's also possible to provide a custom `com.dylibso.chicory.log.Logger` implementation if JDK Platform Logging is not available or doesn't fit. +It's also possible to provide a custom `run.endive.log.Logger` implementation if JDK Platform Logging is not available or doesn't fit. diff --git a/docs/docs/advanced/memory.md b/docs/docs/advanced/memory-customization.md similarity index 52% rename from docs/docs/advanced/memory.md rename to docs/docs/advanced/memory-customization.md index d72736866..9821c8e9b 100644 --- a/docs/docs/advanced/memory.md +++ b/docs/docs/advanced/memory-customization.md @@ -1,12 +1,12 @@ --- -sidebar_position: 1 +sidebar_position: 5 sidebar_label: Memory title: Advanced Wasm Memory Customization --- diff --git a/docs/docs/usage/simd.md b/docs/docs/advanced/simd.md similarity index 65% rename from docs/docs/usage/simd.md rename to docs/docs/advanced/simd.md index c5b23d167..7a0c25dca 100644 --- a/docs/docs/usage/simd.md +++ b/docs/docs/advanced/simd.md @@ -1,5 +1,5 @@ --- -sidebar_position: 90 +sidebar_position: 2 sidebar_label: Simd title: Simd support --- @@ -10,11 +10,11 @@ If you are using a version of Java that supports [JEP 448 - Vector API](https:// @@ -32,7 +31,7 @@ After adding the dependency: ```xml - com.dylibso.chicory + run.endive simd ``` @@ -40,7 +39,7 @@ After adding the dependency: You can instantiate a module with SIMD support by explicitly providing a `MachineFactory`: ```java -import com.dylibso.chicory.simd.SimdInterpreterMachine; +import run.endive.simd.SimdInterpreterMachine; var module = Parser.parse(new File("your.wasm")); var instance = Instance.builder(module).withMachineFactory(SimdInterpreterMachine::new).build(); @@ -50,9 +49,9 @@ var instance = Instance.builder(module).withMachineFactory(SimdInterpreterMachin diff --git a/docs/docs/usage/tools.md b/docs/docs/advanced/tools.md similarity index 67% rename from docs/docs/usage/tools.md rename to docs/docs/advanced/tools.md index 918454568..d7f1e4a4b 100644 --- a/docs/docs/usage/tools.md +++ b/docs/docs/advanced/tools.md @@ -1,5 +1,5 @@ --- -sidebar_position: 60 +sidebar_position: 3 sidebar_label: WABT title: WABT --- @@ -7,13 +7,13 @@ title: WABT ## WebAssembly Binary Toolkit -Since we use them in the build of the project, we publish a few [wabt](https://github.com/WebAssembly/wabt) tools compiled at build time with Chicory. +Since we use them in the build of the project, we publish a few [wabt](https://github.com/WebAssembly/wabt) tools compiled at build time with Endive. Adding support for more tools is easy and we welcome contributions in this direction. The relevant module can be added to the build with: ```xml - com.dylibso.chicory + run.endive wabt latest-release @@ -21,12 +21,12 @@ The relevant module can be added to the build with: ## Wasm Tools -As we need it to catch up with the latest development of the Wasm spec we publish a few [wasm-tools](https://github.com/bytecodealliance/wasm-tools) compiled at build time with Chicory. +As we need it to catch up with the latest development of the Wasm spec we publish a few [wasm-tools](https://github.com/bytecodealliance/wasm-tools) compiled at build time with Endive. The relevant module can be added to the build with: ```xml - com.dylibso.chicory + run.endive wasm-tools latest-release @@ -34,28 +34,28 @@ The relevant module can be added to the build with: ## wat2wasm -In Chicory, we don't have a Wasm text format parser just yet. +In Endive, we don't have a Wasm text format parser just yet. To overcome this limitation you can use `wat2wasm`, for example: ```java -import com.dylibso.chicory.wabt.Wat2Wasm; +import run.endive.wabt.Wat2Wasm; // or -import com.dylibso.chicory.tools.wasm.Wat2Wasm; +import run.endive.tools.wasm.Wat2Wasm; var wasm = Wat2Wasm.parse( "(module (func (export \"add\") (param $x i32) (param $y i32) (result i32)" diff --git a/docs/docs/annotations/_category_.yml b/docs/docs/annotations/_category_.yml new file mode 100644 index 000000000..3f46b5dc7 --- /dev/null +++ b/docs/docs/annotations/_category_.yml @@ -0,0 +1,2 @@ +label: Annotations +position: 35 diff --git a/docs/docs/usage/annotations.md b/docs/docs/annotations/index.md similarity index 81% rename from docs/docs/usage/annotations.md rename to docs/docs/annotations/index.md index c20ef68af..4c18d4d84 100644 --- a/docs/docs/usage/annotations.md +++ b/docs/docs/annotations/index.md @@ -6,13 +6,13 @@ title: Annotations ## Host Modules Instead of writing host functions by hand, you can write a class containing annotated methods -and let the Chicory annotation processor generate the host functions for you. This is especially +and let the Endive annotation processor generate the host functions for you. This is especially useful when you have many host functions. @@ -54,7 +54,7 @@ To use the host module, you need to instantiate the host module and fetch the ho ```java -import com.dylibso.chicory.runtime.ImportValues; +import run.endive.runtime.ImportValues; var demo = new Demo(); var imports = ImportValues.builder().addFunction(demo.toHostFunctions()).build(); @@ -88,7 +88,7 @@ The following conversions are supported: ## WasmModuleInterface :::tip -If you are using the [build-time compiler](build-time-compiler.md), you can use the `moduleInterface` parameter in the Maven plugin instead of the annotation processor. This is simpler and avoids the setup described below. See [Generating Module Exports and Imports](build-time-compiler.md#generating-module-exports-and-imports). +If you are using the [build-time compiler](../execution/build-time-compiler.md), you can use the `moduleInterface` parameter in the Maven plugin instead of the annotation processor. This is simpler and avoids the setup described below. See [Generating Module Exports and Imports](../execution/build-time-compiler.md#generating-module-exports-and-imports). ::: If you already have a Wasm module and want to generate scaffolded Java code to interact with it, you can use the `@WasmModuleInterface` annotation. @@ -116,13 +116,13 @@ In order to use host modules, you need to import the relevant annotations, e.g. ```xml - com.dylibso.chicory + run.endive annotations latest-release ``` -and configure the Java compiler to include the Chicory `annotations-processor` as an annotation processor. +and configure the Java compiler to include the Endive `annotations-processor` as an annotation processor. Exactly how this is done depends on the build system you are using, for instance, with Maven: ```xml @@ -132,7 +132,7 @@ Exactly how this is done depends on the build system you are using, for instance - com.dylibso.chicory + run.endive annotations-processor latest-release @@ -143,6 +143,6 @@ Exactly how this is done depends on the build system you are using, for instance diff --git a/docs/docs/core/_category_.yml b/docs/docs/core/_category_.yml new file mode 100644 index 000000000..a4e2616b6 --- /dev/null +++ b/docs/docs/core/_category_.yml @@ -0,0 +1,2 @@ +label: Core Concepts +position: 10 diff --git a/docs/docs/usage/execution_modes.md b/docs/docs/core/execution-modes.md similarity index 83% rename from docs/docs/usage/execution_modes.md rename to docs/docs/core/execution-modes.md index 287da4d13..ef9e0b6fd 100644 --- a/docs/docs/usage/execution_modes.md +++ b/docs/docs/core/execution-modes.md @@ -1,5 +1,5 @@ --- -sidebar_position: 110 +sidebar_position: 4 sidebar_label: Execution modes title: Execution modes --- @@ -14,7 +14,7 @@ title: Execution modes ## Summary -- **Interpreter**: Executes WebAssembly (Wasm) modules directly without prior compilation. It's the default mode in Chicory, offering maximum portability and simplicity. However, it has slower execution speed compared to compiled modes. +- **Interpreter**: Executes WebAssembly (Wasm) modules directly without prior compilation. It's the default mode in Endive, offering maximum portability and simplicity. However, it has slower execution speed compared to compiled modes. - **Runtime Compilation**: Compiles Wasm modules to Java bytecode at runtime for fast execution. This mode requires one additional dependency on [ASM](https://asm.ow2.io/), it uses reflection, and it loads bytecode dynamically. It fully supports loading new Wasm modules on-the-fly, but it might not be supported on some platforms (such as Android, or GraalVM's native-image). @@ -22,8 +22,8 @@ title: Execution modes diff --git a/docs/docs/usage/host-functions.md b/docs/docs/core/host-functions.md similarity index 78% rename from docs/docs/usage/host-functions.md rename to docs/docs/core/host-functions.md index 5b452a11c..1e6f32960 100644 --- a/docs/docs/usage/host-functions.md +++ b/docs/docs/core/host-functions.md @@ -1,14 +1,18 @@ --- -sidebar_position: 20 +sidebar_position: 1 sidebar_label: Host Functions title: Host Functions --- # Host and guests +:::warning[Security Consideration] +Host functions cross the sandbox boundary. Validate all arguments received from Wasm code — especially memory offsets and lengths — before accessing host resources. Never trust guest-provided pointers without bounds checking. See [Security Best Practices](/docs/security/best-practices). +::: + In Wasm, the instance of a module is generally regarded as the **guest**, and the surrounding runtime environment is called the **host**. -For example, an **application** using Chicory as a **library** would be the **host** +For example, an **application** using Endive as a **library** would be the **host** to a Wasm module **guest** you have instantiated. Wasm modules may **export** functions, so that they can be externally invoked. @@ -42,13 +46,13 @@ and determine what they do. Let's see it with another example. Download the following Wasm binary: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/host-function.wat.wasm > logger.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/host-function.wat.wasm > logger.wasm ``` ```java -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.FunctionType; +import run.endive.runtime.Instance; +import run.endive.runtime.HostFunction; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.FunctionType; var func = new HostFunction( "console", @@ -106,9 +110,9 @@ We now need to pass this host function when we instantiate the module. We can do so by using a `Store`: ```java -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Store; +import run.endive.wasm.Parser; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Store; // instantiate the store var store = new Store(); @@ -120,4 +124,4 @@ logIt.apply(); // should print "Hello, World!" 10 times ``` -> **_NOTE:_** For an easier way to write host function and interact with a wasm module, see [Annotations](../usage/annotations.md). +> **_NOTE:_** For an easier way to write host function and interact with a wasm module, see [Annotations](../annotations/index.md). diff --git a/docs/docs/usage/linking.md b/docs/docs/core/linking.md similarity index 85% rename from docs/docs/usage/linking.md rename to docs/docs/core/linking.md index 16640c6c5..1635c7bd6 100644 --- a/docs/docs/usage/linking.md +++ b/docs/docs/core/linking.md @@ -1,5 +1,5 @@ --- -sidebar_position: 40 +sidebar_position: 3 sidebar_label: Linking title: Linking --- @@ -14,18 +14,18 @@ In the simplest case, it allows to register single host functions, globals, memo ```java -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Store; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.FunctionType; +import run.endive.wasm.Parser; +import run.endive.runtime.Instance; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Store; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.FunctionType; var func = new HostFunction( "console", @@ -84,6 +84,6 @@ have interdependencies, you will have to instantiate and register them in the ri diff --git a/docs/docs/usage/memory.md b/docs/docs/core/memory.md similarity index 74% rename from docs/docs/usage/memory.md rename to docs/docs/core/memory.md index 076284ac4..127e23649 100644 --- a/docs/docs/usage/memory.md +++ b/docs/docs/core/memory.md @@ -1,5 +1,5 @@ --- -sidebar_position: 10 +sidebar_position: 2 sidebar_label: Memory title: Memory --- @@ -7,18 +7,18 @@ title: Memory Wasm only understands basic integer and float primitives. Passing more complex types across the boundaries involves passing low level pointers. -To read, write, or allocate memory in a module, Chicory provides the `Memory` class. +To read, write, or allocate memory in a module, Endive provides the `Memory` class. Let's look at an example where we have a module `count_vowels.wasm`, written in Rust, that takes a string input and counts the number of vowels in the string: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/count_vowels.rs.wasm > count_vowels.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/count_vowels.rs.wasm > count_vowels.wasm ``` diff --git a/docs/docs/examples/_category_.yml b/docs/docs/examples/_category_.yml index c57c40486..e2c291542 100644 --- a/docs/docs/examples/_category_.yml +++ b/docs/docs/examples/_category_.yml @@ -1,2 +1,2 @@ label: Examples -position: 30 +position: 70 diff --git a/docs/docs/examples/rust.md b/docs/docs/examples/rust.md index af9959208..b0a7f8c35 100644 --- a/docs/docs/examples/rust.md +++ b/docs/docs/examples/rust.md @@ -1,7 +1,7 @@ --- sidebar_position: 1 sidebar_label: Rust -title: Using Rust with Chicory +title: Using Rust with Endive --- ## Compile Rust to Wasm @@ -19,12 +19,12 @@ rustc --target=wasm32-wasi --crate-type=bin > **NOTE:** For production usage, make sure to produce an optimized Wasm module by using the standard compiler options `-C opt-level = 3`(speed) or `-C opt-level = "z"`(size) -## Using in Chicory +## Using in Endive ```java -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.runtime.Instance; var instance = Instance.builder(Parser.parse(new File("count_vowels.rs.wasm"))).build(); diff --git a/docs/docs/execution/_category_.yml b/docs/docs/execution/_category_.yml new file mode 100644 index 000000000..e27915040 --- /dev/null +++ b/docs/docs/execution/_category_.yml @@ -0,0 +1,2 @@ +label: Compilation +position: 20 diff --git a/docs/docs/usage/build-time-compiler.md b/docs/docs/execution/build-time-compiler.md similarity index 84% rename from docs/docs/usage/build-time-compiler.md rename to docs/docs/execution/build-time-compiler.md index 9b60628fa..154893282 100644 --- a/docs/docs/usage/build-time-compiler.md +++ b/docs/docs/execution/build-time-compiler.md @@ -1,10 +1,14 @@ --- -sidebar_position: 130 +sidebar_position: 2 sidebar_label: Build time Compilation title: Build Time Compilation --- ## Overview +:::warning[Security Consideration] +The compiler translates Wasm to JVM bytecode without post-compilation verification. Only compile Wasm modules you trust. See [Security Model](/docs/security/overview). +::: + The build time compiler backend is a drop-in replacement for the interpreter, and it passes 100% of the same spec tests that the interpreter already supports. @@ -41,8 +45,8 @@ Example configuration of the Maven plug-in: - com.dylibso.chicory - chicory-compiler-maven-plugin + run.endive + endive-compiler-maven-plugin compiler-gen @@ -66,14 +70,14 @@ In the codebase you can use the generated module by configuring appropriately th ```java -import com.dylibso.chicory.runtime.Instance; +import run.endive.runtime.Instance; // load the bundled module var module = Add.load(); @@ -107,7 +111,7 @@ var instance = Instance.builder(module). ### Generating Module Exports and Imports The build-time compiler can also generate typed Java wrappers for a module's exports and imports, -eliminating the need for the [`@WasmModuleInterface` annotation](annotations.md#wasmmoduleinterface) and the annotation processor setup. +eliminating the need for the [`@WasmModuleInterface` annotation](../annotations/index.md#wasmmoduleinterface) and the annotation processor setup. Add the `moduleInterface` parameter to the plugin configuration: @@ -124,14 +128,14 @@ You can then use them directly in your code without any annotation: diff --git a/docs/docs/experimental/runtime-compiler-cache.md b/docs/docs/execution/compiler-cache.md similarity index 69% rename from docs/docs/experimental/runtime-compiler-cache.md rename to docs/docs/execution/compiler-cache.md index b755b152c..fcf826766 100644 --- a/docs/docs/experimental/runtime-compiler-cache.md +++ b/docs/docs/execution/compiler-cache.md @@ -1,14 +1,18 @@ --- -sidebar_position: 6 +sidebar_position: 3 sidebar_label: Runtime Compiler Cache title: Runtime Compiler Cache --- # Overview of the Runtime Compiler Cache -The runtime compiler cache lets the Chicory runtime compiler store the results of compiling WASM modules to Java bytecode. Subsequent executions can skip compilation and start faster. +:::warning[Security Consideration] +The directory cache stores compiled bytecode on disk without integrity verification. Ensure the cache directory has restrictive permissions (`chmod 700`) and is not writable by untrusted users. Do not share caches across trust boundaries. +::: -Use the experimental directory-based cache, or implement the simple `com.dylibso.chicory.compiler.Cache` interface: +The runtime compiler cache lets the Endive runtime compiler store the results of compiling WASM modules to Java bytecode. Subsequent executions can skip compilation and start faster. + +Use the experimental directory-based cache, or implement the simple `run.endive.compiler.Cache` interface: ```java public interface Cache { @@ -38,7 +42,7 @@ The implementation uses file system atomic moves (write to a temp file, then mov ### Using the Directory Cache -We assume you already use the runtime compiler. If not, see the [Runtime Compiler](../usage/runtime-compiler) guide first. +We assume you already use the runtime compiler. If not, see the [Runtime Compiler](../execution/runtime-compiler) guide first. ### Add the Maven Dependency @@ -46,7 +50,7 @@ Add the following dependency: ```xml - com.dylibso.chicory + run.endive dircache-experimental ``` @@ -57,14 +61,14 @@ Create the cache: ```java import java.nio.file.Path; -import com.dylibso.chicory.experimental.dircache.DirectoryCache; +import run.endive.experimental.dircache.DirectoryCache; var cache = new DirectoryCache(Path.of("cache")); ``` @@ -75,10 +79,10 @@ Configure the compiler to use the cache via `MachineFactoryCompiler.builder(...) ```java import java.io.File; import java.nio.file.Files; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.runtime.Instance; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.runtime.Instance; docs.FileOps.copyFromWasmCorpus("count_vowels.rs.wasm", "your.wasm"); var cache = new DirectoryCache(Files.createTempDirectory("cache")); @@ -96,7 +100,7 @@ var instance = Instance.builder(module). diff --git a/docs/docs/usage/runtime-compiler.md b/docs/docs/execution/runtime-compiler.md similarity index 73% rename from docs/docs/usage/runtime-compiler.md rename to docs/docs/execution/runtime-compiler.md index 8f442c3da..edd1f3011 100644 --- a/docs/docs/usage/runtime-compiler.md +++ b/docs/docs/execution/runtime-compiler.md @@ -1,10 +1,18 @@ --- -sidebar_position: 120 +sidebar_position: 1 sidebar_label: Runtime Compilation title: Runtime Compilation --- ## Overview +:::warning[Security Consideration] +The compiler translates Wasm to JVM bytecode without post-compilation verification. When compiling untrusted modules, prefer the interpreter for higher assurance, or run compiled code in an isolated classloader. See [Security Model](/docs/security/overview). +::: + +:::info[Resource Limits] +Compiling very large Wasm modules can consume significant memory and CPU. Consider setting JVM heap limits and compilation timeouts when processing untrusted input. +::: + The runtime compiler backend is a drop-in replacement for the interpreter, and it passes 100% of the same spec tests that the interpreter already supports. @@ -24,7 +32,7 @@ Add the following dependency: ```xml - com.dylibso.chicory + run.endive compiler ``` @@ -36,19 +44,19 @@ of the default `InterpreterMachine`. ```java -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; var module = Parser.parse(new File("your.wasm")); var instance = Instance.builder(module). @@ -69,11 +77,11 @@ Warning: using interpreted mode for WASM function index: 232 By default, the compiler uses `InterpreterFallback.WARN` behavior, which logs warning messages when falling back to the interpreter. If you are happy with these methods being interpreted, you can configure the compiler with `InterpreterFallback.SILENT` to silence those messages: ```java -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.compiler.InterpreterFallback; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.compiler.InterpreterFallback; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; var module = Parser.parse(new File("your.wasm")); var instance = Instance.builder(module). @@ -90,11 +98,11 @@ If you want to ensure the functions are never interpreted, you can modify the ab An even better way to silence the use of interpreted functions (this will speed up your compile times) is to explicitly list the function indexes that should be interpreted: ```java -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.compiler.InterpreterFallback; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.compiler.InterpreterFallback; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; import java.io.File; import java.util.Set; @@ -120,6 +128,6 @@ This is usually fine when running on a standard JVM, but it involves some additi diff --git a/docs/docs/experimental/_category_.yml b/docs/docs/experimental/_category_.yml index 76048f04d..0c82b5f63 100644 --- a/docs/docs/experimental/_category_.yml +++ b/docs/docs/experimental/_category_.yml @@ -1,2 +1,2 @@ label: Experimental -position: 20 +position: 60 diff --git a/docs/docs/experimental/cli.md b/docs/docs/experimental/cli.md index 67c808fee..27409eb66 100644 --- a/docs/docs/experimental/cli.md +++ b/docs/docs/experimental/cli.md @@ -5,24 +5,28 @@ title: CLI --- # Install and use the CLI -The experimental Chicory CLI is available for download on Maven at the link: +:::warning[Security Consideration] +The experimental CLI uses `inheritSystem()` by default, granting the Wasm module full access to the host filesystem, environment, and stdio. Do not use it with untrusted modules in its current form. +::: + +The experimental Endive CLI is available for download on Maven at the link: ``` -https://repo1.maven.org/maven2/com/dylibso/chicory/cli//cli-.sh +https://repo1.maven.org/maven2/run/endive/cli//cli-.sh ``` you can download the latest version and use it locally by typing: ```bash -export VERSION=$(curl -sS https://api.github.com/repos/dylibso/chicory/tags --header "Accept: application/json" | jq -r '.[0].name') -curl -L -o chicory https://repo1.maven.org/maven2/com/dylibso/chicory/cli-experimental/${VERSION}/cli-experimental-${VERSION}.sh -chmod a+x chicory -./chicory +export VERSION=$(curl -sS https://api.github.com/repos/bytecodealliance/endive/tags --header "Accept: application/json" | jq -r '.[0].name') +curl -L -o endive https://repo1.maven.org/maven2/run/endive/cli-experimental/${VERSION}/cli-experimental-${VERSION}.sh +chmod a+x endive +./endive ``` diff --git a/docs/docs/index.md b/docs/docs/index.md index 070e838b6..5ee9e9ae8 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -6,14 +6,14 @@ title: Quick start ### Install the dependency -To use the runtime, you need to add the `com.dylibso.chicory:runtime` dependency +To use the runtime, you need to add the `run.endive:runtime` dependency to your dependency management system. #### Maven ```xml - com.dylibso.chicory + run.endive runtime latest-release @@ -22,26 +22,26 @@ to your dependency management system. #### Gradle ```groovy -implementation 'com.dylibso.chicory:runtime:latest-release' +implementation 'run.endive:runtime:latest-release' ``` ### Loading and Instantiating Wasm Modules -First your Wasm module must be loaded from disk and then instantiated. Let's [download a test module](https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/iterfact.wat.wasm) . +First your Wasm module must be loaded from disk and then instantiated. Let's [download a test module](https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/iterfact.wat.wasm) . This module contains some code to compute factorial: Download from the link or with curl: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/iterfact.wat.wasm > factorial.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/iterfact.wat.wasm > factorial.wasm ``` diff --git a/docs/docs/security/_category_.yml b/docs/docs/security/_category_.yml new file mode 100644 index 000000000..b37e7c072 --- /dev/null +++ b/docs/docs/security/_category_.yml @@ -0,0 +1,2 @@ +label: Security +position: 40 diff --git a/docs/docs/security/best-practices.md b/docs/docs/security/best-practices.md new file mode 100644 index 000000000..95cfd50ed --- /dev/null +++ b/docs/docs/security/best-practices.md @@ -0,0 +1,99 @@ +--- +sidebar_position: 2 +sidebar_label: Best Practices +title: Security Best Practices +--- + +# Security Best Practices + +Practical guidance for running Wasm modules securely with Endive. + +## Writing Safe Host Functions + +Host functions are the primary attack surface — they cross the sandbox boundary and execute with full JVM privileges. + +**Always validate arguments from Wasm:** + +```java title="Example" +HostFunction readMemory = (Instance instance, long... args) -> { + int offset = (int) args[0]; + int length = (int) args[1]; + + // Validate bounds BEFORE accessing memory + var memory = instance.memory(); + if (offset < 0 || length < 0 || offset + length > memory.pages() * 65536) { + throw new TrapException("out of bounds memory access"); + } + + byte[] data = memory.readBytes(offset, length); + // ... process data safely + return new long[0]; +}; +``` + +**Key rules:** +- Validate all memory offsets and lengths before reading/writing +- Never use Wasm-provided values as array indices without bounds checking +- Be cautious with string decoding — enforce maximum lengths +- Avoid exposing file paths, SQL queries, or shell commands derived from Wasm input + +## WASI Sandboxing + +:::warning[Security Consideration] +WASI file access does not enforce path sandboxing by default. Passing the host filesystem directly exposes all files the JVM process can access. +::: + +**Use a virtual filesystem:** + +```java title="Example" +var options = WasiOptions.builder() + // Use ZeroFS to restrict access to specific directories + .withDirectory("/guest/data", Path.of("/host/sandboxed/data")) + .withStdout(myStdout) + .withStderr(myStderr) + .build(); +``` + +**Never use `inheritSystem()` with untrusted modules** — it grants full host filesystem, environment, and stdio access. + +## Resource Limits + +Wasm modules can consume unbounded CPU and memory. Always set limits when running untrusted code. + +**CPU timeout via thread interruption:** + +```java title="Example" +var executor = Executors.newSingleThreadExecutor(); +var future = executor.submit(() -> instance.export("run").apply()); + +try { + var result = future.get(5, TimeUnit.SECONDS); +} catch (TimeoutException e) { + future.cancel(true); // interrupts the Wasm execution +} +``` + +See [CPU Limits](/docs/advanced/cpu-limits) for more patterns. + +## Compiler Security + +The runtime and build-time compilers translate Wasm to JVM bytecode for performance. When running untrusted modules: + +- **Prefer the interpreter** for maximum sandbox assurance — it doesn't generate JVM bytecode +- **Protect compiler cache directories** with restrictive permissions (`chmod 700`) if using the directory cache +- **Set JVM heap limits** when compiling large untrusted modules to prevent resource exhaustion + +## Dependency Supply Chain + +- All Endive dependencies are checked against the [Bytecode Alliance allowed license list](/docs/security/overview) in CI +- Dependency vulnerabilities are scanned nightly via OWASP Dependency-Check +- Dependabot is enabled for automated security updates +- All dependency updates are manually reviewed before merging + + diff --git a/docs/docs/security/overview.md b/docs/docs/security/overview.md new file mode 100644 index 000000000..a9bfcdc88 --- /dev/null +++ b/docs/docs/security/overview.md @@ -0,0 +1,68 @@ +--- +sidebar_position: 1 +sidebar_label: Security Model +title: Security Model +--- + +# Security Model + +Endive executes WebAssembly modules inside the JVM. Understanding the security boundaries is essential when running untrusted code. + +## The Wasm Sandbox + +WebAssembly provides a sandboxed execution environment by design: + +- **Memory isolation**: Each Wasm module operates on its own linear memory. It cannot access the JVM heap, other modules' memory, or host memory directly. +- **No ambient capabilities**: Wasm modules have no access to the filesystem, network, environment variables, or system calls unless the host explicitly provides them via imports. +- **Control flow integrity**: Indirect calls are checked against a type table. Modules cannot jump to arbitrary code. +- **Deterministic execution**: The core Wasm spec produces deterministic results (with exceptions for floating-point NaN bit patterns and threading). + +## Trust Boundaries + +``` ++------------------------------------------------+ +| JVM Host Process | +| | +| +----------------+ +----------------+ | +| | Host Function A| | Host Function B| | +| +-------+--------+ +-------+--------+ | +| | | | +| - - - - | - trust boundary - | - - - - - - | +| | | | +| +-------v---------------------v--------+ | +| | Endive Runtime | | +| | | | +| | +----------+ +----------+ | | +| | | Wasm | | Wasm | | | +| | | Module A | | Module B | | | +| | +----------+ +----------+ | | +| +--------------------------------------+ | ++------------------------------------------------+ +``` + +The critical trust boundary is between **Wasm guest code** and **host functions**. Host functions have full JVM privileges. Any argument passed from Wasm to a host function must be validated before use. + +## What the Sandbox Does NOT Guarantee + +- **CPU limits**: Wasm modules can execute infinite loops. The host must enforce timeouts (see [CPU Limits](/docs/advanced/cpu-limits)). +- **Memory growth limits**: Modules can request memory growth up to the declared maximum. The host should set appropriate limits. +- **Post-compilation verification**: The build-time and runtime compilers translate Wasm to JVM bytecode without a separate verification pass. For maximum assurance with untrusted code, prefer the interpreter. +- **Cache integrity**: The directory-based compiler cache does not verify bytecode integrity on load. Protect cache directories with restrictive permissions. + +## WASI and Capability-Based Security + +When using WASI, the host controls what capabilities the guest receives: + +- **Filesystem access** is opt-in. Use a virtual filesystem (e.g., ZeroFS) to restrict access to specific directories. +- **Environment variables** and **command-line arguments** are explicitly passed by the host. +- **Standard I/O** streams are host-controlled. + +See [Best Practices](/docs/security/best-practices) for actionable guidance on securing your Endive deployment. + + diff --git a/docs/docs/usage/_category_.yml b/docs/docs/usage/_category_.yml deleted file mode 100644 index 71333ce4f..000000000 --- a/docs/docs/usage/_category_.yml +++ /dev/null @@ -1,2 +0,0 @@ -label: Usage -position: 10 diff --git a/docs/docs/usage/bom.md b/docs/docs/usage/bom.md deleted file mode 100644 index 9cb6d87f3..000000000 --- a/docs/docs/usage/bom.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -sidebar_position: 70 -sidebar_label: BOM -title: BOM ---- -# Bill of Materials - -To keep the versions of different Chicory artifacts aligned in your project you can use the provided -[Maven BOM file](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms). - -Import it in the `dependencyManagement` section of your `pom.xml`: - -```xml - - - - com.dylibso.chicory - bom - ${chicory.version} - pom - import - - - -``` - -and you can use any Chicory dependency without declaring the version number again in the build: - -```xml - - com.dylibso.chicory - runtime - -``` - - diff --git a/docs/docs/wasi/_category_.yml b/docs/docs/wasi/_category_.yml new file mode 100644 index 000000000..d861a92f6 --- /dev/null +++ b/docs/docs/wasi/_category_.yml @@ -0,0 +1,2 @@ +label: WASI +position: 30 diff --git a/docs/docs/usage/wasi.md b/docs/docs/wasi/index.md similarity index 88% rename from docs/docs/usage/wasi.md rename to docs/docs/wasi/index.md index 110a079b1..856555b3e 100644 --- a/docs/docs/usage/wasi.md +++ b/docs/docs/wasi/index.md @@ -5,11 +5,15 @@ title: Wasi Preview 1 --- # WASI Preview 1 +:::warning[Security Consideration] +WASI file access does not enforce path sandboxing by default. Always use a virtual filesystem (e.g., ZeroFS or JimFS) to restrict guest access to pre-opened directories. Passing the host filesystem directly exposes all files the JVM process can access. See [Security Best Practices](/docs/security/best-practices). +::: + @@ -30,7 +34,7 @@ Add the dependency to your build: ```xml - com.dylibso.chicory + run.endive wasi latest-release @@ -51,7 +55,7 @@ In order to instantiate a WASI module you need an instance of `WasiPreview1`. For instance, download the following example from the link or with curl: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/hello-wasi.wat.wasm > hello-wasi.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/hello-wasi.wat.wasm > hello-wasi.wasm ``` ```java -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.runtime.Store; +import run.endive.log.SystemLogger; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; +import run.endive.runtime.Store; import java.io.File; @@ -81,19 +85,19 @@ store.instantiate("hello-wasi", Parser.parse(new File("hello-wasi.wasm"))); ``` > **Note**: Notice that we don't explicitly execute the module. The module will run when you instantiate it. This -> is part of the WASI spec. A WASI module will implicitly call [`_start`](https://webassembly.github.io/spec/core/syntax/modules.html#start-function). To learn more [read this blog post](https://dylibso.com/blog/wasi-command-reactor/). +> is part of the WASI spec. A WASI module will implicitly call [`_start`](https://webassembly.github.io/spec/core/syntax/modules.html#start-function). To learn more [read this blog post](https://endive.run/historical-blog/wasi-command-reactor). ### stdin, stdout, and stderr To start with, you want to orchestrate stdin, stdout, and stderr of the module. -Often, this is the way you communicate with basic WASI-enabled modules by way of the [command pattern](https://dylibso.com/blog/wasi-command-reactor/). +Often, this is the way you communicate with basic WASI-enabled modules by way of the [command pattern](https://endive.run/historical-blog/wasi-command-reactor). In order to make it easy to manipulate these streams, we expose stdin as an [InputStream](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html) and stdout/stderr as an [OutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html). Download from the link or with curl: ```bash -curl https://raw.githubusercontent.com/dylibso/chicory/main/wasm-corpus/src/main/resources/compiled/greet-wasi.rs.wasm > greet-wasi.wasm +curl https://raw.githubusercontent.com/bytecodealliance/endive/main/wasm-corpus/src/main/resources/compiled/greet-wasi.rs.wasm > greet-wasi.wasm ``` ```java -// Let's create a fake stdin stream with the bytes "Chicory" -var fakeStdin = new ByteArrayInputStream("Chicory".getBytes()); +// Let's create a fake stdin stream with the bytes "Endive" +var fakeStdin = new ByteArrayInputStream("Endive".getBytes()); // We will create two output streams to capture stdout and stderr var fakeStdout = new ByteArrayOutputStream(); var fakeStderr = new ByteArrayOutputStream(); @@ -120,14 +124,14 @@ store.instantiate("hello-wasi", Parser.parse(new File("greet-wasi.wasm"))); // check that we output the greeting -assert(fakeStdout.toString().equals("Hello, Chicory!")); +assert(fakeStdout.toString().equals("Hello, Endive!")); // there should be no bytes in stderr! assert(fakeStderr.toString().equals("")); ``` @@ -181,7 +185,7 @@ import com.google.common.jimfs.Jimfs; try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix().toBuilder().setAttributeViews("unix").build())) { Path source = Path.of("my-source"); Path target = fs.getPath("my-source"); - com.dylibso.chicory.wasi.Files.copyDirectory(source, target); + run.endive.wasi.Files.copyDirectory(source, target); var wasi = WasiOptions.builder().withDirectory(target.toString(), target).build(); @@ -194,7 +198,7 @@ try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix().toBuilder().setAtt If your module calls a wasi function that we don't support, or uses a feature that we don't support, we will throw a `WasmRuntimeException`. -For the most up-to-date info, and to see what specific functions we support, see the [WasiPreview1.java](https://github.com/dylibso/chicory/blob/main/wasi/src/main/java/com/dylibso/chicory/wasi/WasiPreview1.java) and the following table: +For the most up-to-date info, and to see what specific functions we support, see the [WasiPreview1.java](https://github.com/bytecodealliance/endive/blob/main/wasi/src/main/java/run/endive/wasi/WasiPreview1.java) and the following table: | WASI Function | Supported | Notes | diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts index 0ec3b91cb..419269cca 100644 --- a/docs/docusaurus.config.ts +++ b/docs/docusaurus.config.ts @@ -3,20 +3,20 @@ import type { Config } from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; const config: Config = { - title: 'Chicory', - tagline: 'Chicory, a JVM native WebAssembly runtime', + title: 'Endive', + tagline: 'Endive, a JVM native WebAssembly runtime', favicon: 'img/favicon.ico', // Set the production url of your site here - url: 'https://chicory.dev', + url: 'https://endive.run', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' baseUrl: '/', // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. - organizationName: 'dylibso', // Usually your GitHub org/user name. - projectName: 'chicory', // Usually your repo name. + organizationName: 'bytecodealliance', // Usually your GitHub org/user name. + projectName: 'endive', // Usually your repo name. onBrokenLinks: 'warn', // TODO: fixme when everything is ready: 'throw', onBrokenMarkdownLinks: 'warn', @@ -35,12 +35,64 @@ const config: Config = { { redirects: [ { - to: '/docs/usage/annotations', - from: ['/docs/experimental/host-modules'], + to: '/docs/annotations', + from: ['/docs/experimental/host-modules', '/docs/usage/annotations'], }, { - to: '/docs/usage/runtime-compiler', - from: ['/docs/experimental/aot'], + to: '/docs/execution/runtime-compiler', + from: ['/docs/experimental/aot', '/docs/usage/runtime-compiler'], + }, + { + to: '/docs/execution/build-time-compiler', + from: ['/docs/usage/build-time-compiler'], + }, + { + to: '/docs/core/host-functions', + from: ['/docs/usage/host-functions'], + }, + { + to: '/docs/core/memory', + from: ['/docs/usage/memory'], + }, + { + to: '/docs/core/linking', + from: ['/docs/usage/linking'], + }, + { + to: '/docs/core/execution-modes', + from: ['/docs/usage/execution_modes'], + }, + { + to: '/docs/wasi', + from: ['/docs/usage/wasi'], + }, + { + to: '/docs/advanced/cpu-limits', + from: ['/docs/usage/cpu'], + }, + { + to: '/docs/advanced/simd', + from: ['/docs/usage/simd'], + }, + { + to: '/docs/advanced/tools', + from: ['/docs/usage/tools'], + }, + { + to: '/docs/advanced/logging', + from: ['/docs/usage/logging'], + }, + { + to: '/docs/getting-started/installation', + from: ['/docs/usage/bom'], + }, + { + to: '/docs/advanced/memory-customization', + from: ['/docs/advanced/memory'], + }, + { + to: '/docs/execution/compiler-cache', + from: ['/docs/experimental/runtime-compiler-cache'], }, ], }, @@ -73,12 +125,13 @@ const config: Config = { themeConfig: { // Replace with your project's social card - image: 'img/chicory1.png', + image: 'img/endive.png', navbar: { - title: 'Chicory', + title: 'Endive', logo: { - alt: 'Chicory Logo', - src: 'img/chicory1.png', + alt: 'Endive Logo', + src: 'img/endive.png', + srcDark: 'img/endive-dark.png', }, items: [ { @@ -89,7 +142,7 @@ const config: Config = { }, { to: '/blog', label: 'Blog', position: 'left' }, { - href: 'https://github.com/dylibso/chicory', + href: 'https://github.com/bytecodealliance/endive', label: 'GitHub', position: 'right', }, @@ -112,7 +165,7 @@ const config: Config = { items: [ { label: 'Zulip', - href: 'https://chicory.zulipchat.com/', + href: 'https://bytecodealliance.zulipchat.com/#narrow/stream/endive', }, ], }, @@ -125,12 +178,12 @@ const config: Config = { }, { label: 'GitHub', - href: 'https://github.com/dylibso/chicory', + href: 'https://github.com/bytecodealliance/endive', }, ], }, ], - copyright: `Copyright © ${new Date().getFullYear()} Dylibso, Inc. Built with Docusaurus.`, + copyright: `Copyright © ${new Date().getFullYear()} Bytecode Alliance. Built with Docusaurus.`, }, prism: { theme: prismThemes.github, diff --git a/docs/src/components/HomepageFeatures/index.tsx b/docs/src/components/HomepageFeatures/index.tsx index 3613de923..9533a76a2 100644 --- a/docs/src/components/HomepageFeatures/index.tsx +++ b/docs/src/components/HomepageFeatures/index.tsx @@ -10,35 +10,36 @@ type FeatureItem = { const FeatureList: FeatureItem[] = [ { - title: 'Pure Java', - Svg: require('@site/static/img/zero-deps.svg').default, + title: 'Zero Native Dependencies', + Svg: require('@site/static/img/icon-zero-deps.svg').default, description: ( <> - Using Chicory you don't need to rely on any system resource. - Everything runs in 100% pure Java on top of the standard library. + Run WebAssembly anywhere the JVM runs — no JNI, no native libraries, + no platform-specific binaries. Ship a single JAR to every OS and architecture. ), }, { - title: 'Easy integration', - Svg: require('@site/static/img/wrench.svg').default, + title: 'Sandboxed by Default', + Svg: require('@site/static/img/icon-sandbox.svg').default, description: ( <> - Integrating Chicory in your project is smooth and only requires a few steps. - Give your application a twist with a plugin system. + Wasm modules execute in an isolated sandbox with no ambient capabilities. + Your host controls what the guest can access — memory, files, and system calls. ), }, { - title: 'Secure by design', - Svg: require('@site/static/img/helmet.svg').default, + title: 'Drop-in Integration', + Svg: require('@site/static/img/icon-integration.svg').default, description: ( <> - Web Assembly modules are running in a sandboxed environment. - You have full control over the used resources. + Add a single Maven dependency to embed Wasm in your Java app. + Choose between interpreter, runtime compiler, or build-time compiler + depending on your needs. ), - } + }, ]; function Feature({title, Svg, description}: FeatureItem) { diff --git a/docs/src/components/HomepageFeatures/styles.module.css b/docs/src/components/HomepageFeatures/styles.module.css index b248eb2e5..c283da564 100644 --- a/docs/src/components/HomepageFeatures/styles.module.css +++ b/docs/src/components/HomepageFeatures/styles.module.css @@ -6,6 +6,7 @@ } .featureSvg { - height: 200px; - width: 200px; + height: 120px; + width: 120px; + color: var(--ifm-color-primary); } diff --git a/docs/src/css/custom.css b/docs/src/css/custom.css index 5377b780a..e7a533233 100644 --- a/docs/src/css/custom.css +++ b/docs/src/css/custom.css @@ -4,27 +4,29 @@ * work well for content-centric websites. */ -/* You can override the default Infima variables here. */ :root { - --ifm-color-primary: #4a7c99; /* Adjusted to a teal color */ - --ifm-color-primary-dark: #2a202b; - --ifm-color-primary-darker: #1f2e3d; /* Darkened to contrast with the lighter colors */ - --ifm-color-primary-darkest: #000000; - --ifm-color-primary-light: #6ea5bd; /* A lighter tone for readability */ - --ifm-color-primary-lighter: #88b2c7; /* A softer shade */ - --ifm-color-primary-lightest: #9cc4d4; /* Very light for accents */ + --ifm-color-primary: #4a6b2a; + --ifm-color-primary-dark: #3d5a1e; + --ifm-color-primary-darker: #335019; + --ifm-color-primary-darkest: #243a10; + --ifm-color-primary-light: #5a7d38; + --ifm-color-primary-lighter: #6a8d48; + --ifm-color-primary-lightest: #7ea05c; --ifm-code-font-size: 95%; - --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); + --docusaurus-highlighted-code-line-bg: rgba(74, 107, 42, 0.1); } -/* Dark mode adjustments */ [data-theme='dark'] { - --ifm-color-primary: #209683; /* Muted teal color */ - --ifm-color-primary-dark: #1b7a6a; /* A bit darker but still within the same hue */ - --ifm-color-primary-darker: #176f61; /* Darker tone for depth */ - --ifm-color-primary-darkest: #13564e; /* Deepest tone for contrast */ - --ifm-color-primary-light: #27a792; /* Softened light version */ - --ifm-color-primary-lighter: #3cb7a2; /* Lighter for accents */ - --ifm-color-primary-lightest: #57c6b3; /* Lightest, slightly muted */ - --docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.2); /* Soft highlight */ + --ifm-color-primary: #8bb86a; + --ifm-color-primary-dark: #7da85c; + --ifm-color-primary-darker: #6f9a4e; + --ifm-color-primary-darkest: #5a7d38; + --ifm-color-primary-light: #99c47a; + --ifm-color-primary-lighter: #a7d08a; + --ifm-color-primary-lightest: #b5dca0; + --docusaurus-highlighted-code-line-bg: rgba(139, 184, 106, 0.15); +} + +.footer--dark { + --ifm-footer-background-color: #1a2e1a; } diff --git a/docs/src/pages/index.module.css b/docs/src/pages/index.module.css index a682d4c08..b18752724 100644 --- a/docs/src/pages/index.module.css +++ b/docs/src/pages/index.module.css @@ -8,6 +8,7 @@ text-align: center; position: relative; overflow: hidden; + background: none; } @media screen and (max-width: 996px) { @@ -16,14 +17,24 @@ } } +.heroLogo { + max-width: 400px; + width: 80%; + margin-bottom: 1.5rem; +} + +[data-theme='dark'] .heroLogo { + filter: invert(0.85) hue-rotate(180deg); +} + +.heroSubtitle { + font-size: 1.4rem; + margin-bottom: 2rem; + color: var(--ifm-color-emphasis-700); +} + .buttons { display: flex; align-items: center; justify-content: center; } - -.bigLogo { - height: 30%; - max-height: 500px; - padding: 4em; -} diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index cb7b2d87d..7faa16866 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -1,28 +1,38 @@ import clsx from 'clsx'; import Link from '@docusaurus/Link'; -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Layout from '@theme/Layout'; import HomepageFeatures from '@site/src/components/HomepageFeatures'; -import Heading from '@theme/Heading'; +import ThemedImage from '@theme/ThemedImage'; import styles from './index.module.css'; function HomepageHeader() { - const {siteConfig} = useDocusaurusContext(); return ( -

+
- - {siteConfig.title} - -

{siteConfig.tagline}

- + +

+ A JVM native WebAssembly runtime +

Get Started + + GitHub +
@@ -30,11 +40,10 @@ function HomepageHeader() { } export default function Home(): JSX.Element { - const {siteConfig} = useDocusaurusContext(); return ( + title="JVM native WebAssembly runtime" + description="Endive is a JVM native WebAssembly runtime with zero native dependencies.">
diff --git a/docs/static/CNAME b/docs/static/CNAME new file mode 100644 index 000000000..d059fa19f --- /dev/null +++ b/docs/static/CNAME @@ -0,0 +1 @@ +endive.run diff --git a/docs/static/img/chicory1.png b/docs/static/img/chicory1.png deleted file mode 100644 index c876b8c59..000000000 Binary files a/docs/static/img/chicory1.png and /dev/null differ diff --git a/docs/static/img/endive-dark.png b/docs/static/img/endive-dark.png new file mode 100644 index 000000000..1ac99c161 Binary files /dev/null and b/docs/static/img/endive-dark.png differ diff --git a/docs/static/img/endive-hero-dark.png b/docs/static/img/endive-hero-dark.png new file mode 100644 index 000000000..4e7cd4ae0 Binary files /dev/null and b/docs/static/img/endive-hero-dark.png differ diff --git a/docs/static/img/endive-hero.png b/docs/static/img/endive-hero.png new file mode 100644 index 000000000..4e7cd4ae0 Binary files /dev/null and b/docs/static/img/endive-hero.png differ diff --git a/docs/static/img/endive.png b/docs/static/img/endive.png new file mode 100644 index 000000000..1ac99c161 Binary files /dev/null and b/docs/static/img/endive.png differ diff --git a/docs/static/img/favicon.ico b/docs/static/img/favicon.ico index c3080e051..fd8efcbd6 100644 Binary files a/docs/static/img/favicon.ico and b/docs/static/img/favicon.ico differ diff --git a/docs/static/img/helmet.svg b/docs/static/img/helmet.svg deleted file mode 100644 index 3f7a18749..000000000 --- a/docs/static/img/helmet.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/static/img/icon-integration.svg b/docs/static/img/icon-integration.svg new file mode 100644 index 000000000..933b1a795 --- /dev/null +++ b/docs/static/img/icon-integration.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docs/static/img/icon-sandbox.svg b/docs/static/img/icon-sandbox.svg new file mode 100644 index 000000000..3b7ba5f12 --- /dev/null +++ b/docs/static/img/icon-sandbox.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/docs/static/img/icon-zero-deps.svg b/docs/static/img/icon-zero-deps.svg new file mode 100644 index 000000000..db70013f0 --- /dev/null +++ b/docs/static/img/icon-zero-deps.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/docs/static/img/wrench.svg b/docs/static/img/wrench.svg deleted file mode 100644 index afe899f47..000000000 --- a/docs/static/img/wrench.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/static/img/zero-deps.svg b/docs/static/img/zero-deps.svg deleted file mode 100644 index 93f6fedb5..000000000 --- a/docs/static/img/zero-deps.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/tests/approvals/docs-advanced-memory.md.approved.txt b/docs/tests/approvals/docs-advanced-cpu-limits.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-advanced-memory.md.approved.txt rename to docs/tests/approvals/docs-advanced-cpu-limits.md.approved.txt diff --git a/docs/tests/approvals/docs-experimental-runtime-compiler-cache.md.approved.txt b/docs/tests/approvals/docs-advanced-logging.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-experimental-runtime-compiler-cache.md.approved.txt rename to docs/tests/approvals/docs-advanced-logging.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-annotations.md.approved.txt b/docs/tests/approvals/docs-advanced-memory-customization.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-annotations.md.approved.txt rename to docs/tests/approvals/docs-advanced-memory-customization.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-bom.md.approved.txt b/docs/tests/approvals/docs-advanced-simd.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-bom.md.approved.txt rename to docs/tests/approvals/docs-advanced-simd.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-tools.md.approved.txt b/docs/tests/approvals/docs-advanced-tools.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-tools.md.approved.txt rename to docs/tests/approvals/docs-advanced-tools.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-build-time-compiler.md.approved.txt b/docs/tests/approvals/docs-annotations-index.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-build-time-compiler.md.approved.txt rename to docs/tests/approvals/docs-annotations-index.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-cpu.md.approved.txt b/docs/tests/approvals/docs-core-execution-modes.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-cpu.md.approved.txt rename to docs/tests/approvals/docs-core-execution-modes.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-host-functions.md.approved.txt b/docs/tests/approvals/docs-core-host-functions.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-host-functions.md.approved.txt rename to docs/tests/approvals/docs-core-host-functions.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-execution_modes.md.approved.txt b/docs/tests/approvals/docs-core-linking.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-execution_modes.md.approved.txt rename to docs/tests/approvals/docs-core-linking.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-memory.md.approved.txt b/docs/tests/approvals/docs-core-memory.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-memory.md.approved.txt rename to docs/tests/approvals/docs-core-memory.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-linking.md.approved.txt b/docs/tests/approvals/docs-execution-build-time-compiler.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-linking.md.approved.txt rename to docs/tests/approvals/docs-execution-build-time-compiler.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-logging.md.approved.txt b/docs/tests/approvals/docs-execution-compiler-cache.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-logging.md.approved.txt rename to docs/tests/approvals/docs-execution-compiler-cache.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-runtime-compiler.md.approved.txt b/docs/tests/approvals/docs-execution-runtime-compiler.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-runtime-compiler.md.approved.txt rename to docs/tests/approvals/docs-execution-runtime-compiler.md.approved.txt diff --git a/docs/tests/approvals/docs-usage-simd.md.approved.txt b/docs/tests/approvals/docs-getting-started-installation.md.approved.txt similarity index 100% rename from docs/tests/approvals/docs-usage-simd.md.approved.txt rename to docs/tests/approvals/docs-getting-started-installation.md.approved.txt diff --git a/docs/tests/approvals/docs-migration-from-chicory.md.approved.txt b/docs/tests/approvals/docs-migration-from-chicory.md.approved.txt new file mode 100644 index 000000000..c6cac6926 --- /dev/null +++ b/docs/tests/approvals/docs-migration-from-chicory.md.approved.txt @@ -0,0 +1 @@ +empty diff --git a/docs/tests/approvals/docs-security-best-practices.md.approved.txt b/docs/tests/approvals/docs-security-best-practices.md.approved.txt new file mode 100644 index 000000000..c6cac6926 --- /dev/null +++ b/docs/tests/approvals/docs-security-best-practices.md.approved.txt @@ -0,0 +1 @@ +empty diff --git a/docs/tests/approvals/docs-security-overview.md.approved.txt b/docs/tests/approvals/docs-security-overview.md.approved.txt new file mode 100644 index 000000000..c6cac6926 --- /dev/null +++ b/docs/tests/approvals/docs-security-overview.md.approved.txt @@ -0,0 +1 @@ +empty diff --git a/docs/tests/approvals/docs-usage-wasi.md.approved.txt b/docs/tests/approvals/docs-usage-wasi.md.approved.txt deleted file mode 100644 index c4137e608..000000000 --- a/docs/tests/approvals/docs-usage-wasi.md.approved.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, Chicory! diff --git a/docs/tests/approvals/docs-wasi-index.md.approved.txt b/docs/tests/approvals/docs-wasi-index.md.approved.txt new file mode 100644 index 000000000..17e8a5e06 --- /dev/null +++ b/docs/tests/approvals/docs-wasi-index.md.approved.txt @@ -0,0 +1 @@ +Hello, Endive! diff --git a/endive-plan.md b/endive-plan.md new file mode 100644 index 000000000..444cf4728 --- /dev/null +++ b/endive-plan.md @@ -0,0 +1,170 @@ + +# Endive Fork Plan — Chicory to Bytecode Alliance + +This project is being forked under the Bytecode Alliance. +We need to take care of all the pre-requisites and legal aspects. + +## Decisions + +- **ArtifactId naming**: Keep current names (`runtime`, `compiler`, `wasm`, etc.) under `run.endive` groupId +- **License**: Keep Apache 2.0 as-is — exemption already granted by BA. Do NOT modify the LICENSE file. +- **Copyright headers**: No — do not add copyright headers to source files +- **Blog posts**: Keep as historical data, move to a separate section in docs +- **Transparent logos**: Create from existing PNGs + +--- + +## 1. Namespace Rename (`com.dylibso.chicory` -> `run.endive`) + +Bulk rename across the entire repo: + +- **Java packages**: All `package com.dylibso.chicory.*` and `import` statements (~236 source + ~61 test files) +- **Directory structure**: `src/main/java/com/dylibso/chicory/` -> `src/main/java/run/endive/` +- **module-info.java**: Module names `com.dylibso.chicory.*` -> `run.endive.*` +- **pom.xml files** (~28): ``, internal dependency references +- **Root pom.xml**: ``, ``, ``, ``, ``, `` +- **Android tests**: `gradle/libs.versions.toml` references `com.dylibso.chicory:*` +- **Java templates**: `wasm/src/main/java-templates/com/dylibso/chicory/wasm/Version.java` + +Validate with `mvn compile` after rename. + +--- + +## 2. Legal & Attribution + +### 2.1 NOTICE file +Create `NOTICE` in repo root: +``` +Endive +Copyright 2026 The Bytecode Alliance + +This project is based on Chicory, originally created by Dylibso, Inc. +Original source: https://github.com/dylibso/chicory +``` + +### 2.2 LICENSE +Do NOT update. Already Apache 2.0, exemption granted for the LLVM exception requirement. + +--- + +## 3. README Rewrite + +Following the Pekko model and BA README requirements: + +- **Header**: Project name "Endive" + new logo + one-line description +- **BA branding** (required): `A Bytecode Alliance hosted project` +- **Fork attribution** (Pekko-style): "Endive is a fork of [Chicory](https://github.com/dylibso/chicory) by Dylibso, Inc. We thank Dylibso for the incubation period." +- **Goals**: Position as "the default Wasm runtime on the JVM" — remove hedging/"negative" references around speed +- **Update all links**: chicory.dev -> endive.run, dylibso/chicory -> bytecodealliance/endive + +--- + +## 4. Governance Files + +### 4.1 CODE_OF_CONDUCT.md (REQUIRED, missing) +Create `CODE_OF_CONDUCT.md` linking to [BA Code of Conduct](https://github.com/bytecodealliance/governance/blob/main/CODE_OF_CONDUCT.md). + +### 4.2 CODEOWNERS (recommended) +Add `.github/CODEOWNERS` assigning reviewers. + +### 4.3 SECURITY.md (needs update) +Currently references "Chicory team" and `dylibso/chicory` security advisories. Update to reference Endive/BA. + +### 4.4 CONTRIBUTING.md (needs update) +Still references Chicory — update project name, links, philosophy section. + +### 4.5 ADOPTERS.md (recommended) +Extract adopter list from README into dedicated `ADOPTERS.md`. + +### 4.6 Automated license validation in CI (required) +Add `license-maven-plugin` or equivalent. Validate all deps use BA-allowed licenses. + +### 4.7 Dependency auditing in CI (required) +Add OWASP Dependency-Check or similar. + +--- + +## 5. CI/CD & Build Configuration + +### 5.1 GitHub Workflows +- **release.yaml**: Bot identity `"Chicory BOT" ` -> update for Endive +- **release.yaml**: Publishing credentials — new Maven Central credentials under BA org +- **perf.yaml**: References `nightly.link/dylibso/chicory` -> update +- **All workflows**: Review and update any hardcoded chicory/dylibso references + +### 5.2 Maven Central Publishing +- New Sonatype/Central credentials for `run.endive` groupId +- New GPG signing key for BA org +- Update `central-publishing-maven-plugin` config + +### 5.3 Root pom.xml Metadata +- `` -> Bytecode Alliance +- `` -> Update email from `oss@dylibso.com` +- `` -> `github.com/bytecodealliance/endive` +- `` -> `github.com/bytecodealliance/endive/issues` +- `` -> `https://endive.run` + +--- + +## 6. Branding & Logos + +Source: `/home/andreatp/Documents/Endive_logos/` (8 PNG variants) + +- Copy appropriate variants into repo root and `docs/static/img/` +- Create transparent-background versions from existing PNGs +- Replace `chicory1.png` in repo root and docs +- Update `docs/static/img/favicon.ico` + +--- + +## 7. Other Files + +- **AGENT.md**: Completely references Chicory — update to Endive +- **scripts/build-jmh-main.sh**: Clones from `github.com/dylibso/chicory` — update URL +- **docs/docusaurus.config.ts**: title, tagline, url (-> endive.run), organizationName, projectName, copyright +- **Blog posts**: Keep as historical data, move to separate section (handle with docs follow-up) + +--- + +## 8. Deferred Items + +- Documentation site deployment/hosting +- Full docs content rewrite +- Blog posts reorganization + +--- + +## Execution Order + +1. **Scripted bulk rename** (namespace, directories, pom files) +2. **Build validation** — `mvn compile` +3. **Legal files** — NOTICE, CODE_OF_CONDUCT.md +4. **README rewrite** — BA header, attribution, goals +5. **Governance files** — SECURITY.md, CONTRIBUTING.md, CODEOWNERS, ADOPTERS.md +6. **Root pom.xml metadata** — organization, SCM, developers +7. **CI/CD updates** — workflows, bot identity +8. **Branding** — logos, favicon, AGENT.md +9. **Docs config** — docusaurus.config.ts +10. **CI additions** — license validation, dependency auditing +11. **Full build + test** — `mvn clean install` + +## Verification + +- `grep -r "dylibso\|chicory" --include="*.java" --include="*.xml" --include="*.yaml" --include="*.md" --include="*.ts" --include="*.toml"` — should return zero hits (except intentional attribution in NOTICE/README/blog) +- `mvn clean install` passes +- All module-info.java compile correctly with new module names + +## BA Governance Checklist + +Reference: `/home/andreatp/workspace/bytecodealliance-governance/projects/hosted/endive.md` + +- [ ] README with BA branding +- [ ] CODE_OF_CONDUCT.md +- [ ] CODEOWNERS +- [ ] SECURITY.md updated +- [ ] CONTRIBUTING.md updated +- [ ] ADOPTERS.md +- [ ] Automated license validation in CI +- [ ] Dependency auditing in CI +- [ ] NOTICE file +- [ ] All links point to bytecodealliance/endive diff --git a/endive.png b/endive.png new file mode 100644 index 000000000..bd84eae0b Binary files /dev/null and b/endive.png differ diff --git a/fuzz/README.md b/fuzz/README.md index d605645fa..bc0099713 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -1,6 +1,6 @@ # fuzz -Differential fuzz testing module — compares Chicory's interpreter against its compiler using randomly generated WebAssembly modules. +Differential fuzz testing module — compares Endive's interpreter against its compiler using randomly generated WebAssembly modules. ## How it works @@ -8,7 +8,7 @@ Differential fuzz testing module — compares Chicory's interpreter against its 2. Each module's exported functions are called with random parameters through both the **interpreter** (oracle) and the **compiler** (subject) 3. Results are compared — any difference is a bug -No external tools are required. Everything runs in-process using Chicory itself. +No external tools are required. Everything runs in-process using Endive itself. ## Running diff --git a/fuzz/pom.xml b/fuzz/pom.xml index 7798ee137..040ea03d5 100644 --- a/fuzz/pom.xml +++ b/fuzz/pom.xml @@ -3,15 +3,15 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT fuzz jar - Chicory - Fuzz - Fuzz testing Chicory + Endive - Fuzz + Fuzz testing Endive true @@ -19,30 +19,25 @@ - com.dylibso.chicory + org.apache.commons + commons-lang3 + + + run.endive log - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - com.dylibso.chicory + run.endive wasm-tools - - org.apache.commons - commons-lang3 - - - com.dylibso.chicory - compiler - test - org.junit.jupiter @@ -59,5 +54,10 @@ junit-jupiter-params test + + run.endive + compiler + test + diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/TestResult.java b/fuzz/src/main/java/com/dylibso/chicory/fuzz/TestResult.java deleted file mode 100644 index 6801c1f48..000000000 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/TestResult.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.dylibso.chicory.fuzz; - -public class TestResult { - - private String oracleResult; - private String chicoryResult; - - public TestResult(String oracleResult, String chicoryResult) { - this.oracleResult = oracleResult; - this.chicoryResult = chicoryResult; - } - - public String getOracleResult() { - return oracleResult; - } - - public String getChicoryResult() { - return chicoryResult; - } -} diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/CrashReproducer.java b/fuzz/src/main/java/run/endive/fuzz/CrashReproducer.java similarity index 98% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/CrashReproducer.java rename to fuzz/src/main/java/run/endive/fuzz/CrashReproducer.java index 1b0ab21ab..fafac9b54 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/CrashReproducer.java +++ b/fuzz/src/main/java/run/endive/fuzz/CrashReproducer.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import java.io.File; import java.io.FileOutputStream; diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/ChicoryRunner.java b/fuzz/src/main/java/run/endive/fuzz/DefaultRunner.java similarity index 73% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/ChicoryRunner.java rename to fuzz/src/main/java/run/endive/fuzz/DefaultRunner.java index 8588aa96f..cacf93f9d 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/ChicoryRunner.java +++ b/fuzz/src/main/java/run/endive/fuzz/DefaultRunner.java @@ -1,29 +1,29 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; -import com.dylibso.chicory.runtime.ChicoryInterruptedException; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.wasm.Parser; import java.io.File; import java.util.List; import java.util.function.Function; +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.runtime.WasmInterruptedException; +import run.endive.wasm.Parser; -public class ChicoryRunner implements WasmRunner { +public class DefaultRunner implements WasmRunner { private final Function machineFactory; - public ChicoryRunner() { + public DefaultRunner() { this(null); } - public ChicoryRunner(Function machineFactory) { + public DefaultRunner(Function machineFactory) { this.machineFactory = machineFactory; } @Override public String run(File wasmFile, String functionName, List params) throws Exception { if (Thread.currentThread().isInterrupted()) { - throw new ChicoryInterruptedException("Thread interrupted"); + throw new WasmInterruptedException("Thread interrupted"); } var module = Parser.parse(wasmFile); var builder = Instance.builder(module).withInitialize(true).withStart(false); diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionType.java b/fuzz/src/main/java/run/endive/fuzz/InstructionType.java similarity index 95% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionType.java rename to fuzz/src/main/java/run/endive/fuzz/InstructionType.java index da4e8cd89..1048f934e 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionType.java +++ b/fuzz/src/main/java/run/endive/fuzz/InstructionType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import java.util.HashMap; import java.util.Map; diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionTypes.java b/fuzz/src/main/java/run/endive/fuzz/InstructionTypes.java similarity index 97% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionTypes.java rename to fuzz/src/main/java/run/endive/fuzz/InstructionTypes.java index ce9e0dcff..d96425991 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/InstructionTypes.java +++ b/fuzz/src/main/java/run/endive/fuzz/InstructionTypes.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import java.util.Arrays; import java.util.Locale; diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/TestModule.java b/fuzz/src/main/java/run/endive/fuzz/TestModule.java similarity index 95% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/TestModule.java rename to fuzz/src/main/java/run/endive/fuzz/TestModule.java index 9f57bcaa0..569e23807 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/TestModule.java +++ b/fuzz/src/main/java/run/endive/fuzz/TestModule.java @@ -1,11 +1,5 @@ -package com.dylibso.chicory.fuzz; - -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionType; +package run.endive.fuzz; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -18,6 +12,12 @@ import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import org.apache.commons.lang3.RandomStringUtils; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.Instance; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionType; public class TestModule { private static final Logger logger = new SystemLogger(); diff --git a/fuzz/src/main/java/run/endive/fuzz/TestResult.java b/fuzz/src/main/java/run/endive/fuzz/TestResult.java new file mode 100644 index 000000000..c2d5f50cc --- /dev/null +++ b/fuzz/src/main/java/run/endive/fuzz/TestResult.java @@ -0,0 +1,20 @@ +package run.endive.fuzz; + +public class TestResult { + + private String oracleResult; + private String engineResult; + + public TestResult(String oracleResult, String engineResult) { + this.oracleResult = oracleResult; + this.engineResult = engineResult; + } + + public String getOracleResult() { + return oracleResult; + } + + public String getEngineResult() { + return engineResult; + } +} diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmRunner.java b/fuzz/src/main/java/run/endive/fuzz/WasmRunner.java similarity index 84% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmRunner.java rename to fuzz/src/main/java/run/endive/fuzz/WasmRunner.java index 3e9770e25..566ee8db8 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmRunner.java +++ b/fuzz/src/main/java/run/endive/fuzz/WasmRunner.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import java.io.File; import java.util.List; diff --git a/fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmSmithWrapper.java b/fuzz/src/main/java/run/endive/fuzz/WasmSmithWrapper.java similarity index 94% rename from fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmSmithWrapper.java rename to fuzz/src/main/java/run/endive/fuzz/WasmSmithWrapper.java index 659df241a..4d56453b7 100644 --- a/fuzz/src/main/java/com/dylibso/chicory/fuzz/WasmSmithWrapper.java +++ b/fuzz/src/main/java/run/endive/fuzz/WasmSmithWrapper.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import static java.nio.charset.StandardCharsets.UTF_8; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.tools.wasm.WasmSmith; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.LinkedHashMap; import org.apache.commons.lang3.RandomStringUtils; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.tools.wasm.WasmSmith; public class WasmSmithWrapper { diff --git a/fuzz/src/test/java/com/dylibso/chicory/fuzz/FuzzTest.java b/fuzz/src/test/java/run/endive/fuzz/FuzzTest.java similarity index 89% rename from fuzz/src/test/java/com/dylibso/chicory/fuzz/FuzzTest.java rename to fuzz/src/test/java/run/endive/fuzz/FuzzTest.java index e9a8bd394..eeba6c5e4 100644 --- a/fuzz/src/test/java/com/dylibso/chicory/fuzz/FuzzTest.java +++ b/fuzz/src/test/java/run/endive/fuzz/FuzzTest.java @@ -1,28 +1,28 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; import java.io.File; import java.io.IOException; import java.util.ArrayList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; public class FuzzTest extends TestModule { private static final Logger logger = new SystemLogger(); private static final int ITERATIONS = Integer.getInteger("fuzz.test.iterations", 10); private final WasmSmithWrapper smith = new WasmSmithWrapper(); - private final WasmRunner interpreterRunner = new ChicoryRunner(); - private final WasmRunner compilerRunner = new ChicoryRunner(MachineFactoryCompiler::compile); + private final WasmRunner interpreterRunner = new DefaultRunner(); + private final WasmRunner compilerRunner = new DefaultRunner(MachineFactoryCompiler::compile); @AfterEach void tearDown() { @@ -104,15 +104,15 @@ void differentialFuzz(InstructionType type) throws Exception { true); for (var res : results) { - if (res.getChicoryResult() == null) { + if (res.getEngineResult() == null) { // Compiler crashed — reproducer already saved by testModule failures.add("compiler crash (subject returned null)"); - } else if (!res.getOracleResult().equals(res.getChicoryResult())) { + } else if (!res.getOracleResult().equals(res.getEngineResult())) { failures.add( "mismatch: oracle=" + res.getOracleResult() + " subject=" - + res.getChicoryResult()); + + res.getEngineResult()); } } } diff --git a/fuzz/src/test/java/com/dylibso/chicory/fuzz/RegressionTest.java b/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java similarity index 88% rename from fuzz/src/test/java/com/dylibso/chicory/fuzz/RegressionTest.java rename to fuzz/src/test/java/run/endive/fuzz/RegressionTest.java index 309fec057..36520565a 100644 --- a/fuzz/src/test/java/com/dylibso/chicory/fuzz/RegressionTest.java +++ b/fuzz/src/test/java/run/endive/fuzz/RegressionTest.java @@ -1,12 +1,9 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import java.io.File; import java.io.FileInputStream; import java.util.Arrays; @@ -15,11 +12,14 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class RegressionTest extends TestModule { - private final WasmRunner interpreterRunner = new ChicoryRunner(); - private final WasmRunner compilerRunner = new ChicoryRunner(MachineFactoryCompiler::compile); + private final WasmRunner interpreterRunner = new DefaultRunner(); + private final WasmRunner compilerRunner = new DefaultRunner(MachineFactoryCompiler::compile); private static Stream crashFolders() { return Stream.of(new File("src/test/resources"), new File("target/crash-reproducers")) @@ -81,8 +81,8 @@ void regressionTests(File folder) throws Exception { false); for (var res : results) { - if (res.getChicoryResult() != null) { - assertEquals(res.getOracleResult(), res.getChicoryResult()); + if (res.getEngineResult() != null) { + assertEquals(res.getOracleResult(), res.getEngineResult()); } } assertDoesNotThrow(() -> Instance.builder(module).build()); diff --git a/fuzz/src/test/java/com/dylibso/chicory/fuzz/SingleReproTest.java b/fuzz/src/test/java/run/endive/fuzz/SingleReproTest.java similarity index 82% rename from fuzz/src/test/java/com/dylibso/chicory/fuzz/SingleReproTest.java rename to fuzz/src/test/java/run/endive/fuzz/SingleReproTest.java index 56dca6714..ff5393238 100644 --- a/fuzz/src/test/java/com/dylibso/chicory/fuzz/SingleReproTest.java +++ b/fuzz/src/test/java/run/endive/fuzz/SingleReproTest.java @@ -1,22 +1,22 @@ -package com.dylibso.chicory.fuzz; +package run.endive.fuzz; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import java.nio.file.Files; import java.nio.file.Paths; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class SingleReproTest extends TestModule { private static final String CHICORY_FUZZ_SEED_KEY = "CHICORY_FUZZ_SEED"; private static final String CHICORY_FUZZ_TYPES_KEY = "CHICORY_FUZZ_TYPES"; private final WasmSmithWrapper smith = new WasmSmithWrapper(); - private final WasmRunner interpreterRunner = new ChicoryRunner(); - private final WasmRunner compilerRunner = new ChicoryRunner(MachineFactoryCompiler::compile); + private final WasmRunner interpreterRunner = new DefaultRunner(); + private final WasmRunner compilerRunner = new DefaultRunner(MachineFactoryCompiler::compile); boolean enableSingleReproducer() { return System.getenv(CHICORY_FUZZ_SEED_KEY) != null diff --git a/jmh/README.md b/jmh/README.md index b362e9f16..817e1fd23 100644 --- a/jmh/README.md +++ b/jmh/README.md @@ -1,6 +1,6 @@ # jmh -This module is used to run JMH performance tests on Chicory and make it easy to compare results. +This module is used to run JMH performance tests on Endive and make it easy to compare results. ## Dependencies @@ -50,5 +50,5 @@ If you run the JMH tests from a GH Action: Or using a container image: ```bash -docker run --rm -it -p 3000:3000 docker.io/andreatp/chicory-show-jmh ci +docker run --rm -it -p 3000:3000 docker.io/andreatp/endive-show-jmh ci ``` diff --git a/jmh/pom.xml b/jmh/pom.xml index 3c3a91018..bcc15027e 100644 --- a/jmh/pom.xml +++ b/jmh/pom.xml @@ -3,41 +3,41 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml jmh jar - Chicory - JMH - JMH tests for the Chicory runtime + Endive - JMH + JMH tests for the Endive runtime - com.dylibso.chicory + org.openjdk.jmh + jmh-core + + + run.endive compiler - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wabt - com.dylibso.chicory + run.endive wasm - com.dylibso.chicory + run.endive wasm-corpus - - org.openjdk.jmh - jmh-core - diff --git a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkDispatchChunkSize.java b/jmh/src/main/java/run/endive/bench/BenchmarkDispatchChunkSize.java similarity index 88% rename from jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkDispatchChunkSize.java rename to jmh/src/main/java/run/endive/bench/BenchmarkDispatchChunkSize.java index 6875675e4..f0bd82ece 100644 --- a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkDispatchChunkSize.java +++ b/jmh/src/main/java/run/endive/bench/BenchmarkDispatchChunkSize.java @@ -1,10 +1,5 @@ -package com.dylibso.chicory.bench; +package run.endive.bench; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.ExportFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasm.Parser; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; @@ -18,10 +13,15 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.ExportFunction; +import run.endive.runtime.Instance; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasm.Parser; // Measures dispatch overhead for large wasm modules (2000 functions). // Compare with/without the HugeMethodLimit-aware chunking: -// java -Dchicory.hugeMethodLimit=1000000 -jar benchmarks.jar BenchmarkDispatchChunkSize (no +// java -Dendive.hugeMethodLimit=1000000 -jar benchmarks.jar BenchmarkDispatchChunkSize (no // limit) // java -jar benchmarks.jar BenchmarkDispatchChunkSize (default // 8KB) diff --git a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkFactorialExecution.java b/jmh/src/main/java/run/endive/bench/BenchmarkFactorialExecution.java similarity index 88% rename from jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkFactorialExecution.java rename to jmh/src/main/java/run/endive/bench/BenchmarkFactorialExecution.java index 736e6c2c3..62ec8ba95 100644 --- a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkFactorialExecution.java +++ b/jmh/src/main/java/run/endive/bench/BenchmarkFactorialExecution.java @@ -1,9 +1,5 @@ -package com.dylibso.chicory.bench; +package run.endive.bench; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.ExportFunction; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import java.io.File; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; @@ -18,6 +14,10 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.ExportFunction; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; @State(Scope.Benchmark) @Warmup(iterations = 2) diff --git a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkParsing.java b/jmh/src/main/java/run/endive/bench/BenchmarkParsing.java similarity index 94% rename from jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkParsing.java rename to jmh/src/main/java/run/endive/bench/BenchmarkParsing.java index 6afc9f4d5..e76babad4 100644 --- a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkParsing.java +++ b/jmh/src/main/java/run/endive/bench/BenchmarkParsing.java @@ -1,6 +1,5 @@ -package com.dylibso.chicory.bench; +package run.endive.bench; -import com.dylibso.chicory.wasm.Parser; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -17,6 +16,7 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import run.endive.wasm.Parser; @State(Scope.Benchmark) @Warmup(iterations = 2) diff --git a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkSievePrimes.java b/jmh/src/main/java/run/endive/bench/BenchmarkSievePrimes.java similarity index 86% rename from jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkSievePrimes.java rename to jmh/src/main/java/run/endive/bench/BenchmarkSievePrimes.java index ccb8c803f..b1cfd4e3d 100644 --- a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkSievePrimes.java +++ b/jmh/src/main/java/run/endive/bench/BenchmarkSievePrimes.java @@ -1,16 +1,5 @@ -package com.dylibso.chicory.bench; - -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.runtime.ExportFunction; -import com.dylibso.chicory.runtime.ImportMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.MemoryLimits; +package run.endive.bench; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -29,6 +18,17 @@ import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.ExportFunction; +import run.endive.runtime.ImportMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.MemoryLimits; @State(Scope.Benchmark) @Warmup(iterations = 2) diff --git a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkWat2Wasm.java b/jmh/src/main/java/run/endive/bench/BenchmarkWat2Wasm.java similarity index 88% rename from jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkWat2Wasm.java rename to jmh/src/main/java/run/endive/bench/BenchmarkWat2Wasm.java index cf423388f..b4cbda318 100644 --- a/jmh/src/main/java/com/dylibso/chicory/bench/BenchmarkWat2Wasm.java +++ b/jmh/src/main/java/run/endive/bench/BenchmarkWat2Wasm.java @@ -1,7 +1,5 @@ -package com.dylibso.chicory.bench; +package run.endive.bench; -import com.dylibso.chicory.corpus.WatGenerator; -import com.dylibso.chicory.wabt.Wat2Wasm; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; @@ -15,6 +13,8 @@ import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import run.endive.corpus.WatGenerator; +import run.endive.wabt.Wat2Wasm; @State(Scope.Benchmark) @Warmup(iterations = 2) diff --git a/log/pom.xml b/log/pom.xml index 740ae09f4..be6a21a27 100644 --- a/log/pom.xml +++ b/log/pom.xml @@ -3,14 +3,14 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT log jar - Chicory - Log + Endive - Log WebAssembly Log Utilities diff --git a/log/src/main/java/module-info.java b/log/src/main/java/module-info.java index 983487bf1..d9fecd077 100644 --- a/log/src/main/java/module-info.java +++ b/log/src/main/java/module-info.java @@ -1,6 +1,6 @@ -module com.dylibso.chicory.log { +module run.endive.log { requires static com.google.errorprone.annotations; requires static java.logging; - exports com.dylibso.chicory.log; + exports run.endive.log; } diff --git a/log/src/main/java/com/dylibso/chicory/log/BasicLogger.java b/log/src/main/java/run/endive/log/BasicLogger.java similarity index 92% rename from log/src/main/java/com/dylibso/chicory/log/BasicLogger.java rename to log/src/main/java/run/endive/log/BasicLogger.java index 218def11f..224cc9132 100644 --- a/log/src/main/java/com/dylibso/chicory/log/BasicLogger.java +++ b/log/src/main/java/run/endive/log/BasicLogger.java @@ -1,8 +1,8 @@ -package com.dylibso.chicory.log; +package run.endive.log; public class BasicLogger implements Logger { private static final java.util.logging.Logger LOGGER = - java.util.logging.Logger.getLogger("chicory"); + java.util.logging.Logger.getLogger("endive"); @Override public void log(Level level, String msg, Throwable throwable) { diff --git a/log/src/main/java/com/dylibso/chicory/log/Logger.java b/log/src/main/java/run/endive/log/Logger.java similarity index 99% rename from log/src/main/java/com/dylibso/chicory/log/Logger.java rename to log/src/main/java/run/endive/log/Logger.java index 01650501b..a05181336 100644 --- a/log/src/main/java/com/dylibso/chicory/log/Logger.java +++ b/log/src/main/java/run/endive/log/Logger.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.log; +package run.endive.log; import com.google.errorprone.annotations.FormatMethod; import java.util.Objects; diff --git a/log/src/main/java/com/dylibso/chicory/log/SystemLogger.java b/log/src/main/java/run/endive/log/SystemLogger.java similarity index 96% rename from log/src/main/java/com/dylibso/chicory/log/SystemLogger.java rename to log/src/main/java/run/endive/log/SystemLogger.java index c47a511e1..1e2b31636 100644 --- a/log/src/main/java/com/dylibso/chicory/log/SystemLogger.java +++ b/log/src/main/java/run/endive/log/SystemLogger.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.log; +package run.endive.log; public class SystemLogger implements Logger { - private static final System.Logger LOGGER = System.getLogger("chicory"); + private static final System.Logger LOGGER = System.getLogger("endive"); @Override public void log(Level level, String msg, Throwable throwable) { diff --git a/logos/dark-light-transparent.png b/logos/dark-light-transparent.png new file mode 100644 index 000000000..a95919e59 Binary files /dev/null and b/logos/dark-light-transparent.png differ diff --git a/logos/dark-light.png b/logos/dark-light.png new file mode 100644 index 000000000..02c09e35a Binary files /dev/null and b/logos/dark-light.png differ diff --git a/logos/hex_logo-transparent.png b/logos/hex_logo-transparent.png new file mode 100644 index 000000000..d854e4b10 Binary files /dev/null and b/logos/hex_logo-transparent.png differ diff --git a/logos/hex_logo.png b/logos/hex_logo.png new file mode 100644 index 000000000..1d57456c8 Binary files /dev/null and b/logos/hex_logo.png differ diff --git a/logos/hex_logo_dark-transparent.png b/logos/hex_logo_dark-transparent.png new file mode 100644 index 000000000..f562e8dd0 Binary files /dev/null and b/logos/hex_logo_dark-transparent.png differ diff --git a/logos/hex_logo_dark.png b/logos/hex_logo_dark.png new file mode 100644 index 000000000..9310b3374 Binary files /dev/null and b/logos/hex_logo_dark.png differ diff --git a/logos/log_plus_text_green-transparent.png b/logos/log_plus_text_green-transparent.png new file mode 100644 index 000000000..e566739a9 Binary files /dev/null and b/logos/log_plus_text_green-transparent.png differ diff --git a/logos/log_plus_text_green.png b/logos/log_plus_text_green.png new file mode 100644 index 000000000..3c701bb6f Binary files /dev/null and b/logos/log_plus_text_green.png differ diff --git a/logos/logo_plus_text-transparent.png b/logos/logo_plus_text-transparent.png new file mode 100644 index 000000000..9e7f2f137 Binary files /dev/null and b/logos/logo_plus_text-transparent.png differ diff --git a/logos/logo_plus_text.png b/logos/logo_plus_text.png new file mode 100644 index 000000000..ba773853c Binary files /dev/null and b/logos/logo_plus_text.png differ diff --git a/logos/logo_plus_text_dark-transparent.png b/logos/logo_plus_text_dark-transparent.png new file mode 100644 index 000000000..f7b964e37 Binary files /dev/null and b/logos/logo_plus_text_dark-transparent.png differ diff --git a/logos/logo_plus_text_dark.png b/logos/logo_plus_text_dark.png new file mode 100644 index 000000000..fb01d337b Binary files /dev/null and b/logos/logo_plus_text_dark.png differ diff --git a/logos/logo_plus_text_dark_green-transparent.png b/logos/logo_plus_text_dark_green-transparent.png new file mode 100644 index 000000000..44ed32fa3 Binary files /dev/null and b/logos/logo_plus_text_dark_green-transparent.png differ diff --git a/logos/logo_plus_text_dark_green.png b/logos/logo_plus_text_dark_green.png new file mode 100644 index 000000000..e553c974b Binary files /dev/null and b/logos/logo_plus_text_dark_green.png differ diff --git a/logos/main-transparent.png b/logos/main-transparent.png new file mode 100644 index 000000000..4d9072cb5 Binary files /dev/null and b/logos/main-transparent.png differ diff --git a/logos/main.png b/logos/main.png new file mode 100644 index 000000000..5b546d59b Binary files /dev/null and b/logos/main.png differ diff --git a/machine-tests/pom.xml b/machine-tests/pom.xml index 4dd63c0f2..e9d0ea1fd 100644 --- a/machine-tests/pom.xml +++ b/machine-tests/pom.xml @@ -3,52 +3,52 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT machine-tests jar - Chicory - Machines tests + Endive - Machines tests - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - com.dylibso.chicory - compiler + io.roastedroot + zerofs test - com.dylibso.chicory - wasi + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - wasm-corpus + org.junit.jupiter + junit-jupiter-params test - io.roastedroot - zerofs + run.endive + compiler test - org.junit.jupiter - junit-jupiter-api + run.endive + wasi test - org.junit.jupiter - junit-jupiter-params + run.endive + wasm-corpus test @@ -56,8 +56,8 @@ - com.dylibso.chicory - chicory-compiler-maven-plugin + run.endive + endive-compiler-maven-plugin compile-quickjs @@ -65,7 +65,7 @@ compile - com.dylibso.chicory.testing.gen.QuickJS + run.endive.testing.gen.QuickJS ${project.basedir}/../wasm-corpus/src/main/resources/compiled/quickjs-provider.javy-dynamic.wasm @@ -75,7 +75,7 @@ compile - com.dylibso.chicory.testing.gen.DynamicHelloJS + run.endive.testing.gen.DynamicHelloJS ${project.basedir}/../wasm-corpus/src/main/resources/compiled/hello-world.js.javy-dynamic.wasm @@ -85,7 +85,7 @@ compile - com.dylibso.chicory.wabt.Wat2Wasm + run.endive.wabt.Wat2Wasm ${project.basedir}/../wabt/src/main/resources/wat2wasm @@ -95,7 +95,7 @@ compile - com.dylibso.chicory.testing.ThreadsExampleModule + run.endive.testing.ThreadsExampleModule ${project.basedir}/../wasm-corpus/src/main/resources/compiled/threads-example.wat.wasm diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/BrOnNullTest.java b/machine-tests/src/test/java/run/endive/testing/BrOnNullTest.java similarity index 85% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/BrOnNullTest.java rename to machine-tests/src/test/java/run/endive/testing/BrOnNullTest.java index 13f9cc41f..e0961a5b4 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/BrOnNullTest.java +++ b/machine-tests/src/test/java/run/endive/testing/BrOnNullTest.java @@ -1,18 +1,18 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; /** * Tests that br_on_null correctly refines the type on the fall-through path diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionGcRefTest.java b/machine-tests/src/test/java/run/endive/testing/ExceptionGcRefTest.java similarity index 88% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionGcRefTest.java rename to machine-tests/src/test/java/run/endive/testing/ExceptionGcRefTest.java index c3fff2784..eb9ca3ab1 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionGcRefTest.java +++ b/machine-tests/src/test/java/run/endive/testing/ExceptionGcRefTest.java @@ -1,23 +1,23 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.ImportFunction; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.ImportFunction; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; /** Tests for exception handling with GC reference payloads. */ public class ExceptionGcRefTest { diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionReturnTest.java b/machine-tests/src/test/java/run/endive/testing/ExceptionReturnTest.java similarity index 85% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionReturnTest.java rename to machine-tests/src/test/java/run/endive/testing/ExceptionReturnTest.java index ed5f15fc1..762b01cf9 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/ExceptionReturnTest.java +++ b/machine-tests/src/test/java/run/endive/testing/ExceptionReturnTest.java @@ -1,18 +1,18 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; /** Tests for exception handling when `return` instruction is used in the call chain. */ public class ExceptionReturnTest { diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/MachinesTest.java b/machine-tests/src/test/java/run/endive/testing/MachinesTest.java similarity index 94% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/MachinesTest.java rename to machine-tests/src/test/java/run/endive/testing/MachinesTest.java index d02d095b8..62cb5042c 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/MachinesTest.java +++ b/machine-tests/src/test/java/run/endive/testing/MachinesTest.java @@ -1,34 +1,12 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.Files.copy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.ImportTable; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.runtime.Store; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.runtime.TrapException; -import com.dylibso.chicory.testing.gen.DynamicHelloJS; -import com.dylibso.chicory.testing.gen.QuickJS; -import com.dylibso.chicory.wabt.Wat2Wasm; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.ValType; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.ByteArrayOutputStream; @@ -41,6 +19,28 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Test; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.HostFunction; +import run.endive.runtime.ImportTable; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.runtime.Store; +import run.endive.runtime.TableInstance; +import run.endive.runtime.TrapException; +import run.endive.testing.gen.DynamicHelloJS; +import run.endive.testing.gen.QuickJS; +import run.endive.wabt.Wat2Wasm; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.ValType; public final class MachinesTest { diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/SievePrimesTest.java b/machine-tests/src/test/java/run/endive/testing/SievePrimesTest.java similarity index 84% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/SievePrimesTest.java rename to machine-tests/src/test/java/run/endive/testing/SievePrimesTest.java index 720b41f84..498c5d02e 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/SievePrimesTest.java +++ b/machine-tests/src/test/java/run/endive/testing/SievePrimesTest.java @@ -1,20 +1,20 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.MemoryLimits; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Memory; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.MemoryLimits; public class SievePrimesTest { diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/ThreadsProposalTest.java b/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java similarity index 95% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/ThreadsProposalTest.java rename to machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java index c1cf6b73a..81f87b187 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/ThreadsProposalTest.java +++ b/machine-tests/src/test/java/run/endive/testing/ThreadsProposalTest.java @@ -1,21 +1,9 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; 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; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.MemoryLimits; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -27,6 +15,18 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.ImportMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.runtime.Memory; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.MemoryLimits; public class ThreadsProposalTest { diff --git a/machine-tests/src/test/java/com/dylibso/chicory/testing/TrySaveStackTest.java b/machine-tests/src/test/java/run/endive/testing/TrySaveStackTest.java similarity index 86% rename from machine-tests/src/test/java/com/dylibso/chicory/testing/TrySaveStackTest.java rename to machine-tests/src/test/java/run/endive/testing/TrySaveStackTest.java index 3adf09cf9..2a2d7e581 100644 --- a/machine-tests/src/test/java/com/dylibso/chicory/testing/TrySaveStackTest.java +++ b/machine-tests/src/test/java/run/endive/testing/TrySaveStackTest.java @@ -1,18 +1,18 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.compiler.MachineFactoryCompiler; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.compiler.MachineFactoryCompiler; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; /** * Tests that values below a try_table scope are preserved when a catch fires. diff --git a/nightly-testsuite/pom.xml b/nightly-testsuite/pom.xml index 2125bdd18..046086c99 100644 --- a/nightly-testsuite/pom.xml +++ b/nightly-testsuite/pom.xml @@ -3,47 +3,47 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT nightly-testsuite jar - Chicory - Nigthly testsuite + Endive - Nigthly testsuite - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - com.dylibso.chicory - log + io.roastedroot + zerofs test - com.dylibso.chicory - wasi + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - wasm-corpus + run.endive + log test - io.roastedroot - zerofs + run.endive + wasi test - org.junit.jupiter - junit-jupiter-api + run.endive + wasm-corpus test @@ -51,8 +51,8 @@ - com.dylibso.chicory - chicory-compiler-maven-plugin + run.endive + endive-compiler-maven-plugin zig-testsuite @@ -60,7 +60,7 @@ compile - com.dylibso.chicory.testing.ZigModule + run.endive.testing.ZigModule ${project.basedir}/../zig-testsuite/test-opt.wasm diff --git a/nightly-testsuite/src/test/java/com/dylibso/chicory/testing/ZigTestsuiteTest.java b/nightly-testsuite/src/test/java/run/endive/testing/ZigTestsuiteTest.java similarity index 84% rename from nightly-testsuite/src/test/java/com/dylibso/chicory/testing/ZigTestsuiteTest.java rename to nightly-testsuite/src/test/java/run/endive/testing/ZigTestsuiteTest.java index f1211e18c..d143b8d6f 100644 --- a/nightly-testsuite/src/test/java/com/dylibso/chicory/testing/ZigTestsuiteTest.java +++ b/nightly-testsuite/src/test/java/run/endive/testing/ZigTestsuiteTest.java @@ -1,17 +1,17 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.nio.file.FileSystem; import java.nio.file.Path; import java.util.List; import org.junit.jupiter.api.Test; +import run.endive.log.SystemLogger; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; public class ZigTestsuiteTest { diff --git a/pom.xml b/pom.xml index 4957b6c8d..da4c0930a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,17 +2,17 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT pom - Chicory + Endive Native JVM WebAssembly runtime - https://github.com/dylibso/chicory + https://github.com/bytecodealliance/endive - Dylibso, Inc. - https://dylibso.com + Bytecode Alliance + https://bytecodealliance.org @@ -26,22 +26,22 @@ - The Chicory Authors - oss@dylibso.com - Dylibso, Inc. - https://dylibso.com + The Endive Authors + endive@bytecodealliance.org + Bytecode Alliance + https://bytecodealliance.org - scm:git:git://github.com/dylibso/chicory.git - scm:git:ssh://github.com:dylibso/chicory.git - http://github.com/dylibso/chicory/tree/main + scm:git:git://github.com/bytecodealliance/endive.git + scm:git:ssh://github.com:bytecodealliance/endive.git + https://github.com/bytecodealliance/endive/tree/main Github - https://github.com/dylibso/chicory/issues + https://github.com/bytecodealliance/endive/issues @@ -96,6 +96,7 @@ 3.1.0 3.2.0 0.23.0 + 2.5.0 3.0.0 0.1.0 @@ -111,93 +112,6 @@ pom import - - com.dylibso.chicory - annotations - ${project.version} - - - com.dylibso.chicory - annotations-processor - ${project.version} - - - com.dylibso.chicory - build-time-compiler - ${project.version} - - - com.dylibso.chicory - chicory-compiler-maven-plugin - ${project.version} - - - com.dylibso.chicory - cli-experimental - ${project.version} - - - com.dylibso.chicory - codegen - ${project.version} - - - - - com.dylibso.chicory - compiler - ${project.version} - - - com.dylibso.chicory - dircache-experimental - ${project.version} - - - com.dylibso.chicory - log - ${project.version} - - - com.dylibso.chicory - runtime - ${project.version} - - - com.dylibso.chicory - simd - ${project.version} - - - com.dylibso.chicory - test-gen-lib - ${project.version} - - - com.dylibso.chicory - wabt - ${project.version} - - - com.dylibso.chicory - wasi - ${project.version} - - - com.dylibso.chicory - wasm - ${project.version} - - - com.dylibso.chicory - wasm-corpus - ${project.version} - - - com.dylibso.chicory - wasm-tools - ${project.version} - @@ -283,6 +197,93 @@ jmh-generator-annprocess ${jmh.version} + + run.endive + annotations + ${project.version} + + + run.endive + annotations-processor + ${project.version} + + + run.endive + build-time-compiler + ${project.version} + + + run.endive + cli-experimental + ${project.version} + + + run.endive + codegen + ${project.version} + + + + + run.endive + compiler + ${project.version} + + + run.endive + dircache-experimental + ${project.version} + + + run.endive + endive-compiler-maven-plugin + ${project.version} + + + run.endive + log + ${project.version} + + + run.endive + runtime + ${project.version} + + + run.endive + simd + ${project.version} + + + run.endive + test-gen-lib + ${project.version} + + + run.endive + wabt + ${project.version} + + + run.endive + wasi + ${project.version} + + + run.endive + wasm + ${project.version} + + + run.endive + wasm-corpus + ${project.version} + + + run.endive + wasm-tools + ${project.version} + @@ -369,11 +370,6 @@ spotless-maven-plugin ${spotless-maven-plugin.version} - - com.dylibso.chicory - chicory-compiler-maven-plugin - ${project.version} - org.apache.maven.plugins maven-antrun-plugin @@ -484,6 +480,11 @@ central-publishing-maven-plugin ${central-publishing-maven-plugin.version} + + run.endive + endive-compiler-maven-plugin + ${project.version} + @@ -618,8 +619,8 @@ ${maven.dependency.failOnWarning} true - com.dylibso.chicory:simd - com.dylibso.chicory:wasm-corpus + run.endive:simd + run.endive:wasm-corpus org.junit.jupiter:junit-jupiter-engine @@ -726,6 +727,54 @@ + + + org.codehaus.mojo + license-maven-plugin + ${license-maven-plugin.version} + + + check-licenses + + add-third-party + + validate + + true + + Apache-2.0 + Apache License, Version 2.0 + The Apache Software License, Version 2.0 + The Apache Software License, version 2.0 + Apache 2 + Apache 2.0 + The Apache License, Version 2.0 + MIT License + The MIT License + MIT + BSD-2-Clause + BSD-3-Clause + The BSD License + The New BSD License + Revised BSD + ISC + ISC License + MPL-2.0 + Mozilla Public License, Version 2.0 + Eclipse Public License 2.0 + Eclipse Public License, Version 2.0 + Eclipse Distribution License - v 1.0 + EDL 1.0 + Unicode/ICU License + Public Domain + GNU General Public License (GPL), version 2, with the Classpath exception + + true + test + + + + @@ -742,6 +791,7 @@ true true true + true false false true @@ -760,6 +810,7 @@ true true true + true false false true diff --git a/runtime-tests/pom.xml b/runtime-tests/pom.xml index 4231e5887..e4a1591d5 100644 --- a/runtime-tests/pom.xml +++ b/runtime-tests/pom.xml @@ -3,52 +3,65 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml runtime-tests jar - Chicory - Runtime tests - Tests for the Chicory runtime using the WebAssembly testsuite + Endive - Runtime tests + Tests for the Endive runtime using the WebAssembly testsuite - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory - wasm + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - wasm-corpus + org.junit.jupiter + junit-jupiter-engine test - com.dylibso.chicory - wasm-tools + run.endive + wasm test - org.junit.jupiter - junit-jupiter-api + run.endive + wasm-corpus test - org.junit.jupiter - junit-jupiter-engine + run.endive + wasm-tools test + + + org.codehaus.mojo + templating-maven-plugin + + + filter-src + + filter-sources + + + + - com.dylibso.chicory + run.endive test-gen-plugin ${project.version} @@ -450,19 +463,6 @@ - - - org.codehaus.mojo - templating-maven-plugin - - - filter-src - - filter-sources - - - - @@ -480,14 +480,58 @@ - com.dylibso.chicory + run.endive simd - com.dylibso.chicory + org.apache.maven.plugins + maven-compiler-plugin + + + --add-modules + jdk.incubator.vector + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + false + false + -Xdoclint:none + + + + org.apache.maven.plugins + maven-surefire-plugin + + --add-modules=jdk.incubator.vector + + + + + org.codehaus.mojo + templating-maven-plugin + + + filter-src + + filter-sources + + + ${basedir}/src/main/java-templates-21 + + + + + + run.endive test-gen-plugin ${project.version} @@ -890,50 +934,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - - --add-modules - jdk.incubator.vector - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - false - false - -Xdoclint:none - - - - org.apache.maven.plugins - maven-surefire-plugin - - --add-modules=jdk.incubator.vector - - - - - org.codehaus.mojo - templating-maven-plugin - - - filter-src - - filter-sources - - - ${basedir}/src/main/java-templates-21 - - - - diff --git a/runtime-tests/src/main/java-templates-21/com/dylibso/chicory/testing/InterpreterMachineFactory.java b/runtime-tests/src/main/java-templates-21/com/dylibso/chicory/testing/InterpreterMachineFactory.java deleted file mode 100644 index b6e74ac59..000000000 --- a/runtime-tests/src/main/java-templates-21/com/dylibso/chicory/testing/InterpreterMachineFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dylibso.chicory.testing; - -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Machine; -import com.dylibso.chicory.simd.SimdInterpreterMachine; - -public class InterpreterMachineFactory { - - public static Machine create(Instance instance) { - return new SimdInterpreterMachine(instance); - } - -} diff --git a/runtime-tests/src/main/java-templates-21/run/endive/testing/InterpreterMachineFactory.java b/runtime-tests/src/main/java-templates-21/run/endive/testing/InterpreterMachineFactory.java new file mode 100644 index 000000000..e7f92d83c --- /dev/null +++ b/runtime-tests/src/main/java-templates-21/run/endive/testing/InterpreterMachineFactory.java @@ -0,0 +1,13 @@ +package run.endive.testing; + +import run.endive.runtime.Instance; +import run.endive.runtime.Machine; +import run.endive.simd.SimdInterpreterMachine; + +public class InterpreterMachineFactory { + + public static Machine create(Instance instance) { + return new SimdInterpreterMachine(instance); + } + +} diff --git a/runtime-tests/src/main/java-templates/com/dylibso/chicory/testing/InterpreterMachineFactory.java b/runtime-tests/src/main/java-templates/com/dylibso/chicory/testing/InterpreterMachineFactory.java deleted file mode 100644 index ff3af23df..000000000 --- a/runtime-tests/src/main/java-templates/com/dylibso/chicory/testing/InterpreterMachineFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dylibso.chicory.testing; - -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.runtime.Machine; - -public class InterpreterMachineFactory { - - public static InterpreterMachine create(Instance instance) { - return new InterpreterMachine(instance); - } - -} diff --git a/runtime-tests/src/main/java-templates/run/endive/testing/InterpreterMachineFactory.java b/runtime-tests/src/main/java-templates/run/endive/testing/InterpreterMachineFactory.java new file mode 100644 index 000000000..05502b715 --- /dev/null +++ b/runtime-tests/src/main/java-templates/run/endive/testing/InterpreterMachineFactory.java @@ -0,0 +1,13 @@ +package run.endive.testing; + +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.runtime.Machine; + +public class InterpreterMachineFactory { + + public static InterpreterMachine create(Instance instance) { + return new InterpreterMachine(instance); + } + +} diff --git a/runtime-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java b/runtime-tests/src/test/java/run/endive/testing/ArgsAdapter.java similarity index 95% rename from runtime-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java rename to runtime-tests/src/test/java/run/endive/testing/ArgsAdapter.java index cfb01e5b5..dae93f93d 100644 --- a/runtime-tests/src/test/java/com/dylibso/chicory/testing/ArgsAdapter.java +++ b/runtime-tests/src/test/java/run/endive/testing/ArgsAdapter.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; import java.util.ArrayDeque; diff --git a/runtime-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java b/runtime-tests/src/test/java/run/endive/testing/Spectest.java similarity index 85% rename from runtime-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java rename to runtime-tests/src/test/java/run/endive/testing/Spectest.java index 2cb6a29f5..b6894154a 100644 --- a/runtime-tests/src/test/java/com/dylibso/chicory/testing/Spectest.java +++ b/runtime-tests/src/test/java/run/endive/testing/Spectest.java @@ -1,24 +1,24 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.runtime.GlobalInstance; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.ImportGlobal; -import com.dylibso.chicory.runtime.ImportMemory; -import com.dylibso.chicory.runtime.ImportTable; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.TableInstance; -import com.dylibso.chicory.runtime.WasmFunctionHandle; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.List; +import run.endive.runtime.ByteBufferMemory; +import run.endive.runtime.GlobalInstance; +import run.endive.runtime.HostFunction; +import run.endive.runtime.ImportGlobal; +import run.endive.runtime.ImportMemory; +import run.endive.runtime.ImportTable; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.TableInstance; +import run.endive.runtime.WasmFunctionHandle; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; // https://github.com/WebAssembly/spec/blob/ee82c8e50c5106e0cedada0a083d4cc4129034a2/interpreter/host/spectest.ml public final class Spectest { diff --git a/runtime-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java b/runtime-tests/src/test/java/run/endive/testing/TestModule.java similarity index 86% rename from runtime-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java rename to runtime-tests/src/test/java/run/endive/testing/TestModule.java index d31ec3246..46473be63 100644 --- a/runtime-tests/src/test/java/com/dylibso/chicory/testing/TestModule.java +++ b/runtime-tests/src/test/java/run/endive/testing/TestModule.java @@ -1,14 +1,14 @@ -package com.dylibso.chicory.testing; +package run.endive.testing; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Store; -import com.dylibso.chicory.tools.wasm.Wat2Wasm; -import com.dylibso.chicory.wasm.MalformedException; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; import java.io.IOException; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Store; +import run.endive.tools.wasm.Wat2Wasm; +import run.endive.wasm.MalformedException; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; public class TestModule { diff --git a/runtime/pom.xml b/runtime/pom.xml index f66279a6b..bd36b5ccb 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -3,26 +3,21 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml runtime jar - Chicory - Runtime + Endive - Runtime Native JVM WebAssembly runtime - com.dylibso.chicory + run.endive wasm - - com.dylibso.chicory - wasm-corpus - test - org.junit.jupiter junit-jupiter-api @@ -38,5 +33,10 @@ junit-jupiter-params test + + run.endive + wasm-corpus + test + diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ChicoryInterruptedException.java b/runtime/src/main/java/com/dylibso/chicory/runtime/ChicoryInterruptedException.java deleted file mode 100644 index 829d132ac..000000000 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ChicoryInterruptedException.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dylibso.chicory.runtime; - -import com.dylibso.chicory.wasm.ChicoryException; - -public class ChicoryInterruptedException extends ChicoryException { - public ChicoryInterruptedException(String msg) { - super(msg); - } - - public ChicoryInterruptedException(Throwable cause) { - super(cause); - } - - public ChicoryInterruptedException(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ExportFunction.java b/runtime/src/main/java/com/dylibso/chicory/runtime/ExportFunction.java deleted file mode 100644 index 1deae190f..000000000 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ExportFunction.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.dylibso.chicory.runtime; - -import com.dylibso.chicory.wasm.ChicoryException; - -/** - * This represents an Exported function from the Wasm module. - */ -@FunctionalInterface -public interface ExportFunction { - long[] apply(long... args) throws ChicoryException; -} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/Machine.java b/runtime/src/main/java/com/dylibso/chicory/runtime/Machine.java deleted file mode 100644 index b058d8537..000000000 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/Machine.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dylibso.chicory.runtime; - -import com.dylibso.chicory.wasm.ChicoryException; - -@FunctionalInterface -public interface Machine { - - long[] call(int funcId, long[] args) throws ChicoryException; -} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/TrapException.java b/runtime/src/main/java/com/dylibso/chicory/runtime/TrapException.java deleted file mode 100644 index a7155687b..000000000 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/TrapException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dylibso.chicory.runtime; - -import com.dylibso.chicory.wasm.ChicoryException; - -public class TrapException extends ChicoryException { - public TrapException(String msg) { - super(msg); - } -} diff --git a/runtime/src/main/java/module-info.java b/runtime/src/main/java/module-info.java index 14773474d..c9d56bea9 100644 --- a/runtime/src/main/java/module-info.java +++ b/runtime/src/main/java/module-info.java @@ -1,7 +1,7 @@ -module com.dylibso.chicory.runtime { - requires transitive com.dylibso.chicory.wasm; +module run.endive.runtime { + requires transitive run.endive.wasm; - exports com.dylibso.chicory.runtime; - exports com.dylibso.chicory.runtime.alloc; - exports com.dylibso.chicory.runtime.internal; + exports run.endive.runtime; + exports run.endive.runtime.alloc; + exports run.endive.runtime.internal; } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/BitOps.java b/runtime/src/main/java/run/endive/runtime/BitOps.java similarity index 78% rename from runtime/src/main/java/com/dylibso/chicory/runtime/BitOps.java rename to runtime/src/main/java/run/endive/runtime/BitOps.java index 588efb680..c79e6ce27 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/BitOps.java +++ b/runtime/src/main/java/run/endive/runtime/BitOps.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public final class BitOps { diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ByteArrayMemory.java b/runtime/src/main/java/run/endive/runtime/ByteArrayMemory.java similarity index 97% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ByteArrayMemory.java rename to runtime/src/main/java/run/endive/runtime/ByteArrayMemory.java index 12de4dedd..7c0971f73 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ByteArrayMemory.java +++ b/runtime/src/main/java/run/endive/runtime/ByteArrayMemory.java @@ -1,15 +1,8 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.runtime.ConstantEvaluators.computeConstantValue; import static java.lang.Math.min; +import static run.endive.runtime.ConstantEvaluators.computeConstantValue; -import com.dylibso.chicory.runtime.alloc.MemAllocStrategy; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.UninstantiableException; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.DataSegment; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.PassiveDataSegment; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle.AccessMode; @@ -19,6 +12,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.BooleanSupplier; import java.util.function.Function; +import run.endive.runtime.alloc.MemAllocStrategy; +import run.endive.wasm.UninstantiableException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.DataSegment; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.PassiveDataSegment; /** * Represents the linear memory in the Wasm program. Can be shared @@ -131,7 +131,7 @@ private Object monitor(int address) { // Wait IF condition is true private int waitOn(int address, BooleanSupplier condition, long timeout) { if (!shared()) { - throw new ChicoryException("Attempt to wait on a non-shared memory, not supported."); + throw new WasmEngineException("Attempt to wait on a non-shared memory, not supported."); } long deadline = (timeout < 0) ? Long.MAX_VALUE : System.nanoTime() + timeout; @@ -159,7 +159,7 @@ private int waitOn(int address, BooleanSupplier condition, long timeout) { state.wait(millis, nanos); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); - throw new ChicoryInterruptedException("Thread interrupted"); + throw new WasmInterruptedException("Thread interrupted"); } } return 0; // woken @@ -313,14 +313,17 @@ public void initialize(Instance instance, DataSegment[] dataSegments, int memory } else if (s instanceof PassiveDataSegment) { // Passive segment should be skipped } else { - throw new ChicoryException("Data segment should be active or passive: " + s); + throw new WasmEngineException("Data segment should be active or passive: " + s); } } } private static void checkBounds( - int addr, int size, int limit, Function exceptionFactory) { - if (addr < 0 || size < 0 || addr > limit || (size > 0 && ((addr + size) > limit))) { + int addr, int size, int limit, Function exceptionFactory) { + if (addr < 0 + || size < 0 + || addr > limit + || (size > 0 && ((long) addr + (long) size > (long) limit))) { var errorMsg = "out of bounds memory access: attempted to access address: " + addr diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ByteBufferMemory.java b/runtime/src/main/java/run/endive/runtime/ByteBufferMemory.java similarity index 96% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ByteBufferMemory.java rename to runtime/src/main/java/run/endive/runtime/ByteBufferMemory.java index dbcef602c..a1b9e3d64 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ByteBufferMemory.java +++ b/runtime/src/main/java/run/endive/runtime/ByteBufferMemory.java @@ -1,15 +1,8 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.runtime.ConstantEvaluators.computeConstantValue; import static java.lang.Math.min; +import static run.endive.runtime.ConstantEvaluators.computeConstantValue; -import com.dylibso.chicory.runtime.alloc.MemAllocStrategy; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.UninstantiableException; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.DataSegment; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.PassiveDataSegment; import java.lang.reflect.InvocationTargetException; import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; @@ -20,6 +13,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.BooleanSupplier; import java.util.function.Function; +import run.endive.runtime.alloc.MemAllocStrategy; +import run.endive.wasm.UninstantiableException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.DataSegment; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.PassiveDataSegment; /** * Represents the linear memory in the Wasm program. Can be shared @@ -102,7 +102,7 @@ public Object lock(int address) { // Wait IF condition is true private int waitOn(int address, BooleanSupplier condition, long timeout) { if (!shared()) { - throw new ChicoryException("Attempt to wait on a non-shared memory, not supported."); + throw new WasmEngineException("Attempt to wait on a non-shared memory, not supported."); } long deadline = (timeout < 0) ? Long.MAX_VALUE : System.nanoTime() + timeout; @@ -130,7 +130,7 @@ private int waitOn(int address, BooleanSupplier condition, long timeout) { state.wait(millis, nanos); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); - throw new ChicoryInterruptedException("Thread interrupted"); + throw new WasmInterruptedException("Thread interrupted"); } } return 0; // woken @@ -284,14 +284,17 @@ public void initialize(Instance instance, DataSegment[] dataSegments, int memory } else if (s instanceof PassiveDataSegment) { // Passive segment should be skipped } else { - throw new ChicoryException("Data segment should be active or passive: " + s); + throw new WasmEngineException("Data segment should be active or passive: " + s); } } } private static void checkBounds( - int addr, int size, int limit, Function exceptionFactory) { - if (addr < 0 || size < 0 || addr > limit || (size > 0 && ((addr + size) > limit))) { + int addr, int size, int limit, Function exceptionFactory) { + if (addr < 0 + || size < 0 + || addr > limit + || (size > 0 && ((long) addr + (long) size > (long) limit))) { var errorMsg = "out of bounds memory access: attempted to access address: " + addr diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/CompiledModule.java b/runtime/src/main/java/run/endive/runtime/CompiledModule.java similarity index 74% rename from runtime/src/main/java/com/dylibso/chicory/runtime/CompiledModule.java rename to runtime/src/main/java/run/endive/runtime/CompiledModule.java index b38fa5556..fadf33f6a 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/CompiledModule.java +++ b/runtime/src/main/java/run/endive/runtime/CompiledModule.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.WasmModule; import java.util.function.Function; +import run.endive.wasm.WasmModule; /** * This interface is implemented by build time compiled wasm modules. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ConstantEvaluators.java b/runtime/src/main/java/run/endive/runtime/ConstantEvaluators.java similarity index 96% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ConstantEvaluators.java rename to runtime/src/main/java/run/endive/runtime/ConstantEvaluators.java index 275e1375b..2d0a43688 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ConstantEvaluators.java +++ b/runtime/src/main/java/run/endive/runtime/ConstantEvaluators.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.OpCode.GLOBAL_GET; +import static run.endive.wasm.types.OpCode.GLOBAL_GET; -import com.dylibso.chicory.wasm.InvalidException; -import com.dylibso.chicory.wasm.MalformedException; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.ArrayDeque; import java.util.Arrays; import java.util.List; +import run.endive.wasm.InvalidException; +import run.endive.wasm.MalformedException; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; public final class ConstantEvaluators { private ConstantEvaluators() {} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/CtrlFrame.java b/runtime/src/main/java/run/endive/runtime/CtrlFrame.java similarity index 91% rename from runtime/src/main/java/com/dylibso/chicory/runtime/CtrlFrame.java rename to runtime/src/main/java/run/endive/runtime/CtrlFrame.java index 0a67a2d30..7659e3c92 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/CtrlFrame.java +++ b/runtime/src/main/java/run/endive/runtime/CtrlFrame.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.OpCode; +import run.endive.wasm.types.OpCode; final class CtrlFrame { // OpCode of the current Control Flow instruction diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionCompletedException.java b/runtime/src/main/java/run/endive/runtime/ExecutionCompletedException.java similarity index 54% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionCompletedException.java rename to runtime/src/main/java/run/endive/runtime/ExecutionCompletedException.java index e59e3434b..c99bc679d 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionCompletedException.java +++ b/runtime/src/main/java/run/endive/runtime/ExecutionCompletedException.java @@ -1,11 +1,9 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.wasm.WasmEngineException; -/* - * Signal a successful stop of execution - */ -public class ExecutionCompletedException extends ChicoryException { +/** Signals successful completion of execution (used by WASI proc_exit with code 0). */ +public class ExecutionCompletedException extends WasmEngineException { public ExecutionCompletedException(String msg) { super(msg); diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionListener.java b/runtime/src/main/java/run/endive/runtime/ExecutionListener.java similarity index 78% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionListener.java rename to runtime/src/main/java/run/endive/runtime/ExecutionListener.java index afc5c6973..d8de44928 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ExecutionListener.java +++ b/runtime/src/main/java/run/endive/runtime/ExecutionListener.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.Instruction; +import run.endive.wasm.types.Instruction; @FunctionalInterface public interface ExecutionListener { @@ -11,7 +11,7 @@ public interface ExecutionListener { * Any issue or performance degradation caused by this code is not going to be supported. * This interface along with its usage is experimental and we might drop it at a later stage. * - * If you have a specific use case for this functionality, please, open an Issue at: https://github.com/dylibso/chicory/issues + * If you have a specific use case for this functionality, please, open an Issue at: https://github.run/endive/issues */ void onExecution(Instruction instruction, MStack stack); } diff --git a/runtime/src/main/java/run/endive/runtime/ExportFunction.java b/runtime/src/main/java/run/endive/runtime/ExportFunction.java new file mode 100644 index 000000000..82ccd2795 --- /dev/null +++ b/runtime/src/main/java/run/endive/runtime/ExportFunction.java @@ -0,0 +1,11 @@ +package run.endive.runtime; + +import run.endive.wasm.WasmEngineException; + +/** + * This represents an Exported function from the Wasm module. + */ +@FunctionalInterface +public interface ExportFunction { + long[] apply(long... args) throws WasmEngineException; +} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/GlobalFactory.java b/runtime/src/main/java/run/endive/runtime/GlobalFactory.java similarity index 64% rename from runtime/src/main/java/com/dylibso/chicory/runtime/GlobalFactory.java rename to runtime/src/main/java/run/endive/runtime/GlobalFactory.java index f81f5533e..d765b009c 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/GlobalFactory.java +++ b/runtime/src/main/java/run/endive/runtime/GlobalFactory.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.MutabilityType; -import com.dylibso.chicory.wasm.types.ValType; +import run.endive.wasm.types.MutabilityType; +import run.endive.wasm.types.ValType; /** * Factory for creating {@link GlobalInstance} objects during module instantiation. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/GlobalInstance.java b/runtime/src/main/java/run/endive/runtime/GlobalInstance.java similarity index 90% rename from runtime/src/main/java/com/dylibso/chicory/runtime/GlobalInstance.java rename to runtime/src/main/java/run/endive/runtime/GlobalInstance.java index 548f8183f..48a93af9e 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/GlobalInstance.java +++ b/runtime/src/main/java/run/endive/runtime/GlobalInstance.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.MutabilityType; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; -import com.dylibso.chicory.wasm.types.ValueType; +import run.endive.wasm.types.MutabilityType; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; +import run.endive.wasm.types.ValueType; public class GlobalInstance { private long valueLow; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/HostFunction.java b/runtime/src/main/java/run/endive/runtime/HostFunction.java similarity index 90% rename from runtime/src/main/java/com/dylibso/chicory/runtime/HostFunction.java rename to runtime/src/main/java/run/endive/runtime/HostFunction.java index d43074932..fcf681c25 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/HostFunction.java +++ b/runtime/src/main/java/run/endive/runtime/HostFunction.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.FunctionType; import java.util.List; +import run.endive.wasm.types.FunctionType; /** * A HostFunction is an ExternalFunction that has been defined by the host. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportFunction.java b/runtime/src/main/java/run/endive/runtime/ImportFunction.java similarity index 95% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportFunction.java rename to runtime/src/main/java/run/endive/runtime/ImportFunction.java index d82c815ae..d4b7c1b16 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportFunction.java +++ b/runtime/src/main/java/run/endive/runtime/ImportFunction.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.ValueType; import java.util.ArrayList; import java.util.List; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.ValueType; public class ImportFunction implements ImportValue { private final String module; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportGlobal.java b/runtime/src/main/java/run/endive/runtime/ImportGlobal.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportGlobal.java rename to runtime/src/main/java/run/endive/runtime/ImportGlobal.java index 091cb93f7..dd796f3b7 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportGlobal.java +++ b/runtime/src/main/java/run/endive/runtime/ImportGlobal.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public class ImportGlobal implements ImportValue { private final GlobalInstance instance; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportMemory.java b/runtime/src/main/java/run/endive/runtime/ImportMemory.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportMemory.java rename to runtime/src/main/java/run/endive/runtime/ImportMemory.java index b6394418f..e6632561d 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportMemory.java +++ b/runtime/src/main/java/run/endive/runtime/ImportMemory.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public class ImportMemory implements ImportValue { private final String module; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportTable.java b/runtime/src/main/java/run/endive/runtime/ImportTable.java similarity index 82% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportTable.java rename to runtime/src/main/java/run/endive/runtime/ImportTable.java index e9c836507..87470387d 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportTable.java +++ b/runtime/src/main/java/run/endive/runtime/ImportTable.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.ValType; import java.util.Map; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.ValType; public class ImportTable implements ImportValue { private final String module; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportTag.java b/runtime/src/main/java/run/endive/runtime/ImportTag.java similarity index 93% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportTag.java rename to runtime/src/main/java/run/endive/runtime/ImportTag.java index 21a471cc5..11e988845 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportTag.java +++ b/runtime/src/main/java/run/endive/runtime/ImportTag.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public class ImportTag implements ImportValue { private final String module; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportValue.java b/runtime/src/main/java/run/endive/runtime/ImportValue.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportValue.java rename to runtime/src/main/java/run/endive/runtime/ImportValue.java index 70ca6258c..af6286807 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportValue.java +++ b/runtime/src/main/java/run/endive/runtime/ImportValue.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * An external value is the runtime representation of an entity that can be imported. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportValues.java b/runtime/src/main/java/run/endive/runtime/ImportValues.java similarity index 99% rename from runtime/src/main/java/com/dylibso/chicory/runtime/ImportValues.java rename to runtime/src/main/java/run/endive/runtime/ImportValues.java index 1b00f0948..47b033381 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/ImportValues.java +++ b/runtime/src/main/java/run/endive/runtime/ImportValues.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import java.util.ArrayList; import java.util.Collection; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/Instance.java b/runtime/src/main/java/run/endive/runtime/Instance.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/Instance.java rename to runtime/src/main/java/run/endive/runtime/Instance.java index 43fae5372..2d4a70085 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/Instance.java +++ b/runtime/src/main/java/run/endive/runtime/Instance.java @@ -1,48 +1,15 @@ -package com.dylibso.chicory.runtime; - -import static com.dylibso.chicory.runtime.ConstantEvaluators.computeConstantInstance; -import static com.dylibso.chicory.runtime.ConstantEvaluators.computeConstantValue; -import static com.dylibso.chicory.wasm.types.ExternalType.FUNCTION; -import static com.dylibso.chicory.wasm.types.ExternalType.GLOBAL; -import static com.dylibso.chicory.wasm.types.ExternalType.MEMORY; -import static com.dylibso.chicory.wasm.types.ExternalType.TABLE; -import static com.dylibso.chicory.wasm.types.ExternalType.TAG; +package run.endive.runtime; + import static java.util.Objects.requireNonNullElse; import static java.util.Objects.requireNonNullElseGet; +import static run.endive.runtime.ConstantEvaluators.computeConstantInstance; +import static run.endive.runtime.ConstantEvaluators.computeConstantValue; +import static run.endive.wasm.types.ExternalType.FUNCTION; +import static run.endive.wasm.types.ExternalType.GLOBAL; +import static run.endive.wasm.types.ExternalType.MEMORY; +import static run.endive.wasm.types.ExternalType.TABLE; +import static run.endive.wasm.types.ExternalType.TAG; -import com.dylibso.chicory.runtime.internal.GcRefStore; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.InvalidException; -import com.dylibso.chicory.wasm.UninstantiableException; -import com.dylibso.chicory.wasm.UnlinkableException; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.ActiveElement; -import com.dylibso.chicory.wasm.types.DataSegment; -import com.dylibso.chicory.wasm.types.Element; -import com.dylibso.chicory.wasm.types.Export; -import com.dylibso.chicory.wasm.types.ExportSection; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionImport; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Global; -import com.dylibso.chicory.wasm.types.GlobalImport; -import com.dylibso.chicory.wasm.types.Import; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.MemoryImport; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.MemorySection; -import com.dylibso.chicory.wasm.types.MutabilityType; -import com.dylibso.chicory.wasm.types.PassiveDataSegment; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableImport; -import com.dylibso.chicory.wasm.types.TagImport; -import com.dylibso.chicory.wasm.types.TagSection; -import com.dylibso.chicory.wasm.types.TagType; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -50,6 +17,39 @@ import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; +import run.endive.runtime.internal.GcRefStore; +import run.endive.wasm.InvalidException; +import run.endive.wasm.UninstantiableException; +import run.endive.wasm.UnlinkableException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.ActiveElement; +import run.endive.wasm.types.DataSegment; +import run.endive.wasm.types.Element; +import run.endive.wasm.types.Export; +import run.endive.wasm.types.ExportSection; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionImport; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Global; +import run.endive.wasm.types.GlobalImport; +import run.endive.wasm.types.Import; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.MemoryImport; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.MemorySection; +import run.endive.wasm.types.MutabilityType; +import run.endive.wasm.types.PassiveDataSegment; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableImport; +import run.endive.wasm.types.TagImport; +import run.endive.wasm.types.TagSection; +import run.endive.wasm.types.TagType; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; public class Instance { public static final String START_FUNCTION_NAME = "_start"; @@ -678,7 +678,7 @@ private void validateHostGlobalType(GlobalImport i, ImportGlobal g) { // for const, subtyping is allowed typesMatch = ValType.matches(g.instance().getType(), i.type()); } else { - throw new ChicoryException( + throw new WasmEngineException( "internal error: mutability type is not var or const: " + i.mutabilityType()); } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/InterpreterMachine.java b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java similarity index 99% rename from runtime/src/main/java/com/dylibso/chicory/runtime/InterpreterMachine.java rename to runtime/src/main/java/run/endive/runtime/InterpreterMachine.java index 21823af2d..f19a591ae 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/InterpreterMachine.java +++ b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java @@ -1,22 +1,22 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.ValType.sizeOf; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; import static java.util.Objects.requireNonNullElse; +import static run.endive.wasm.types.ValType.sizeOf; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.InvalidException; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.CatchOpCode; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.ArrayDeque; import java.util.Deque; import java.util.List; +import run.endive.wasm.InvalidException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.CatchOpCode; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; /** * This is responsible for holding and interpreting the Wasm code. @@ -56,12 +56,12 @@ protected void evalDefault( Deque callStack, Instruction instruction, Operands operands) - throws ChicoryException { + throws WasmEngineException { throw new RuntimeException("Machine doesn't recognize Instruction " + instruction); } @Override - public long[] call(int funcId, long[] args) throws ChicoryException { + public long[] call(int funcId, long[] args) throws WasmEngineException { return call(stack, instance, callStack, funcId, args, null, true); } @@ -73,7 +73,7 @@ protected long[] call( long[] args, FunctionType callType, boolean popResults) - throws ChicoryException { + throws WasmEngineException { checkInterruption(); var typeId = instance.functionType(funcId); @@ -99,7 +99,7 @@ protected long[] call( try { eval(stack, instance, callStack); } catch (StackOverflowError e) { - throw new ChicoryException("call stack exhausted", e); + throw new WasmEngineException("call stack exhausted", e); } finally { if (!callStack.isEmpty() && callStack.peek() == stackFrame) { callStack.pop(); @@ -158,7 +158,7 @@ protected MStack stack() { } protected void eval(MStack stack, Instance instance, Deque callStack) - throws ChicoryException { + throws WasmEngineException { var frame = callStack.peek(); boolean shouldReturn = false; @@ -2721,7 +2721,7 @@ private static StackFrame RETURN_CALL_INDIRECT( var refMachine = refInstance.getMachine().getClass(); if (!refInstance.equals(instance) && !refMachine.equals(instance.getMachine().getClass())) { - throw new ChicoryException( + throw new WasmEngineException( "Indirect tail-call to a different Machine implementation is not supported: " + refMachine.getName()); } @@ -3119,17 +3119,17 @@ private static boolean functionTypeMatch( } protected static void verifyIndirectCall( - FunctionType actual, FunctionType expected, TypeSection ts) throws ChicoryException { + FunctionType actual, FunctionType expected, TypeSection ts) throws WasmEngineException { if (!functionTypeMatch(actual, expected, ts)) { - throw new ChicoryException("indirect call type mismatch"); + throw new WasmEngineException("indirect call type mismatch"); } } protected static void verifyIndirectCallByTypeIdx( - int actualTypeIdx, int expectedTypeIdx, TypeSection ts) throws ChicoryException { + int actualTypeIdx, int expectedTypeIdx, TypeSection ts) throws WasmEngineException { if (actualTypeIdx != expectedTypeIdx && !ValType.heapTypeSubtype(actualTypeIdx, expectedTypeIdx, ts)) { - throw new ChicoryException("indirect call type mismatch"); + throw new WasmEngineException("indirect call type mismatch"); } } @@ -3141,7 +3141,7 @@ protected static void verifyIndirectCallByTypeIdx( */ private static void checkInterruption() { if (Thread.currentThread().isInterrupted()) { - throw new ChicoryInterruptedException("Thread interrupted"); + throw new WasmInterruptedException("Thread interrupted"); } } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/MStack.java b/runtime/src/main/java/run/endive/runtime/MStack.java similarity index 96% rename from runtime/src/main/java/com/dylibso/chicory/runtime/MStack.java rename to runtime/src/main/java/run/endive/runtime/MStack.java index 3a16b2d7a..40d002556 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/MStack.java +++ b/runtime/src/main/java/run/endive/runtime/MStack.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public class MStack { public static final int MIN_CAPACITY = 8; diff --git a/runtime/src/main/java/run/endive/runtime/Machine.java b/runtime/src/main/java/run/endive/runtime/Machine.java new file mode 100644 index 000000000..d981d58ae --- /dev/null +++ b/runtime/src/main/java/run/endive/runtime/Machine.java @@ -0,0 +1,9 @@ +package run.endive.runtime; + +import run.endive.wasm.WasmEngineException; + +@FunctionalInterface +public interface Machine { + + long[] call(int funcId, long[] args) throws WasmEngineException; +} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/MemCopyWorkaround.java b/runtime/src/main/java/run/endive/runtime/MemCopyWorkaround.java similarity index 98% rename from runtime/src/main/java/com/dylibso/chicory/runtime/MemCopyWorkaround.java rename to runtime/src/main/java/run/endive/runtime/MemCopyWorkaround.java index bf08874f8..7c3b00389 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/MemCopyWorkaround.java +++ b/runtime/src/main/java/run/endive/runtime/MemCopyWorkaround.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; // // This class is used by compiler generated classes. It MUST remain backwards compatible diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/Memory.java b/runtime/src/main/java/run/endive/runtime/Memory.java similarity index 99% rename from runtime/src/main/java/com/dylibso/chicory/runtime/Memory.java rename to runtime/src/main/java/run/endive/runtime/Memory.java index 7cf691d54..382d00c28 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/Memory.java +++ b/runtime/src/main/java/run/endive/runtime/Memory.java @@ -1,8 +1,8 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.DataSegment; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import run.endive.wasm.types.DataSegment; public interface Memory { diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/OpCodeIdentifier.java b/runtime/src/main/java/run/endive/runtime/OpCodeIdentifier.java similarity index 77% rename from runtime/src/main/java/com/dylibso/chicory/runtime/OpCodeIdentifier.java rename to runtime/src/main/java/run/endive/runtime/OpCodeIdentifier.java index e313a97e3..6cc455eb8 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/OpCodeIdentifier.java +++ b/runtime/src/main/java/run/endive/runtime/OpCodeIdentifier.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.OpCode; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import run.endive.wasm.types.OpCode; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/OpcodeImpl.java b/runtime/src/main/java/run/endive/runtime/OpcodeImpl.java similarity index 96% rename from runtime/src/main/java/com/dylibso/chicory/runtime/OpcodeImpl.java rename to runtime/src/main/java/run/endive/runtime/OpcodeImpl.java index 8b3b911a3..f0edaae9f 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/OpcodeImpl.java +++ b/runtime/src/main/java/run/endive/runtime/OpcodeImpl.java @@ -1,14 +1,14 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.runtime.BitOps.FALSE; -import static com.dylibso.chicory.runtime.BitOps.TRUE; -import static com.dylibso.chicory.runtime.ConstantEvaluators.computeConstantValue; +import static run.endive.runtime.BitOps.FALSE; +import static run.endive.runtime.BitOps.TRUE; +import static run.endive.runtime.ConstantEvaluators.computeConstantValue; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.PassiveElement; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.lang.reflect.InvocationTargetException; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.PassiveElement; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; /** * Note: Some opcodes are easy or trivial to implement as compiler intrinsics (local.get, i32.add, etc). @@ -798,13 +798,14 @@ public static int TABLE_GET(Instance instance, int tableIndex, int index) { public static void TABLE_FILL( Instance instance, int tableIndex, int size, int value, int offset) { - int end = offset + size; + long endL = (long) offset + (long) size; var table = instance.table(tableIndex); - if (size < 0 || end > table.size()) { + if (size < 0 || offset < 0 || endL > (long) table.size()) { throw new WasmRuntimeException("out of bounds table access"); } + int end = (int) endL; for (int i = offset; i < end; i++) { table.setRef(i, value, instance); } @@ -821,12 +822,14 @@ public static void TABLE_COPY( for (int i = size - 1; i >= 0; i--) { if (d <= s) { - var val = src.ref(s++); - var inst = src.instance(d); - dest.setRef(d++, (int) val, inst); + var val = src.ref(s); + var inst = src.instance(s); + dest.setRef(d, (int) val, inst); + s++; + d++; } else { var val = src.ref(s + i); - var inst = src.instance(d + i); + var inst = src.instance(s + i); dest.setRef(d + i, (int) val, inst); } } @@ -834,7 +837,7 @@ public static void TABLE_COPY( public static void TABLE_INIT( Instance instance, int tableidx, int elementidx, int size, int elemidx, int offset) { - var end = offset + size; + long endL = (long) offset + (long) size; var table = instance.table(tableidx); var elementCount = instance.elementCount(); @@ -843,10 +846,12 @@ public static void TABLE_INIT( (currentElement instanceof PassiveElement) ? currentElement.elementCount() : 0; boolean isOutOfBounds = (size < 0 + || offset < 0 + || elemidx < 0 || elementidx > elementCount || (size > 0 && !(currentElement instanceof PassiveElement)) - || elemidx + size > currentElementCount - || end > table.size()); + || (long) elemidx + (long) size > (long) currentElementCount + || endL > (long) table.size()); if (isOutOfBounds) { throw new WasmRuntimeException("out of bounds table access"); @@ -855,6 +860,7 @@ public static void TABLE_INIT( return; } + int end = (int) endL; for (int i = offset; i < end; i++) { var elem = instance.element(elementidx); var val = diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/StackFrame.java b/runtime/src/main/java/run/endive/runtime/StackFrame.java similarity index 95% rename from runtime/src/main/java/com/dylibso/chicory/runtime/StackFrame.java rename to runtime/src/main/java/run/endive/runtime/StackFrame.java index 4287fb584..eb684f7a9 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/StackFrame.java +++ b/runtime/src/main/java/run/endive/runtime/StackFrame.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.ValType.sizeOf; +import static run.endive.wasm.types.ValType.sizeOf; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; /** * Represents a frame, doesn't hold the stack, just local variables and the `pc` which diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/Store.java b/runtime/src/main/java/run/endive/runtime/Store.java similarity index 97% rename from runtime/src/main/java/com/dylibso/chicory/runtime/Store.java rename to runtime/src/main/java/run/endive/runtime/Store.java index 7dee7860f..bdc3351e3 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/Store.java +++ b/runtime/src/main/java/run/endive/runtime/Store.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.Export; -import com.dylibso.chicory.wasm.types.ExportSection; import java.util.LinkedHashMap; import java.util.Objects; import java.util.function.Function; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.Export; +import run.endive.wasm.types.ExportSection; /** * The runtime storage for all function, global, memory, table instances. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/TableFactory.java b/runtime/src/main/java/run/endive/runtime/TableFactory.java similarity index 71% rename from runtime/src/main/java/com/dylibso/chicory/runtime/TableFactory.java rename to runtime/src/main/java/run/endive/runtime/TableFactory.java index 4932e62e0..76ac58619 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/TableFactory.java +++ b/runtime/src/main/java/run/endive/runtime/TableFactory.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.Table; +import run.endive.wasm.types.Table; /** * Factory for creating {@link TableInstance} objects during module instantiation. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/TableInstance.java b/runtime/src/main/java/run/endive/runtime/TableInstance.java similarity index 80% rename from runtime/src/main/java/com/dylibso/chicory/runtime/TableInstance.java rename to runtime/src/main/java/run/endive/runtime/TableInstance.java index ca54b252b..36eb8cf36 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/TableInstance.java +++ b/runtime/src/main/java/run/endive/runtime/TableInstance.java @@ -1,13 +1,13 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.UninstantiableException; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.ValType; import java.util.Arrays; +import run.endive.wasm.UninstantiableException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.ValType; public class TableInstance { @@ -52,7 +52,7 @@ public int grow(int size, int value, Instance instance) { public int ref(int index) { if (index < 0 || index >= this.refs.length) { - throw new ChicoryException("undefined element"); + throw new WasmEngineException("undefined element"); } return this.refs[index]; } @@ -60,7 +60,7 @@ public int ref(int index) { public int requiredRef(int index) { int ref = ref(index); if (ref == REF_NULL_VALUE) { - throw new ChicoryException("uninitialized element " + index); + throw new WasmEngineException("uninitialized element " + index); } return ref; } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/TagInstance.java b/runtime/src/main/java/run/endive/runtime/TagInstance.java similarity index 77% rename from runtime/src/main/java/com/dylibso/chicory/runtime/TagInstance.java rename to runtime/src/main/java/run/endive/runtime/TagInstance.java index bd7188e1b..2b0619f26 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/TagInstance.java +++ b/runtime/src/main/java/run/endive/runtime/TagInstance.java @@ -1,7 +1,7 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.TagType; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.TagType; public class TagInstance { diff --git a/runtime/src/main/java/run/endive/runtime/TrapException.java b/runtime/src/main/java/run/endive/runtime/TrapException.java new file mode 100644 index 000000000..2a6000ebb --- /dev/null +++ b/runtime/src/main/java/run/endive/runtime/TrapException.java @@ -0,0 +1,10 @@ +package run.endive.runtime; + +import run.endive.wasm.WasmEngineException; + +/** Wasm spec: runtime trap during execution (unreachable, OOB access, null ref, etc.). */ +public class TrapException extends WasmEngineException { + public TrapException(String msg) { + super(msg); + } +} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmArray.java b/runtime/src/main/java/run/endive/runtime/WasmArray.java similarity index 95% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmArray.java rename to runtime/src/main/java/run/endive/runtime/WasmArray.java index 2dd410935..a46fb3d47 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmArray.java +++ b/runtime/src/main/java/run/endive/runtime/WasmArray.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Runtime representation of a WasmGC array instance. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmException.java b/runtime/src/main/java/run/endive/runtime/WasmException.java similarity index 93% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmException.java rename to runtime/src/main/java/run/endive/runtime/WasmException.java index c49479780..3ba19c2ad 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmException.java +++ b/runtime/src/main/java/run/endive/runtime/WasmException.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; public class WasmException extends RuntimeException { private final int tagIdx; diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmExternRef.java b/runtime/src/main/java/run/endive/runtime/WasmExternRef.java similarity index 93% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmExternRef.java rename to runtime/src/main/java/run/endive/runtime/WasmExternRef.java index 6fe9c6c2d..92e34c192 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmExternRef.java +++ b/runtime/src/main/java/run/endive/runtime/WasmExternRef.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Wrapper for externref values converted to anyref via any.convert_extern. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmFunctionHandle.java b/runtime/src/main/java/run/endive/runtime/WasmFunctionHandle.java similarity index 83% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmFunctionHandle.java rename to runtime/src/main/java/run/endive/runtime/WasmFunctionHandle.java index 2b70815b8..627cdc08f 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmFunctionHandle.java +++ b/runtime/src/main/java/run/endive/runtime/WasmFunctionHandle.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Represents a Java function that can be called from Wasm. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmGcRef.java b/runtime/src/main/java/run/endive/runtime/WasmGcRef.java similarity index 77% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmGcRef.java rename to runtime/src/main/java/run/endive/runtime/WasmGcRef.java index 20060ad83..00e2b2a14 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmGcRef.java +++ b/runtime/src/main/java/run/endive/runtime/WasmGcRef.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Marker interface for WasmGC heap objects (structs and arrays). diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmI31Ref.java b/runtime/src/main/java/run/endive/runtime/WasmI31Ref.java similarity index 82% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmI31Ref.java rename to runtime/src/main/java/run/endive/runtime/WasmI31Ref.java index d1c18cdc2..8a03239e3 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmI31Ref.java +++ b/runtime/src/main/java/run/endive/runtime/WasmI31Ref.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Boxed representation of an i31ref value for storage in int-typed containers (tables, globals). * On the stack, i31 values use an efficient tagged-long encoding (see {@link - * com.dylibso.chicory.wasm.types.Value#encodeI31}). This class is only used when i31 values need + * run.endive.wasm.types.Value#encodeI31}). This class is only used when i31 values need * to pass through int-typed storage where the tag would be lost. */ public final class WasmI31Ref implements WasmGcRef { diff --git a/runtime/src/main/java/run/endive/runtime/WasmInterruptedException.java b/runtime/src/main/java/run/endive/runtime/WasmInterruptedException.java new file mode 100644 index 000000000..a48eafb41 --- /dev/null +++ b/runtime/src/main/java/run/endive/runtime/WasmInterruptedException.java @@ -0,0 +1,18 @@ +package run.endive.runtime; + +import run.endive.wasm.WasmEngineException; + +/** Thrown when the host interrupts a running Wasm execution via thread interruption. */ +public class WasmInterruptedException extends WasmEngineException { + public WasmInterruptedException(String msg) { + super(msg); + } + + public WasmInterruptedException(Throwable cause) { + super(cause); + } + + public WasmInterruptedException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmRuntimeException.java b/runtime/src/main/java/run/endive/runtime/WasmRuntimeException.java similarity index 53% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmRuntimeException.java rename to runtime/src/main/java/run/endive/runtime/WasmRuntimeException.java index dcd6b0322..595389f76 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmRuntimeException.java +++ b/runtime/src/main/java/run/endive/runtime/WasmRuntimeException.java @@ -1,8 +1,9 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.wasm.WasmEngineException; -public class WasmRuntimeException extends ChicoryException { +/** Engine-specific runtime error in compiled code paths (e.g., OOB memory access). */ +public class WasmRuntimeException extends WasmEngineException { public WasmRuntimeException(String msg) { super(msg); } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmStruct.java b/runtime/src/main/java/run/endive/runtime/WasmStruct.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/WasmStruct.java rename to runtime/src/main/java/run/endive/runtime/WasmStruct.java index 32c2ac9e9..35e3eb049 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/WasmStruct.java +++ b/runtime/src/main/java/run/endive/runtime/WasmStruct.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; /** * Runtime representation of a WasmGC struct instance. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/DefaultMemAllocStrategy.java b/runtime/src/main/java/run/endive/runtime/alloc/DefaultMemAllocStrategy.java similarity index 94% rename from runtime/src/main/java/com/dylibso/chicory/runtime/alloc/DefaultMemAllocStrategy.java rename to runtime/src/main/java/run/endive/runtime/alloc/DefaultMemAllocStrategy.java index 80fea4dd7..33e308f10 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/DefaultMemAllocStrategy.java +++ b/runtime/src/main/java/run/endive/runtime/alloc/DefaultMemAllocStrategy.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime.alloc; +package run.endive.runtime.alloc; /** * Default memory allocation strategy that doubles the buffer size on growth. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/ExactMemAllocStrategy.java b/runtime/src/main/java/run/endive/runtime/alloc/ExactMemAllocStrategy.java similarity index 92% rename from runtime/src/main/java/com/dylibso/chicory/runtime/alloc/ExactMemAllocStrategy.java rename to runtime/src/main/java/run/endive/runtime/alloc/ExactMemAllocStrategy.java index 9ca4e9d67..db39cd938 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/ExactMemAllocStrategy.java +++ b/runtime/src/main/java/run/endive/runtime/alloc/ExactMemAllocStrategy.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime.alloc; +package run.endive.runtime.alloc; /** * Memory allocation strategy that allocates exactly the requested size. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/MemAllocStrategy.java b/runtime/src/main/java/run/endive/runtime/alloc/MemAllocStrategy.java similarity index 89% rename from runtime/src/main/java/com/dylibso/chicory/runtime/alloc/MemAllocStrategy.java rename to runtime/src/main/java/run/endive/runtime/alloc/MemAllocStrategy.java index 62233cd0d..885011441 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/alloc/MemAllocStrategy.java +++ b/runtime/src/main/java/run/endive/runtime/alloc/MemAllocStrategy.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime.alloc; +package run.endive.runtime.alloc; /** * Strategy for allocating memory buffers. diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/internal/CompilerInterpreterMachine.java b/runtime/src/main/java/run/endive/runtime/internal/CompilerInterpreterMachine.java similarity index 84% rename from runtime/src/main/java/com/dylibso/chicory/runtime/internal/CompilerInterpreterMachine.java rename to runtime/src/main/java/run/endive/runtime/internal/CompilerInterpreterMachine.java index 0af6bfe96..b725f75a0 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/internal/CompilerInterpreterMachine.java +++ b/runtime/src/main/java/run/endive/runtime/internal/CompilerInterpreterMachine.java @@ -1,16 +1,16 @@ -package com.dylibso.chicory.runtime.internal; +package run.endive.runtime.internal; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.runtime.MStack; -import com.dylibso.chicory.runtime.StackFrame; -import com.dylibso.chicory.runtime.WasmException; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.types.FunctionType; import java.util.Deque; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.runtime.MStack; +import run.endive.runtime.StackFrame; +import run.endive.runtime.WasmException; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.FunctionType; /** * This class is used by compiler generated classes. It MUST remain backwards compatible @@ -22,7 +22,7 @@ public class CompilerInterpreterMachine extends InterpreterMachine { static { if (Boolean.parseBoolean( - System.getProperty("chicory.compiler.printUseOfInterpretedFunctions"))) { + System.getProperty("endive.compiler.printUseOfInterpretedFunctions"))) { usedInterpretedFunctions = new HashSet<>(); } else { usedInterpretedFunctions = null; @@ -46,10 +46,10 @@ protected long[] call( long[] args, FunctionType callType, boolean popResults) - throws ChicoryException { + throws WasmEngineException { if (usedInterpretedFunctions != null && !usedInterpretedFunctions.contains(funcId)) { usedInterpretedFunctions.add(funcId); - System.err.println("Chicory: calling interpreted function " + funcId); + System.err.println("Endive: calling interpreted function " + funcId); } return super.call(stack, instance, callStack, funcId, args, callType, popResults); } diff --git a/runtime/src/main/java/com/dylibso/chicory/runtime/internal/GcRefStore.java b/runtime/src/main/java/run/endive/runtime/internal/GcRefStore.java similarity index 93% rename from runtime/src/main/java/com/dylibso/chicory/runtime/internal/GcRefStore.java rename to runtime/src/main/java/run/endive/runtime/internal/GcRefStore.java index 8307ad72a..bfefbc214 100644 --- a/runtime/src/main/java/com/dylibso/chicory/runtime/internal/GcRefStore.java +++ b/runtime/src/main/java/run/endive/runtime/internal/GcRefStore.java @@ -1,14 +1,14 @@ -package com.dylibso.chicory.runtime.internal; +package run.endive.runtime.internal; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.WasmArray; -import com.dylibso.chicory.runtime.WasmGcRef; -import com.dylibso.chicory.runtime.WasmStruct; -import com.dylibso.chicory.wasm.types.Value; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import run.endive.runtime.Instance; +import run.endive.runtime.WasmArray; +import run.endive.runtime.WasmGcRef; +import run.endive.runtime.WasmStruct; +import run.endive.wasm.types.Value; /** * Store for GC-managed references keyed by auto-assigned integers. diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/ImportValuesTest.java b/runtime/src/test/java/run/endive/runtime/ImportValuesTest.java similarity index 98% rename from runtime/src/test/java/com/dylibso/chicory/runtime/ImportValuesTest.java rename to runtime/src/test/java/run/endive/runtime/ImportValuesTest.java index 379855321..e8d53105c 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/ImportValuesTest.java +++ b/runtime/src/test/java/run/endive/runtime/ImportValuesTest.java @@ -1,13 +1,13 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Value; import java.util.Arrays; import java.util.Collections; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Value; class ImportValuesTest { diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/InterruptionTest.java b/runtime/src/test/java/run/endive/runtime/InterruptionTest.java similarity index 90% rename from runtime/src/test/java/com/dylibso/chicory/runtime/InterruptionTest.java rename to runtime/src/test/java/run/endive/runtime/InterruptionTest.java index c53c3cde2..b6dc10686 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/InterruptionTest.java +++ b/runtime/src/test/java/run/endive/runtime/InterruptionTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -6,11 +6,11 @@ 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; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmEngineException; public class InterruptionTest { @Test @@ -38,7 +38,7 @@ private static void assertInterruption(Runnable function) throws InterruptedExce AtomicBoolean interrupted = new AtomicBoolean(); Runnable runnable = () -> { - var e = assertThrows(ChicoryException.class, function::run); + var e = assertThrows(WasmEngineException.class, function::run); assertEquals("Thread interrupted", e.getMessage()); interrupted.set(true); }; diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/MemCopyWorkaroundTest.java b/runtime/src/test/java/run/endive/runtime/MemCopyWorkaroundTest.java similarity index 97% rename from runtime/src/test/java/com/dylibso/chicory/runtime/MemCopyWorkaroundTest.java rename to runtime/src/test/java/run/endive/runtime/MemCopyWorkaroundTest.java index fcee644ab..a1b30abbb 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/MemCopyWorkaroundTest.java +++ b/runtime/src/test/java/run/endive/runtime/MemCopyWorkaroundTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/MemoryTest.java b/runtime/src/test/java/run/endive/runtime/MemoryTest.java similarity index 92% rename from runtime/src/test/java/com/dylibso/chicory/runtime/MemoryTest.java rename to runtime/src/test/java/run/endive/runtime/MemoryTest.java index a82d9eda1..3d9b08afa 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/MemoryTest.java +++ b/runtime/src/test/java/run/endive/runtime/MemoryTest.java @@ -1,8 +1,8 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -import com.dylibso.chicory.wasm.types.MemoryLimits; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; @@ -10,6 +10,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.MemoryLimits; public class MemoryTest { @@ -165,4 +167,11 @@ public void nonOverlappingCopyCrossPage(String name, Supplier memorySupp // Source should be unchanged assertArrayEquals(data, memory.readBytes(100, data.length)); } + + @ParameterizedTest(name = "{0}") + @MethodSource("memoryImplementations") + public void checkBoundsOverflowShouldTrap(String name, Supplier memorySupplier) { + var memory = memorySupplier.get(); + assertThrows(WasmEngineException.class, () -> memory.readBytes(1, Integer.MAX_VALUE)); + } } diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/StoreTest.java b/runtime/src/test/java/run/endive/runtime/StoreTest.java similarity index 96% rename from runtime/src/test/java/com/dylibso/chicory/runtime/StoreTest.java rename to runtime/src/test/java/run/endive/runtime/StoreTest.java index 60ba1d0cc..17ad0e1e6 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/StoreTest.java +++ b/runtime/src/test/java/run/endive/runtime/StoreTest.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.FunctionType; import java.util.List; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.FunctionType; public class StoreTest { diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/WasmModuleTest.java b/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java similarity index 97% rename from runtime/src/test/java/com/dylibso/chicory/runtime/WasmModuleTest.java rename to runtime/src/test/java/run/endive/runtime/WasmModuleTest.java index 3bd35614b..1783e89ce 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/WasmModuleTest.java +++ b/runtime/src/test/java/run/endive/runtime/WasmModuleTest.java @@ -1,6 +1,5 @@ -package com.dylibso.chicory.runtime; +package run.endive.runtime; -import static com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -8,20 +7,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.wasm.types.Value.REF_NULL_VALUE; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.wasm.InvalidException; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.UninstantiableException; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.CatchOpCode; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.TagType; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.HashMap; import java.util.List; import java.util.concurrent.ExecutorService; @@ -33,6 +20,19 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; +import run.endive.wasm.InvalidException; +import run.endive.wasm.Parser; +import run.endive.wasm.UninstantiableException; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.CatchOpCode; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.TagType; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; public class WasmModuleTest { diff --git a/runtime/src/test/java/com/dylibso/chicory/runtime/internal/GcRefStoreTest.java b/runtime/src/test/java/run/endive/runtime/internal/GcRefStoreTest.java similarity index 91% rename from runtime/src/test/java/com/dylibso/chicory/runtime/internal/GcRefStoreTest.java rename to runtime/src/test/java/run/endive/runtime/internal/GcRefStoreTest.java index f9bad1d2e..e0d2a4173 100644 --- a/runtime/src/test/java/com/dylibso/chicory/runtime/internal/GcRefStoreTest.java +++ b/runtime/src/test/java/run/endive/runtime/internal/GcRefStoreTest.java @@ -1,15 +1,15 @@ -package com.dylibso.chicory.runtime.internal; +package run.endive.runtime.internal; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.WasmGcRef; -import com.dylibso.chicory.wasm.Parser; import java.io.ByteArrayInputStream; import org.junit.jupiter.api.Test; +import run.endive.runtime.Instance; +import run.endive.runtime.WasmGcRef; +import run.endive.wasm.Parser; public class GcRefStoreTest { diff --git a/scripts/build-jmh-main.sh b/scripts/build-jmh-main.sh index 637cd97ec..c3d2ca2af 100755 --- a/scripts/build-jmh-main.sh +++ b/scripts/build-jmh-main.sh @@ -6,6 +6,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ( cd "${SCRIPT_DIR}/.." rm -rf main - git clone --depth 1 --branch main https://github.com/dylibso/chicory.git main + git clone --depth 1 --branch main https://github.com/bytecodealliance/endive.git main mvn -Dquickly ) diff --git a/scripts/build-zig-testsuite.sh b/scripts/build-zig-testsuite.sh index 21e3b3899..4d3446edb 100755 --- a/scripts/build-zig-testsuite.sh +++ b/scripts/build-zig-testsuite.sh @@ -20,7 +20,7 @@ if [ ! -d "$ZIG_INSTALL" ]; then mkdir -p ${ZIG_INSTALL} ARCHIVE=zig-linux-x86_64-${ZIG_VERSION}.tar.xz - curl -sSL "${ZIG_MIRROR}/${ARCHIVE}?source=github-chicory-nightly" -o "${ARCHIVE}" + curl -sSL "${ZIG_MIRROR}/${ARCHIVE}?source=github-endive-nightly" -o "${ARCHIVE}" echo "473ec26806133cf4d1918caf1a410f8403a13d979726a9045b421b685031a982 ${ARCHIVE}" | sha256sum -c - tar -xJ --strip-components=1 -C "${ZIG_INSTALL}" -f "${ARCHIVE}" fi @@ -30,7 +30,7 @@ if [ ! -d "$ZIG_SOURCE" ]; then mkdir -p ${ZIG_SOURCE} ARCHIVE=zig-${ZIG_VERSION}.tar.xz - curl -sSL "${ZIG_MIRROR}/${ARCHIVE}?source=github-chicory-nightly" -o "${ARCHIVE}" + curl -sSL "${ZIG_MIRROR}/${ARCHIVE}?source=github-endive-nightly" -o "${ARCHIVE}" echo "c76638c03eb204c4432ae092f6fa07c208567e110fbd4d862d131a7332584046 ${ARCHIVE}" | sha256sum -c - tar -xJ --strip-components=1 -C "${ZIG_SOURCE}" -f "${ARCHIVE}" fi diff --git a/scripts/compile-resources.sh b/scripts/compile-resources.sh index f851c3243..595053d24 100755 --- a/scripts/compile-resources.sh +++ b/scripts/compile-resources.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euxo pipefail -CONTAINER_IMAGE="docker.io/andreatp/chicory-compilation-support" +CONTAINER_IMAGE="docker.io/andreatp/endive-compilation-support" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) declare -a arr=("wasm" "runtime" "wasi") diff --git a/simd/pom.xml b/simd/pom.xml index 98ef3961c..f63818d90 100644 --- a/simd/pom.xml +++ b/simd/pom.xml @@ -3,15 +3,15 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml simd jar - Chicory - SIMD - SIMD instructions support for Chicory + Endive - SIMD + SIMD instructions support for Endive 25 @@ -22,18 +22,13 @@ - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - - com.dylibso.chicory - wasm-corpus - test - org.junit.jupiter junit-jupiter-api @@ -44,6 +39,11 @@ junit-jupiter-engine test + + run.endive + wasm-corpus + test + diff --git a/simd/src/main/java-templates-21/com/dylibso/chicory/simd/VectorOperators.java b/simd/src/main/java-templates-21/run/endive/simd/VectorOperators.java similarity index 98% rename from simd/src/main/java-templates-21/com/dylibso/chicory/simd/VectorOperators.java rename to simd/src/main/java-templates-21/run/endive/simd/VectorOperators.java index 29d09d61c..951bab3ac 100644 --- a/simd/src/main/java-templates-21/com/dylibso/chicory/simd/VectorOperators.java +++ b/simd/src/main/java-templates-21/run/endive/simd/VectorOperators.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.simd; +package run.endive.simd; /** * Generated compatibility shim for cross-version compatibility with jdk.incubator.vector.VectorOperators diff --git a/simd/src/main/java-templates/com/dylibso/chicory/simd/VectorOperators.java b/simd/src/main/java-templates/run/endive/simd/VectorOperators.java similarity index 98% rename from simd/src/main/java-templates/com/dylibso/chicory/simd/VectorOperators.java rename to simd/src/main/java-templates/run/endive/simd/VectorOperators.java index b3f17adef..784581d9b 100644 --- a/simd/src/main/java-templates/com/dylibso/chicory/simd/VectorOperators.java +++ b/simd/src/main/java-templates/run/endive/simd/VectorOperators.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.simd; +package run.endive.simd; /** * Generated compatibility shim for cross-version compatibility with jdk.incubator.vector.VectorOperators diff --git a/simd/src/main/java/module-info.java b/simd/src/main/java/module-info.java index ec5a36819..5e8096f4f 100644 --- a/simd/src/main/java/module-info.java +++ b/simd/src/main/java/module-info.java @@ -1,5 +1,5 @@ -module com.dylibso.chicory.simd { - requires transitive com.dylibso.chicory.runtime; - requires com.dylibso.chicory.wasm; +module run.endive.simd { + requires transitive run.endive.runtime; + requires run.endive.wasm; requires jdk.incubator.vector; } diff --git a/simd/src/main/java/com/dylibso/chicory/simd/SimdInterpreterMachine.java b/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java similarity index 99% rename from simd/src/main/java/com/dylibso/chicory/simd/SimdInterpreterMachine.java rename to simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java index 0aaebaceb..8e08b7c9f 100644 --- a/simd/src/main/java/com/dylibso/chicory/simd/SimdInterpreterMachine.java +++ b/simd/src/main/java/run/endive/simd/SimdInterpreterMachine.java @@ -1,15 +1,5 @@ -package com.dylibso.chicory.simd; - -import com.dylibso.chicory.runtime.BitOps; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.InterpreterMachine; -import com.dylibso.chicory.runtime.MStack; -import com.dylibso.chicory.runtime.OpcodeImpl; -import com.dylibso.chicory.runtime.StackFrame; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.Value; +package run.endive.simd; + import java.util.Arrays; import java.util.Deque; import java.util.function.BiConsumer; @@ -17,6 +7,16 @@ import java.util.function.Function; import jdk.incubator.vector.LongVector; import jdk.incubator.vector.Vector; +import run.endive.runtime.BitOps; +import run.endive.runtime.Instance; +import run.endive.runtime.InterpreterMachine; +import run.endive.runtime.MStack; +import run.endive.runtime.OpcodeImpl; +import run.endive.runtime.StackFrame; +import run.endive.wasm.WasmEngineException; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.Value; public final class SimdInterpreterMachine extends InterpreterMachine { @@ -31,7 +31,7 @@ protected void evalDefault( Deque callStack, Instruction instruction, Operands operands) - throws ChicoryException { + throws WasmEngineException { switch (instruction.opcode()) { case OpCode.V128_CONST: V128_CONST(stack, operands); diff --git a/simd/src/test/java/com/dylibso/chicory/simd/BasicSimdTest.java b/simd/src/test/java/run/endive/simd/BasicSimdTest.java similarity index 81% rename from simd/src/test/java/com/dylibso/chicory/simd/BasicSimdTest.java rename to simd/src/test/java/run/endive/simd/BasicSimdTest.java index 2cb3e0cf1..f4168bddb 100644 --- a/simd/src/test/java/com/dylibso/chicory/simd/BasicSimdTest.java +++ b/simd/src/test/java/run/endive/simd/BasicSimdTest.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.simd; +package run.endive.simd; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public class BasicSimdTest { diff --git a/test-gen-lib/pom.xml b/test-gen-lib/pom.xml index fa87d5300..52d5a0d88 100644 --- a/test-gen-lib/pom.xml +++ b/test-gen-lib/pom.xml @@ -3,21 +3,17 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml test-gen-lib jar - Chicory - Test Gen Lib + Endive - Test Gen Lib A library to generate tests from the WebAssembly testsuite - - com.dylibso.chicory - wasm-tools - com.fasterxml.jackson.core jackson-annotations @@ -34,5 +30,9 @@ net.lingala.zip4j zip4j + + run.endive + wasm-tools + diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/Constants.java b/test-gen-lib/src/main/java/run/endive/testgen/Constants.java similarity index 80% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/Constants.java rename to test-gen-lib/src/main/java/run/endive/testgen/Constants.java index e0c340d48..cb209ce43 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/Constants.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/Constants.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen; +package run.endive.testgen; public final class Constants { diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/JavaTestGen.java b/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java similarity index 90% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/JavaTestGen.java rename to test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java index 1a8c26ac6..79f22924c 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/JavaTestGen.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/JavaTestGen.java @@ -1,11 +1,5 @@ -package com.dylibso.chicory.testgen; - -import com.dylibso.chicory.testgen.wast.ActionType; -import com.dylibso.chicory.testgen.wast.Command; -import com.dylibso.chicory.testgen.wast.CommandType; -import com.dylibso.chicory.testgen.wast.WasmValue; -import com.dylibso.chicory.testgen.wast.WasmValueType; -import com.dylibso.chicory.testgen.wast.Wast; +package run.endive.testgen; + import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; @@ -28,6 +22,12 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import run.endive.testgen.wast.ActionType; +import run.endive.testgen.wast.Command; +import run.endive.testgen.wast.CommandType; +import run.endive.testgen.wast.WasmValue; +import run.endive.testgen.wast.WasmValueType; +import run.endive.testgen.wast.Wast; public class JavaTestGen { @@ -57,7 +57,7 @@ public JavaTestGen( } public CompilationUnit generate(String name, Wast wast, String wasmClasspath) { - var cu = new CompilationUnit("com.dylibso.chicory.test.gen"); + var cu = new CompilationUnit("run.endive.test.gen"); var testName = "SpecV1" + StringUtils.capitalize(StringUtils.escapedCamelCase(name)) + "Test"; @@ -80,40 +80,40 @@ public CompilationUnit generate(String name, Wast wast, String wasmClasspath) { cu.addImport("org.junit.jupiter.api.Assertions.assertDoesNotThrow", true, false); // testing imports - cu.addImport("com.dylibso.chicory.testing.TestModule"); - cu.addImport("com.dylibso.chicory.testing.ArgsAdapter"); + cu.addImport("run.endive.testing.TestModule"); + cu.addImport("run.endive.testing.ArgsAdapter"); // runtime imports - cu.addImport("com.dylibso.chicory.wasm.ChicoryException"); - cu.addImport("com.dylibso.chicory.runtime.WasmException"); - cu.addImport("com.dylibso.chicory.runtime.ExportFunction"); - cu.addImport("com.dylibso.chicory.runtime.Instance"); + cu.addImport("run.endive.wasm.WasmEngineException"); + cu.addImport("run.endive.runtime.WasmException"); + cu.addImport("run.endive.runtime.ExportFunction"); + cu.addImport("run.endive.runtime.Instance"); // base imports - cu.addImport("com.dylibso.chicory.wasm.InvalidException"); - cu.addImport("com.dylibso.chicory.wasm.MalformedException"); - cu.addImport("com.dylibso.chicory.wasm.UninstantiableException"); - cu.addImport("com.dylibso.chicory.wasm.UnlinkableException"); - cu.addImport("com.dylibso.chicory.wasm.types.Value"); - - cu.addImport("com.dylibso.chicory.wasm.types.Value.REF_NULL_VALUE", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.vecTo8", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.vecTo16", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.vecTo32", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.vecToF32", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.vecToF64", true, false); - - cu.addImport("com.dylibso.chicory.wasm.types.Value.i8ToVec", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.i16ToVec", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.i32ToVec", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.i64ToVec", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.f64ToVec", true, false); - cu.addImport("com.dylibso.chicory.wasm.types.Value.f32ToVec", true, false); + cu.addImport("run.endive.wasm.InvalidException"); + cu.addImport("run.endive.wasm.MalformedException"); + cu.addImport("run.endive.wasm.UninstantiableException"); + cu.addImport("run.endive.wasm.UnlinkableException"); + cu.addImport("run.endive.wasm.types.Value"); + + cu.addImport("run.endive.wasm.types.Value.REF_NULL_VALUE", true, false); + cu.addImport("run.endive.wasm.types.Value.vecTo8", true, false); + cu.addImport("run.endive.wasm.types.Value.vecTo16", true, false); + cu.addImport("run.endive.wasm.types.Value.vecTo32", true, false); + cu.addImport("run.endive.wasm.types.Value.vecToF32", true, false); + cu.addImport("run.endive.wasm.types.Value.vecToF64", true, false); + + cu.addImport("run.endive.wasm.types.Value.i8ToVec", true, false); + cu.addImport("run.endive.wasm.types.Value.i16ToVec", true, false); + cu.addImport("run.endive.wasm.types.Value.i32ToVec", true, false); + cu.addImport("run.endive.wasm.types.Value.i64ToVec", true, false); + cu.addImport("run.endive.wasm.types.Value.f64ToVec", true, false); + cu.addImport("run.endive.wasm.types.Value.f32ToVec", true, false); // import for Store instance - cu.addImport("com.dylibso.chicory.runtime.Store"); + cu.addImport("run.endive.runtime.Store"); // import for shared Spectest host module - cu.addImport("com.dylibso.chicory.testing.Spectest"); + cu.addImport("run.endive.testing.Spectest"); var testClass = cu.addClass(testName); testClass.addSingleMemberAnnotation( @@ -315,7 +315,7 @@ private String getExceptionType(CommandType typ) { return "UnlinkableException"; case ASSERT_TRAP: case ASSERT_EXHAUSTION: - return "ChicoryException"; + return "WasmEngineException"; case ASSERT_EXCEPTION: return "WasmException"; default: diff --git a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/StringUtils.java b/test-gen-lib/src/main/java/run/endive/testgen/StringUtils.java similarity index 96% rename from wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/StringUtils.java rename to test-gen-lib/src/main/java/run/endive/testgen/StringUtils.java index 685cf1912..4ab5955b3 100644 --- a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/StringUtils.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/StringUtils.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.maven; +package run.endive.testgen; public final class StringUtils { diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestGen.java b/test-gen-lib/src/main/java/run/endive/testgen/TestGen.java similarity index 96% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestGen.java rename to test-gen-lib/src/main/java/run/endive/testgen/TestGen.java index 457a8e704..c3db42180 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestGen.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/TestGen.java @@ -1,10 +1,8 @@ -package com.dylibso.chicory.testgen; +package run.endive.testgen; -import static com.dylibso.chicory.testgen.Constants.SPEC_JSON; -import static com.dylibso.chicory.testgen.StringUtils.escapedCamelCase; +import static run.endive.testgen.Constants.SPEC_JSON; +import static run.endive.testgen.StringUtils.escapedCamelCase; -import com.dylibso.chicory.testgen.wast.Wast; -import com.dylibso.chicory.tools.wasm.Wast2Json; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.javaparser.utils.SourceRoot; import java.io.File; @@ -18,6 +16,8 @@ import java.util.Locale; import java.util.Set; import java.util.stream.Collectors; +import run.endive.testgen.wast.Wast; +import run.endive.tools.wasm.Wast2Json; /** * This plugin should generate the testsuite out of wast files diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestSuiteDownloader.java b/test-gen-lib/src/main/java/run/endive/testgen/TestSuiteDownloader.java similarity index 98% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestSuiteDownloader.java rename to test-gen-lib/src/main/java/run/endive/testgen/TestSuiteDownloader.java index 20454524c..ce607b2be 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/TestSuiteDownloader.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/TestSuiteDownloader.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen; +package run.endive.testgen; import java.io.File; import java.io.IOException; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Action.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/Action.java similarity index 96% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Action.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/Action.java index e99e10621..f752acfa8 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Action.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/Action.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/ActionType.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/ActionType.java similarity index 90% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/ActionType.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/ActionType.java index 48e100152..b82bafd68 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/ActionType.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/ActionType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Command.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/Command.java similarity index 97% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Command.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/Command.java index a9543543d..c6b09ded4 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Command.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/Command.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/CommandType.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/CommandType.java similarity index 96% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/CommandType.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/CommandType.java index bd0da3298..ff76a7ea0 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/CommandType.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/CommandType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/LaneType.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/LaneType.java similarity index 92% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/LaneType.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/LaneType.java index 670d81de6..115c599b8 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/LaneType.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/LaneType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValue.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java similarity index 99% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValue.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java index d6878f14f..cc6af11b5 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValue.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValue.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValueType.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValueType.java similarity index 96% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValueType.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValueType.java index fcb1efbbc..379fe2cac 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/WasmValueType.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/WasmValueType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Wast.java b/test-gen-lib/src/main/java/run/endive/testgen/wast/Wast.java similarity index 89% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Wast.java rename to test-gen-lib/src/main/java/run/endive/testgen/wast/Wast.java index 3f00e0514..6d545a170 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/wast/Wast.java +++ b/test-gen-lib/src/main/java/run/endive/testgen/wast/Wast.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen.wast; +package run.endive.testgen.wast; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.File; diff --git a/test-gen-plugin/pom.xml b/test-gen-plugin/pom.xml index d56a2d9da..779e02e53 100644 --- a/test-gen-plugin/pom.xml +++ b/test-gen-plugin/pom.xml @@ -3,25 +3,25 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml test-gen-plugin maven-plugin - Chicory - Test Gen Maven Plugin + Endive - Test Gen Maven Plugin A Maven Plugin to generate tests from the WebAssembly testsuite - - com.dylibso.chicory - test-gen-lib - com.github.javaparser javaparser-core + + run.endive + test-gen-lib + org.apache.maven maven-core diff --git a/test-gen-plugin/src/main/java/com/dylibso/chicory/maven/JavaParserMavenUtils.java b/test-gen-plugin/src/main/java/run/endive/maven/JavaParserMavenUtils.java similarity index 96% rename from test-gen-plugin/src/main/java/com/dylibso/chicory/maven/JavaParserMavenUtils.java rename to test-gen-plugin/src/main/java/run/endive/maven/JavaParserMavenUtils.java index d240c39cc..bc5eb2bba 100644 --- a/test-gen-plugin/src/main/java/com/dylibso/chicory/maven/JavaParserMavenUtils.java +++ b/test-gen-plugin/src/main/java/run/endive/maven/JavaParserMavenUtils.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.maven; +package run.endive.maven; import java.util.function.Supplier; import org.apache.maven.plugin.logging.Log; diff --git a/test-gen-plugin/src/main/java/com/dylibso/chicory/maven/TestGenMojo.java b/test-gen-plugin/src/main/java/run/endive/maven/TestGenMojo.java similarity index 98% rename from test-gen-plugin/src/main/java/com/dylibso/chicory/maven/TestGenMojo.java rename to test-gen-plugin/src/main/java/run/endive/maven/TestGenMojo.java index 81937bb24..207e92525 100644 --- a/test-gen-plugin/src/main/java/com/dylibso/chicory/maven/TestGenMojo.java +++ b/test-gen-plugin/src/main/java/run/endive/maven/TestGenMojo.java @@ -1,8 +1,7 @@ -package com.dylibso.chicory.maven; +package run.endive.maven; import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_TEST_SOURCES; -import com.dylibso.chicory.testgen.TestGen; import java.io.File; import java.util.List; import java.util.stream.Collectors; @@ -12,6 +11,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import run.endive.testgen.TestGen; /** * This plugin should generate the testsuite out of wast files diff --git a/wabt/pom.xml b/wabt/pom.xml index c65f14c4e..ddd1f18d6 100644 --- a/wabt/pom.xml +++ b/wabt/pom.xml @@ -3,45 +3,45 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT wabt jar - Chicory - wabt - wabt tools compiled to pure Java with Chicory + Endive - wabt + wabt tools compiled to pure Java with Endive - com.dylibso.chicory + io.roastedroot + zerofs + + + run.endive log - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasi - com.dylibso.chicory + run.endive wasm - io.roastedroot - zerofs - - - com.dylibso.chicory - wasm-corpus + org.junit.jupiter + junit-jupiter-api test - org.junit.jupiter - junit-jupiter-api + run.endive + wasm-corpus test @@ -50,8 +50,8 @@ - com.dylibso.chicory - chicory-compiler-maven-plugin + run.endive + endive-compiler-maven-plugin wast2json @@ -59,7 +59,7 @@ compile - com.dylibso.chicory.wabt.Wast2JsonModule + run.endive.wabt.Wast2JsonModule src/main/resources/wast2json @@ -69,7 +69,7 @@ compile - com.dylibso.chicory.wabt.Wat2WasmModule + run.endive.wabt.Wat2WasmModule src/main/resources/wat2wasm diff --git a/wabt/src/main/java/module-info.java b/wabt/src/main/java/module-info.java index 0d074fd95..5266f4b90 100644 --- a/wabt/src/main/java/module-info.java +++ b/wabt/src/main/java/module-info.java @@ -1,9 +1,9 @@ -module com.dylibso.chicory.wabt { - requires com.dylibso.chicory.log; - requires com.dylibso.chicory.runtime; - requires com.dylibso.chicory.wasi; - requires com.dylibso.chicory.wasm; +module run.endive.wabt { + requires run.endive.log; + requires run.endive.runtime; + requires run.endive.wasi; + requires run.endive.wasm; requires io.roastedroot.zerofs.ZeroFs; - exports com.dylibso.chicory.wabt; + exports run.endive.wabt; } diff --git a/wabt/src/main/java/com/dylibso/chicory/wabt/Files.java b/wabt/src/main/java/run/endive/wabt/Files.java similarity index 97% rename from wabt/src/main/java/com/dylibso/chicory/wabt/Files.java rename to wabt/src/main/java/run/endive/wabt/Files.java index cd0e6de79..ddab9f259 100644 --- a/wabt/src/main/java/com/dylibso/chicory/wabt/Files.java +++ b/wabt/src/main/java/run/endive/wabt/Files.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; import static java.nio.file.Files.copy; import static java.nio.file.Files.walkFileTree; diff --git a/wabt/src/main/java/com/dylibso/chicory/wabt/Wast2Json.java b/wabt/src/main/java/run/endive/wabt/Wast2Json.java similarity index 94% rename from wabt/src/main/java/com/dylibso/chicory/wabt/Wast2Json.java rename to wabt/src/main/java/run/endive/wabt/Wast2Json.java index 4dff0afd9..200261d3f 100644 --- a/wabt/src/main/java/com/dylibso/chicory/wabt/Wast2Json.java +++ b/wabt/src/main/java/run/endive/wabt/Wast2Json.java @@ -1,15 +1,8 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; import static java.nio.file.Files.copy; import static java.nio.file.Files.createDirectories; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.File; @@ -21,6 +14,13 @@ import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.List; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class Wast2Json { private static final Logger logger = diff --git a/wabt/src/main/java/com/dylibso/chicory/wabt/Wat2Wasm.java b/wabt/src/main/java/run/endive/wabt/Wat2Wasm.java similarity index 89% rename from wabt/src/main/java/com/dylibso/chicory/wabt/Wat2Wasm.java rename to wabt/src/main/java/run/endive/wabt/Wat2Wasm.java index 6a0dad437..9fd9c0f3f 100644 --- a/wabt/src/main/java/com/dylibso/chicory/wabt/Wat2Wasm.java +++ b/wabt/src/main/java/run/endive/wabt/Wat2Wasm.java @@ -1,15 +1,7 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; import static java.nio.file.Files.copy; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.ByteArrayInputStream; @@ -24,6 +16,14 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.List; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class Wat2Wasm { private static final Logger logger = new SystemLogger(); diff --git a/wabt/src/main/java/com/dylibso/chicory/wabt/WatParseException.java b/wabt/src/main/java/run/endive/wabt/WatParseException.java similarity index 89% rename from wabt/src/main/java/com/dylibso/chicory/wabt/WatParseException.java rename to wabt/src/main/java/run/endive/wabt/WatParseException.java index 5840b65f9..cb81875a9 100644 --- a/wabt/src/main/java/com/dylibso/chicory/wabt/WatParseException.java +++ b/wabt/src/main/java/run/endive/wabt/WatParseException.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; public class WatParseException extends RuntimeException { diff --git a/wabt/src/test/java/com/dylibso/chicory/wabt/Wast2JsonTest.java b/wabt/src/test/java/run/endive/wabt/Wast2JsonTest.java similarity index 96% rename from wabt/src/test/java/com/dylibso/chicory/wabt/Wast2JsonTest.java rename to wabt/src/test/java/run/endive/wabt/Wast2JsonTest.java index a6569b8d2..da6da8b58 100644 --- a/wabt/src/test/java/com/dylibso/chicory/wabt/Wast2JsonTest.java +++ b/wabt/src/test/java/run/endive/wabt/Wast2JsonTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/wabt/src/test/java/com/dylibso/chicory/wabt/Wat2WasmTest.java b/wabt/src/test/java/run/endive/wabt/Wat2WasmTest.java similarity index 91% rename from wabt/src/test/java/com/dylibso/chicory/wabt/Wat2WasmTest.java rename to wabt/src/test/java/run/endive/wabt/Wat2WasmTest.java index be6b6f698..ef6049658 100644 --- a/wabt/src/test/java/com/dylibso/chicory/wabt/Wat2WasmTest.java +++ b/wabt/src/test/java/run/endive/wabt/Wat2WasmTest.java @@ -1,17 +1,17 @@ -package com.dylibso.chicory.wabt; +package run.endive.wabt; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.corpus.WatGenerator; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasm.Parser; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Test; +import run.endive.corpus.WatGenerator; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasm.Parser; public class Wat2WasmTest { diff --git a/wasi-test-gen-plugin/pom.xml b/wasi-test-gen-plugin/pom.xml index 14d14f546..74e7ab2eb 100644 --- a/wasi-test-gen-plugin/pom.xml +++ b/wasi-test-gen-plugin/pom.xml @@ -3,14 +3,14 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml wasi-test-gen-plugin maven-plugin - Chicory - WASI Test Gen Maven Plugin + Endive - WASI Test Gen Maven Plugin A Maven Plugin to generate tests from the WebAssembly wasi-testsuite diff --git a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/Specification.java b/wasi-test-gen-plugin/src/main/java/run/endive/maven/Specification.java similarity index 97% rename from wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/Specification.java rename to wasi-test-gen-plugin/src/main/java/run/endive/maven/Specification.java index 330022b41..1910ff8dd 100644 --- a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/Specification.java +++ b/wasi-test-gen-plugin/src/main/java/run/endive/maven/Specification.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.maven; +package run.endive.maven; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; diff --git a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/StringUtils.java b/wasi-test-gen-plugin/src/main/java/run/endive/maven/StringUtils.java similarity index 96% rename from test-gen-lib/src/main/java/com/dylibso/chicory/testgen/StringUtils.java rename to wasi-test-gen-plugin/src/main/java/run/endive/maven/StringUtils.java index 54774bf19..89bd19dab 100644 --- a/test-gen-lib/src/main/java/com/dylibso/chicory/testgen/StringUtils.java +++ b/wasi-test-gen-plugin/src/main/java/run/endive/maven/StringUtils.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.testgen; +package run.endive.maven; public final class StringUtils { diff --git a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestGenMojo.java b/wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestGenMojo.java similarity index 96% rename from wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestGenMojo.java rename to wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestGenMojo.java index 37b1aadfd..fedee714e 100644 --- a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestGenMojo.java +++ b/wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestGenMojo.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.maven; +package run.endive.maven; -import static com.dylibso.chicory.maven.StringUtils.capitalize; -import static com.dylibso.chicory.maven.StringUtils.escapedCamelCase; import static com.github.javaparser.utils.StringEscapeUtils.escapeJava; import static java.lang.String.format; import static java.util.stream.Collectors.toList; import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_TEST_SOURCES; +import static run.endive.maven.StringUtils.capitalize; +import static run.endive.maven.StringUtils.escapedCamelCase; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.javaparser.ast.CompilationUnit; @@ -43,7 +43,7 @@ public class WasiTestGenMojo extends AbstractMojo { private static final String JUNIT_TEST = "org.junit.jupiter.api.Test"; - private static final String WASI_TEST_RUNNER = "com.dylibso.chicory.wasi.WasiTestRunner"; + private static final String WASI_TEST_RUNNER = "run.endive.wasi.WasiTestRunner"; private final Log log = new SystemStreamLog(); @@ -149,7 +149,7 @@ public void execute() throws MojoExecutionException { String testSuite = entry.getKey(); List files = entry.getValue(); - String packageName = "com.dylibso.chicory.wasi.test"; + String packageName = "run.endive.wasi.test"; var cu = new CompilationUnit(packageName); cu.addImport(WASI_TEST_RUNNER); diff --git a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestSuiteDownloader.java b/wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestSuiteDownloader.java similarity index 97% rename from wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestSuiteDownloader.java rename to wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestSuiteDownloader.java index 78dddb27f..af664259c 100644 --- a/wasi-test-gen-plugin/src/main/java/com/dylibso/chicory/maven/WasiTestSuiteDownloader.java +++ b/wasi-test-gen-plugin/src/main/java/run/endive/maven/WasiTestSuiteDownloader.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.maven; +package run.endive.maven; import java.io.File; import java.io.IOException; diff --git a/wasi-tests/pom.xml b/wasi-tests/pom.xml index 964356ab1..ec3a97ffb 100644 --- a/wasi-tests/pom.xml +++ b/wasi-tests/pom.xml @@ -3,63 +3,87 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml wasi-tests jar - Chicory - WASI Tests - WASI Preview 1 tests for Chicory + Endive - WASI Tests + WASI Preview 1 tests for Endive - com.dylibso.chicory - log + io.roastedroot + zerofs test - com.dylibso.chicory - runtime + org.junit.jupiter + junit-jupiter-api test - com.dylibso.chicory - wasi + org.junit.jupiter + junit-jupiter-engine test - com.dylibso.chicory - wasm + run.endive + log test - com.dylibso.chicory - wasm-corpus + run.endive + runtime test - io.roastedroot - zerofs + run.endive + wasi test - org.junit.jupiter - junit-jupiter-api + run.endive + wasm test - org.junit.jupiter - junit-jupiter-engine + run.endive + wasm-corpus test + + + org.apache.maven.plugins + maven-compiler-plugin + + + + run.endive + annotations-processor + ${project.version} + + + + + - com.dylibso.chicory + org.apache.maven.plugins + maven-dependency-plugin + + + run.endive:annotations-processor + + + + + run.endive wasi-test-gen-plugin ${project.version} @@ -93,30 +117,6 @@ - - - org.apache.maven.plugins - maven-compiler-plugin - - - - com.dylibso.chicory - annotations-processor - ${project.version} - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - com.dylibso.chicory:annotations-processor - - - diff --git a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/MockPrintStream.java b/wasi-tests/src/test/java/run/endive/wasi/MockPrintStream.java similarity index 93% rename from wasi-tests/src/test/java/com/dylibso/chicory/wasi/MockPrintStream.java rename to wasi-tests/src/test/java/run/endive/wasi/MockPrintStream.java index 877dad7c5..ef6029ff9 100644 --- a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/MockPrintStream.java +++ b/wasi-tests/src/test/java/run/endive/wasi/MockPrintStream.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiPreview1Test.java b/wasi-tests/src/test/java/run/endive/wasi/WasiPreview1Test.java similarity index 79% rename from wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiPreview1Test.java rename to wasi-tests/src/test/java/run/endive/wasi/WasiPreview1Test.java index 1273fcff1..1e7e217d7 100644 --- a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiPreview1Test.java +++ b/wasi-tests/src/test/java/run/endive/wasi/WasiPreview1Test.java @@ -1,6 +1,5 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; -import static com.dylibso.chicory.wasi.Files.copyDirectory; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.Files.createDirectory; import static java.nio.file.Files.createSymbolicLink; @@ -9,9 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static run.endive.wasi.Files.copyDirectory; -import com.dylibso.chicory.runtime.ByteBufferMemory; -import com.dylibso.chicory.wasm.types.MemoryLimits; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.ByteArrayInputStream; @@ -22,6 +20,8 @@ import java.util.Random; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import run.endive.runtime.ByteBufferMemory; +import run.endive.wasm.types.MemoryLimits; @Timeout(10) public class WasiPreview1Test { @@ -235,6 +235,65 @@ public void wasiPollOneoffClockAbstime() { assertTrue(System.nanoTime() >= deadline); } + @Test + public void fdReadNegativeIovLenShouldReturnEinval() throws IOException { + try (var fs = newZeroFs()) { + Path root = fs.getPath("test"); + createDirectory(root); + writeString(root.resolve("hello.txt"), "Hello"); + try (var wasi = wasiWithDirectory(root.toString(), root)) { + var memory = new ByteBufferMemory(new MemoryLimits(1)); + + int fdPtr = 0; + int result = wasi.pathOpen(memory, 3, 0, "hello.txt", 0, 0, 0, 0, fdPtr); + assertEquals(WasiErrno.ESUCCESS.value(), result); + int fd = memory.readInt(fdPtr); + + int iovs = 100; + int iovBase = 200; + memory.writeI32(iovs, iovBase); + memory.writeI32(iovs + 4, 0x80000001); // negative in signed int + int nreadPtr = 300; + result = wasi.fdRead(memory, fd, iovs, 1, nreadPtr); + assertEquals(WasiErrno.EINVAL.value(), result); + } + } + } + + @Test + public void symlinkEscapeShouldReturnEacces() throws IOException { + Path tmpDir = java.nio.file.Files.createTempDirectory("wasi-symlink-test"); + try { + Path sandbox = tmpDir.resolve("sandbox"); + createDirectory(sandbox); + Path outside = tmpDir.resolve("outside"); + createDirectory(outside); + writeString(outside.resolve("secret.txt"), "secret"); + createSymbolicLink(sandbox.resolve("escape"), outside.resolve("secret.txt")); + + try (var wasi = wasiWithDirectory(sandbox.toString(), sandbox)) { + var memory = new ByteBufferMemory(new MemoryLimits(1)); + int buf = 0; + int result = + wasi.pathFilestatGet( + memory, 3, WasiLookupFlags.SYMLINK_FOLLOW, "escape", buf); + assertEquals(WasiErrno.EACCES.value(), result); + } + } finally { + try (var paths = java.nio.file.Files.walk(tmpDir)) { + paths.sorted(java.util.Comparator.reverseOrder()) + .forEach( + p -> { + try { + java.nio.file.Files.deleteIfExists(p); + } catch (IOException ignored) { + // best-effort cleanup + } + }); + } + } + } + private static FileSystem newZeroFs() { return ZeroFs.newFileSystem( Configuration.unix().toBuilder().setAttributeViews("unix").build()); diff --git a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiTestRunner.java b/wasi-tests/src/test/java/run/endive/wasi/WasiTestRunner.java similarity index 92% rename from wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiTestRunner.java rename to wasi-tests/src/test/java/run/endive/wasi/WasiTestRunner.java index 8d9e75447..9cf3c4148 100644 --- a/wasi-tests/src/test/java/com/dylibso/chicory/wasi/WasiTestRunner.java +++ b/wasi-tests/src/test/java/run/endive/wasi/WasiTestRunner.java @@ -1,12 +1,8 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; -import static com.dylibso.chicory.wasi.Files.copyDirectory; import static org.junit.jupiter.api.Assertions.assertEquals; +import static run.endive.wasi.Files.copyDirectory; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasm.Parser; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.File; @@ -18,6 +14,10 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import run.endive.log.SystemLogger; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasm.Parser; public final class WasiTestRunner { private static final SystemLogger LOGGER = new SystemLogger(); diff --git a/wasi/README.md b/wasi/README.md index e255942b0..7d462dd61 100644 --- a/wasi/README.md +++ b/wasi/README.md @@ -5,4 +5,4 @@ This library contains code for instantiating and running WASI modules. by many of the compilers out there. This library implements the widely-available version 0.1 of the spec, also known as `wasip1`. -For further details see the [corresponding docs](https://chicory.dev/docs/usage/wasi) section +For further details see the [corresponding docs](https://endive.run/docs/usage/wasi) section diff --git a/wasi/pom.xml b/wasi/pom.xml index 6cd487130..04942e9b9 100644 --- a/wasi/pom.xml +++ b/wasi/pom.xml @@ -3,45 +3,40 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml wasi jar - Chicory - WASI - WASI Preview 1 implementation for Chicory + Endive - WASI + WASI Preview 1 implementation for Endive - com.dylibso.chicory + run.endive log - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasm - com.dylibso.chicory + run.endive annotations provided - com.dylibso.chicory + run.endive annotations-processor provided - - com.dylibso.chicory - wasm-corpus - test - org.junit.jupiter junit-jupiter-api @@ -52,6 +47,11 @@ junit-jupiter-engine test + + run.endive + wasm-corpus + test + @@ -63,7 +63,7 @@ - com.dylibso.chicory + run.endive annotations-processor ${project.version} @@ -76,7 +76,7 @@ maven-dependency-plugin - com.dylibso.chicory:annotations-processor + run.endive:annotations-processor diff --git a/wasi/src/main/java/module-info.java b/wasi/src/main/java/module-info.java index 89439f532..7d3bbc943 100644 --- a/wasi/src/main/java/module-info.java +++ b/wasi/src/main/java/module-info.java @@ -1,8 +1,8 @@ -module com.dylibso.chicory.wasi { - requires static com.dylibso.chicory.annotations; - requires com.dylibso.chicory.log; - requires transitive com.dylibso.chicory.runtime; +module run.endive.wasi { + requires static run.endive.annotations; + requires run.endive.log; + requires transitive run.endive.runtime; requires static java.compiler; - exports com.dylibso.chicory.wasi; + exports run.endive.wasi; } diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/Descriptors.java b/wasi/src/main/java/run/endive/wasi/Descriptors.java similarity index 99% rename from wasi/src/main/java/com/dylibso/chicory/wasi/Descriptors.java rename to wasi/src/main/java/run/endive/wasi/Descriptors.java index 2d2f8f2c4..2dd488910 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/Descriptors.java +++ b/wasi/src/main/java/run/endive/wasi/Descriptors.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; import static java.util.Objects.requireNonNull; diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/Files.java b/wasi/src/main/java/run/endive/wasi/Files.java similarity index 98% rename from wasi/src/main/java/com/dylibso/chicory/wasi/Files.java rename to wasi/src/main/java/run/endive/wasi/Files.java index 240161cd2..9d2de7bce 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/Files.java +++ b/wasi/src/main/java/run/endive/wasi/Files.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; import static java.nio.file.Files.copy; import static java.nio.file.Files.createDirectory; diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/IO.java b/wasi/src/main/java/run/endive/wasi/IO.java similarity index 99% rename from wasi/src/main/java/com/dylibso/chicory/wasi/IO.java rename to wasi/src/main/java/run/endive/wasi/IO.java index 9c09f337e..dab499896 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/IO.java +++ b/wasi/src/main/java/run/endive/wasi/IO.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; import java.io.IOException; import java.io.InputStream; diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiClockId.java b/wasi/src/main/java/run/endive/wasi/WasiClockId.java similarity index 91% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiClockId.java rename to wasi/src/main/java/run/endive/wasi/WasiClockId.java index 1e63cf05e..6b6db492e 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiClockId.java +++ b/wasi/src/main/java/run/endive/wasi/WasiClockId.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI clockid diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiErrno.java b/wasi/src/main/java/run/endive/wasi/WasiErrno.java similarity index 97% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiErrno.java rename to wasi/src/main/java/run/endive/wasi/WasiErrno.java index 06f188680..b319aa374 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiErrno.java +++ b/wasi/src/main/java/run/endive/wasi/WasiErrno.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI errno diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiEventType.java b/wasi/src/main/java/run/endive/wasi/WasiEventType.java similarity index 90% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiEventType.java rename to wasi/src/main/java/run/endive/wasi/WasiEventType.java index 431174c53..0dde28eb9 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiEventType.java +++ b/wasi/src/main/java/run/endive/wasi/WasiEventType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI eventtype diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiExitException.java b/wasi/src/main/java/run/endive/wasi/WasiExitException.java similarity index 66% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiExitException.java rename to wasi/src/main/java/run/endive/wasi/WasiExitException.java index 0fd0fe954..3d3d2ff11 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiExitException.java +++ b/wasi/src/main/java/run/endive/wasi/WasiExitException.java @@ -1,8 +1,9 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; -import com.dylibso.chicory.wasm.ChicoryException; +import run.endive.wasm.WasmEngineException; -public class WasiExitException extends ChicoryException { +/** WASI proc_exit with a specific exit code. */ +public class WasiExitException extends WasmEngineException { private final int exitCode; public WasiExitException(int exitCode) { diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFdFlags.java b/wasi/src/main/java/run/endive/wasi/WasiFdFlags.java similarity index 93% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiFdFlags.java rename to wasi/src/main/java/run/endive/wasi/WasiFdFlags.java index 5f56caf3c..b42981fad 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFdFlags.java +++ b/wasi/src/main/java/run/endive/wasi/WasiFdFlags.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI fdflags diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFileType.java b/wasi/src/main/java/run/endive/wasi/WasiFileType.java similarity index 91% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiFileType.java rename to wasi/src/main/java/run/endive/wasi/WasiFileType.java index 4cffa1da9..d08d10ae9 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFileType.java +++ b/wasi/src/main/java/run/endive/wasi/WasiFileType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI filetype diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFstFlags.java b/wasi/src/main/java/run/endive/wasi/WasiFstFlags.java similarity index 92% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiFstFlags.java rename to wasi/src/main/java/run/endive/wasi/WasiFstFlags.java index 1b9afd0a4..ebd2c3c70 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiFstFlags.java +++ b/wasi/src/main/java/run/endive/wasi/WasiFstFlags.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI fstflags diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiLookupFlags.java b/wasi/src/main/java/run/endive/wasi/WasiLookupFlags.java similarity index 87% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiLookupFlags.java rename to wasi/src/main/java/run/endive/wasi/WasiLookupFlags.java index a9f2dbe4c..84409b189 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiLookupFlags.java +++ b/wasi/src/main/java/run/endive/wasi/WasiLookupFlags.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI lookupflags flags diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiOpenFlags.java b/wasi/src/main/java/run/endive/wasi/WasiOpenFlags.java similarity index 92% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiOpenFlags.java rename to wasi/src/main/java/run/endive/wasi/WasiOpenFlags.java index 5938c04af..71d56b596 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiOpenFlags.java +++ b/wasi/src/main/java/run/endive/wasi/WasiOpenFlags.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI oflags diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiOptions.java b/wasi/src/main/java/run/endive/wasi/WasiOptions.java similarity index 99% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiOptions.java rename to wasi/src/main/java/run/endive/wasi/WasiOptions.java index 1a71f22ca..f880b67be 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiOptions.java +++ b/wasi/src/main/java/run/endive/wasi/WasiOptions.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiPreview1.java b/wasi/src/main/java/run/endive/wasi/WasiPreview1.java similarity index 96% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiPreview1.java rename to wasi/src/main/java/run/endive/wasi/WasiPreview1.java index e2f43c992..e7ff06786 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiPreview1.java +++ b/wasi/src/main/java/run/endive/wasi/WasiPreview1.java @@ -1,10 +1,5 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; -import static com.dylibso.chicory.wasi.Descriptors.DataReader; -import static com.dylibso.chicory.wasi.Descriptors.DataWriter; -import static com.dylibso.chicory.wasi.Descriptors.Descriptor; -import static com.dylibso.chicory.wasi.Descriptors.OpenDirectory; -import static com.dylibso.chicory.wasi.Descriptors.OpenFile; import static java.lang.Math.max; import static java.lang.Math.min; import static java.nio.charset.StandardCharsets.UTF_8; @@ -13,22 +8,12 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toList; +import static run.endive.wasi.Descriptors.DataReader; +import static run.endive.wasi.Descriptors.DataWriter; +import static run.endive.wasi.Descriptors.Descriptor; +import static run.endive.wasi.Descriptors.OpenDirectory; +import static run.endive.wasi.Descriptors.OpenFile; -import com.dylibso.chicory.annotations.Buffer; -import com.dylibso.chicory.annotations.HostModule; -import com.dylibso.chicory.annotations.WasmExport; -import com.dylibso.chicory.log.BasicLogger; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ExecutionCompletedException; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.Memory; -import com.dylibso.chicory.runtime.WasmRuntimeException; -import com.dylibso.chicory.wasi.Descriptors.Directory; -import com.dylibso.chicory.wasi.Descriptors.InStream; -import com.dylibso.chicory.wasi.Descriptors.OutStream; -import com.dylibso.chicory.wasi.Descriptors.PreopenedDirectory; -import com.dylibso.chicory.wasm.ChicoryException; import java.io.Closeable; import java.io.IOException; import java.nio.ByteBuffer; @@ -65,6 +50,21 @@ import java.util.Random; import java.util.Set; import java.util.stream.Stream; +import run.endive.annotations.Buffer; +import run.endive.annotations.HostModule; +import run.endive.annotations.WasmExport; +import run.endive.log.BasicLogger; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ExecutionCompletedException; +import run.endive.runtime.HostFunction; +import run.endive.runtime.Memory; +import run.endive.runtime.WasmRuntimeException; +import run.endive.wasi.Descriptors.Directory; +import run.endive.wasi.Descriptors.InStream; +import run.endive.wasi.Descriptors.OutStream; +import run.endive.wasi.Descriptors.PreopenedDirectory; +import run.endive.wasm.WasmEngineException; /** * WASI preview 1 implementation @@ -570,6 +570,9 @@ public int fdPread(Memory memory, int fd, int iovs, int iovsLen, long offset, in int base = iovs + (i * 8); int iovBase = memory.readInt(base); var iovLen = memory.readInt(base + 4); + if (iovLen < 0) { + return wasiResult(WasiErrno.EINVAL); + } try { byte[] data = new byte[iovLen]; int read = file.read(data, offset); @@ -670,6 +673,9 @@ public int fdPwrite( var base = iovs + (i * 8); var iovBase = memory.readInt(base); var iovLen = memory.readInt(base + 4); + if (iovLen < 0) { + return wasiResult(WasiErrno.EINVAL); + } var data = memory.readBytes(iovBase, iovLen); try { int written = file.write(data, offset); @@ -713,6 +719,9 @@ public int fdRead(Memory memory, int fd, int iovs, int iovsLen, int nreadPtr) { int base = iovs + (i * 8); int iovBase = memory.readInt(base); var iovLen = memory.readInt(base + 4); + if (iovLen < 0) { + return wasiResult(WasiErrno.EINVAL); + } try { byte[] data = new byte[iovLen]; int read = reader.read(data); @@ -938,6 +947,9 @@ public int fdWrite(Memory memory, int fd, int iovs, int iovsLen, int nwrittenPtr var base = iovs + (i * 8); var iovBase = memory.readInt(base); var iovLen = memory.readInt(base + 4); + if (iovLen < 0) { + return wasiResult(WasiErrno.EINVAL); + } var data = memory.readBytes(iovBase, iovLen); try { int written = writer.write(data); @@ -1010,7 +1022,7 @@ public int pathFilestatGet( Map attributes; try { if (flagSet(lookupFlags, WasiLookupFlags.SYMLINK_FOLLOW)) { - var resolved = resolveSymlinks(path); + var resolved = resolveSymlinks(path, directory); if (resolved.isError()) { return resolved.error(); } else { @@ -1088,7 +1100,7 @@ Path resolved() { } } - private ResolvedSymlink resolveSymlinks(Path path) { + private ResolvedSymlink resolveSymlinks(Path path, Path directory) { List visited = new ArrayList<>(); while (Files.isSymbolicLink(path)) { if (visited.contains(path)) { @@ -1104,6 +1116,17 @@ private ResolvedSymlink resolveSymlinks(Path path) { } } + try { + Path dirReal = directory.toRealPath(); + Path pathReal = + Files.exists(path) ? path.toRealPath() : path.toAbsolutePath().normalize(); + if (!pathReal.startsWith(dirReal)) { + return new ResolvedSymlink(wasiResult(WasiErrno.EACCES)); + } + } catch (IOException e) { + return new ResolvedSymlink(wasiResult(WasiErrno.EIO)); + } + return new ResolvedSymlink(path); } @@ -1163,7 +1186,7 @@ public int pathLink( try { if (flagSet(oldFlags, WasiLookupFlags.SYMLINK_FOLLOW)) { - var resolved = resolveSymlinks(oldPath); + var resolved = resolveSymlinks(oldPath, oldDirectory); if (resolved.isError()) { return resolved.error(); } else { @@ -1234,7 +1257,7 @@ public int pathOpen( } if (flagSet(lookupFlags, WasiLookupFlags.SYMLINK_FOLLOW)) { - var resolved = resolveSymlinks(path); + var resolved = resolveSymlinks(path, directory); if (resolved.isError()) { return resolved.error(); } else { @@ -1639,7 +1662,7 @@ public int pollOneoff( try { NANOSECONDS.sleep(duration); } catch (InterruptedException e) { - throw new ChicoryException("Thread interrupted", e); + throw new WasmEngineException("Thread interrupted", e); } } @@ -1685,7 +1708,7 @@ public int randomGet(Memory memory, int buf, int bufLen) { int written = 0; while (written < bufLen) { if (Thread.currentThread().isInterrupted()) { - throw new ChicoryException("Thread interrupted"); + throw new WasmEngineException("Thread interrupted"); } int size = min(data.length, bufLen - written); if (size < data.length) { diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiRights.java b/wasi/src/main/java/run/endive/wasi/WasiRights.java similarity index 98% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiRights.java rename to wasi/src/main/java/run/endive/wasi/WasiRights.java index edf37a057..1ca93d3b0 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiRights.java +++ b/wasi/src/main/java/run/endive/wasi/WasiRights.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI rights diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiSubClockFlags.java b/wasi/src/main/java/run/endive/wasi/WasiSubClockFlags.java similarity index 88% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiSubClockFlags.java rename to wasi/src/main/java/run/endive/wasi/WasiSubClockFlags.java index 8c0d6b547..6bce04753 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiSubClockFlags.java +++ b/wasi/src/main/java/run/endive/wasi/WasiSubClockFlags.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI subclockflags flags diff --git a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiWhence.java b/wasi/src/main/java/run/endive/wasi/WasiWhence.java similarity index 89% rename from wasi/src/main/java/com/dylibso/chicory/wasi/WasiWhence.java rename to wasi/src/main/java/run/endive/wasi/WasiWhence.java index 4306f1631..9e08d61f0 100644 --- a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiWhence.java +++ b/wasi/src/main/java/run/endive/wasi/WasiWhence.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasi; +package run.endive.wasi; /** * WASI whence diff --git a/wasi/src/test/java/wasi/WasiPreview1Test.java b/wasi/src/test/java/wasi/WasiPreview1Test.java index 0b186c9f4..39e444cf5 100644 --- a/wasi/src/test/java/wasi/WasiPreview1Test.java +++ b/wasi/src/test/java/wasi/WasiPreview1Test.java @@ -4,24 +4,24 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.runtime.HostFunction; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.runtime.Store; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.Parser; -import com.dylibso.chicory.wasm.WasmModule; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.ValType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.List; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import run.endive.corpus.CorpusResources; +import run.endive.runtime.HostFunction; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.runtime.Store; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.Parser; +import run.endive.wasm.WasmModule; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.ValType; @Timeout(10) public class WasiPreview1Test { diff --git a/wasm-corpus/pom.xml b/wasm-corpus/pom.xml index c28d07c74..36e380bdd 100644 --- a/wasm-corpus/pom.xml +++ b/wasm-corpus/pom.xml @@ -2,12 +2,12 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT wasm-corpus - Chicory - WASM Corpus + Endive - WASM Corpus A Corpus of guest modules for testing @@ -25,7 +25,7 @@ - com.dylibso.chicory.corpus + run.endive.corpus @@ -46,7 +46,7 @@ -cp - com.dylibso.chicory.corpus.WatGenerator + run.endive.corpus.WatGenerator 10 0 diff --git a/wasm-corpus/run.sh b/wasm-corpus/run.sh index d7f7b52c1..4fa37291f 100755 --- a/wasm-corpus/run.sh +++ b/wasm-corpus/run.sh @@ -4,9 +4,9 @@ # run with no args to compile everything if [[ "$1" = "rebuild" ]]; then - docker build . --platform linux/amd64 -t chicory/wasm-corpus + docker build . --platform linux/amd64 -t endive/wasm-corpus else # Optionally takes the args `lang` (ex: wat, rust) and `file` (ex: br.wat) # both default to all - docker run --platform linux/amd64 -v $(pwd)/src/main/resources:/usr/code --rm chicory/wasm-corpus $1 $2 + docker run --platform linux/amd64 -v $(pwd)/src/main/resources:/usr/code --rm endive/wasm-corpus $1 $2 fi diff --git a/wasm-corpus/src/main/java/com/dylibso/chicory/corpus/CorpusResources.java b/wasm-corpus/src/main/java/run/endive/corpus/CorpusResources.java similarity index 91% rename from wasm-corpus/src/main/java/com/dylibso/chicory/corpus/CorpusResources.java rename to wasm-corpus/src/main/java/run/endive/corpus/CorpusResources.java index a6f630f01..a3d2ea68b 100644 --- a/wasm-corpus/src/main/java/com/dylibso/chicory/corpus/CorpusResources.java +++ b/wasm-corpus/src/main/java/run/endive/corpus/CorpusResources.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.corpus; +package run.endive.corpus; import java.io.InputStream; diff --git a/wasm-corpus/src/main/java/com/dylibso/chicory/corpus/WatGenerator.java b/wasm-corpus/src/main/java/run/endive/corpus/WatGenerator.java similarity index 92% rename from wasm-corpus/src/main/java/com/dylibso/chicory/corpus/WatGenerator.java rename to wasm-corpus/src/main/java/run/endive/corpus/WatGenerator.java index 50013e18f..c726809f7 100644 --- a/wasm-corpus/src/main/java/com/dylibso/chicory/corpus/WatGenerator.java +++ b/wasm-corpus/src/main/java/run/endive/corpus/WatGenerator.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.corpus; +package run.endive.corpus; import java.io.StringWriter; import java.util.ArrayDeque; @@ -28,7 +28,7 @@ public static String bigWat(int funcCount, int funcSize) { } return render( - "/com/dylibso/chicory/corpus/big.wat", + "/run/endive/corpus/big.wat", Map.of( "functions", functions, "instructions", instructions)); @@ -41,8 +41,7 @@ public static String methodTooLarge(int funcSize) { } return render( - "/com/dylibso/chicory/corpus/method_too_large.wat", - Map.of("instructions", instructions)); + "/run/endive/corpus/method_too_large.wat", Map.of("instructions", instructions)); } private static String render(String template, Map map) { diff --git a/wasm-corpus/src/main/resources/com/dylibso/chicory/corpus/big.wat b/wasm-corpus/src/main/resources/run/endive/corpus/big.wat similarity index 100% rename from wasm-corpus/src/main/resources/com/dylibso/chicory/corpus/big.wat rename to wasm-corpus/src/main/resources/run/endive/corpus/big.wat diff --git a/wasm-corpus/src/main/resources/com/dylibso/chicory/corpus/method_too_large.wat b/wasm-corpus/src/main/resources/run/endive/corpus/method_too_large.wat similarity index 100% rename from wasm-corpus/src/main/resources/com/dylibso/chicory/corpus/method_too_large.wat rename to wasm-corpus/src/main/resources/run/endive/corpus/method_too_large.wat diff --git a/wasm-tools/pom.xml b/wasm-tools/pom.xml index 2a8cfd08e..68602ad73 100644 --- a/wasm-tools/pom.xml +++ b/wasm-tools/pom.xml @@ -3,15 +3,15 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT wasm-tools jar - Chicory - wasm-tools - wasm tools compiled to pure Java with Chicory + Endive - wasm-tools + wasm tools compiled to pure Java with Endive 1.240.0 @@ -19,25 +19,25 @@ - com.dylibso.chicory + io.roastedroot + zerofs + + + run.endive log - com.dylibso.chicory + run.endive runtime - com.dylibso.chicory + run.endive wasi - com.dylibso.chicory + run.endive wasm - - io.roastedroot - zerofs - org.junit.jupiter junit-jupiter-api @@ -47,30 +47,6 @@ - - com.dylibso.chicory - chicory-compiler-maven-plugin - - - wasmtools - - compile - - - com.dylibso.chicory.tools.wasm.WasmToolsModule - ${project.basedir}/target/wasm-tools.wasm - - - 4725 - 5095 - 5422 - 7668 - 10543 - - - - - org.apache.maven.plugins maven-antrun-plugin @@ -112,6 +88,30 @@ + + run.endive + endive-compiler-maven-plugin + + + wasmtools + + compile + + + run.endive.tools.wasm.WasmToolsModule + ${project.basedir}/target/wasm-tools.wasm + + + 4725 + 5095 + 5422 + 7668 + 10543 + + + + + diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Files.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Files.java similarity index 96% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Files.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/Files.java index ce2ac69b0..e547064e8 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Files.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Files.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; import static java.nio.file.Files.copy; import static java.nio.file.Files.walkFileTree; diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Validate.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java similarity index 86% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Validate.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java index 84ea31b2a..59e2863a7 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Validate.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Validate.java @@ -1,14 +1,5 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -18,6 +9,15 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.List; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class Validate { diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmith.java b/wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmith.java similarity index 89% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmith.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmith.java index b8993196e..1632642dd 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmith.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmith.java @@ -1,14 +1,5 @@ -package com.dylibso.chicory.tools.wasm; - -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; +package run.endive.tools.wasm; + import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.ByteArrayInputStream; @@ -20,6 +11,15 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class WasmSmith { diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmithException.java b/wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmithException.java similarity index 85% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmithException.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmithException.java index 22fa99bc8..c84cd4221 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WasmSmithException.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/WasmSmithException.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; public class WasmSmithException extends RuntimeException { public WasmSmithException(String message) { diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wast2Json.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java similarity index 91% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wast2Json.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java index 9d075c74f..4306503f3 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wast2Json.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Wast2Json.java @@ -1,15 +1,7 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; import static java.nio.file.Files.createDirectories; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; import io.roastedroot.zerofs.Configuration; import io.roastedroot.zerofs.ZeroFs; import java.io.File; @@ -22,6 +14,14 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class Wast2Json { private static final Logger logger = diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wat2Wasm.java b/wasm-tools/src/main/java/run/endive/tools/wasm/Wat2Wasm.java similarity index 84% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wat2Wasm.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/Wat2Wasm.java index 440554e98..3ab892d84 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/Wat2Wasm.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/Wat2Wasm.java @@ -1,16 +1,7 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; -import static com.dylibso.chicory.tools.wasm.Validate.validate; +import static run.endive.tools.wasm.Validate.validate; -import com.dylibso.chicory.log.Logger; -import com.dylibso.chicory.log.SystemLogger; -import com.dylibso.chicory.runtime.ByteArrayMemory; -import com.dylibso.chicory.runtime.ImportValues; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasi.WasiOptions; -import com.dylibso.chicory.wasi.WasiPreview1; -import com.dylibso.chicory.wasm.WasmModule; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -20,6 +11,15 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.List; +import run.endive.log.Logger; +import run.endive.log.SystemLogger; +import run.endive.runtime.ByteArrayMemory; +import run.endive.runtime.ImportValues; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasi.WasiOptions; +import run.endive.wasi.WasiPreview1; +import run.endive.wasm.WasmModule; public final class Wat2Wasm { private Wat2Wasm() {} diff --git a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WatParseException.java b/wasm-tools/src/main/java/run/endive/tools/wasm/WatParseException.java similarity index 87% rename from wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WatParseException.java rename to wasm-tools/src/main/java/run/endive/tools/wasm/WatParseException.java index 542d11cd1..55cba0adc 100644 --- a/wasm-tools/src/main/java/com/dylibso/chicory/tools/wasm/WatParseException.java +++ b/wasm-tools/src/main/java/run/endive/tools/wasm/WatParseException.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; public class WatParseException extends RuntimeException { diff --git a/wasm-tools/src/test/java/com/dylibso/chicory/tools/wasm/WasmToolsTest.java b/wasm-tools/src/test/java/run/endive/tools/wasm/WasmToolsTest.java similarity index 95% rename from wasm-tools/src/test/java/com/dylibso/chicory/tools/wasm/WasmToolsTest.java rename to wasm-tools/src/test/java/run/endive/tools/wasm/WasmToolsTest.java index 1b28c12ee..e80d958f9 100644 --- a/wasm-tools/src/test/java/com/dylibso/chicory/tools/wasm/WasmToolsTest.java +++ b/wasm-tools/src/test/java/run/endive/tools/wasm/WasmToolsTest.java @@ -1,17 +1,17 @@ -package com.dylibso.chicory.tools.wasm; +package run.endive.tools.wasm; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.runtime.Instance; -import com.dylibso.chicory.wasi.WasiExitException; -import com.dylibso.chicory.wasm.Parser; import java.io.File; import java.nio.file.Path; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import run.endive.runtime.Instance; +import run.endive.wasi.WasiExitException; +import run.endive.wasm.Parser; public class WasmToolsTest { diff --git a/wasm/README.md b/wasm/README.md index c1feffda9..c56f036cf 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -11,8 +11,8 @@ module using `Parser.parse`: @@ -32,7 +32,7 @@ public void writeResultFile(String name, String content) throws Exception { --> ```java -import com.dylibso.chicory.wasm.Parser; +import run.endive.wasm.Parser; var is = ClassLoader.getSystemClassLoader().getResourceAsStream("compiled/count_vowels.rs.wasm"); var module = Parser.parse(is); @@ -52,9 +52,9 @@ sections. This is useful for performance if you only want to parse a piece of th If you don't call this method once it will parse all sections. ```java -import com.dylibso.chicory.wasm.ParserListener; -import com.dylibso.chicory.wasm.types.CustomSection; -import com.dylibso.chicory.wasm.types.SectionId; +import run.endive.wasm.ParserListener; +import run.endive.wasm.types.CustomSection; +import run.endive.wasm.types.SectionId; var parser = new Parser(); diff --git a/wasm/pom.xml b/wasm/pom.xml index 4cc8c5d42..b674ec5df 100644 --- a/wasm/pom.xml +++ b/wasm/pom.xml @@ -3,22 +3,17 @@ 4.0.0 - com.dylibso.chicory - chicory + run.endive + endive 999-SNAPSHOT ../pom.xml wasm jar - Chicory - WASM + Endive - WASM WebAssembly tools - - com.dylibso.chicory - wasm-corpus - test - org.junit.jupiter junit-jupiter-api @@ -29,6 +24,11 @@ junit-jupiter-engine test + + run.endive + wasm-corpus + test + diff --git a/wasm/src/main/java-templates/com/dylibso/chicory/wasm/Version.java b/wasm/src/main/java-templates/run/endive/wasm/Version.java similarity index 77% rename from wasm/src/main/java-templates/com/dylibso/chicory/wasm/Version.java rename to wasm/src/main/java-templates/run/endive/wasm/Version.java index 1cd557919..08305e24a 100644 --- a/wasm/src/main/java-templates/com/dylibso/chicory/wasm/Version.java +++ b/wasm/src/main/java-templates/run/endive/wasm/Version.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; public final class Version { diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/ChicoryException.java b/wasm/src/main/java/com/dylibso/chicory/wasm/ChicoryException.java deleted file mode 100644 index 683df0433..000000000 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/ChicoryException.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.dylibso.chicory.wasm; - -public class ChicoryException extends RuntimeException { - public ChicoryException(String msg) { - super(msg); - } - - public ChicoryException(Throwable cause) { - super(cause); - } - - public ChicoryException(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/wasm/src/main/java/module-info.java b/wasm/src/main/java/module-info.java index 854fbc3bf..9687b3ac5 100644 --- a/wasm/src/main/java/module-info.java +++ b/wasm/src/main/java/module-info.java @@ -1,5 +1,5 @@ -module com.dylibso.chicory.wasm { - exports com.dylibso.chicory.wasm; - exports com.dylibso.chicory.wasm.io; - exports com.dylibso.chicory.wasm.types; +module run.endive.wasm { + exports run.endive.wasm; + exports run.endive.wasm.io; + exports run.endive.wasm.types; } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/ControlTree.java b/wasm/src/main/java/run/endive/wasm/ControlTree.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/ControlTree.java rename to wasm/src/main/java/run/endive/wasm/ControlTree.java index e19941cc6..14ce49158 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/ControlTree.java +++ b/wasm/src/main/java/run/endive/wasm/ControlTree.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.OpCode; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.OpCode; /** * The purpose of this class is to provide a control structure to, in-line, label branches in a list of instructions. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/Encoding.java b/wasm/src/main/java/run/endive/wasm/Encoding.java similarity index 99% rename from wasm/src/main/java/com/dylibso/chicory/wasm/Encoding.java rename to wasm/src/main/java/run/endive/wasm/Encoding.java index a5eb004aa..dc3757020 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/Encoding.java +++ b/wasm/src/main/java/run/endive/wasm/Encoding.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/InvalidException.java b/wasm/src/main/java/run/endive/wasm/InvalidException.java similarity index 59% rename from wasm/src/main/java/com/dylibso/chicory/wasm/InvalidException.java rename to wasm/src/main/java/run/endive/wasm/InvalidException.java index 0b9533f9b..adb3cd2e6 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/InvalidException.java +++ b/wasm/src/main/java/run/endive/wasm/InvalidException.java @@ -1,6 +1,7 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -public class InvalidException extends ChicoryException { +/** Wasm spec: module fails validation (type errors, constraint violations). */ +public class InvalidException extends WasmEngineException { public InvalidException(String msg) { super(msg); } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/MalformedException.java b/wasm/src/main/java/run/endive/wasm/MalformedException.java similarity index 62% rename from wasm/src/main/java/com/dylibso/chicory/wasm/MalformedException.java rename to wasm/src/main/java/run/endive/wasm/MalformedException.java index 040197633..bca915109 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/MalformedException.java +++ b/wasm/src/main/java/run/endive/wasm/MalformedException.java @@ -1,6 +1,7 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -public class MalformedException extends ChicoryException { +/** Wasm spec: binary format is malformed (parsing error). */ +public class MalformedException extends WasmEngineException { public MalformedException(String msg) { super(msg); } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/Parser.java b/wasm/src/main/java/run/endive/wasm/Parser.java similarity index 93% rename from wasm/src/main/java/com/dylibso/chicory/wasm/Parser.java rename to wasm/src/main/java/run/endive/wasm/Parser.java index 5f76500ce..9a71c32ae 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/Parser.java +++ b/wasm/src/main/java/run/endive/wasm/Parser.java @@ -1,73 +1,17 @@ -package com.dylibso.chicory.wasm; - -import static com.dylibso.chicory.wasm.Encoding.readByte; -import static com.dylibso.chicory.wasm.Encoding.readBytes; -import static com.dylibso.chicory.wasm.Encoding.readFloat32; -import static com.dylibso.chicory.wasm.Encoding.readFloat64; -import static com.dylibso.chicory.wasm.Encoding.readName; -import static com.dylibso.chicory.wasm.Encoding.readVarSInt32; -import static com.dylibso.chicory.wasm.Encoding.readVarSInt64; -import static com.dylibso.chicory.wasm.Encoding.readVarUInt32; -import static com.dylibso.chicory.wasm.WasmLimits.MAX_FUNCTION_LOCALS; -import static com.dylibso.chicory.wasm.types.Instruction.EMPTY_OPERANDS; +package run.endive.wasm; + import static java.util.Objects.requireNonNull; +import static run.endive.wasm.Encoding.readByte; +import static run.endive.wasm.Encoding.readBytes; +import static run.endive.wasm.Encoding.readFloat32; +import static run.endive.wasm.Encoding.readFloat64; +import static run.endive.wasm.Encoding.readName; +import static run.endive.wasm.Encoding.readVarSInt32; +import static run.endive.wasm.Encoding.readVarSInt64; +import static run.endive.wasm.Encoding.readVarUInt32; +import static run.endive.wasm.WasmLimits.MAX_FUNCTION_LOCALS; +import static run.endive.wasm.types.Instruction.EMPTY_OPERANDS; -import com.dylibso.chicory.wasm.io.InputStreams; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.ActiveElement; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.ArrayType; -import com.dylibso.chicory.wasm.types.CatchOpCode; -import com.dylibso.chicory.wasm.types.CodeSection; -import com.dylibso.chicory.wasm.types.CompType; -import com.dylibso.chicory.wasm.types.CustomSection; -import com.dylibso.chicory.wasm.types.DataCountSection; -import com.dylibso.chicory.wasm.types.DataSection; -import com.dylibso.chicory.wasm.types.DeclarativeElement; -import com.dylibso.chicory.wasm.types.Element; -import com.dylibso.chicory.wasm.types.ElementSection; -import com.dylibso.chicory.wasm.types.Export; -import com.dylibso.chicory.wasm.types.ExportSection; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FieldType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionImport; -import com.dylibso.chicory.wasm.types.FunctionSection; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Global; -import com.dylibso.chicory.wasm.types.GlobalImport; -import com.dylibso.chicory.wasm.types.GlobalSection; -import com.dylibso.chicory.wasm.types.ImportSection; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.Memory; -import com.dylibso.chicory.wasm.types.MemoryImport; -import com.dylibso.chicory.wasm.types.MemoryLimits; -import com.dylibso.chicory.wasm.types.MemorySection; -import com.dylibso.chicory.wasm.types.MutabilityType; -import com.dylibso.chicory.wasm.types.NameCustomSection; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.PackedType; -import com.dylibso.chicory.wasm.types.PassiveDataSegment; -import com.dylibso.chicory.wasm.types.PassiveElement; -import com.dylibso.chicory.wasm.types.RawSection; -import com.dylibso.chicory.wasm.types.RecType; -import com.dylibso.chicory.wasm.types.Section; -import com.dylibso.chicory.wasm.types.SectionId; -import com.dylibso.chicory.wasm.types.StartSection; -import com.dylibso.chicory.wasm.types.StorageType; -import com.dylibso.chicory.wasm.types.StructType; -import com.dylibso.chicory.wasm.types.SubType; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableImport; -import com.dylibso.chicory.wasm.types.TableLimits; -import com.dylibso.chicory.wasm.types.TableSection; -import com.dylibso.chicory.wasm.types.TagImport; -import com.dylibso.chicory.wasm.types.TagSection; -import com.dylibso.chicory.wasm.types.TagType; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.UnknownCustomSection; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -91,6 +35,62 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; +import run.endive.wasm.io.InputStreams; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.ActiveElement; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.ArrayType; +import run.endive.wasm.types.CatchOpCode; +import run.endive.wasm.types.CodeSection; +import run.endive.wasm.types.CompType; +import run.endive.wasm.types.CustomSection; +import run.endive.wasm.types.DataCountSection; +import run.endive.wasm.types.DataSection; +import run.endive.wasm.types.DeclarativeElement; +import run.endive.wasm.types.Element; +import run.endive.wasm.types.ElementSection; +import run.endive.wasm.types.Export; +import run.endive.wasm.types.ExportSection; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FieldType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionImport; +import run.endive.wasm.types.FunctionSection; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Global; +import run.endive.wasm.types.GlobalImport; +import run.endive.wasm.types.GlobalSection; +import run.endive.wasm.types.ImportSection; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.Memory; +import run.endive.wasm.types.MemoryImport; +import run.endive.wasm.types.MemoryLimits; +import run.endive.wasm.types.MemorySection; +import run.endive.wasm.types.MutabilityType; +import run.endive.wasm.types.NameCustomSection; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.PackedType; +import run.endive.wasm.types.PassiveDataSegment; +import run.endive.wasm.types.PassiveElement; +import run.endive.wasm.types.RawSection; +import run.endive.wasm.types.RecType; +import run.endive.wasm.types.Section; +import run.endive.wasm.types.SectionId; +import run.endive.wasm.types.StartSection; +import run.endive.wasm.types.StorageType; +import run.endive.wasm.types.StructType; +import run.endive.wasm.types.SubType; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableImport; +import run.endive.wasm.types.TableLimits; +import run.endive.wasm.types.TableSection; +import run.endive.wasm.types.TagImport; +import run.endive.wasm.types.TagSection; +import run.endive.wasm.types.TagType; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.UnknownCustomSection; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; /** * Parser for Web Assembly binaries. @@ -98,7 +98,7 @@ @SuppressWarnings("UnnecessaryCodeBlock") public final class Parser { private static final String DIGEST_ALGORITHM = - System.getProperty("com.dylibso.chicory.wasm.Parser.DIGEST_ALGORITHM", "SHA-256"); + System.getProperty("run.endive.wasm.Parser.DIGEST_ALGORITHM", "SHA-256"); static final byte[] MAGIC_BYTES = {0x00, 0x61, 0x73, 0x6D}; // Magic prefix \0asm static final byte[] VERSION_BYTES = {0x01, 0x00, 0x00, 0x00}; // Version 1 @@ -266,7 +266,7 @@ public WasmModule parse(Supplier inputStreamSupplier) { } parse(maybeDigestedInputStream, (s) -> onSection(moduleBuilder, s)); } catch (IOException | NoSuchAlgorithmException e) { - throw new ChicoryException(e); + throw new WasmEngineException(e); } catch (MalformedException e) { throw new MalformedException( "section size mismatch, unexpected end of section or function, " @@ -945,7 +945,7 @@ private static Element parseSingleElement(ByteBuffer buffer, TypeSection typeSec .withTypeIdx(ValType.TypeIdxCode.FUNC.code()) .build(); } else { - throw new ChicoryException("Invalid element kind"); + throw new WasmEngineException("Invalid element kind"); } } else { assert hasRefType; @@ -1244,7 +1244,8 @@ private static DataSection parseDataSection(ByteBuffer buffer) { readBytes(buffer, data); dataSection.addDataSegment(new ActiveDataSegment(memoryId, List.of(offset), data)); } else { - throw new ChicoryException("Failed to parse data segment with data mode: " + mode); + throw new WasmEngineException( + "Failed to parse data segment with data mode: " + mode); } } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/ParserListener.java b/wasm/src/main/java/run/endive/wasm/ParserListener.java similarity index 54% rename from wasm/src/main/java/com/dylibso/chicory/wasm/ParserListener.java rename to wasm/src/main/java/run/endive/wasm/ParserListener.java index cc821f1d7..4f4d8015e 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/ParserListener.java +++ b/wasm/src/main/java/run/endive/wasm/ParserListener.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -import com.dylibso.chicory.wasm.types.Section; +import run.endive.wasm.types.Section; @FunctionalInterface public interface ParserListener { diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/UninstantiableException.java b/wasm/src/main/java/run/endive/wasm/UninstantiableException.java similarity index 60% rename from wasm/src/main/java/com/dylibso/chicory/wasm/UninstantiableException.java rename to wasm/src/main/java/run/endive/wasm/UninstantiableException.java index dc8f1610f..9676916ea 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/UninstantiableException.java +++ b/wasm/src/main/java/run/endive/wasm/UninstantiableException.java @@ -1,6 +1,7 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -public class UninstantiableException extends ChicoryException { +/** Wasm spec: module cannot be instantiated (trap during initialization). */ +public class UninstantiableException extends WasmEngineException { public UninstantiableException(String msg) { super(msg); } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/UnlinkableException.java b/wasm/src/main/java/run/endive/wasm/UnlinkableException.java similarity index 60% rename from wasm/src/main/java/com/dylibso/chicory/wasm/UnlinkableException.java rename to wasm/src/main/java/run/endive/wasm/UnlinkableException.java index 6c17a03e4..17825d9c9 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/UnlinkableException.java +++ b/wasm/src/main/java/run/endive/wasm/UnlinkableException.java @@ -1,6 +1,7 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -public class UnlinkableException extends ChicoryException { +/** Wasm spec: module cannot be linked (import/export type mismatches). */ +public class UnlinkableException extends WasmEngineException { public UnlinkableException(String msg) { super(msg); } diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/Validator.java b/wasm/src/main/java/run/endive/wasm/Validator.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/Validator.java rename to wasm/src/main/java/run/endive/wasm/Validator.java index bd668641e..8b9bed02f 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/Validator.java +++ b/wasm/src/main/java/run/endive/wasm/Validator.java @@ -1,38 +1,10 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.ActiveElement; -import com.dylibso.chicory.wasm.types.AnnotatedInstruction; -import com.dylibso.chicory.wasm.types.ArrayType; -import com.dylibso.chicory.wasm.types.CatchOpCode; -import com.dylibso.chicory.wasm.types.CompType; -import com.dylibso.chicory.wasm.types.Element; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.FieldType; -import com.dylibso.chicory.wasm.types.FunctionBody; -import com.dylibso.chicory.wasm.types.FunctionImport; -import com.dylibso.chicory.wasm.types.FunctionType; -import com.dylibso.chicory.wasm.types.Global; -import com.dylibso.chicory.wasm.types.GlobalImport; -import com.dylibso.chicory.wasm.types.Instruction; -import com.dylibso.chicory.wasm.types.MutabilityType; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.StorageType; -import com.dylibso.chicory.wasm.types.StructType; -import com.dylibso.chicory.wasm.types.SubType; -import com.dylibso.chicory.wasm.types.Table; -import com.dylibso.chicory.wasm.types.TableImport; -import com.dylibso.chicory.wasm.types.TagImport; -import com.dylibso.chicory.wasm.types.TagSection; -import com.dylibso.chicory.wasm.types.TagType; -import com.dylibso.chicory.wasm.types.TypeSection; -import com.dylibso.chicory.wasm.types.ValType; -import com.dylibso.chicory.wasm.types.Value; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -40,6 +12,34 @@ import java.util.Locale; import java.util.Set; import java.util.stream.Stream; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.ActiveElement; +import run.endive.wasm.types.AnnotatedInstruction; +import run.endive.wasm.types.ArrayType; +import run.endive.wasm.types.CatchOpCode; +import run.endive.wasm.types.CompType; +import run.endive.wasm.types.Element; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.FieldType; +import run.endive.wasm.types.FunctionBody; +import run.endive.wasm.types.FunctionImport; +import run.endive.wasm.types.FunctionType; +import run.endive.wasm.types.Global; +import run.endive.wasm.types.GlobalImport; +import run.endive.wasm.types.Instruction; +import run.endive.wasm.types.MutabilityType; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.StorageType; +import run.endive.wasm.types.StructType; +import run.endive.wasm.types.SubType; +import run.endive.wasm.types.Table; +import run.endive.wasm.types.TableImport; +import run.endive.wasm.types.TagImport; +import run.endive.wasm.types.TagSection; +import run.endive.wasm.types.TagType; +import run.endive.wasm.types.TypeSection; +import run.endive.wasm.types.ValType; +import run.endive.wasm.types.Value; // Heavily inspired by wazero // https://github.com/tetratelabs/wazero/blob/5a8a053bff0ae795b264de9672016745cb842070/internal/wasm/func_validation.go diff --git a/wasm/src/main/java/run/endive/wasm/WasmEngineException.java b/wasm/src/main/java/run/endive/wasm/WasmEngineException.java new file mode 100644 index 000000000..25fbbf40e --- /dev/null +++ b/wasm/src/main/java/run/endive/wasm/WasmEngineException.java @@ -0,0 +1,20 @@ +package run.endive.wasm; + +/** + * Base exception for errors raised by the Wasm engine (parsing, validation, linking, + * instantiation, or execution). Distinct from {@code run.endive.runtime.WasmException}, + * which represents Wasm-level tagged exceptions from the exception-handling proposal. + */ +public class WasmEngineException extends RuntimeException { + public WasmEngineException(String msg) { + super(msg); + } + + public WasmEngineException(Throwable cause) { + super(cause); + } + + public WasmEngineException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmLimits.java b/wasm/src/main/java/run/endive/wasm/WasmLimits.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/WasmLimits.java rename to wasm/src/main/java/run/endive/wasm/WasmLimits.java index 7612cb7a6..d4b462ffc 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmLimits.java +++ b/wasm/src/main/java/run/endive/wasm/WasmLimits.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; // Spec: https://webassembly.github.io/spec/core/appendix/implementation.html#syntactic-limits // From: https://github.com/WebKit/webkit/blob/main/Source/JavaScriptCore/wasm/WasmLimits.h diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmModule.java b/wasm/src/main/java/run/endive/wasm/WasmModule.java similarity index 93% rename from wasm/src/main/java/com/dylibso/chicory/wasm/WasmModule.java rename to wasm/src/main/java/run/endive/wasm/WasmModule.java index 7a5863932..36297e224 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmModule.java +++ b/wasm/src/main/java/run/endive/wasm/WasmModule.java @@ -1,28 +1,28 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; import static java.util.Objects.requireNonNull; -import com.dylibso.chicory.wasm.types.CodeSection; -import com.dylibso.chicory.wasm.types.CustomSection; -import com.dylibso.chicory.wasm.types.DataCountSection; -import com.dylibso.chicory.wasm.types.DataSection; -import com.dylibso.chicory.wasm.types.ElementSection; -import com.dylibso.chicory.wasm.types.ExportSection; -import com.dylibso.chicory.wasm.types.FunctionSection; -import com.dylibso.chicory.wasm.types.GlobalSection; -import com.dylibso.chicory.wasm.types.ImportSection; -import com.dylibso.chicory.wasm.types.MemorySection; -import com.dylibso.chicory.wasm.types.NameCustomSection; -import com.dylibso.chicory.wasm.types.StartSection; -import com.dylibso.chicory.wasm.types.TableSection; -import com.dylibso.chicory.wasm.types.TagSection; -import com.dylibso.chicory.wasm.types.TypeSection; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import run.endive.wasm.types.CodeSection; +import run.endive.wasm.types.CustomSection; +import run.endive.wasm.types.DataCountSection; +import run.endive.wasm.types.DataSection; +import run.endive.wasm.types.ElementSection; +import run.endive.wasm.types.ExportSection; +import run.endive.wasm.types.FunctionSection; +import run.endive.wasm.types.GlobalSection; +import run.endive.wasm.types.ImportSection; +import run.endive.wasm.types.MemorySection; +import run.endive.wasm.types.NameCustomSection; +import run.endive.wasm.types.StartSection; +import run.endive.wasm.types.TableSection; +import run.endive.wasm.types.TagSection; +import run.endive.wasm.types.TypeSection; public final class WasmModule { private final Map customSections; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmWriter.java b/wasm/src/main/java/run/endive/wasm/WasmWriter.java similarity index 83% rename from wasm/src/main/java/com/dylibso/chicory/wasm/WasmWriter.java rename to wasm/src/main/java/run/endive/wasm/WasmWriter.java index f2de85384..d8e4c381a 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/WasmWriter.java +++ b/wasm/src/main/java/run/endive/wasm/WasmWriter.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -import static com.dylibso.chicory.wasm.Parser.MAGIC_BYTES; -import static com.dylibso.chicory.wasm.Parser.VERSION_BYTES; import static java.lang.Integer.toUnsignedLong; +import static run.endive.wasm.Parser.MAGIC_BYTES; +import static run.endive.wasm.Parser.VERSION_BYTES; -import com.dylibso.chicory.wasm.types.RawSection; import java.io.ByteArrayOutputStream; +import run.endive.wasm.types.RawSection; public final class WasmWriter { diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/io/InputStreams.java b/wasm/src/main/java/run/endive/wasm/io/InputStreams.java similarity index 95% rename from wasm/src/main/java/com/dylibso/chicory/wasm/io/InputStreams.java rename to wasm/src/main/java/run/endive/wasm/io/InputStreams.java index 91f8a79bb..bb1b41813 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/io/InputStreams.java +++ b/wasm/src/main/java/run/endive/wasm/io/InputStreams.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.io; +package run.endive.wasm.io; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveDataSegment.java b/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveDataSegment.java rename to wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java index 24eb1c468..fbbbd0f8d 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveDataSegment.java +++ b/wasm/src/main/java/run/endive/wasm/types/ActiveDataSegment.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveElement.java b/wasm/src/main/java/run/endive/wasm/types/ActiveElement.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveElement.java rename to wasm/src/main/java/run/endive/wasm/types/ActiveElement.java index 80502d349..3a4cebbcc 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ActiveElement.java +++ b/wasm/src/main/java/run/endive/wasm/types/ActiveElement.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/AnnotatedInstruction.java b/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/AnnotatedInstruction.java rename to wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java index b01e18c4d..20fab3caf 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/AnnotatedInstruction.java +++ b/wasm/src/main/java/run/endive/wasm/types/AnnotatedInstruction.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.InvalidException; import java.util.List; import java.util.Objects; import java.util.Optional; +import run.endive.wasm.InvalidException; /* * An instruction with additional metadata for control flow. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ArrayType.java b/wasm/src/main/java/run/endive/wasm/types/ArrayType.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ArrayType.java rename to wasm/src/main/java/run/endive/wasm/types/ArrayType.java index 46743e534..8356054df 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ArrayType.java +++ b/wasm/src/main/java/run/endive/wasm/types/ArrayType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CatchOpCode.java b/wasm/src/main/java/run/endive/wasm/types/CatchOpCode.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/CatchOpCode.java rename to wasm/src/main/java/run/endive/wasm/types/CatchOpCode.java index 6a0da1296..2a951fd70 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CatchOpCode.java +++ b/wasm/src/main/java/run/endive/wasm/types/CatchOpCode.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CodeSection.java b/wasm/src/main/java/run/endive/wasm/types/CodeSection.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/CodeSection.java rename to wasm/src/main/java/run/endive/wasm/types/CodeSection.java index 5535c3552..38144b55f 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CodeSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/CodeSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CompType.java b/wasm/src/main/java/run/endive/wasm/types/CompType.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/CompType.java rename to wasm/src/main/java/run/endive/wasm/types/CompType.java index d5368fb5b..d75b934a5 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CompType.java +++ b/wasm/src/main/java/run/endive/wasm/types/CompType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CustomSection.java b/wasm/src/main/java/run/endive/wasm/types/CustomSection.java similarity index 83% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/CustomSection.java rename to wasm/src/main/java/run/endive/wasm/types/CustomSection.java index 35c05a389..fdf738c2a 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/CustomSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/CustomSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; /** * A custom section of some kind. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataCountSection.java b/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/DataCountSection.java rename to wasm/src/main/java/run/endive/wasm/types/DataCountSection.java index f975ee8b2..94f33cc86 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataCountSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/DataCountSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public final class DataCountSection extends Section { private final int dataCount; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSection.java b/wasm/src/main/java/run/endive/wasm/types/DataSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSection.java rename to wasm/src/main/java/run/endive/wasm/types/DataSection.java index fb75b3627..d8629453a 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/DataSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSegment.java b/wasm/src/main/java/run/endive/wasm/types/DataSegment.java similarity index 94% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSegment.java rename to wasm/src/main/java/run/endive/wasm/types/DataSegment.java index afd8e3a9b..de911884f 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DataSegment.java +++ b/wasm/src/main/java/run/endive/wasm/types/DataSegment.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Arrays; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DeclarativeElement.java b/wasm/src/main/java/run/endive/wasm/types/DeclarativeElement.java similarity index 93% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/DeclarativeElement.java rename to wasm/src/main/java/run/endive/wasm/types/DeclarativeElement.java index 1210711ff..d586b1859 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/DeclarativeElement.java +++ b/wasm/src/main/java/run/endive/wasm/types/DeclarativeElement.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Element.java b/wasm/src/main/java/run/endive/wasm/types/Element.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Element.java rename to wasm/src/main/java/run/endive/wasm/types/Element.java index 1c8f058db..f744e5c06 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Element.java +++ b/wasm/src/main/java/run/endive/wasm/types/Element.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static java.util.Objects.requireNonNull; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ElementSection.java b/wasm/src/main/java/run/endive/wasm/types/ElementSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ElementSection.java rename to wasm/src/main/java/run/endive/wasm/types/ElementSection.java index 6dc9606a9..29e566ebe 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ElementSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/ElementSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Export.java b/wasm/src/main/java/run/endive/wasm/types/Export.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Export.java rename to wasm/src/main/java/run/endive/wasm/types/Export.java index b625170c0..7eb9b5ef4 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Export.java +++ b/wasm/src/main/java/run/endive/wasm/types/Export.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ExportSection.java b/wasm/src/main/java/run/endive/wasm/types/ExportSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ExportSection.java rename to wasm/src/main/java/run/endive/wasm/types/ExportSection.java index aa9dbaba5..1e237ae5e 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ExportSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/ExportSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ExternalType.java b/wasm/src/main/java/run/endive/wasm/types/ExternalType.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ExternalType.java rename to wasm/src/main/java/run/endive/wasm/types/ExternalType.java index 4fa046b15..072ba097b 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ExternalType.java +++ b/wasm/src/main/java/run/endive/wasm/types/ExternalType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FieldType.java b/wasm/src/main/java/run/endive/wasm/types/FieldType.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/FieldType.java rename to wasm/src/main/java/run/endive/wasm/types/FieldType.java index b8d2ca2be..feafa0392 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FieldType.java +++ b/wasm/src/main/java/run/endive/wasm/types/FieldType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionBody.java b/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionBody.java rename to wasm/src/main/java/run/endive/wasm/types/FunctionBody.java index a40b4cf17..a95ae84fb 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionBody.java +++ b/wasm/src/main/java/run/endive/wasm/types/FunctionBody.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionImport.java b/wasm/src/main/java/run/endive/wasm/types/FunctionImport.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionImport.java rename to wasm/src/main/java/run/endive/wasm/types/FunctionImport.java index e7192f480..2dfc6c678 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionImport.java +++ b/wasm/src/main/java/run/endive/wasm/types/FunctionImport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; /** * An imported function. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionSection.java b/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionSection.java rename to wasm/src/main/java/run/endive/wasm/types/FunctionSection.java index 8544b57b0..f6a0cd424 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/FunctionSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionType.java b/wasm/src/main/java/run/endive/wasm/types/FunctionType.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionType.java rename to wasm/src/main/java/run/endive/wasm/types/FunctionType.java index 450da6ef9..d20296792 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/FunctionType.java +++ b/wasm/src/main/java/run/endive/wasm/types/FunctionType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Global.java b/wasm/src/main/java/run/endive/wasm/types/Global.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Global.java rename to wasm/src/main/java/run/endive/wasm/types/Global.java index 480b7abb0..d431f4a12 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Global.java +++ b/wasm/src/main/java/run/endive/wasm/types/Global.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalImport.java b/wasm/src/main/java/run/endive/wasm/types/GlobalImport.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalImport.java rename to wasm/src/main/java/run/endive/wasm/types/GlobalImport.java index 71a478511..911c7e573 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalImport.java +++ b/wasm/src/main/java/run/endive/wasm/types/GlobalImport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalSection.java b/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalSection.java rename to wasm/src/main/java/run/endive/wasm/types/GlobalSection.java index f36a1a983..dce82b182 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/GlobalSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/GlobalSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Import.java b/wasm/src/main/java/run/endive/wasm/types/Import.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Import.java rename to wasm/src/main/java/run/endive/wasm/types/Import.java index aea3d8981..c1bacae11 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Import.java +++ b/wasm/src/main/java/run/endive/wasm/types/Import.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static java.util.Objects.requireNonNull; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ImportSection.java b/wasm/src/main/java/run/endive/wasm/types/ImportSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ImportSection.java rename to wasm/src/main/java/run/endive/wasm/types/ImportSection.java index ae1ae0281..52a83a291 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ImportSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/ImportSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Instruction.java b/wasm/src/main/java/run/endive/wasm/types/Instruction.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Instruction.java rename to wasm/src/main/java/run/endive/wasm/types/Instruction.java index 60d166042..ab802a3be 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Instruction.java +++ b/wasm/src/main/java/run/endive/wasm/types/Instruction.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Arrays; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Memory.java b/wasm/src/main/java/run/endive/wasm/types/Memory.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Memory.java rename to wasm/src/main/java/run/endive/wasm/types/Memory.java index 48c621083..c06152991 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Memory.java +++ b/wasm/src/main/java/run/endive/wasm/types/Memory.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryImport.java b/wasm/src/main/java/run/endive/wasm/types/MemoryImport.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryImport.java rename to wasm/src/main/java/run/endive/wasm/types/MemoryImport.java index e70106965..81fdb2663 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryImport.java +++ b/wasm/src/main/java/run/endive/wasm/types/MemoryImport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; /** * An imported memory. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryLimits.java b/wasm/src/main/java/run/endive/wasm/types/MemoryLimits.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryLimits.java rename to wasm/src/main/java/run/endive/wasm/types/MemoryLimits.java index b878db93b..b3f7f8411 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemoryLimits.java +++ b/wasm/src/main/java/run/endive/wasm/types/MemoryLimits.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.InvalidException; +import run.endive.wasm.InvalidException; /** * Limits for memory sizes, in pages. diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemorySection.java b/wasm/src/main/java/run/endive/wasm/types/MemorySection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/MemorySection.java rename to wasm/src/main/java/run/endive/wasm/types/MemorySection.java index 8be084520..ebf0c1a6e 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MemorySection.java +++ b/wasm/src/main/java/run/endive/wasm/types/MemorySection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MutabilityType.java b/wasm/src/main/java/run/endive/wasm/types/MutabilityType.java similarity index 90% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/MutabilityType.java rename to wasm/src/main/java/run/endive/wasm/types/MutabilityType.java index 9eb508611..44c13f464 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/MutabilityType.java +++ b/wasm/src/main/java/run/endive/wasm/types/MutabilityType.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.MalformedException; +import run.endive.wasm.MalformedException; /** * The kind of mutability diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/NameCustomSection.java b/wasm/src/main/java/run/endive/wasm/types/NameCustomSection.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/NameCustomSection.java rename to wasm/src/main/java/run/endive/wasm/types/NameCustomSection.java index e10c0e649..582116cd7 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/NameCustomSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/NameCustomSection.java @@ -1,8 +1,8 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import static com.dylibso.chicory.wasm.Encoding.readName; -import static com.dylibso.chicory.wasm.Encoding.readVarUInt32; import static java.util.Objects.requireNonNull; +import static run.endive.wasm.Encoding.readName; +import static run.endive.wasm.Encoding.readVarUInt32; import java.nio.ByteBuffer; import java.util.ArrayList; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/OpCode.java b/wasm/src/main/java/run/endive/wasm/types/OpCode.java similarity index 95% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/OpCode.java rename to wasm/src/main/java/run/endive/wasm/types/OpCode.java index eabe68409..70e177b3a 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/OpCode.java +++ b/wasm/src/main/java/run/endive/wasm/types/OpCode.java @@ -1,17 +1,17 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import static com.dylibso.chicory.wasm.types.WasmEncoding.BLOCK_TYPE; -import static com.dylibso.chicory.wasm.types.WasmEncoding.BYTE; -import static com.dylibso.chicory.wasm.types.WasmEncoding.FLOAT32; -import static com.dylibso.chicory.wasm.types.WasmEncoding.FLOAT64; -import static com.dylibso.chicory.wasm.types.WasmEncoding.MEMARG; -import static com.dylibso.chicory.wasm.types.WasmEncoding.V128; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VARSINT32; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VARSINT64; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VARUINT; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VEC_CATCH; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VEC_VALUE_TYPE; -import static com.dylibso.chicory.wasm.types.WasmEncoding.VEC_VARUINT; +import static run.endive.wasm.types.WasmEncoding.BLOCK_TYPE; +import static run.endive.wasm.types.WasmEncoding.BYTE; +import static run.endive.wasm.types.WasmEncoding.FLOAT32; +import static run.endive.wasm.types.WasmEncoding.FLOAT64; +import static run.endive.wasm.types.WasmEncoding.MEMARG; +import static run.endive.wasm.types.WasmEncoding.V128; +import static run.endive.wasm.types.WasmEncoding.VARSINT32; +import static run.endive.wasm.types.WasmEncoding.VARSINT64; +import static run.endive.wasm.types.WasmEncoding.VARUINT; +import static run.endive.wasm.types.WasmEncoding.VEC_CATCH; +import static run.endive.wasm.types.WasmEncoding.VEC_VALUE_TYPE; +import static run.endive.wasm.types.WasmEncoding.VEC_VARUINT; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PackedType.java b/wasm/src/main/java/run/endive/wasm/types/PackedType.java similarity index 91% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/PackedType.java rename to wasm/src/main/java/run/endive/wasm/types/PackedType.java index 38fabbe47..c5bca9421 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PackedType.java +++ b/wasm/src/main/java/run/endive/wasm/types/PackedType.java @@ -1,6 +1,6 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.MalformedException; +import run.endive.wasm.MalformedException; public enum PackedType { I8(0x78), diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveDataSegment.java b/wasm/src/main/java/run/endive/wasm/types/PassiveDataSegment.java similarity index 84% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveDataSegment.java rename to wasm/src/main/java/run/endive/wasm/types/PassiveDataSegment.java index 2949fb516..7746881da 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveDataSegment.java +++ b/wasm/src/main/java/run/endive/wasm/types/PassiveDataSegment.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public final class PassiveDataSegment extends DataSegment { public static final PassiveDataSegment EMPTY = new PassiveDataSegment(new byte[] {}); diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveElement.java b/wasm/src/main/java/run/endive/wasm/types/PassiveElement.java similarity index 93% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveElement.java rename to wasm/src/main/java/run/endive/wasm/types/PassiveElement.java index 1b5957307..f86246771 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/PassiveElement.java +++ b/wasm/src/main/java/run/endive/wasm/types/PassiveElement.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/RawSection.java b/wasm/src/main/java/run/endive/wasm/types/RawSection.java similarity index 87% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/RawSection.java rename to wasm/src/main/java/run/endive/wasm/types/RawSection.java index f57748c6a..5105fd6d4 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/RawSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/RawSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public class RawSection extends Section { private final byte[] contents; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/RecType.java b/wasm/src/main/java/run/endive/wasm/types/RecType.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/RecType.java rename to wasm/src/main/java/run/endive/wasm/types/RecType.java index 57bdff2b1..05b82430b 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/RecType.java +++ b/wasm/src/main/java/run/endive/wasm/types/RecType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Arrays; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Section.java b/wasm/src/main/java/run/endive/wasm/types/Section.java similarity index 81% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Section.java rename to wasm/src/main/java/run/endive/wasm/types/Section.java index b09c6ce19..c61b1df51 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Section.java +++ b/wasm/src/main/java/run/endive/wasm/types/Section.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public abstract class Section { private final int id; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/SectionId.java b/wasm/src/main/java/run/endive/wasm/types/SectionId.java similarity index 93% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/SectionId.java rename to wasm/src/main/java/run/endive/wasm/types/SectionId.java index e4e145c2b..0fa721571 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/SectionId.java +++ b/wasm/src/main/java/run/endive/wasm/types/SectionId.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public final class SectionId { public static final int CUSTOM = 0; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StartSection.java b/wasm/src/main/java/run/endive/wasm/types/StartSection.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/StartSection.java rename to wasm/src/main/java/run/endive/wasm/types/StartSection.java index cc03dc53e..1e5551885 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StartSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/StartSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public final class StartSection extends Section { private final long startIndex; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StorageType.java b/wasm/src/main/java/run/endive/wasm/types/StorageType.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/StorageType.java rename to wasm/src/main/java/run/endive/wasm/types/StorageType.java index e02c0089c..c869c1aa7 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StorageType.java +++ b/wasm/src/main/java/run/endive/wasm/types/StorageType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StructType.java b/wasm/src/main/java/run/endive/wasm/types/StructType.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/StructType.java rename to wasm/src/main/java/run/endive/wasm/types/StructType.java index 4a12bbd94..6754b548c 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/StructType.java +++ b/wasm/src/main/java/run/endive/wasm/types/StructType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.Arrays; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/SubType.java b/wasm/src/main/java/run/endive/wasm/types/SubType.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/SubType.java rename to wasm/src/main/java/run/endive/wasm/types/SubType.java index fa2a5703f..5e40fc982 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/SubType.java +++ b/wasm/src/main/java/run/endive/wasm/types/SubType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Arrays; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Table.java b/wasm/src/main/java/run/endive/wasm/types/Table.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Table.java rename to wasm/src/main/java/run/endive/wasm/types/Table.java index 6627f6089..8be8bda1d 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Table.java +++ b/wasm/src/main/java/run/endive/wasm/types/Table.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.List; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableImport.java b/wasm/src/main/java/run/endive/wasm/types/TableImport.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TableImport.java rename to wasm/src/main/java/run/endive/wasm/types/TableImport.java index e38bf3f65..f785fa368 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableImport.java +++ b/wasm/src/main/java/run/endive/wasm/types/TableImport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableLimits.java b/wasm/src/main/java/run/endive/wasm/types/TableLimits.java similarity index 91% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TableLimits.java rename to wasm/src/main/java/run/endive/wasm/types/TableLimits.java index 573769407..2303123b9 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableLimits.java +++ b/wasm/src/main/java/run/endive/wasm/types/TableLimits.java @@ -1,8 +1,8 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import static com.dylibso.chicory.wasm.WasmLimits.MAX_TABLE_ENTRIES; +import static run.endive.wasm.WasmLimits.MAX_TABLE_ENTRIES; -import com.dylibso.chicory.wasm.InvalidException; +import run.endive.wasm.InvalidException; public class TableLimits { public static final long LIMIT_MAX = MAX_TABLE_ENTRIES; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableSection.java b/wasm/src/main/java/run/endive/wasm/types/TableSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TableSection.java rename to wasm/src/main/java/run/endive/wasm/types/TableSection.java index 7f1c9a19b..7aee063a0 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TableSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/TableSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagImport.java b/wasm/src/main/java/run/endive/wasm/types/TagImport.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TagImport.java rename to wasm/src/main/java/run/endive/wasm/types/TagImport.java index 3748fc968..b941f7e45 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagImport.java +++ b/wasm/src/main/java/run/endive/wasm/types/TagImport.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.Objects; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagSection.java b/wasm/src/main/java/run/endive/wasm/types/TagSection.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TagSection.java rename to wasm/src/main/java/run/endive/wasm/types/TagSection.java index 7faccab8e..0d18b80c7 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/TagSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import java.util.ArrayList; import java.util.List; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagType.java b/wasm/src/main/java/run/endive/wasm/types/TagType.java similarity index 89% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TagType.java rename to wasm/src/main/java/run/endive/wasm/types/TagType.java index e8e435559..c5eb8ca7b 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TagType.java +++ b/wasm/src/main/java/run/endive/wasm/types/TagType.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public class TagType { private final byte attribute; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TypeSection.java b/wasm/src/main/java/run/endive/wasm/types/TypeSection.java similarity index 99% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/TypeSection.java rename to wasm/src/main/java/run/endive/wasm/types/TypeSection.java index 07bbe0c33..85557281c 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/TypeSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/TypeSection.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.InvalidException; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import run.endive.wasm.InvalidException; public final class TypeSection extends Section { private final List types; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/UnknownCustomSection.java b/wasm/src/main/java/run/endive/wasm/types/UnknownCustomSection.java similarity index 96% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/UnknownCustomSection.java rename to wasm/src/main/java/run/endive/wasm/types/UnknownCustomSection.java index 5a41e8b48..a27ea1396 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/UnknownCustomSection.java +++ b/wasm/src/main/java/run/endive/wasm/types/UnknownCustomSection.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static java.util.Objects.requireNonNull; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ValType.java b/wasm/src/main/java/run/endive/wasm/types/ValType.java similarity index 98% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ValType.java rename to wasm/src/main/java/run/endive/wasm/types/ValType.java index 7b75fe0b5..189de8df6 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ValType.java +++ b/wasm/src/main/java/run/endive/wasm/types/ValType.java @@ -1,9 +1,9 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.ChicoryException; -import com.dylibso.chicory.wasm.InvalidException; import java.util.List; import java.util.function.Function; +import run.endive.wasm.InvalidException; +import run.endive.wasm.WasmEngineException; /** * The possible WASM value types. @@ -675,7 +675,7 @@ public boolean isReference() { @Deprecated(since = "use .build.resolve(typeSection) instead") public ValType build(Function context) { if (!isValidOpcode(opcode)) { - throw new ChicoryException("Invalid type opcode: " + opcode); + throw new WasmEngineException("Invalid type opcode: " + opcode); } var resolvedFunctionType = substitute(opcode, typeIdx, context); @@ -694,7 +694,7 @@ public ValType build(Function context) { public ValType build() { if (!isValidOpcode(opcode)) { - throw new ChicoryException("Invalid type opcode: " + opcode); + throw new WasmEngineException("Invalid type opcode: " + opcode); } return new ValType( diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Value.java b/wasm/src/main/java/run/endive/wasm/types/Value.java similarity index 99% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/Value.java rename to wasm/src/main/java/run/endive/wasm/types/Value.java index 54201eca3..84771e6f7 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/Value.java +++ b/wasm/src/main/java/run/endive/wasm/types/Value.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static java.util.Objects.requireNonNull; diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ValueType.java b/wasm/src/main/java/run/endive/wasm/types/ValueType.java similarity index 97% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/ValueType.java rename to wasm/src/main/java/run/endive/wasm/types/ValueType.java index f24d853db..7cd43faa9 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/ValueType.java +++ b/wasm/src/main/java/run/endive/wasm/types/ValueType.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import com.dylibso.chicory.wasm.MalformedException; import java.util.List; +import run.endive.wasm.MalformedException; /** - * @deprecated use {@link com.dylibso.chicory.wasm.types.ValType} + * @deprecated use {@link run.endive.wasm.types.ValType} */ @Deprecated(since = "1.3.0") public enum ValueType { diff --git a/wasm/src/main/java/com/dylibso/chicory/wasm/types/WasmEncoding.java b/wasm/src/main/java/run/endive/wasm/types/WasmEncoding.java similarity index 83% rename from wasm/src/main/java/com/dylibso/chicory/wasm/types/WasmEncoding.java rename to wasm/src/main/java/run/endive/wasm/types/WasmEncoding.java index 47041b90b..eab428653 100644 --- a/wasm/src/main/java/com/dylibso/chicory/wasm/types/WasmEncoding.java +++ b/wasm/src/main/java/run/endive/wasm/types/WasmEncoding.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; public enum WasmEncoding { VARUINT, diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/ParserTest.java b/wasm/src/test/java/run/endive/wasm/ParserTest.java similarity index 96% rename from wasm/src/test/java/com/dylibso/chicory/wasm/ParserTest.java rename to wasm/src/test/java/run/endive/wasm/ParserTest.java index 0646239c6..2b74dba3d 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/ParserTest.java +++ b/wasm/src/test/java/run/endive/wasm/ParserTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.assertArrayEquals; @@ -7,13 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.wasm.types.ActiveDataSegment; -import com.dylibso.chicory.wasm.types.CustomSection; -import com.dylibso.chicory.wasm.types.ExternalType; -import com.dylibso.chicory.wasm.types.OpCode; -import com.dylibso.chicory.wasm.types.SectionId; -import com.dylibso.chicory.wasm.types.ValType; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -25,6 +18,13 @@ import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; +import run.endive.corpus.CorpusResources; +import run.endive.wasm.types.ActiveDataSegment; +import run.endive.wasm.types.CustomSection; +import run.endive.wasm.types.ExternalType; +import run.endive.wasm.types.OpCode; +import run.endive.wasm.types.SectionId; +import run.endive.wasm.types.ValType; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class ParserTest { diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/WasmModuleTest.java b/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java similarity index 90% rename from wasm/src/test/java/com/dylibso/chicory/wasm/WasmModuleTest.java rename to wasm/src/test/java/run/endive/wasm/WasmModuleTest.java index 7146eb4a6..e59fc6ee1 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/WasmModuleTest.java +++ b/wasm/src/test/java/run/endive/wasm/WasmModuleTest.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.dylibso.chicory.corpus.CorpusResources; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; public class WasmModuleTest { diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/WasmWriterTest.java b/wasm/src/test/java/run/endive/wasm/WasmWriterTest.java similarity index 77% rename from wasm/src/test/java/com/dylibso/chicory/wasm/WasmWriterTest.java rename to wasm/src/test/java/run/endive/wasm/WasmWriterTest.java index d594f45ff..eb7459232 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/WasmWriterTest.java +++ b/wasm/src/test/java/run/endive/wasm/WasmWriterTest.java @@ -1,13 +1,13 @@ -package com.dylibso.chicory.wasm; +package run.endive.wasm; -import static com.dylibso.chicory.wasm.Parser.parseWithoutDecoding; -import static com.dylibso.chicory.wasm.ParserTest.wasmCorpusFiles; import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static run.endive.wasm.Parser.parseWithoutDecoding; +import static run.endive.wasm.ParserTest.wasmCorpusFiles; -import com.dylibso.chicory.wasm.types.RawSection; import java.io.IOException; import java.nio.file.Files; import org.junit.jupiter.api.Test; +import run.endive.wasm.types.RawSection; public class WasmWriterTest { diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/types/FunctionTypeTest.java b/wasm/src/test/java/run/endive/wasm/types/FunctionTypeTest.java similarity index 68% rename from wasm/src/test/java/com/dylibso/chicory/wasm/types/FunctionTypeTest.java rename to wasm/src/test/java/run/endive/wasm/types/FunctionTypeTest.java index ddf901a48..956236d1c 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/types/FunctionTypeTest.java +++ b/wasm/src/test/java/run/endive/wasm/types/FunctionTypeTest.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; -import static com.dylibso.chicory.wasm.types.ValType.F32; -import static com.dylibso.chicory.wasm.types.ValType.I32; -import static com.dylibso.chicory.wasm.types.ValType.I64; -import static com.dylibso.chicory.wasm.types.ValType.V128; import static org.junit.jupiter.api.Assertions.assertEquals; +import static run.endive.wasm.types.ValType.F32; +import static run.endive.wasm.types.ValType.I32; +import static run.endive.wasm.types.ValType.I64; +import static run.endive.wasm.types.ValType.V128; import java.util.List; import org.junit.jupiter.api.Test; diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/types/MemoryLimitsTest.java b/wasm/src/test/java/run/endive/wasm/types/MemoryLimitsTest.java similarity index 91% rename from wasm/src/test/java/com/dylibso/chicory/wasm/types/MemoryLimitsTest.java rename to wasm/src/test/java/run/endive/wasm/types/MemoryLimitsTest.java index c0619b225..73f9a7c8f 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/types/MemoryLimitsTest.java +++ b/wasm/src/test/java/run/endive/wasm/types/MemoryLimitsTest.java @@ -1,11 +1,11 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.dylibso.chicory.wasm.InvalidException; import org.junit.jupiter.api.Test; +import run.endive.wasm.InvalidException; class MemoryLimitsTest { diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/types/ValTypeTest.java b/wasm/src/test/java/run/endive/wasm/types/ValTypeTest.java similarity index 92% rename from wasm/src/test/java/com/dylibso/chicory/wasm/types/ValTypeTest.java rename to wasm/src/test/java/run/endive/wasm/types/ValTypeTest.java index 1f9ea92c1..080e10519 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/types/ValTypeTest.java +++ b/wasm/src/test/java/run/endive/wasm/types/ValTypeTest.java @@ -1,10 +1,10 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static org.junit.jupiter.api.Assertions.assertEquals; -import com.dylibso.chicory.corpus.CorpusResources; -import com.dylibso.chicory.wasm.Parser; import org.junit.jupiter.api.Test; +import run.endive.corpus.CorpusResources; +import run.endive.wasm.Parser; public class ValTypeTest { diff --git a/wasm/src/test/java/com/dylibso/chicory/wasm/types/ValueTest.java b/wasm/src/test/java/run/endive/wasm/types/ValueTest.java similarity index 99% rename from wasm/src/test/java/com/dylibso/chicory/wasm/types/ValueTest.java rename to wasm/src/test/java/run/endive/wasm/types/ValueTest.java index 9f3756d7b..1c35b53b2 100644 --- a/wasm/src/test/java/com/dylibso/chicory/wasm/types/ValueTest.java +++ b/wasm/src/test/java/run/endive/wasm/types/ValueTest.java @@ -1,4 +1,4 @@ -package com.dylibso.chicory.wasm.types; +package run.endive.wasm.types; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals;