Skip to content
Snippets Groups Projects
Commit 4502dcb7 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[ContextManager] Re-initialze contexts if necessary

In case a Context has been retrieved from the MemoryManager, without
it malloced, then we need to re-initialze some of the Context's values
before we can use the Context.
parent d1a02300
No related branches found
No related tags found
1 merge request!395Fix ContextManager with MemoryManager
...@@ -106,6 +106,15 @@ class EMPER_CONTEXT_ALIGNAS Context : Logger<LogSubsystem::C> { ...@@ -106,6 +106,15 @@ class EMPER_CONTEXT_ALIGNAS Context : Logger<LogSubsystem::C> {
static auto calcBos(char* context) -> void*; static auto calcBos(char* context) -> void*;
auto calcBos() -> void*; auto calcBos() -> void*;
/*
* Used by ContextManager to re-initialize a cached unused context.
*/
inline void reinit() {
currentFiber = nullptr;
savedStackpointer = const_cast<void*>(alphaFunctionIpLocation);
setEmptyHook();
}
public: public:
Context(func_t mainFunction); Context(func_t mainFunction);
......
...@@ -31,6 +31,7 @@ auto ContextManager::getFreeContext() -> Context* { ...@@ -31,6 +31,7 @@ auto ContextManager::getFreeContext() -> Context* {
} }
auto* context = static_cast<Context*>(memory); auto* context = static_cast<Context*>(memory);
context->reinit();
if constexpr (emper::STATS_STACK_USAGE == emper::StatsStackUsage::accurate) { if constexpr (emper::STATS_STACK_USAGE == emper::StatsStackUsage::accurate) {
// If we want accurate stack-usage stats, then we need to re-mark // If we want accurate stack-usage stats, then we need to re-mark
// the stack if we got the memory from the memory manager but if // the stack if we got the memory from the memory manager but if
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment