Changeset c44e622 for src


Ignore:
Timestamp:
Feb 24, 2016, 10:36:17 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, 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, qualifiedEnum, resolv-new, with_gc
Children:
ae7f1e0
Parents:
d41280e
Message:

intermediate implementation of vector

Location:
src/examples/gc_no_raii
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/premake4.lua

    rd41280e rc44e622  
    4242                linkoptions (linkOptionList)
    4343                includedirs (includeDirList)
    44                 files { "../fstream.c", "../iostream.c", "../iterator.c", "src/**.c" }
     44                files { "src/**.c" }
    4545
    4646        configuration "debug"
  • src/examples/gc_no_raii/src/gcpointers.c

    rd41280e rc44e622  
    33#include "gc.h"
    44#include "internal/collector.h"
    5 #include "internal/object_header.h"
     5//#include "internal/object_header.h"
    66// #include "internal/state.h"
    7 
     7/*
    88void register_ptr(gcpointer_t* this)
    99{
    10         if(gcpointer_null(this)) return;
    11 
    12         _Bool managed = gc_is_managed(this);
    13 
    14         if(managed)
    15         {
    16                 gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this);
    17                 check(obj);
    18                 check(gc_obj_is_valide(obj));
    19                 check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);
    20                 this->next = obj->type_chain;
    21                 obj->type_chain = this;
    22                 check(obj->is_valide());
    23         }
    24         else
    25         {
    26                 gc_object_header* obj = gc_get_object_ptr((void*)this->ptr);
    27                 check(obj);
    28                 check(gc_obj_is_valide(obj));
    29                 check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL);
    30                 this->next = obj->root_chain;
    31                 obj->root_chain = this;
    32                 check(gc_obj_is_valide(obj));
    33         }
     10        // if(gcpointer_null(this)) return;
     11        //
     12        // _Bool managed = gc_is_managed(this);
     13        //
     14        // if(managed)
     15        // {
     16        //      gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this);
     17        //      check(obj);
     18        //      check(gc_obj_is_valide(obj));
     19        //      check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);
     20        //      this->next = obj->type_chain;
     21        //      obj->type_chain = this;
     22        //      check(obj->is_valide());
     23        // }
     24        // else
     25        // {
     26        //      gc_object_header* obj = gc_get_object_ptr((void*)this->ptr);
     27        //      check(obj);
     28        //      check(gc_obj_is_valide(obj));
     29        //      check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL);
     30        //      this->next = obj->root_chain;
     31        //      obj->root_chain = this;
     32        //      check(gc_obj_is_valide(obj));
     33        // }
    3434}
    3535
    3636void unregister_ptr(gcpointer_t* this)
    3737{
    38         if(gcpointer_null(this)) return;
    39 
    40         gcpointer_t** prev_next_ptr = gc_find_previous_ref(this);
    41         check((*prev_next_ptr) == this);
    42 
    43         (*prev_next_ptr) = this->next;
     38        // if(gcpointer_null(this)) return;
     39        //
     40        // gcpointer_t** prev_next_ptr = gc_find_previous_ref(this);
     41        // check((*prev_next_ptr) == this);
     42        //
     43        // (*prev_next_ptr) = this->next;
    4444}
    4545
     
    9999{
    100100        return this->ptr == (intptr_t)NULL;
    101 }
     101}*/
  • src/examples/gc_no_raii/src/gctest.c

    rd41280e rc44e622  
     1#include <fstream>
    12
    23#include "gc.h"
    3 #include "fstream.h"
    44
    55int main() {
  • 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)
  • src/examples/gc_no_raii/src/tools/worklist.h

    rd41280e rc44e622  
    44#include <stdint.h>
    55
     6#include "vector.h"
     7/*
    68typedef intptr_t* worklist_element_t;
    79
     
    1315
    1416void push_back(worklist_t* worklist, worklist_element_t element);
     17*/
     18
     19//typedef vector(intptr_t*) worklist_t;
Note: See TracChangeset for help on using the changeset viewer.