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

Fix label docs (and a couple of misc bits) #92

Closed
wants to merge 7 commits into from

Conversation

vext01
Copy link
Contributor

@vext01 vext01 commented Mar 25, 2024

Main work is in 8d5f2f2, as discussed in #91.

I was unable to check the rendered output of my non-sourcefile doc changes (e.g. language ref), as I don't know how to generate the html :)

vext01 added 3 commits March 25, 2024 14:52
```
$ cargo doc
error: document output filename collision
The bin `aarch64` in package `hello-world v0.1.0 (/home/vext01/source/dynasm-rs/doc/examples/hello-world)` has the same name as the bin `aarch64` in package `bf-jit v0.1.0 (/home/vext01/source/dynasm-rs/doc/examples/bf-jit)`.
Only one may be documented at once since they output to the same path.
Consider documenting only one, renaming one, or marking one with `doc = false` in Cargo.toml.
```
Recently Rust starting warning about redundant imports, e.g.:
```
warning: the item `Extend` is imported redundantly
   --> runtime/src/lib.rs:39:5
    |
39  | use std::iter::Extend;
    |     ^^^^^^^^^^^^^^^^^
```

This change removes all such imports.
Dynamic | dynamic | `=>expr` | `=>expr`
Extern | dynamic | `-` | `extern expr`

Static label kinds ("Local" and "Global") have their addresses resolved at the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this true?

Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't seem correct. All label types are resolved at commit time. Extern is also not a dynamic label, it's something completely different (it is literally just targetting a given address).

The difference between static and dynamic labels is that the identifier (name) is fixed at rustc compile time for static labels, while you can create new identifiers (basically just an incrementing integer) at runtime for dynamic labels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must admit, there was a fair amount of guesswork going on here. I don't actually know how dynasm works under the hood!

What I'd like the docs to be able to tell me is which kinds of label can be looked up with LabelRegistry::resolve_static() and what kinds can be looked up with LabelRegistry::resolve_dynamic().

I assume that local and global are for resolve_static(), and that dynamic is (guess what?) resolve_dynamic(). But what about extern?

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for the delay, life has a way.

Anyway, extern doesn't need a lookup. if you assemble jmp extern 0x1234 it'll literally insert a jump to 0x1234. This is mostly relevant to x86, as the default jump in x86 can access the entire address space, always. However, that jump is relative, so we need to know about it for when the buffer gets moved around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a544dea addresses the above comments.

@vext01 vext01 mentioned this pull request Mar 25, 2024
@vext01
Copy link
Contributor Author

vext01 commented Mar 25, 2024

I've pushed a few more commits.

I'll wait for you response about the label types before attempting to fix that.

I also notice that on nightly rust, cargo doc gives warnings like:

warning: field `span` is never read                                                                                                                                                                                                           
   --> plugin/src/arch/x64/ast.rs:337:9                                                                                                                                                                                                       
    |                                                                                                                                                                                                                                         
336 |     Indirect {                                                                                                                                                                                                                          
    |     -------- field in this variant                                                                                                                                                                                                      
337 |         span: Span,                                                                                                                                                                                                                     
    |         ^^^^                                                                                                                                                                                                                            
    |
    = note: `#[warn(dead_code)]` on by default

warning: field `span` is never read
   --> plugin/src/arch/x64/ast.rs:345:9
    |
344 |     Direct {
    |     ------ field in this variant
345 |         span: Span,
    |         ^^^^
...

But removing them also isn't correct. I'm not sure about this...

@CensoredUsername
Copy link
Owner

I'll likely look over this in the weekend. in the meantime, you should be able to generate the docs by running ./build_docs.sh

@vext01
Copy link
Contributor Author

vext01 commented Apr 2, 2024

Let me know and I can push changes to fix whatever I've misunderstood.

@CensoredUsername
Copy link
Owner

Poke ;) could you fix the errors in the label documentation I mentioned?

@vext01
Copy link
Contributor Author

vext01 commented May 15, 2024

My apologies. I missed your message. I'll try to get to this soon.

@vext01
Copy link
Contributor Author

vext01 commented Jul 26, 2024

@CensoredUsername were those changes any good?

@CensoredUsername
Copy link
Owner

Heya, sorry for the late reply. I want to merge this somewhere next week, it looks good 👍

@CensoredUsername
Copy link
Owner

I did some cleanup, and it's all merged into dev now. thanks! And apologies for the delay.

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