OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Create a ZoneScopeInfo instance from a scope. | 156 // Create a ZoneScopeInfo instance from a scope. |
157 explicit ZoneScopeInfo(Scope* scope) | 157 explicit ZoneScopeInfo(Scope* scope) |
158 : ScopeInfo<ZoneListAllocationPolicy>(scope) {} | 158 : ScopeInfo<ZoneListAllocationPolicy>(scope) {} |
159 | 159 |
160 // Create a ZoneScopeInfo instance from a Code object. | 160 // Create a ZoneScopeInfo instance from a Code object. |
161 explicit ZoneScopeInfo(Code* code) | 161 explicit ZoneScopeInfo(Code* code) |
162 : ScopeInfo<ZoneListAllocationPolicy>(code) {} | 162 : ScopeInfo<ZoneListAllocationPolicy>(code) {} |
163 }; | 163 }; |
164 | 164 |
165 | 165 |
| 166 class ContextSlotCacheData { |
| 167 static const int kLength = 256; |
| 168 struct Key { |
| 169 Code* code; |
| 170 String* name; |
| 171 }; |
| 172 |
| 173 Key keys_[kLength]; |
| 174 uint32_t values_[kLength]; |
| 175 |
| 176 friend class V8Context; |
| 177 friend class ContextSlotCache; |
| 178 |
| 179 ContextSlotCacheData(); |
| 180 DISALLOW_COPY_AND_ASSIGN(ContextSlotCacheData); |
| 181 }; |
| 182 |
166 // Cache for mapping (code, property name) into context slot index. | 183 // Cache for mapping (code, property name) into context slot index. |
167 // The cache contains both positive and negative results. | 184 // The cache contains both positive and negative results. |
168 // Slot index equals -1 means the property is absent. | 185 // Slot index equals -1 means the property is absent. |
169 // Cleared at startup and prior to mark sweep collection. | 186 // Cleared at startup and prior to mark sweep collection. |
170 class ContextSlotCache { | 187 class ContextSlotCache { |
171 public: | 188 public: |
172 // Lookup context slot index for (code, name). | 189 // Lookup context slot index for (code, name). |
173 // If absent, kNotFound is returned. | 190 // If absent, kNotFound is returned. |
174 static int Lookup(Code* code, | 191 static int Lookup(Code* code, |
175 String* name, | 192 String* name, |
(...skipping 12 matching lines...) Expand all Loading... |
188 private: | 205 private: |
189 inline static int Hash(Code* code, String* name); | 206 inline static int Hash(Code* code, String* name); |
190 | 207 |
191 #ifdef DEBUG | 208 #ifdef DEBUG |
192 static void ValidateEntry(Code* code, | 209 static void ValidateEntry(Code* code, |
193 String* name, | 210 String* name, |
194 Variable::Mode mode, | 211 Variable::Mode mode, |
195 int slot_index); | 212 int slot_index); |
196 #endif | 213 #endif |
197 | 214 |
198 static const int kLength = 256; | |
199 struct Key { | |
200 Code* code; | |
201 String* name; | |
202 }; | |
203 | |
204 struct Value { | 215 struct Value { |
205 Value(Variable::Mode mode, int index) { | 216 Value(Variable::Mode mode, int index) { |
206 ASSERT(ModeField::is_valid(mode)); | 217 ASSERT(ModeField::is_valid(mode)); |
207 ASSERT(IndexField::is_valid(index)); | 218 ASSERT(IndexField::is_valid(index)); |
208 value_ = ModeField::encode(mode) | IndexField::encode(index); | 219 value_ = ModeField::encode(mode) | IndexField::encode(index); |
209 ASSERT(mode == this->mode()); | 220 ASSERT(mode == this->mode()); |
210 ASSERT(index == this->index()); | 221 ASSERT(index == this->index()); |
211 } | 222 } |
212 | 223 |
213 inline Value(uint32_t value) : value_(value) {} | 224 inline Value(uint32_t value) : value_(value) {} |
214 | 225 |
215 uint32_t raw() { return value_; } | 226 uint32_t raw() { return value_; } |
216 | 227 |
217 Variable::Mode mode() { return ModeField::decode(value_); } | 228 Variable::Mode mode() { return ModeField::decode(value_); } |
218 | 229 |
219 int index() { return IndexField::decode(value_); } | 230 int index() { return IndexField::decode(value_); } |
220 | 231 |
221 // Bit fields in value_ (type, shift, size). Must be public so the | 232 // Bit fields in value_ (type, shift, size). Must be public so the |
222 // constants can be embedded in generated code. | 233 // constants can be embedded in generated code. |
223 class ModeField: public BitField<Variable::Mode, 0, 3> {}; | 234 class ModeField: public BitField<Variable::Mode, 0, 3> {}; |
224 class IndexField: public BitField<int, 3, 32-3> {}; | 235 class IndexField: public BitField<int, 3, 32-3> {}; |
225 private: | 236 private: |
226 uint32_t value_; | 237 uint32_t value_; |
227 }; | 238 }; |
228 | |
229 static Key keys_[kLength]; | |
230 static uint32_t values_[kLength]; | |
231 }; | 239 }; |
232 | 240 |
233 | 241 |
234 } } // namespace v8::internal | 242 } } // namespace v8::internal |
235 | 243 |
236 #endif // V8_SCOPEINFO_H_ | 244 #endif // V8_SCOPEINFO_H_ |
OLD | NEW |