Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_INTERN_TABLE_H_ |
| 4 | #define ART_SRC_INTERN_TABLE_H_ |
| 5 | |
| 6 | #include "unordered_map.h" |
| 7 | |
| 8 | #include "heap.h" |
| 9 | #include "object.h" |
| 10 | |
| 11 | namespace art { |
| 12 | |
| 13 | class InternTable { |
| 14 | public: |
| 15 | InternTable(); |
Elliott Hughes | de69d7f | 2011-08-18 16:49:37 -0700 | [diff] [blame] | 16 | ~InternTable(); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 17 | |
| 18 | // intern a potentially new string |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 19 | String* Intern(int32_t utf16_length, const char* utf8_data); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 20 | |
| 21 | // register a String trusting that it is safe to intern. |
| 22 | // used when reinitializing InternTable from an image. |
| 23 | void Register(String* string); |
| 24 | |
| 25 | size_t Size() const; |
| 26 | void VisitRoots(Heap::RootVistor* root_visitor, void* arg) const; |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 27 | |
| 28 | private: |
| 29 | typedef std::tr1::unordered_multimap<int32_t, String*> Table; |
| 30 | Table intern_table_; |
| 31 | Mutex* intern_table_lock_; |
| 32 | }; |
| 33 | |
| 34 | } // namespace art |
| 35 | |
| 36 | #endif // ART_SRC_CLASS_LINKER_H_ |