Changeset 986dd36


Ignore:
Timestamp:
Mar 2, 2018, 5:34:51 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
dd05e12
Parents:
244b934
git-author:
Rob Schluntz <rschlunt@…> (03/02/18 09:47:18)
git-committer:
Rob Schluntz <rschlunt@…> (03/02/18 17:34:51)
Message:

Update CFA evaluation code

Location:
doc/papers/general/evaluation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/general/evaluation/cfa-bench.c

    r244b934 r986dd36  
    1010        stack(int) si, ti;
    1111
    12         REPEAT_TIMED( "push_int", N, push( &si, vali ); )
     12        REPEAT_TIMED( "push_int", N, push( si, vali ); )
    1313        TIMED( "copy_int", ti = si; )
    14         TIMED( "clear_int", clear( &si ); )
    15         REPEAT_TIMED( "pop_int", N, 
    16                 int xi = pop( &ti );
     14        TIMED( "clear_int", clear( si ); )
     15        REPEAT_TIMED( "pop_int", N,
     16                int xi = pop( ti );
    1717                if ( xi > maxi ) { maxi = xi; } )
    1818        REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); )
     
    2121        stack(pair(_Bool, char)) sp, tp;
    2222
    23         REPEAT_TIMED( "push_pair", N, push( &sp, valp ); )
     23        REPEAT_TIMED( "push_pair", N, push( sp, valp ); )
    2424        TIMED( "copy_pair", tp = sp; )
    25         TIMED( "clear_pair", clear( &sp ); )
    26         REPEAT_TIMED( "pop_pair", N, 
    27                 pair(_Bool, char) xp = pop( &tp );
     25        TIMED( "clear_pair", clear( sp ); )
     26        REPEAT_TIMED( "pop_pair", N,
     27                pair(_Bool, char) xp = pop( tp );
    2828                if ( xp > maxp ) { maxp = xp; } )
    2929        REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); )
  • doc/papers/general/evaluation/cfa-stack.c

    r244b934 r986dd36  
    77};
    88
    9 forall(otype T) void ?{}(stack(T)* s) { (&s->head){ 0 }; }
     9forall(otype T) void ?{}(stack(T)& s) { (s.head){ 0 }; }
    1010
    11 forall(otype T) void ?{}(stack(T)* s, stack(T) t) {
    12         stack_node(T)** crnt = &s->head;
     11forall(otype T) void ?{}(stack(T)& s, stack(T) t) {
     12        stack_node(T)** crnt = &s.head;
    1313        for ( stack_node(T)* next = t.head; next; next = next->next ) {
    14                 *crnt = ((stack_node(T)*)malloc()){ next->value }; /***/
     14                // *crnt = &(*(stack_node(T)*)malloc()){ next->value }; /***/
     15                stack_node(T)* new_node = ((stack_node(T)*)malloc());
     16                (*new_node){ next->value }; /***/
     17                *crnt = new_node;
     18
    1519                stack_node(T)* acrnt = *crnt;
    1620                crnt = &acrnt->next;
     
    1923}
    2024
    21 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) {
    22         if ( s->head == t.head ) return *s;
     25forall(otype T) stack(T) ?=?(stack(T)& s, stack(T) t) {
     26        if ( s.head == t.head ) return s;
    2327        clear(s);
    2428        s{ t };
    25         return *s;
     29        return s;
    2630}
    2731
    28 forall(otype T) void ^?{}(stack(T)* s) { clear(s); }
     32forall(otype T) void ^?{}(stack(T)& s) { clear(s); }
    2933
    30 forall(otype T) _Bool empty(const stack(T)* s) { return s->head == 0; }
     34forall(otype T) _Bool empty(const stack(T)& s) { return s.head == 0; }
    3135
    32 forall(otype T) void push(stack(T)* s, T value) {
    33         s->head = ((stack_node(T)*)malloc()){ value, s->head }; /***/
     36forall(otype T) void push(stack(T)& s, T value) {
     37        // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/
     38        stack_node(T)* new_node = ((stack_node(T)*)malloc());
     39        (*new_node){ value, s.head }; /***/
     40        s.head = new_node;
    3441}
    3542
    36 forall(otype T) T pop(stack(T)* s) {
    37         stack_node(T)* n = s->head;
    38         s->head = n->next;
     43forall(otype T) T pop(stack(T)& s) {
     44        stack_node(T)* n = s.head;
     45        s.head = n->next;
    3946        T x = n->value;
    4047        ^n{};
     
    4350}
    4451
    45 forall(otype T) void clear(stack(T)* s) {
    46     for ( stack_node(T)* next = s->head; next; ) {
     52forall(otype T) void clear(stack(T)& s) {
     53    for ( stack_node(T)* next = s.head; next; ) {
    4754                stack_node(T)* crnt = next;
    4855                next = crnt->next;
    4956                delete(crnt);
    5057        }
    51         s->head = 0;
     58        s.head = 0;
    5259}
  • doc/papers/general/evaluation/cfa-stack.h

    r244b934 r986dd36  
    66};
    77
    8 forall(otype T) void ?{}(stack(T)* s);
    9 forall(otype T) void ?{}(stack(T)* s, stack(T) t);
    10 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t);
    11 forall(otype T) void ^?{}(stack(T)* s);
     8forall(otype T) void ?{}(stack(T)& s);
     9forall(otype T) void ?{}(stack(T)& s, stack(T) t);
     10forall(otype T) stack(T) ?=?(stack(T)& s, stack(T) t);
     11forall(otype T) void ^?{}(stack(T)& s);
    1212
    13 forall(otype T) _Bool empty(const stack(T)* s);
    14 forall(otype T) void push(stack(T)* s, T value);
    15 forall(otype T) T pop(stack(T)* s);
    16 forall(otype T) void clear(stack(T)* s);
     13forall(otype T) _Bool empty(const stack(T)& s);
     14forall(otype T) void push(stack(T)& s, T value);
     15forall(otype T) T pop(stack(T)& s);
     16forall(otype T) void clear(stack(T)& s);
Note: See TracChangeset for help on using the changeset viewer.