Skip to content

Commit

Permalink
util, spad: handholding overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
ravyu-jump committed Jan 10, 2025
1 parent 4676b93 commit 033574f
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 93 deletions.
1 change: 1 addition & 0 deletions config/extra/with-handholding.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ CPPFLAGS+=-DFD_EQVOC_USE_HANDHOLDING=1
CPPFLAGS+=-DFD_FORKS_USE_HANDHOLDING=1
CPPFLAGS+=-DFD_GHOST_USE_HANDHOLDING=1
CPPFLAGS+=-DFD_SCRATCH_USE_HANDHOLDING=1
CPPFLAGS+=-DFD_SPAD_USE_HANDHOLDING=1
CPPFLAGS+=-DFD_TOWER_USE_HANDHOLDING=1
# CPPFLAGS+=-DFD_TXN_HANDHOLDING=1 # FIXME: Compile errors
26 changes: 11 additions & 15 deletions src/util/spad/fd_spad.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ fd_spad_alloc_max_debug( fd_spad_t const * spad,
ulong align ) {
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
if( FD_UNLIKELY( (!!align) & (!fd_ulong_is_pow2( align ) ) ) ) FD_LOG_CRIT(( "bad align" ));
return fd_spad_alloc_max( spad, align );
return fd_spad_alloc_max_impl( spad, align );
}

void *
fd_spad_frame_lo_debug( fd_spad_t * spad ) {
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
return fd_spad_frame_lo( spad );
return fd_spad_frame_lo_impl( spad );
}

void *
fd_spad_frame_hi_debug( fd_spad_t * spad ) {
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
return fd_spad_frame_hi( spad );
return fd_spad_frame_hi_impl( spad );
}

void
fd_spad_push_debug( fd_spad_t * spad ) {
if( FD_UNLIKELY( !fd_spad_frame_free( spad ) ) ) FD_LOG_CRIT(( "too many frames" ));
fd_spad_push( spad );
fd_spad_push_impl( spad );
}

void
fd_spad_pop_debug( fd_spad_t * spad ) {
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
fd_spad_pop( spad );
fd_spad_pop_impl( spad );
}

void *
Expand All @@ -71,7 +71,7 @@ fd_spad_alloc_debug( fd_spad_t * spad,
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
if( FD_UNLIKELY( (!!align) & (!fd_ulong_is_pow2( align ) ) ) ) FD_LOG_CRIT(( "bad align" ));
if( FD_UNLIKELY( fd_spad_alloc_max( spad, align )<sz ) ) FD_LOG_CRIT(( "bad sz" ));
return fd_spad_alloc( spad, align, sz );
return fd_spad_alloc_impl( spad, align, sz );
}

void
Expand All @@ -80,7 +80,7 @@ fd_spad_trim_debug( fd_spad_t * spad,
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
if( FD_UNLIKELY( ((ulong)fd_spad_frame_lo( spad ))>(ulong)hi ) ) FD_LOG_CRIT(( "hi below frame_lo" ));
if( FD_UNLIKELY( ((ulong)fd_spad_frame_hi( spad ))<(ulong)hi ) ) FD_LOG_CRIT(( "hi above frame_hi" ));
fd_spad_trim( spad, hi );
fd_spad_trim_impl( spad, hi );
}

void *
Expand All @@ -90,15 +90,15 @@ fd_spad_prepare_debug( fd_spad_t * spad,
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
if( FD_UNLIKELY( (!!align) & (!fd_ulong_is_pow2( align ) ) ) ) FD_LOG_CRIT(( "bad align" ));
if( FD_UNLIKELY( fd_spad_alloc_max( spad, align )<max ) ) FD_LOG_CRIT(( "bad max" ));
return fd_spad_prepare( spad, align, max );
return fd_spad_prepare_impl( spad, align, max );
}

void
fd_spad_cancel_debug( fd_spad_t * spad ) {
if( FD_UNLIKELY( !fd_spad_frame_used( spad ) ) ) FD_LOG_CRIT(( "not in a frame" ));
/* FIXME: check if in prepare? needs extra state and a lot of extra
tracking that state */
fd_spad_cancel( spad );
fd_spad_cancel_impl( spad );
}

void
Expand All @@ -108,7 +108,7 @@ fd_spad_publish_debug( fd_spad_t * spad,
if( FD_UNLIKELY( fd_spad_alloc_max( spad, 1UL )<sz ) ) FD_LOG_CRIT(( "bad sz" ));
/* FIXME: check if in prepare? needs extra state and a lot of extra
tracking that state */
fd_spad_publish( spad, sz );
fd_spad_publish_impl( spad, sz );
}

/* fd_valloc virtual function table for spad */
Expand All @@ -117,11 +117,7 @@ fd_spad_valloc_malloc( void * _self,
ulong align,
ulong sz ) {
fd_spad_t * spad = _self;
void * rv = fd_spad_alloc( spad, align, sz );
if( FD_UNLIKELY( fd_spad_mem_used( spad )>fd_spad_mem_max( spad ) ) ) {
FD_LOG_ERR(( "spad overflow mem_used=%lu mem_max=%lu", fd_spad_mem_used( spad ), fd_spad_mem_max( spad ) ));
}
return rv;
return fd_spad_alloc( spad, align, sz );
}

static void
Expand Down
Loading

0 comments on commit 033574f

Please sign in to comment.