Esempio n. 1
0
void* gcAllocateUncollectable(size_t size) {
    void* m = GC_MALLOC_UNCOLLECTABLE(size);
    if (!m) {
        // Force GC and try again
        GC_gcollect();
        m = GC_MALLOC_UNCOLLECTABLE(size);
    }
    return m;
}
Esempio n. 2
0
void lua_boxobject( lua_State *L,BBObject *obj ){
	void *p;
	
	struct BBObjectContainer * uc = (struct BBObjectContainer *)GC_MALLOC_UNCOLLECTABLE(sizeof(struct BBObjectContainer*));
	uc->o = obj;
	
	p=lua_newuserdata( L,4 );
	*(struct BBObjectContainer**)p=uc;
}
Esempio n. 3
0
void
GC_linger(void *ptr)
{ linger *l = GC_MALLOC_UNCOLLECTABLE(sizeof(*l));

  l->object = ptr;
  LOCK();
  l->next = GC_lingering;
  GC_lingering = l->next;
  UNLOCK();
}
Esempio n. 4
0
File: load.c Progetto: adh/dfsch
static load_thread_info_t* get_load_ti(){
  load_thread_info_t *lti;
  pthread_once(&load_thread_once, load_thread_key_alloc);
  lti = pthread_getspecific(load_thread_key);
  if (DFSCH_UNLIKELY(!lti)){
    lti = GC_MALLOC_UNCOLLECTABLE(sizeof(load_thread_info_t)); 
    lti->operation = NULL;
    pthread_setspecific(load_thread_key, lti);
  }
  return lti;
  
}
Esempio n. 5
0
void* Object::operator new( size_t size, GCPlacement gcp) {
    if(SYLPH_UNLIKELY(!Object::gc_inited)) {
        GC_INIT();
        Object::gc_inited = true;
    }
    void * toReturn;
    if (gcp == UseGC) toReturn = GC_MALLOC(size);
    else if (gcp == PointerFreeGC) toReturn = GC_MALLOC_ATOMIC(size);
    else toReturn = GC_MALLOC_UNCOLLECTABLE(size);
    if (!toReturn) throw std::bad_alloc();
    else return toReturn;
}
Esempio n. 6
0
sexpr small_cons_uncollectable (sexpr x, sexpr y)
{
    sexpr r;

    uncollectable_count++;
    r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR));
    if (r == 0) {
        GC_printf("Out of memory\n");
        exit(1);
    }
    r -> sexpr_car = x;
    r -> sexpr_cdr = (sexpr)(~(GC_word)y);
    return(r);
}
Esempio n. 7
0
const char* alloc_perm_string(const char *s) {
  nAllocPermStr++;

  //  log_stringf("old_gc_str_dup: allocating %s", s);
  if (GC_base((void*)s) == s) {
    nAllocPermGC++;
    // string in gc_space, thus constant.
    return s;
  } 
  else {
    // try to find string in hash space
    int index = hash_string(s);
    while (str_hash_table[index] != NULL && strcmp(str_hash_table[index], s))
      index = (index + 1) % STR_HASH_SIZE; //better: re-hash.

    char* s2;
    if (str_hash_table[index] == NULL) {
      nAllocPermNoHash++;

      // not found!
      int size =  strlen(s) + 1;
      //s2 = (char *)GC_MALLOC_ATOMIC(size);
      s2 = (char *)GC_MALLOC_UNCOLLECTABLE(size);
      if (str_hash_count >= STR_HASH_SIZE/2) {
	// not enough free hash keys.
	bug("alloc_perm_string: string space overloaded [%s] str_hash_count=%d\n\r", s, str_hash_count);
      } 
      else {
	sAllocPermStr += size;
	str_hash_table[index] = s2;
	str_hash_count++;
      }
      strcpy(s2, s);
    } 
    else {
      nAllocPermHash++;

      s2 = str_hash_table[index];
    }
    return s2;
  }
}
Esempio n. 8
0
void* gcAllocateUncollectable(jint size) {
    return GC_MALLOC_UNCOLLECTABLE(size);
}
Esempio n. 9
0
void str_space_init() {
  str_hash_table = (char**) GC_MALLOC_UNCOLLECTABLE(STR_HASH_SIZE * sizeof(char*));
  stringResult = alloc_perm_string("result");
  stringThis = alloc_perm_string("this");
  dump_GC_info();
}
Esempio n. 10
0
void* ava_alloc_unmanaged(size_t sz) {
  return ava_oom_if_null(GC_MALLOC_UNCOLLECTABLE(sz));
}
Esempio n. 11
0
void *ILGCAllocPersistent(unsigned long size)
{
	/* The Hans-Boehm routines guarantee to zero the block */
	return GC_MALLOC_UNCOLLECTABLE((size_t)size);
}
Esempio n. 12
0
RUN_TIME_API
void *MMAllocMisc(size_t size)
{
  return GC_MALLOC_UNCOLLECTABLE(size);
}