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

VM initialization and creating contracts #46

Merged
merged 7 commits into from
Dec 17, 2024
Merged

Conversation

virgil-serbanuta
Copy link
Member

@virgil-serbanuta virgil-serbanuta commented Dec 16, 2024

Fixes #15

@virgil-serbanuta virgil-serbanuta changed the base branch from master to resolve-imports December 16, 2024 18:12
@virgil-serbanuta virgil-serbanuta force-pushed the implement-hooks branch 3 times, most recently from f9e0fa4 to 7406e48 Compare December 16, 2024 23:27
Base automatically changed from resolve-imports to master December 17, 2024 04:05
@virgil-serbanuta virgil-serbanuta marked this pull request as ready for review December 17, 2024 16:21
Copy link

@sskeirik sskeirik left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! I have a few minor questions/comments.

Also, after clicking the merge button but before merging, could we change the generated commit header to be a bit more descriptive? To me, at the moment, the PR title (which is used to auto-populate the commit header), is a bit more broad than the PR contents.

Comment on lines 512 to 530
rule [memLoad-zero-len]:
<instrs> #memLoad(OFFSET, 0) => b""
...
</instrs>
<contractModIdx> MODIDX:Int </contractModIdx>
<moduleInst>
<modIdx> MODIDX </modIdx>
<memAddrs> ListItem(ADDR) </memAddrs>
...
</moduleInst>
<mems> MEMS </mems>
requires true
andBool 0 <=Int ADDR
andBool ADDR <Int size(MEMS)
andBool #signed(i32, OFFSET) >=Int 0
andBool
(#let memInst(_, SIZE, _DATA) = MEMS[ADDR] #in
#signed(i32 , OFFSET) <=Int (SIZE *Int #pageSize())
)

Choose a reason for hiding this comment

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

Just curious: is this an optimization or is it required because it is not covered by another case? I don't have a strong opinion about it, just curious.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it was a corner case that should be handled separately, but it wasn't. I included it in the rule below.

Comment on lines +206 to +208
=> setContractModIdx
~> #resolveCurModuleFuncExport(#getEntryPoint())
~> setSuccessStatus

Choose a reason for hiding this comment

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

This is a style question, so feel free to resolve it however. On some other added lines, the two arrow styles (=> and ~>) have matching columns. Here, they're different. I'm not sure if this is intended or if, e.g., some editor is mixing whitespace styles.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if I understand this properly, but I went through all occurrences of ~> in this file and I think that it works like this:

  1. Here (and in the place below with a similar comment), there are three items in a K list on the RHS of => (setContractModIdx, resolveCurModuleFuncExport, setSuccessStatus). Because the K list made of these three is a child of the rewrite, they are indented.
  2. In other places, we have the rewrite as a child of ~> (e.g. the rule at line 136) and there I'm using the following pattern: an operator-like thing (e.g. ~> and =>) are printed like this:
term
op term
op term
...

This means that something like (a => b) ~> c would be formatted as one of:

(a => b)
~> c

or

(a
=> b
)
~> c

Arguably, the latter may work better as:

(   a
    => b
)
~> c

(with or without spaces before a) since the rewrite is a child of the parenthesis. Is this what you meant? If yes, I can just fix this. (I can also fix it if the issue is different, it's just that I'm not fully sure what you think should be fixed).

Choose a reason for hiding this comment

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

Hmm... I haven't thought about this to the level of detail that you have! Since this is just a style question anyway, let's keep this as is and we can discuss later the possibility of a K coding style.

Comment on lines +328 to +330
#throwException(Code:Int, Reason:String)
=> setStatus(Code)
~> #exception(Reason)

Choose a reason for hiding this comment

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

A similar style comment about arrows as above.

@virgil-serbanuta virgil-serbanuta changed the title Implement hooks VM initialization and creating contracts Dec 17, 2024
@virgil-serbanuta virgil-serbanuta merged commit c09539c into master Dec 17, 2024
2 checks passed
@virgil-serbanuta virgil-serbanuta deleted the implement-hooks branch December 17, 2024 18:40
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.

Handle Wasm VM Initialization (the CREATE flag)
2 participants