29 void Amd64::ValidateStackSize(
const size_t size) {
 
   30     if (!size) 
throw std::runtime_error(
"Size may not be nil");
 
   31     if (size % 
kStackAlignment) 
throw std::runtime_error(
"Stack is misaligned");
 
   47 void* Amd64::AllocStack(
const size_t bytes) {
 
   50         throw std::runtime_error(
"failed to allocate stack");
 
   62 void Amd64::DeallocStack(
void* stack) {
 
   82     static_assert(offsetof(
Amd64, stackTop) == COTHREAD_OFF_CONTEXT_TOP, 
"cothread stack top is invalid");
 
   85     auto info = 
new CallInfo{ entry };
 
   86     if (!info) 
throw std::runtime_error(
"Failed to allocate call info");
 
   90     auto& stackBuf = wrap->
stack;
 
   91     auto stackFrame = 
reinterpret_cast<std::byte*
>(stackBuf.data());
 
   92     stackFrame += ((stackBuf.size() * 
sizeof(uintptr_t)) & ~(0x10 - 1))
 
   94     auto stack = 
reinterpret_cast<uintptr_t*
>(stackFrame);
 
   97     *--
stack = 
reinterpret_cast<uintptr_t
>(&Amd64::EntryReturnedStub);
 
  100     *--
stack = 
reinterpret_cast<uintptr_t
>(info);
 
  101     *--
stack = 
reinterpret_cast<uintptr_t
>(&Amd64::DereferenceCallInfo);
 
  102     *--
stack = 
reinterpret_cast<uintptr_t
>(&Amd64::JumpToEntry);
 
  111     wrap->stackTop = 
stack;
 
std::function< void()> Entry
Type alias for an entry point of a cothread.
 
Architecture specific methods for working with cothreads on amd64 based systems.
 
static const size_t kNumSavedRegisters
 
static constexpr const size_t kStackAlignment
 
Implementation details (including architecture/platform specific code) for the library.
 
Main namespace for the libcommunism library.
 
std::span< uintptr_t > stack
Stack used by this cothread, if any.