Changeset 1270 for proto


Ignore:
Timestamp:
Aug 3, 2011, 5:15:51 PM (8 years ago)
Author:
vla24
Message:

SymbolTable?: Changed hash table memory allocation. Previously we pre-allocated the memory, now we allocate the memory as we need.

Location:
proto/SymbolTable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/SymbolTable/symtab_hash_template.cpp

    r1228 r1270  
    5353char * source;
    5454LineColTracker tracker;
     55
     56static inline void ReportError(const char * error_msg, int error_pos_in_block) {
     57  int error_line, error_column;
     58  tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
     59  fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
     60}
     61
     62class ErrorTracker {
     63public:
     64    ErrorTracker() { noted_pos_in_block = -1;}
     65
     66    inline void NoteError(const char * error_msg, BitBlock err_strm) {
     67      int pos_in_block = count_forward_zeroes(err_strm);
     68      if ((noted_pos_in_block == -1) || (noted_pos_in_block > pos_in_block)) {
     69        noted_pos_in_block = pos_in_block;
     70        noted_error = error_msg;
     71      }
     72    }
     73
     74    inline void If_Error_Report_First() {
     75      if (noted_pos_in_block > -1) {
     76              int error_line, error_column;
     77              ReportError(noted_error, noted_pos_in_block);
     78              exit(-1);
     79      }
     80    }
     81
     82private:
     83  const char * noted_error;
     84  int noted_pos_in_block;
     85};
     86
     87
    5588TagMatcher matcher;
    5689BitBlock EOF_mask = simd_const_1(1);
     90
     91ErrorTracker error_tracker;
    5792
    5893queue <size_t> elem_starts_buf;
     
    74109        }
    75110        return 0;
    76 }
    77 
    78 
    79 static inline void ReportError(const char * error_msg, int error_pos_in_block) {
    80   int error_line, error_column;
    81   tracker.get_Line_and_Column(error_pos_in_block, error_line, error_column);
    82   fprintf(stderr, "%s at line %i, column %i\n", error_msg, error_line, error_column);
    83111}
    84112
     
    320348                }
    321349
    322                 if (bitblock_has_bit(check_streams.error_mask)) {
    323                   int errpos = count_forward_zeroes(check_streams.error_mask);
    324                   ReportError("error found", errpos);
    325               exit(-1);
    326                 }
    327 
    328                 matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     350                error_tracker.If_Error_Report_First();
     351
     352                matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
    329353                tracker.AdvanceBlock();
    330354}
  • proto/SymbolTable/symtab_pbgs_log_template.cpp

    r1232 r1270  
    22#define TEMPLATED_SIMD_LIB
    33
    4 #define USE_MASK_COMPARE    //Comparison using masking technique.
     4//#define USE_MASK_COMPARE    //Comparison using masking technique.
    55
    66#define DEBUG 0
Note: See TracChangeset for help on using the changeset viewer.