-
Notifications
You must be signed in to change notification settings - Fork 160
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
Allow multi-module kernels #1436
Comments
Just one point to clarify: we can create compiled libraries with a subset of exports of all the modules contained in that library, i.e. only the modules passed explicitly to So I think what we need is actually a way, in the Miden Assembly syntax, to mark a procedure as having I think we can solve this in one of two ways:
Aside from the type signature aspect, the only other key difference is replacing I believe the above could be implemented in a backwards-compatible fashion, as a result of using With a type system in place, we can generate better documentation, and we can generate the necessary metadata to be able to bind to MASM procedures from higher-level languages, without having to manually maintain those type definitions separately. We don't need to implement any kind of type checker, but it would be an option, as this would allow us to infer the contents of the operand stack, and via abstract interpretation, it would be possible for us to determine whether there are any invalid instruction uses, incorrect arguments for |
I like this approach but a few questions/comments. First, I wonder if we should change Second, I'd probably prefer single-word visibility modifiers. So, overall, I'm thinking we could have something like this:
The one thing missing from the above is ability to specify whether a given procedure is supposed to be Regarding adding signature info to procedures, I like this as well. The only potential concern that I have is that people may confuse these as binding signatures while we view them more like documentation (i.e., as you mentioned, these signatures would not be enforced). If the signature is described in the comments, it is much more likely to be interpreted as documentation. But maybe this is OK and the benefits of this clean syntax outweigh the potential confusion downsides. |
I tend to evaluate a lot of this in the context of what I'd expect from a typical assembly language and associated linker. A standard linker, e.g.
I think there is a pretty clear value proposition to having symbols which are clearly private, while also being able to share code within the same library, without exposing those procedures in the public API of the library. It is more about conveying intent, and being able to better represent the boundaries of your API, than it is about literally protecting the code, at least in my opinion. I could be convinced to treat
There are pretty significant downsides to this IMO:
In any case, I would recommend sticking to one special form for procedure definitions, with an optional visibility specifier - it is dead simple to parse, and will make the language feel more familiar to those coming from typical programming languages that have to get their hands dirty with MASM.
Could you clarify what you mean by "assembly context" here, in terms of inputs to the
I think annotations are probably the most appropriate way to represent that particular distinction, since it is only actionable from a high-level language compiler, though I can think of some ways that one could use abstract interpretation to determine if any inputs from the caller violate the conventions (i.e.
Well, I said that they would not have to be enforced, but obviously it would be desirable to do so once we have them. The main reason I want it, is to generate bindings for the compiler (it is in fact critical to be able to do so against hand-written MASM modules if you want to call them from e.g. Rust). So to that end, it is actually best that people think of them as binding, and not simply as documentation. We can definitely drive type checking off of them, what I was mostly trying to do was convey that it isn't essential to the implementation of the type system and syntax for it, but instead a natural consequence of having types, is that we will want to start using them to help us check our programs. In other words, I didn't want to make the implementation of it contingent on the type checker being implemented at the same time, since backwards-compatibility would be a necessary aspect of the design (hence the system would necessarily be gradually-typed, with a success typing approach, so as to maximally benefit from types when available, without requiring them to be added everywhere at once). |
I am fine with having privately-scoped procedures - though, one thing I was trying to avoid is overloading the meaning of
OK - I'm convinced. Let's use only
Yes - correct, I meant the AST modules only (i.e., not including any compiled libraries).
I actually think that we can enforce some checks on this in the assembler as well. For example, in the MASM code, if somebody tries to Putting the above together, here is another sketch of how things could look like:
A couple of additional comments on this:
Makes sense - though, I'd probably create a separate issue for procedure signatures as I think we'd tackle procedure visibility modifiers and more comprehensive procedure signatures in different PRs. |
Currently, a kernel library can be assembled only from a single module. For complex kernels (e.g., the transaction kernel in
miden-base
), this means that to avoid having one giant file we need to introduce a separate library which the kernel then relies on. It would be much more convenient to be able to build a kernel library from multiple modules.One open question is how to identify a set of procedures exported from the module library vs. exported from modules to be used within the kernel internally. There are probably several options here, a couple that come to mind:
sys.foo
instead ofexport.foo
) or via annotations described in #1434.The text was updated successfully, but these errors were encountered: