Changeset fb2ce27 for doc/papers


Ignore:
Timestamp:
Mar 8, 2018, 1:37:46 PM (4 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
28bc8c8
Parents:
f1f8e55
Message:

Update all benchmarks to match new CFA

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

Legend:

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

    rf1f8e55 rfb2ce27  
    55#include "c-stack.h"
    66
    7 _Bool* new_bool( _Bool b ) {
    8         _Bool* q = malloc(sizeof(_Bool)); /***/
    9         *q = b;
     7char* new_char( char c ) {
     8        char* q = malloc(sizeof(char)); /***/
     9        *q = c;
    1010        return q;
    1111}
    1212
    13 char* new_char( char c ) {
    14         char* q = malloc(sizeof(char)); /***/
    15         *q = c;
     13short* new_short( short s ) {
     14        short* q = malloc(sizeof(short)); /***/
     15        *q = s;
    1616        return q;
    1717}
     
    2323}
    2424
    25 void* copy_bool( const void* p ) { return new_bool( *(const _Bool*)p ); } /***/
    2625void* copy_char( const void* p ) { return new_char( *(const char*)p ); } /***/
     26void* copy_short( const void* p ) { return new_short( *(const short*)p ); } /***/
    2727void* copy_int( const void* p ) { return new_int( *(const int*)p ); } /***/
    28 void* copy_pair_bool_char( const void* p ) { return copy_pair( p, copy_bool, copy_char ); } /***/
    29 void free_pair_bool_char( void* p ) { free_pair( p, free, free ); } /***/
    30 
    31 int cmp_bool( const void* a, const void* b ) { /***/
    32         return *(const _Bool*)a == *(const _Bool*)b ? 0 : *(const _Bool*)a < *(const _Bool*)b ? -1 : 1;
    33 }
     28void* copy_pair_short_char( const void* p ) { return copy_pair( p, copy_short, copy_char ); } /***/
     29void free_pair_short_char( void* p ) { free_pair( p, free, free ); } /***/
    3430
    3531int cmp_char( const void* a, const void* b ) { /***/
    3632        return *(const char*)a == *(const char*)b ? 0 : *(const char*)a < *(const char*)b ? -1 : 1;
     33}
     34
     35int cmp_short( const void* a, const void* b ) { /***/
     36        return *(const short*)a == *(const short*)b ? 0 : *(const short*)a < *(const short*)b ? -1 : 1;
    3737}
    3838
     
    4949                free(xi); )
    5050
    51         struct pair * maxp = new_pair( new_bool(0), new_char('\0') ),
    52                 * valp = new_pair( new_bool(1), new_char('a') );
     51        struct pair * maxp = new_pair( new_short(0), new_char('\0') ),
     52                * valp = new_pair( new_short(42), new_char('a') );
    5353        struct stack sp = new_stack(), tp;
    5454
    55         REPEAT_TIMED( "push_pair", N, push_stack( &sp, copy_pair_bool_char( valp ) ); )
    56         TIMED( "copy_pair", copy_stack( &tp, &sp, copy_pair_bool_char ); /***/ )
    57         TIMED( "clear_pair", clear_stack( &sp, free_pair_bool_char ); /***/ )
     55        REPEAT_TIMED( "push_pair", N, push_stack( &sp, copy_pair_short_char( valp ) ); )
     56        TIMED( "copy_pair", copy_stack( &tp, &sp, copy_pair_short_char ); /***/ )
     57        TIMED( "clear_pair", clear_stack( &sp, free_pair_short_char ); /***/ )
    5858        REPEAT_TIMED( "pop_pair", N,
    5959                struct pair * xp = pop_stack( &tp );
    60                 if ( cmp_pair( xp, maxp, cmp_bool, cmp_char /***/ ) > 0 ) {
    61                         free_pair_bool_char( maxp ); /***/
     60                if ( cmp_pair( xp, maxp, cmp_short, cmp_char /***/ ) > 0 ) {
     61                        free_pair_short_char( maxp ); /***/
    6262                        maxp = xp;
    6363                } else {
    64                         free_pair_bool_char( xp ); /***/
     64                        free_pair_short_char( xp ); /***/
    6565                } )
    66         free_pair_bool_char( maxp ); /***/
    67         free_pair_bool_char( valp ); /***/
     66        free_pair_short_char( maxp ); /***/
     67        free_pair_short_char( valp ); /***/
    6868}
  • doc/papers/general/evaluation/c-stack.c

    rf1f8e55 rfb2ce27  
    1313        for ( struct stack_node* next = t->head; next; next = next->next ) {
    1414                *crnt = malloc(sizeof(struct stack_node)); /***/
    15                 **crnt = (struct stack_node){ copy(next->value) }; /***/
     15                (*crnt)->value = copy(next->value);
    1616                crnt = &(*crnt)->next;
    1717        }
    18         *crnt = 0;
     18        *crnt = NULL;
    1919}
    2020
  • doc/papers/general/evaluation/cfa-stack.c

    rf1f8e55 rfb2ce27  
    3131
    3232forall(otype T) void push( stack(T) & s, T value ) with( s ) {
    33         stack_node(T)* new_node = malloc();
    34         (*new_node){ value, head };
    35         head = new_node;
     33        stack_node(T)* n = malloc();
     34        (*n){ value, head };
     35        head = n;
    3636}
    3737
     
    3939        stack_node(T) * n = head;
    4040        head = n->next;
    41         T v = n->value;
     41        T x = n->value;
    4242        ^(*n){};
    4343        free( n );
    44         return v;
     44        return x;
    4545}
    4646
     
    5252                free(crnt);
    5353        }
    54         s.head = 0;
     54        head = 0;
    5555}
  • doc/papers/general/evaluation/cpp-bench.cpp

    rf1f8e55 rfb2ce27  
    1313        REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop() ); )
    1414
    15         pair<bool, char> maxp = { false, '\0' }, valp = { true, 'a' };
    16         stack<pair<bool, char>> sp, tp;
     15        pair<short, char> maxp = { 0, '\0' }, valp = { 42, 'a' };
     16        stack<pair<short, char>> sp, tp;
    1717       
    1818        REPEAT_TIMED( "push_pair", N, sp.push( valp ); )
  • doc/papers/general/evaluation/cpp-vbench.cpp

    rf1f8e55 rfb2ce27  
    1313        REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop()->as<integer>() ); /***/ )
    1414
    15         ptr<pair> maxp = make<pair>( make<boolean>(false), make<character>('\0') );
    16         pair valp{ make<boolean>(true), make<character>('a') };
     15        ptr<pair> maxp = make<pair>( make<short_integer>(0), make<character>('\0') );
     16        pair valp{ make<short_integer>(42), make<character>('a') };
    1717        stack sp, tp;
    1818       
  • doc/papers/general/evaluation/cpp-vstack.cpp

    rf1f8e55 rfb2ce27  
    77        node** crnt = &head;
    88        for ( node* next = o.head; next; next = next->next ) {
    9                 *crnt = new node{ *next->value };
     9                *crnt = new node{ *next->value }; /***/
    1010                crnt = &(*crnt)->next;
    1111        }
  • doc/papers/general/evaluation/object.hpp

    rf1f8e55 rfb2ce27  
    6767};
    6868
    69 class boolean : public ordered, public printable {
    70         bool x;
    71 public:
    72         boolean() = default;
    73         boolean(bool x) : x(x) {}
    74         boolean(const boolean&) = default;
    75         boolean(boolean&&) = default;
    76         ptr<object> new_inst() const override { return make<boolean>(); }
    77         ptr<object> new_copy() const override { return make<boolean>(*this); }
    78         boolean& operator= (const boolean& that) {
    79                 x = that.x;
    80                 return *this;   
    81         }
    82         object& operator= (const object& that) override { return *this = that.as<boolean>(); } /***/
    83         boolean& operator= (boolean&&) = default;
    84         ~boolean() override = default;
    85 
    86         int cmp(const boolean& that) const { return x == that.x ? 0 : x == false ? -1 : 1; }
    87         int cmp(const ordered& that) const override { return cmp( that.as<boolean>() ); } /***/
    88 
    89         void print(std::ostream& out) const override { out << (x ? "true" : "false"); }
    90 };
    91 
    9269class character : public ordered, public printable {
    9370        char x;
     
    11693};
    11794
     95class short_integer : public ordered, public printable {
     96        short x;
     97public:
     98        short_integer() = default;
     99        short_integer(short x) : x(x) {}
     100        short_integer(const short_integer&) = default;
     101        short_integer(short_integer&&) = default;
     102        ptr<object> new_inst() const override { return make<short_integer>(); }
     103        ptr<object> new_copy() const override { return make<short_integer>(*this); }
     104        short_integer& operator= (const short_integer& that) {
     105                x = that.x;
     106                return *this;   
     107        }
     108        object& operator= (const object& that) override { return *this = that.as<short_integer>(); } /***/
     109        short_integer& operator= (short_integer&&) = default;
     110        ~short_integer() override = default;
     111
     112        int cmp(const short_integer& that) const { return x == that.x ? 0 : x < that.x ? -1 : 1; }
     113        int cmp(const ordered& that) const override { return cmp( that.as<short_integer>() ); } /***/
     114
     115        void print(std::ostream& out) const override { out << x; }
     116};
     117
    118118class integer : public ordered, public printable {
    119119        int x;
     
    137137
    138138        void print(std::ostream& out) const override { out << x; }
    139 };
    140 
    141 class c_string : public printable {
    142         static constexpr const char* empty = "";
    143         const char* s;
    144 public:
    145         c_string() : s(empty) {}
    146         c_string(const char* s) : s(s) {}
    147         c_string(const c_string&) = default;
    148         c_string(c_string&&) = default;
    149         ptr<object> new_inst() const override { return make<c_string>(); }
    150         ptr<object> new_copy() const override { return make<c_string>(s); }
    151         c_string& operator= (const c_string& that) {
    152                 s = that.s;
    153                 return *this;
    154         }
    155         object& operator= (const object& that) override { return *this = that.as<c_string>(); } /***/
    156         c_string& operator= (c_string&&) = default;
    157         ~c_string() override = default;
    158 
    159         void print(std::ostream& out) const override { out << s; }
    160139};
    161140
     
    188167                return y->as<ordered>().cmp( that.y->as<ordered>() ); /***/
    189168        }
    190         int cmp(const ordered& that) const override { return cmp( that.as<pair>() ); }
     169        int cmp(const ordered& that) const override { return cmp( that.as<pair>() ); } /***/
    191170
    192171        void print(std::ostream& out) const override {
Note: See TracChangeset for help on using the changeset viewer.