Changeset 000ff2c for doc/papers/general/evaluation
- Timestamp:
- Mar 2, 2018, 6:22:52 PM (7 years ago)
- 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:
- 2097cd4, 82c367d
- Parents:
- 938dd75 (diff), c9b3a41 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- doc/papers/general/evaluation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/evaluation/cfa-bench.c
r938dd75 r000ff2c 1 #include <stdio.h> 1 #include <fstream> 2 #include <stdlib> 2 3 #include "bench.h" 3 4 #include "cfa-stack.h" … … 5 6 #include "cfa-print.h" 6 7 7 int main( int argc, char * argv[] ) {8 FILE * out = fopen( "/dev/null", "w" );9 int max i = 0, vali= 42;10 stack( int) si, ti;8 int main( int argc, char * argv[] ) { 9 ofstream out = { "/dev/null" }; 10 int max = 0, val = 42; 11 stack( int ) si, t; 11 12 12 REPEAT_TIMED( "push_int", N, push( si, val i); )13 TIMED( "copy_int", t i= si; )13 REPEAT_TIMED( "push_int", N, push( si, val ); ) 14 TIMED( "copy_int", t = si; ) 14 15 TIMED( "clear_int", clear( si ); ) 15 REPEAT_TIMED( "pop_int", N, 16 int xi = pop( ti ); 17 if ( xi > maxi ) { maxi = xi; } ) 18 REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); ) 16 REPEAT_TIMED( "pop_int", N, int x = pop( t ); max = max( x, max ); ) 17 REPEAT_TIMED( "print_int", N/2, out | val | ':' | val | endl; ) 19 18 20 pair( _Bool, char) maxp = { (_Bool)0, '\0' }, valp= { (_Bool)1, 'a' };21 stack( pair(_Bool, char)) sp, tp;19 pair( _Bool, char ) max = { (_Bool)0, '\0' }, val = { (_Bool)1, 'a' }; 20 stack( pair( _Bool, char ) ) s, t; 22 21 23 REPEAT_TIMED( "push_pair", N, push( sp, valp ); ) 24 TIMED( "copy_pair", tp = sp; ) 25 TIMED( "clear_pair", clear( sp ); ) 26 REPEAT_TIMED( "pop_pair", N, 27 pair(_Bool, char) xp = pop( tp ); 28 if ( xp > maxp ) { maxp = xp; } ) 29 REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); ) 30 fclose(out); 22 REPEAT_TIMED( "push_pair", N, push( s, val ); ) 23 TIMED( "copy_pair", t = s; ) 24 TIMED( "clear_pair", clear( s ); ) 25 REPEAT_TIMED( "pop_pair", N, pair(_Bool, char) x = pop( t ); max = max( x, max ); ) 26 REPEAT_TIMED( "print_pair", N/2, out | val | ':' | val | endl; ) 31 27 } -
doc/papers/general/evaluation/cfa-pair.c
r938dd75 r000ff2c 1 1 #include "cfa-pair.h" 2 #include "fstream" 2 3 3 forall(otype R, otype S 4 forall(otype R, otype S 4 5 | { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); }) 5 6 int ?<?(pair(R, S) p, pair(R, S) q) { … … 7 8 } 8 9 9 forall(otype R, otype S 10 forall(otype R, otype S 10 11 | { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); }) 11 12 int ?<=?(pair(R, S) p, pair(R, S) q) { … … 23 24 } 24 25 25 forall(otype R, otype S 26 forall(otype R, otype S 26 27 | { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); }) 27 28 int ?>?(pair(R, S) p, pair(R, S) q) { … … 29 30 } 30 31 31 forall(otype R, otype S 32 forall(otype R, otype S 32 33 | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); }) 33 34 int ?>=?(pair(R, S) p, pair(R, S) q) { 34 35 return p.first > q.first || ( p.first == q.first && p.second >= q.second ); 35 36 } 37 38 forall(otype R, otype S) 39 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S ); }) 40 ostype & ?|?( ostype & os, pair(R, S) p ) { 41 return os | '[' | p.first | ',' | p.second | ']'; 42 } // ?|? -
doc/papers/general/evaluation/cfa-pair.h
r938dd75 r000ff2c 1 1 #pragma once 2 3 #include "iostream" 2 4 3 5 forall(otype R, otype S) struct pair { … … 27 29 | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); }) 28 30 int ?>=?(pair(R, S) p, pair(R, S) q); 31 32 forall(otype R, otype S) 33 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, pair(R, S) ); }) 34 ostype & ?|?( ostype & os, pair(R, S) ); -
doc/papers/general/evaluation/cfa-stack.c
r938dd75 r000ff2c 4 4 forall(otype T) struct stack_node { 5 5 T value; 6 stack_node(T) * next;6 stack_node(T) * next; 7 7 }; 8 forall(otype T) void ?{}( stack_node(T) & node, T value, stack_node(T) * next ) { 9 node.value = value; 10 node.next = next; 11 } 8 12 9 forall(otype T) void ?{}( stack(T)& s) { (s.head){ 0 }; }13 forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; } 10 14 11 forall(otype T) void ?{}( stack(T)& s, stack(T) t) {12 stack_node(T) ** crnt = &s.head;13 for ( stack_node(T) * next = t.head; next; next = next->next ) {14 // *crnt = &(*(stack_node(T)*)malloc()){ next->value }; /***/15 forall(otype T) void ?{}( stack(T) & s, stack(T) t ) { 16 stack_node(T) ** crnt = &s.head; 17 for ( stack_node(T) * next = t.head; next; next = next->next ) { 18 // *crnt = new( next->value, 0 ); 15 19 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 16 20 (*new_node){ next->value }; /***/ 17 21 *crnt = new_node; 18 19 stack_node(T)* acrnt = *crnt; 22 stack_node(T) * acrnt = *crnt; 20 23 crnt = &acrnt->next; 21 24 } … … 23 26 } 24 27 25 forall(otype T) stack(T) ?=?( stack(T)& s, stack(T) t) {28 forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) { 26 29 if ( s.head == t.head ) return s; 27 clear( s);30 clear( s ); 28 31 s{ t }; 29 32 return s; 30 33 } 31 34 32 forall(otype T) void ^?{}( stack(T)& s) { clear(s); }35 forall(otype T) void ^?{}( stack(T) & s) { clear( s ); } 33 36 34 forall(otype T) _Bool empty( const stack(T)& s) { return s.head == 0; }37 forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; } 35 38 36 forall(otype T) void push( stack(T)& s, T value) {37 // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/39 forall(otype T) void push( stack(T) & s, T value ) { 40 // s.head = new( value, s.head ); 38 41 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 39 42 (*new_node){ value, s.head }; /***/ … … 41 44 } 42 45 43 forall(otype T) T pop( stack(T)& s) {44 stack_node(T) * n = s.head;46 forall(otype T) T pop( stack(T) & s ) { 47 stack_node(T) * n = s.head; 45 48 s.head = n->next; 46 T x = n->value; 47 ^n{}; 48 free(n); 49 return x; 49 T v = n->value; 50 delete( n ); 51 return v; 50 52 } 51 53 52 forall(otype T) void clear( stack(T)& s) {53 for ( stack_node(T)* next = s.head; next; ) {54 stack_node(T) * crnt = next;54 forall(otype T) void clear( stack(T) & s ) { 55 for ( stack_node(T) * next = s.head; next; ) { 56 stack_node(T) * crnt = next; 55 57 next = crnt->next; 56 delete( crnt);58 delete( crnt ); 57 59 } 58 60 s.head = 0; -
doc/papers/general/evaluation/cfa-stack.h
r938dd75 r000ff2c 3 3 forall(otype T) struct stack_node; 4 4 forall(otype T) struct stack { 5 stack_node(T) * head;5 stack_node(T) * head; 6 6 }; 7 7 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);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); 12 12 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);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 );
Note: See TracChangeset
for help on using the changeset viewer.