mulle-objc / mulle-objc-runtime

⏩ A fast, portable Objective-C runtime written 100% in C11
https://www.mulle-kybernetik.com/mulle-objc
Other
110 stars 8 forks source link

mulle-clang in debug mode pushes the stackpointer too much #11

Closed mulle-kybernetik-tv closed 2 years ago

mulle-kybernetik-tv commented 2 years ago
#import "import-private.h"

#include <stdio.h>

#include "regression-version.h"

typedef double  mulle_relativetime_t;
typedef double  mulle_absolutetime_t;
struct UIWindowFrameStatistics;

@interface Foo : NSObject
@end  

@implementation Foo 

static MULLE_C_NEVER_INLINE void  stackPointer( void)
{
}

- (mulle_relativetime_t) remainingFrameTime:(mulle_absolutetime_t) now
                                  frameRate:(mulle_relativetime_t) frameRate
                              animationRate:(mulle_relativetime_t) animationRate
                            frameStatistics:(struct UIWindowFrameStatistics *) stats
                           frameRateLimiter:(BOOL) frameRateLimiter
{
   void* p = NULL;
   fprintf( stderr, "stackPointer %p ", (void*)&p);
   fprintf( stderr, "_param=%p ", _param);
   fprintf( stderr, "now=%g ", now);
   fprintf( stderr, "frameRate=%g ", frameRate);
   fprintf( stderr, "animationRate=%g ", animationRate);
   fprintf( stderr, "stats=%p ", stats);
   fprintf( stderr, "frameRateLimiter=%ld ", (long) frameRateLimiter);

   return( 0.0);        
}

- (mulle_relativetime_t) remainingFrameTime:(mulle_relativetime_t) now
                                  frameRate:(mulle_relativetime_t) frameRate
{
   void* p = NULL;
   fprintf( stderr, "stackPointer %p ", (void*)&p);
   fprintf( stderr, "_param=%p ", _param);
   fprintf( stderr, "now=%g ", now);
   fprintf( stderr, "frameRate=%g ", frameRate);

   return( 0.0);        
}

@end 

int  main( int argc, char *argv[])
{
   double   x;
   Foo      *foo;

#if defined( DEBUG) && defined( __MULLE_OBJC__)
   mulle_objc_global_check_universe( __MULLE_OBJC_UNIVERSENAME__);
#endif
   foo = [Foo new];

   for(;;)
   {
      x = [foo remainingFrameTime:1.0
                                     frameRate:2.0
//                                 animationRate:3.0
//                               frameStatistics:NULL
//                              frameRateLimiter:1
          ];
      fprintf( stderr, "x=%g\n", x);
   }           

   return( 0);
}

This only happens with DEBUG. It's probably an alloca which doesn't get reclaimed.

mulle-nat commented 2 years ago

This is fixed in 0.21