Skip to content

Conversation

@titzer
Copy link
Contributor

@titzer titzer commented Dec 2, 2025

This PR is just to get the ball rolling by adding a page type to a memory type.

@titzer titzer changed the title Add page type to IR of memory types [interpreter] Add page type to IR of memory types Dec 2, 2025
Copy link
Collaborator

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

LGTM, although I am definitely not an ocaml programmer.

@rossberg do you want to lend another pair of eyes to this?

@titzer
Copy link
Contributor Author

titzer commented Dec 2, 2025

LGTM, although I am definitely not an ocaml programmer.

I'm winging it--trad coding, if you can believe it!

Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

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

LGTM mostly, but why did you not order the arguments of MemoryT consistently with TableT and with the text format, i.e., put the page type last?

@titzer
Copy link
Contributor Author

titzer commented Dec 2, 2025

LGTM mostly, but why did you not order the arguments of MemoryT consistently with TableT and with the text format, i.e., put the page type last?

Done.

let GlobalT (_mut, t) = gt in
check_valtype c t at

let check_memorytype (c : context) (mt : memorytype) at =
Copy link
Member

Choose a reason for hiding this comment

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

Don't you need to check here that pt is either 1 or 0x10000?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

require (I64.le_u min max) at
"size minimum must not be greater than maximum"

let check_pagesize (PageT ps) at =
Copy link
Member

Choose a reason for hiding this comment

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

Nit: check_pagetype, since that's what you named the thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@titzer titzer merged commit 1afa12a into main Dec 3, 2025
1 check passed
@titzer titzer deleted the impl_ir branch December 3, 2025 15:09
@fitzgen
Copy link
Collaborator

fitzgen commented Dec 3, 2025

Thanks @titzer and @rossberg!

@titzer
Copy link
Contributor Author

titzer commented Dec 3, 2025

Thanks @titzer and @rossberg!

AFAICT the missing parts now are just the parser, decoder, and encoder, and then it should actually be able to pass tests. The bounds-check machinery is already based on byte-sized memories and doesn't really concern itself with the pagesize, except in the places I already modified.

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.

4 participants