Chromium Code Reviews| 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 // Cache for mapping (code, property name) into context slot index. | |
| 167 // The cache contains both positive and negative results. | |
| 168 // slot index -1 means the property is absent. | |
|
Mads Ager (chromium)
2009/06/22 08:00:18
Capitalize 'Slot'?
| |
| 169 // Cleared at startup and prior to mark sweep collection. | |
| 170 class ContextSlotCache { | |
| 171 public: | |
| 172 // Lookup context slot index for (code, name). | |
| 173 // If absent, kNotFound is returned. | |
| 174 static int Lookup(Code* code, | |
| 175 String* name, | |
| 176 Variable::Mode* mode); | |
| 177 | |
| 178 // Update an element in the cache. | |
| 179 static void Update(Code* code, | |
| 180 String* name, | |
| 181 Variable::Mode mode, | |
| 182 int slot_index); | |
| 183 | |
| 184 // Clear the cache. | |
| 185 static void Clear(); | |
| 186 | |
| 187 static const int kNotFound = -2; | |
| 188 private: | |
| 189 inline static int Hash(Code* code, String* name); | |
| 190 | |
| 191 #ifdef DEBUG | |
| 192 // Checks whether an entry is valid. | |
| 193 static void Check(Code* code, | |
|
Mads Ager (chromium)
2009/06/22 08:00:18
Use a more telling name such as 'IsValidEntry'?
| |
| 194 String* name, | |
| 195 Variable::Mode mode, | |
| 196 int slot_index); | |
| 197 #endif | |
| 198 | |
| 199 static const int kLength = 256; | |
| 200 struct Key { | |
| 201 Code* code; | |
| 202 String* name; | |
| 203 }; | |
| 204 | |
| 205 struct Value { | |
| 206 Value(Variable::Mode mode, int index) { | |
| 207 ASSERT(ModeField::is_valid(mode)); | |
| 208 ASSERT(IndexField::is_valid(index)); | |
| 209 value_ = ModeField::encode(mode) | IndexField::encode(index); | |
| 210 ASSERT(mode == this->mode()); | |
| 211 ASSERT(index == this->index()); | |
| 212 } | |
| 213 | |
| 214 inline Value(uint32_t value) : value_(value) {} | |
| 215 | |
| 216 uint32_t raw() { return value_; } | |
| 217 | |
| 218 Variable::Mode mode() { return ModeField::decode(value_); } | |
| 219 | |
| 220 int index() { return IndexField::decode(value_); } | |
| 221 | |
| 222 // Bit fields in value_ (type, shift, size). Must be public so the | |
| 223 // constants can be embedded in generated code. | |
| 224 class ModeField: public BitField<Variable::Mode, 0, 3> {}; | |
| 225 class IndexField: public BitField<int, 3, 32-3> {}; | |
| 226 private: | |
| 227 uint32_t value_; | |
| 228 }; | |
| 229 | |
| 230 static Key keys_[kLength]; | |
| 231 static uint32_t values_[kLength]; | |
| 232 }; | |
| 233 | |
| 234 | |
| 166 } } // namespace v8::internal | 235 } } // namespace v8::internal |
| 167 | 236 |
| 168 #endif // V8_SCOPEINFO_H_ | 237 #endif // V8_SCOPEINFO_H_ |
| OLD | NEW |