Back to index

plt-scheme  4.2.1
Classes | Defines | Typedefs | Functions | Variables
test.c File Reference
#include <sys/types.h>
#include "sgc.h"

Go to the source code of this file.

Classes

struct  Chained

Defines

#define MAX_C_SIZE   70
#define CHAIN_DEPTH   100
#define NUM_REPEATS   10
#define CHAINS_AS_LOCAL   1

Typedefs

typedef struct Chained Chained

Functions

void work ()
 work2 ()
 main ()

Variables

voidx
voidy

Class Documentation

struct Chained

Definition at line 31 of file test.c.

Collaboration diagram for Chained:
Class Members
int data
struct Chained * next

Define Documentation

#define CHAIN_DEPTH   100

Definition at line 38 of file test.c.

#define CHAINS_AS_LOCAL   1

Definition at line 41 of file test.c.

#define MAX_C_SIZE   70

Definition at line 37 of file test.c.

#define NUM_REPEATS   10

Definition at line 39 of file test.c.


Typedef Documentation


Function Documentation

main ( void  )

Definition at line 115 of file test.c.

{
  int dummy;

  GC_set_stack_base((void *)&dummy);

  GC_add_roots((void *)&y, ((char *)&y) + sizeof(y) + 1);
  GC_add_roots((void *)&x, ((char *)&x) + sizeof(x) + 1);

  work();

  work2();
}

Here is the call graph for this function:

void work ( )

Definition at line 8 of file test.c.

{
  char *v, *w;

  x = (char *)GC_malloc(20);
  y = (char *)GC_malloc(2000);

  v = (char *)GC_malloc(2);
  GC_gcollect();
  v[0] = 0;
  v = (char *)GC_malloc(10);
  GC_gcollect();
  v[0] = 0;
  v = (char *)GC_malloc(10000);
  w = (char *)GC_malloc(11000);
  GC_gcollect();
  v[0] = 0;
  v = (char *)GC_malloc(10);
  GC_gcollect();
  v[0] = 0;
  w[0] = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

work2 ( )

Definition at line 47 of file test.c.

{
  int broken = 15;
  int i, j, k, l;
#if CHAINS_AS_LOCAL
  Chained *chains[MAX_C_SIZE];
#endif

#if !CHAINS_AS_LOCAL
  GC_add_roots((void *)chains, ((char *)chains) + sizeof(chains) + 1);
#endif

  printf("chains at %lx\n", (long)chains);

  for (l = NUM_REPEATS; l--; ) {
    printf("cycle: %d\n", NUM_REPEATS - l);

    for (i = 0; i < MAX_C_SIZE; i++)
      chains[i] = 0L;

    if (l & 1) {
      /* Same size together: */
      for (i = 0; i < MAX_C_SIZE; i++) {
       for (k = CHAIN_DEPTH; k--; ) {
         Chained *c;
         
         c = (Chained *)GC_malloc(sizeof(Chained) + (i - 1) * sizeof(int));
         for (j = 0; j < i; j++) {
           c->data[j] = i;
         }
         
         c->next = chains[i];
         chains[i] = c;
       }
      }
    } else {
      /* Sizes shuffled: */
      for (k = CHAIN_DEPTH; k--; ) {
       for (i = 0; i < MAX_C_SIZE; i++) {
         Chained *c;
         
         c = (Chained *)GC_malloc(sizeof(Chained) + (i - 1) * sizeof(int));
         for (j = 0; j < i; j++) {
           c->data[j] = i;
         }
         
         c->next = chains[i];
         chains[i] = c;
       }
      }      
    }

    for (i = 0; i < MAX_C_SIZE; i++) {
      Chained *c;
      
      c = chains[i];
      for (k = CHAIN_DEPTH; k--; c = c->next) {
       for (j = 0; j < i; j++)
         if (c->data[j] != i) {
           printf("broken: %d[%d][%d] = %d\n", i, (CHAIN_DEPTH - k), j, c->data[j]);
           if (!(broken--))
             return;
         }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

void* x

Definition at line 5 of file test.c.

void* y

Definition at line 6 of file test.c.