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

[WIP] Refactoring RefLayout #198

Merged
merged 7 commits into from
Sep 19, 2023
Merged

[WIP] Refactoring RefLayout #198

merged 7 commits into from
Sep 19, 2023

Conversation

btwj
Copy link
Contributor

@btwj btwj commented Sep 4, 2023

The RefLayout{Get/Set}Field opcodes (and their repeated counterparts) would read/write one byte at a time.
This PR introduces two new Opcodes that are created during normalization:

  • ByteArrayGetField[offset: int]<T>(arr: Array<byte>, i_offset: int) -> T
  • ByteArraySetField[offset: int]<T>(arr: Array<byte>, i_offset: int, value: T) -> void

All RefLayout reads/writes (including those for repeated fields) are normalized into this form.

When lowering to machine code, we decompose these loads/stores into power-of-two loads/stores (e.g. a u56, with 7 bytes, will be decomposed into loads of 4+2+1 bytes).

Todo:

  • Since there is no intermediate lowering for JVM code generation, add a normalizer flag to perform byte-by-byte loads/stores (same as the old behavior) specially for the JVM target.

aeneas/src/ir/SsaNormalizer.v3 Show resolved Hide resolved
aeneas/src/ir/SsaNormalizer.v3 Show resolved Hide resolved

var loads = Array<SsaInstr>.new(tn.size);

for (i < loads.length) {
Copy link
Owner

Choose a reason for hiding this comment

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

As discussed, I think you only need to worry about handling partial reads for the last tn.sub[i]. You can over-read for a field that is not too close to the end of a struct. We can do that optimization later and control it with a Fact set on the instruction.

rt/jvm/Makefile Outdated Show resolved Hide resolved
Copy link
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

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

lgtm other than small comments

aeneas/src/core/Eval.v3 Show resolved Hide resolved
aeneas/src/mach/MachLowering.v3 Outdated Show resolved Hide resolved
rt/jvm/src/V3S_System.java Outdated Show resolved Hide resolved
@titzer titzer marked this pull request as ready for review September 19, 2023 14:17
@titzer titzer merged commit 7a9af29 into titzer:master Sep 19, 2023
7 checks passed
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