@@ -83,28 +83,35 @@ namespace rubinius {
83
83
return k;
84
84
}
85
85
86
- size_t SymbolTable::add (std::string str, int enc) {
87
- bytes_used_ += (str.size () + sizeof (std::string) + sizeof (int ) + sizeof (Kind));
86
+ size_t SymbolTable::add (STATE, std::string str, int enc) {
87
+ size_t bytes = (str.size () + sizeof (std::string) + sizeof (int ) + sizeof (Kind));
88
+ bytes_used_ += bytes;
88
89
89
90
strings.push_back (str);
90
91
encodings.push_back (enc);
91
92
kinds.push_back (eUnknown);
93
+
94
+ state->vm ()->metrics ().memory .symbols ++;
95
+ state->vm ()->metrics ().memory .symbols_bytes += bytes;
96
+
92
97
return strings.size () - 1 ;
93
98
}
94
99
95
100
Symbol* SymbolTable::lookup (STATE, const char * str, size_t length) {
96
- return lookup (str, length, Encoding::eAscii, state->hash_seed ());
101
+ return lookup (state, str, length, Encoding::eAscii, state->hash_seed ());
97
102
}
98
103
99
- Symbol* SymbolTable::lookup (SharedState* shared, const std::string& str) {
100
- return lookup (str.data (), str.size (), Encoding::eAscii, shared->hash_seed );
104
+ Symbol* SymbolTable::lookup (STATE, SharedState* shared, const std::string& str) {
105
+ return lookup (state, str.data (), str.size (), Encoding::eAscii, shared->hash_seed );
101
106
}
102
107
103
108
Symbol* SymbolTable::lookup (STATE, const std::string& str) {
104
- return lookup (str.data (), str.size (), Encoding::eAscii, state->hash_seed ());
109
+ return lookup (state, str.data (), str.size (), Encoding::eAscii, state->hash_seed ());
105
110
}
106
111
107
- Symbol* SymbolTable::lookup (const char * str, size_t length, int enc, uint32_t seed) {
112
+ Symbol* SymbolTable::lookup (STATE, const char * str, size_t length,
113
+ int enc, uint32_t seed)
114
+ {
108
115
size_t sym;
109
116
110
117
hashval hash = String::hash_str ((unsigned char *)str, length, seed);
@@ -115,7 +122,7 @@ namespace rubinius {
115
122
utilities::thread::SpinLock::LockGuard guard (lock_);
116
123
SymbolMap::iterator entry = symbols.find (hash);
117
124
if (entry == symbols.end ()) {
118
- sym = add (std::string (str, length), enc);
125
+ sym = add (state, std::string (str, length), enc);
119
126
SymbolIds v (1 , sym);
120
127
symbols[hash] = v;
121
128
} else {
@@ -126,7 +133,7 @@ namespace rubinius {
126
133
127
134
if (!strncmp (s.data (), str, length) && e == enc) return Symbol::from_index (*i);
128
135
}
129
- sym = add (std::string (str, length), enc);
136
+ sym = add (state, std::string (str, length), enc);
130
137
v.push_back (sym);
131
138
}
132
139
}
@@ -150,7 +157,7 @@ namespace rubinius {
150
157
if (CBOOL (str->ascii_only_p (state))) {
151
158
enc = Encoding::eAscii;
152
159
}
153
- return lookup (bytes, size, enc, state->hash_seed ());
160
+ return lookup (state, bytes, size, enc, state->hash_seed ());
154
161
}
155
162
156
163
String* SymbolTable::lookup_string (STATE, const Symbol* sym) {
0 commit comments