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

Refactor SLJIT's documentation #292

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Conversation

ningvin
Copy link
Contributor

@ningvin ningvin commented Jan 18, 2025

This is the first part of the changes discussed in #285. This PR pretty much only covers refactoring the existing stuff for now.

An overview of the changes:

  • Renamed doc folder to docs, which I though was more canonical. Can be easily changed back to doc though if you want to keep it.
  • Collected the information currently found in the README, doc/overview.txt and the website and compiled it into markdown files in docs.
  • Added a website generator based on Docusarus into docs/website. The generator will use the markdown files in docs. You can preview the website by following the instructions in docs/website/README.md.

Still to do:

  • Finish converting the tutorial to markdown.
  • Look into GitHub workflows to automatically deploy the website (if desired)
  • Some cleanup

Open questions:

  • Some of the PCRE related stuff, especially concerning PCRE 1, seems a bit outdated at this point. I converted the PCRE 2 related things to markdown and skipped PCRE 1 for now.
  • The sources for the regex performance comparison are currently provided as an archive. I kept it that way, though it would also be possible to just have the plain source files in the repo and link to them.
  • What is the canonical spelling? SLJIT or sljit?

Copy link
Owner

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. The change is very large, and it is hard to track what is changed in the reworked files. Is it worth to split it into a few smaller PRs?

Do we need to add docs/website/package-lock.json ? Looks very big.


## 🚀 Quickstart

Copy the `sljit_src` directory into your project's source directory and include [`sljitLir.h`](./sljit_src/sljitLir.h):
Copy link
Owner

Choose a reason for hiding this comment

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

I would not add code examples to readme. A comment could be added to a file which contains a basic example.


---

## 👉 Purpose
Copy link
Owner

Choose a reason for hiding this comment

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

I usually don't prefer the colorful characters. Please remove them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I forgot to ask about them. I was already pretty sure that the clean look without emojis would be preferred :-D

The CPU has:
- integer registers, which can store either an `int32_t` (4 byte) or `intptr_t` (4 or 8 byte) value
- floating point registers, which can store either a single (4 byte) or double (8 byte) precision value
- boolean status flags
Copy link
Owner

Choose a reason for hiding this comment

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

Some cpus have vector registers as well. On others vector registers also contain the floating point values.

@@ -0,0 +1,8 @@
{
Copy link
Owner

Choose a reason for hiding this comment

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

Is this file used by some generator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is used by Docusaurus to add some metadata to a category / subfolder in the documentation, see here.

| `MIPS` | ✅[^3] | ✅[^3] |

[^1]: only on certain platforms
[^2]: ARM-v5, ARM-v7 and Thumb2 instruction sets
Copy link
Owner

Choose a reason for hiding this comment

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

ARM-v6 now is the minimum. ARM-v5 is 25 years old, and probably not used by high performance use cases anymore.


# Bytecode Interpreters

SLJIT's approach is very effective for bytecode interpreters, since their machine-independent bytecode (middle-level representation) typically contains instructions which either can be easly translated to machine code, or which are not worth to translate to machine code in the first place.
Copy link
Owner

Choose a reason for hiding this comment

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

When I wrote that part, I just added some words, but never be happy about it. If you have a better idea about explaining this, it could be better. Or perhaps we could delete the whole thing.


SLJIT tries to strike a good balance between performance and maintainability.
The LIR code can be compiled to many CPU architectures, and the performance of the generated code is very close to code written in native assembly languages.
Although SLJIT does not support higher level features such as automatic register allocation, it can be a code generation backend for other JIT compiler libraries.
Copy link
Owner

Choose a reason for hiding this comment

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

We could mention that there are simple register allocation algorithms, such as linear scan, which is not difficult to implement.

@ningvin
Copy link
Contributor Author

ningvin commented Jan 21, 2025

The change is very large, and it is hard to track what is changed in the reworked files. Is it worth to split it into a few smaller PRs?

For me it would be easier to let this fly under a single PR, though if multiple PRs are easier for you to review that would be fine as well. Alternatively, I could rework the commit history of the branch to consist of fewer but more concise commits.

Do we need to add docs/website/package-lock.json ? Looks very big.

According to the official npm documentation, it is best practice to commit package-lock.json to version control. This file would only change when the website generator is updated.

@zherczeg
Copy link
Owner

I think the doc -> docs renaming could go as one PR, should be easy to review. Another for the documentation updates, and another for the generator. Usually it is easier to discuss things in separate PRs.

@ningvin
Copy link
Contributor Author

ningvin commented Jan 22, 2025

I think the doc -> docs renaming could go as one PR, should be easy to review. Another for the documentation updates, and another for the generator. Usually it is easier to discuss things in separate PRs.

Yes you are absolutely right. For some reason I assumed you wanted very fine granular PRs...

I will split up the PR in the next couple of days.

@ningvin ningvin mentioned this pull request Jan 26, 2025
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.

2 participants