-
Notifications
You must be signed in to change notification settings - Fork 70
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
Encapsulate wasm execution context #428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we need non-const pointers? In fact, initialising them to null
in the header file is AFAICT not very useful as we check the stack size and return null
or not basing on that (not on the pointer being null). Thus, we could initialise a const
pointer in the initialisation list.
Plus, I haven't seen (maybe I have missed) where we actually need the message to be non-const?
@@ -2,6 +2,7 @@ | |||
#include <faabric/util/bytes.h> | |||
#include <faabric/util/macros.h> | |||
#include <wamr/native.h> | |||
#include <wasm/WasmExecutionContext.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this include necessary here? It's not used in the file elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, because the getExecutingCall
/ getExecutingModule
functions now live in this header rather than WasmModule.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right I had missed that 👍
#include <conf/FaasmConfig.h> | ||
#include <wasm/WasmExecutionContext.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, just wondering, is this used here?
The existing interface (i.e. the old version of the I opted to do a message copy in the
Always initialising pointers to |
To give intrinsic functions access to the executing module and call, we set them as global thread-local variables with global accessor methods.
Currently the logic for this is spread around the place and because it's handled with global variables, can end up affecting subsequent executions if not cleared up properly. It's also wrapped in a load of assertions because it's so fragile, and these assertions enforce needless restrictions (e.g. each thread can only ever set one executing call and not be changed).
In an attempt to tidy things up I've encapsulated this context into a class which hides the use of the local variables and uses RAII-like scoping, i.e. I can do something like:
Unfortunately things rely on having access to a non-const
Message
object, so there's a bit of a cascade of non-const-ifying and I've had to add one unnecessary copy when resetting the context.