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

Host API implementation and runtime updates #81

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

mariopil
Copy link
Collaborator

Closes #79

4 host API methods were implemented which are called by the Core_version runtime call:

  • ext_logging_max_level_version_1
  • ext_logging_log_version_1
  • ext_allocator_malloc_version_1
  • ext_allocator_free_version_1

I've also added memory management (based on Kagome code) - this was needed by both ext_allocator... methods. Currently it is possible to run Core_version and get the resulting Version struct - however it is missing decoding of the APIs as this requires implementing blake2 algorithms which is out of this task scope. It should be straightforward now to implement other host and runtime methods.

}
}
std::shared_ptr<plc::core::runtime::Memory> m_memory;
std::map<soralog::Level, int> m_wasm_log_level_map;
Copy link
Collaborator

Choose a reason for hiding this comment

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

m_wasm_log_level_map looks like something constant (the map is initialized with const values in constructor in api.cpp file) - it's only searched and retrieved values.
So it could be at least const (or even maybe constexpr).

Well, it could be thought about using unordered_map as it would speed up the looking log level in ext_logging_max_level_version_1 method and possibility of element collision is none. Ordering seems also to not matter.

}

wasm::Literals ExternalInterface::callImport(wasm::Function* import, wasm::LiteralList& arguments) {
if (import->module == env) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can import be nullptr?

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.

Implement host API - only needed methods
3 participants