diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-11-26 14:14:45 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-11-26 14:14:45 +0000 |
commit | d35973cb47a75034dbbb64e9b0a91fcb4cc971d6 (patch) | |
tree | 89f02766f5cdfa59aab4b035851ff24acebe68f6 /trace_parser.hpp | |
parent | 44d2764149bf3c37f047bb267f216bdce9e16b43 (diff) |
More efficient bitmask representation.
Diffstat (limited to 'trace_parser.hpp')
-rw-r--r-- | trace_parser.hpp | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/trace_parser.hpp b/trace_parser.hpp index 850dc8d..b77fc3e 100644 --- a/trace_parser.hpp +++ b/trace_parser.hpp @@ -56,6 +56,9 @@ protected: typedef std::map<unsigned, Call *> callmap; callmap calls; + typedef std::map<size_t, Bitmask::Signature *> BitmaskMap; + BitmaskMap bitmasks; + unsigned next_call_no; public: @@ -235,30 +238,26 @@ public: } Value *parse_bitmask() { - unsigned long long value = 0; - int c; - do { - c = read_byte(); - switch(c) { - case Trace::TYPE_SINT: - value |= -(signed long long)read_uint(); - break; - case Trace::TYPE_UINT: - value |= read_uint(); - break; - case Trace::TYPE_CONST: - read_name(); - break; - case Trace::TYPE_NULL: - goto done; - default: - std::cerr << "error: uexpected type " << c << "\n"; - assert(0); - return NULL; - } - } while(true); -done: - return new UInt(value); + size_t id = read_uint(); + Bitmask::Signature *sig; + BitmaskMap::const_iterator it = bitmasks.find(id); + if (it == bitmasks.end()) { + size_t size = read_uint(); + sig = new Bitmask::Signature(size); + for (Bitmask::Signature::iterator it = sig->begin(); it != sig->end(); ++it) { + it->first = read_string(); + it->second = read_uint(); + assert(it->second); + } + bitmasks[id] = sig; + } else { + sig = it->second; + } + assert(sig); + + unsigned long long value = read_uint(); + + return new Bitmask(sig, value); } Value *parse_array(void) { |