blob: 46e0e0553f903ca9ef98ce20d4026b8c9293ee55 [file] [log] [blame]
Brian Carlstrom7e93b502011-08-04 14:16:22 -07001// 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
11namespace art {
12
13class InternTable {
14 public:
15 InternTable();
Elliott Hughesde69d7f2011-08-18 16:49:37 -070016 ~InternTable();
Brian Carlstroma663ea52011-08-19 23:33:41 -070017
18 // intern a potentially new string
Brian Carlstrom7e93b502011-08-04 14:16:22 -070019 String* Intern(int32_t utf16_length, const char* utf8_data);
Brian Carlstroma663ea52011-08-19 23:33:41 -070020
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 Carlstrom7e93b502011-08-04 14:16:22 -070027
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_