Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
psyqo::ScratchpadStackful< StackSize > Class Template Reference

Stackful coroutine whose stack is the scratchpad. More...

#include <psyqo/coroutine.hh>

Inheritance diagram for psyqo::ScratchpadStackful< StackSize >:
Inheritance graph
[legend]
Collaboration diagram for psyqo::ScratchpadStackful< StackSize >:
Collaboration graph
[legend]

Public Member Functions

 ScratchpadStackful ()=default
 
 ScratchpadStackful (const ScratchpadStackful &)=delete
 
ScratchpadStackful & operator= (const ScratchpadStackful &)=delete
 
void initialize (eastl::function< void()> &&func)
 Initialize the coroutine with a function.
 
void resume ()
 Resume the coroutine. See Stackful::resume.
 
void yield ()
 Yield the coroutine. See Stackful::yield.
 
bool isAlive () const
 Check if the coroutine is currently alive. See Stackful::isAlive.
 

Static Public Attributes

static constexpr uintptr_t c_stackBase = 0x1f800400 - StackSize
 
static constexpr unsigned c_stackSize = StackSize
 
static constexpr unsigned c_freeBytes = 1024 - StackSize
 

Additional Inherited Members

- Protected Member Functions inherited from psyqo::StackfulBase
void initializeInternal (eastl::function< void()> &&func, void *ss_sp, unsigned ss_size)
 
void resume ()
 
void yield ()
 
bool isAlive () const
 
 StackfulBase ()=default
 
 StackfulBase (const StackfulBase &)=delete
 
StackfulBase & operator= (const StackfulBase &)=delete
 

Detailed Description

template<unsigned StackSize = 1024>
class psyqo::ScratchpadStackful< StackSize >

Stackful coroutine whose stack is the scratchpad.

Same as Stackful, except that the stack is not part of the object: it is the top StackSize bytes of the 1KB scratchpad, growing down from 0x1f800400. The scratchpad answers a load in one cycle where main RAM takes several, so a hot routine that spends its time saving and restoring registers and reloading spilled locals gets faster by running here. The scratchpad-stack example measures it.

The constraints all come from the scratchpad itself:

Template Parameters
StackSizeThe number of bytes taken from the top of the scratchpad. A multiple of 8, at most 1024.

Constructor & Destructor Documentation

◆ ScratchpadStackful() [1/2]

template<unsigned StackSize = 1024>
psyqo::ScratchpadStackful< StackSize >::ScratchpadStackful ( )
default

◆ ScratchpadStackful() [2/2]

template<unsigned StackSize = 1024>
psyqo::ScratchpadStackful< StackSize >::ScratchpadStackful ( const ScratchpadStackful< StackSize > &  )
delete

Member Function Documentation

◆ initialize()

template<unsigned StackSize = 1024>
void psyqo::ScratchpadStackful< StackSize >::initialize ( eastl::function< void()> &&  func)
inline

Initialize the coroutine with a function.

Parameters
funcFunction to be executed by the coroutine.

◆ isAlive()

template<unsigned StackSize = 1024>
bool psyqo::ScratchpadStackful< StackSize >::isAlive ( ) const
inline

Check if the coroutine is currently alive. See Stackful::isAlive.

◆ operator=()

template<unsigned StackSize = 1024>
ScratchpadStackful & psyqo::ScratchpadStackful< StackSize >::operator= ( const ScratchpadStackful< StackSize > &  )
delete

◆ resume()

template<unsigned StackSize = 1024>
void psyqo::ScratchpadStackful< StackSize >::resume ( )
inline

Resume the coroutine. See Stackful::resume.

◆ yield()

template<unsigned StackSize = 1024>
void psyqo::ScratchpadStackful< StackSize >::yield ( )
inline

Yield the coroutine. See Stackful::yield.

Member Data Documentation

◆ c_freeBytes

template<unsigned StackSize = 1024>
constexpr unsigned psyqo::ScratchpadStackful< StackSize >::c_freeBytes = 1024 - StackSize
staticconstexpr

◆ c_stackBase

template<unsigned StackSize = 1024>
constexpr uintptr_t psyqo::ScratchpadStackful< StackSize >::c_stackBase = 0x1f800400 - StackSize
staticconstexpr

◆ c_stackSize

template<unsigned StackSize = 1024>
constexpr unsigned psyqo::ScratchpadStackful< StackSize >::c_stackSize = StackSize
staticconstexpr

The documentation for this class was generated from the following file: