Ignore:
Timestamp:
Feb 24, 2016, 10:36:17 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, resolv-new, with_gc
Children:
ae7f1e0
Parents:
d41280e
Message:

intermediate implementation of vector

Location:
src/examples/gc_no_raii/src/internal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/internal/collector.c

    rd41280e rc44e622  
    66#include <string.h>
    77
    8 #include "fstream.h"
     8#include <fstream>
    99
    1010#include "memory_pool.h"
  • src/examples/gc_no_raii/src/internal/collector.h

    rd41280e rc44e622  
    66#include "tools.h"
    77
    8 #include "gcpointers.h"
    9 #include "internal/collector.h"
    10 #include "internal/gc_tools.h"
    11 #include "internal/globals.h"
     8//#include "gcpointers.h"
     9//#include "internal/gc_tools.h"
     10//#include "internal/globals.h"
    1211#include "internal/object_header.h"
    13 #include "internal/state.h"
     12//#include "internal/state.h"
    1413#include "tools/worklist.h"
    15 
     14/*
    1615inline bool gc_is_managed(void* address)
    1716{
     
    2726inline gc_memory_pool* gc_pool_of(void* address)
    2827{
    29         return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK);
     28        //return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK);
    3029}
    3130
     
    4746
    4847void gc_scan_object(struct gc_object_header* object, worklist_t* worklist);
     48*/
  • src/examples/gc_no_raii/src/internal/state.c

    rd41280e rc44e622  
    11#include "state.h"
    22
    3 #include <stdlib.h>
    4 
    5 //general purpouse includes
    6 #include "tools.h"
    7 
    8 //platform abstraction includes
    9 #include "allocate-pool.h"
    10 
    11 //gc internal includes
    12 // #include "globals.h"
    13 #include "memory_pool.h"
     3// #include <stdlib.h>
     4//
     5// //general purpouse includes
     6// #include "tools.h"
     7//
     8// //platform abstraction includes
     9// #include "allocate-pool.h"
     10//
     11// //gc internal includes
     12// // #include "globals.h"
     13// #include "memory_pool.h"
    1414// #include "memory_pool_iterator.h"
    1515// #include "object_header.h"
     
    2525// #endif
    2626
    27 void gc_state_ctor(gc_state* state)
    28 {
    29         state->from_code = 0;
    30         state->to_space = NULL;
    31         state->from_space = NULL;
    32         state->total_space = 0;
    33         state->used_space = 0;
    34         // state->pools_table();
    35 
    36         gc_allocate_pool(state);
    37 
    38         state->is_initialized = true;
    39 }
     27// void gc_state_ctor(gc_state* state)
     28// {
     29//      state->from_code = 0;
     30//      state->to_space = NULL;
     31//      state->from_space = NULL;
     32//      state->total_space = 0;
     33//      state->used_space = 0;
     34//      // state->pools_table();
     35//
     36//      gc_allocate_pool(state);
     37//
     38//      state->is_initialized = true;
     39// }
    4040
    4141// bool state::is_in_heap(void* address) const
     
    5959// }
    6060//
    61 gc_object_header* gc_get_object_for_ref(gc_state* state, void* member)
    62 {
    63         intptr_t target = ((intptr_t)member);
    64         if(!gc_is_in_heap(state, member)) return NULL;
    65 
    66         gc_memory_pool* pool = gc_pool_of(member);
    67         gc_pool_object_iterator it = gc_pool_iterator_for(pool, member);
    68         gc_pool_object_iterator end = gc_pool_end(pool);
    69 
    70         while(it != end)
    71         {
    72                 gc_object_header* object = *it;
    73                 {
    74                         intptr_t start = ((intptr_t)object);
    75                         intptr_t end = ((intptr_t)start + object->size);
    76                         if(start < target && end > target)
    77                         {
    78                                 return object;
    79                         }
    80                 }
    81                 ++it;
    82         }
    83 
    84         checkf(false, "is_in_heap() and iterator_for() return inconsistent data");
    85         abort();
    86         return NULL;
    87 }
     61// gc_object_header* gc_get_object_for_ref(gc_state* state, void* member)
     62// {
     63//      intptr_t target = ((intptr_t)member);
     64//      if(!gc_is_in_heap(state, member)) return NULL;
     65//
     66//      gc_memory_pool* pool = gc_pool_of(member);
     67//      gc_pool_object_iterator it = gc_pool_iterator_for(pool, member);
     68//      gc_pool_object_iterator end = gc_pool_end(pool);
     69//
     70//      while(it != end)
     71//      {
     72//              gc_object_header* object = *it;
     73//              {
     74//                      intptr_t start = ((intptr_t)object);
     75//                      intptr_t end = ((intptr_t)start + object->size);
     76//                      if(start < target && end > target)
     77//                      {
     78//                              return object;
     79//                      }
     80//              }
     81//              ++it;
     82//      }
     83//
     84//      checkf(false, "is_in_heap() and iterator_for() return inconsistent data");
     85//      abort();
     86//      return NULL;
     87// }
    8888//
    8989// void* state::try_allocate(size_t size)
Note: See TracChangeset for help on using the changeset viewer.