Changeset bee4283


Ignore:
Timestamp:
Aug 4, 2016, 9:18:10 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
00c32e9, 76e8c55
Parents:
aea7168
Message:

GC files now compile, still working on a compiling example

Location:
src/examples/gc_no_raii
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/bug-repro/return_template.c

    raea7168 rbee4283  
    55};
    66
     7forall(otype T) void ?{}(wrap(T)* this);
     8forall(otype T) void ?{}(wrap(T)* this, wrap(T)* rhs);
     9forall(otype T) void ^?{}(wrap(T)* this);
     10forall(otype T) void ?=?(wrap(T)* this, wrap(T)* rhs);
     11
    712forall(otype T)
    8 static inline wrap(T) test()
     13wrap(T) test()
    914{
    1015        wrap(T) tester;
  • src/examples/gc_no_raii/src/gc.h

    raea7168 rbee4283  
    77static inline gcpointer(T) gcmalloc()
    88{
    9     gcpointer(T) test;
    10     // ctor(&test, gc_allocate(sizeof(T)));
    11     // gc_conditional_collect();
    12     return test;
     9    gcpointer(T) ptr;
     10    void* address = gc_allocate(sizeof(T));
     11    (&ptr){ address };
     12    ctor(&ptr, address);
     13    gc_conditional_collect();
     14    return ptr;
    1315}
  • src/examples/gc_no_raii/src/gcpointers.c

    raea7168 rbee4283  
    11#include "gcpointers.h"
    22
    3 #include "gc.h"
     3// #include "gc.h"
    44#include "internal/collector.h"
    55#include "internal/object_header.h"
  • src/examples/gc_no_raii/src/gcpointers.h

    raea7168 rbee4283  
    1010};
    1111
    12 void gcpointer_ctor(gcpointer_t* this);
    13 void gcpointer_ctor(gcpointer_t* this, void* address);
    14 void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other);
    15 void gcpointer_dtor(gcpointer_t* this);
    16 gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs);
     12void ?{}(gcpointer_t* this);
     13void ?{}(gcpointer_t* this, void* address);
     14void ?{}(gcpointer_t* this, gcpointer_t other);
     15void ^?{}(gcpointer_t* this);
     16gcpointer_t* ?=?(gcpointer_t this, gcpointer_t rhs);
    1717
    1818//Logical operators
     
    2727};
    2828
    29 forall(otype T)
    30 static inline void ctor(gcpointer(T)* this)
    31 {
    32         gcpointer_ctor(&this->internal);
    33 }
     29//
     30forall(otype T) void ?{}(gcpointer(T)* this);
     31forall(otype T) void ?{}(gcpointer(T)* this, void* address);
     32forall(otype T) void ctor(gcpointer(T)* this, void* address);
     33forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other);
     34forall(otype T) void ^?{}(gcpointer(T)* this);
     35forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);
    3436
    35 // forall(otype T)
    36 // static inline void ctor(gcpointer(T)* this, int null)
    37 // {
    38 //      gcpointer_ctor(&this->internal, NULL);
    39 // }
    4037
    41 forall(otype T)
    42 static inline void ctor(gcpointer(T)* this, void* address)
    43 {
    44         gcpointer_ctor(&this->internal, address);
    45 }
    46 
    47 forall(otype T)
    48 static inline void ctor(gcpointer(T)* this, gcpointer(T)* other)
    49 {
    50         gcpointer_ctor(&this->internal, other);
    51 }
    52 
    53 forall(otype T)
    54 static inline void dtor(gcpointer(T)* this)
    55 {
    56         gcpointer_dtor(&this->internal);
    57 }
    58 
    59 forall(otype T)
    60 static inline gcpointer(T)* ?=?(gcpointer(T)* this, gcpointer(T)* rhs)
    61 {
    62         gcpointer_assign(&this->internal, &rhs->internal);
    63         return this;
    64 }
    65 
    66 forall(otype T)
    67 static inline T *?(gcpointer(T) this)
    68 {
    69         return *(T*)this.internal.ptr;
    70 }
     38forall(otype T) T *?(gcpointer(T) this);
    7139
    7240//Logical operators
    73 forall(otype T)
    74 static inline int ?!=?(gcpointer(T) this, gcpointer(T) rhs)
    75 {
    76         return this.internal.ptr != rhs.internal.ptr;
    77 }
    78 
    79 forall(otype T)
    80 static inline int ?==?(gcpointer(T) this, gcpointer(T) rhs)
    81 {
    82         return !(this == rhs);
    83 }
    84 
    85 forall(otype T)
    86 extern struct gcpointer(T) 0;
     41forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
     42forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
  • src/examples/gc_no_raii/src/internal/memory_pool.h

    raea7168 rbee4283  
    33extern "C" {
    44#include <stdbool.h>
     5#include <stddef.h>
    56#include <stdint.h>
    67}
  • src/examples/gc_no_raii/src/internal/state.h

    raea7168 rbee4283  
    11#pragma once
    22
     3#ifdef __cforall
     4extern "C" {
     5#endif
    36#include <stddef.h>
    47#include <stdint.h>
     8#ifdef __cforall
     9}
     10#endif
     11#include <vector>
    512
    613#include "tools.h"
    7 #include "vector.h"
    814
    915typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t;
  • src/examples/gc_no_raii/src/tools/worklist.h

    raea7168 rbee4283  
    1010#endif
    1111
    12 #include "vector.h"
     12#include <vector>
    1313
    1414typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t;
  • src/examples/gc_no_raii/test/badlll.c

    raea7168 rbee4283  
    77};
    88
     9void ?{}(List_t* this);
     10List_t* ?=?(List_t* this, List_t* rhs);
     11
    912typedef gcpointer(List_t) LLL;
    1013
    1114#define MAX (1024 * 1024)
    1215
    13 LLL buildLLL(int sz)
     16// LLL buildLLL(int sz)
     17void bla()
    1418{
    1519        int i;
    16         LLL ll0, lll, llc;
    17 
    18         ll0 = gcmalloc();
    19         ll0->val = 0;
    20         lll = ll0;
    21 
    22         for (i = 1; i < sz; i++)
    23         {
    24                 llc = gcmalloc();
    25                 llc->val = i;
    26                 lll->next = llc;
    27                 lll = llc;
    28         }
    29 
    30         return ll0;
     20        // LLL ll0;//, lll, llc;
     21//
     22//      ll0 = gcmalloc();
     23//      ll0->val = 0;
     24//      lll = ll0;
     25//
     26//      for (i = 1; i < sz; i++)
     27//      {
     28//              llc = gcmalloc();
     29//              llc->val = i;
     30//              lll->next = llc;
     31//              lll = llc;
     32//      }
     33//
     34        // return ll0;
    3135}
    32 
    33 void testLLL(LLL lll)
    34 {
    35         unsigned char *counted;
    36 
    37         counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
    38         while (lll)
    39         {
    40                 counted[lll->val]++;
    41                 if (counted[lll->val] > 1)
    42                 {
    43                         fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
    44                         exit(1);
    45                 }
    46                 lll = lll->next;
    47         }
    48 
    49         return;
    50 }
     36//
     37// void testLLL(LLL lll)
     38// {
     39//      unsigned char *counted;
     40//
     41//      counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
     42//      while (lll)
     43//      {
     44//              counted[lll->val]++;
     45//              if (counted[lll->val] > 1)
     46//              {
     47//                      fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
     48//                      exit(1);
     49//              }
     50//              lll = lll->next;
     51//      }
     52//
     53//      return;
     54// }
    5155
    5256int main(void)
     
    5458        LLL mylll;
    5559
    56         mylll = buildLLL(MAX);
    57 
    58         testLLL(mylll);
     60        // mylll = buildLLL(MAX);
     61        //
     62        // testLLL(mylll);
    5963
    6064        return 0;
  • src/examples/gc_no_raii/test/gctest.c

    raea7168 rbee4283  
    77int main() {
    88        sout | "Bonjour au monde!\n";
     9
     10        gcpointer(int) anInt = gcmalloc();
    911}
Note: See TracChangeset for help on using the changeset viewer.