Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example use of VIXL #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Example use of VIXL #5

wants to merge 3 commits into from

Conversation

a74nh
Copy link
Owner

@a74nh a74nh commented Oct 4, 2023

This PR provides an example of how VIXL could be used within coreclr.

VIXL is a Simulator, Assembler and Disassembler for Aarch64 and AArch64.

It is used by the following projects:

  • The V8 javascript project, using a slightly modified copy of the source code.
  • The Android Runtime (ART), using a prebuilt VIXL library.
  • Mozilla, using a increasingly modified copy of the source code.

It has a detailed test suite and bug fixes / requests from the above projects have fed back into VIXL.

Writing Assemblers and Dissemblers requires a lot of work and are subject to subtle bugs. VIXL was specifically written to help development across open source projects.

In coreclr there is already a fully working assembler for Arm64 core instructions plus NEON. There is currently no assembler for SVE. AIUI, there is no proper disassembler within coreclr (ie one that can print the instructions at any arbitrary address).

The initial PR is split into three commits:

  • The first is a bulk import of the AArch64 Assembler and Disassembler from VIXL. There are no code changes to the code being copied.

  • The second adds VIXL into the build and all the changes required for VIXL to compile. This requires various changes due to standard C++ libraries not being available. Some code remains commented out, some addition support has been added to the coreclr headers. This code is a little hacky.

  • The third adds some example usage of VIXL:
    -- Add an assembler and disassmbler to the codegen object.
    -- Use VIXL for codgen of shift nodes (this was randomly chosen).
    -- At the end of codegen, disassemble the vixl buffer to the jit dump.

This appears to mostly work, but there is a memory corruption issue. When stepped through via a debugger, the shifts are correctly printed to the dump. Without a debugger, the thread vanishes before printing. I suspect an issue in my hacks.

Going forwards there are a number of ways this could be used. One solution would be to modify the VIXL code to use the same buffers as the Emit class. All SVE code would generate via VIXL. Then VIXL would be used to print the codegen buffer to the jit dump.

A more extreme version would be to just take the lowest level functions that emit the binary code, and modify them to look like the existing emit functions. Going in the other direction, the coreclr emit class could be replaced with the VIXL class.

a74nh added 3 commits October 4, 2023 12:24
No changes to any of the files. Not added to the build.

TEST_IMG: ubuntu/dotnet-build
TEST_CMD: safe ./projects/dotnet/build-runtime.sh

Change-Id: I80174799bb833c0edd517bfb9e7b57dd114f0ab7
Jira: ENTLLT-6871
TEST_IMG: ubuntu/dotnet-build
TEST_CMD: safe ./projects/dotnet/build-runtime.sh

Jira: ENTLLT-6871
Change-Id: Ic5445f3378ac9d3fa4e79d4ae1649504819d27e2
TEST_IMG: ubuntu/dotnet-build
TEST_CMD: safe ./projects/dotnet/build-runtime.sh

Jira: ENTLLT-6871
Change-Id: Ifa04a618ccb50ee906eb10dead9dd4fbe4a3b736
@a74nh a74nh changed the title Vixl Example use of VIXL Oct 4, 2023
a74nh pushed a commit that referenced this pull request Sep 9, 2024
* bug #1: don't allow for values out of the SerializationRecordType enum range

* bug #2: throw SerializationException rather than KeyNotFoundException when the referenced record is missing or it points to a record of different type

* bug #3: throw SerializationException rather than FormatException when it's being thrown by BinaryReader (or sth else that we use)

* bug #4: document the fact that IOException can be thrown

* bug #5: throw SerializationException rather than OverflowException when parsing the decimal fails

* bug #6: 0 and 17 are illegal values for PrimitiveType enum

* bug #7: throw SerializationException when a surrogate character is read (so far an ArgumentException was thrown)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant