| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SCOPEINFO_H_ | 5 #ifndef V8_SCOPEINFO_H_ |
| 6 #define V8_SCOPEINFO_H_ | 6 #define V8_SCOPEINFO_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "variables.h" | 9 #include "variables.h" |
| 10 #include "zone-inl.h" | 10 #include "zone-inl.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 // Cache for mapping (data, property name) into context slot index. | 15 // Cache for mapping (data, property name) into context slot index. |
| 16 // The cache contains both positive and negative results. | 16 // The cache contains both positive and negative results. |
| 17 // Slot index equals -1 means the property is absent. | 17 // Slot index equals -1 means the property is absent. |
| 18 // Cleared at startup and prior to mark sweep collection. | 18 // Cleared at startup and prior to mark sweep collection. |
| 19 class ContextSlotCache { | 19 class ContextSlotCache { |
| 20 public: | 20 public: |
| 21 // Lookup context slot index for (data, name). | 21 // Lookup context slot index for (data, name). |
| 22 // If absent, kNotFound is returned. | 22 // If absent, kNotFound is returned. |
| 23 int Lookup(Object* data, | 23 int Lookup(Object* data, |
| 24 String* name, | 24 String* name, |
| 25 VariableMode* mode, | 25 VariableMode* mode, |
| 26 InitializationFlag* init_flag); | 26 InitializationFlag* init_flag); |
| 27 | 27 |
| 28 // Update an element in the cache. | 28 // Update an element in the cache. |
| 29 void Update(Object* data, | 29 void Update(Handle<Object> data, |
| 30 String* name, | 30 Handle<String> name, |
| 31 VariableMode mode, | 31 VariableMode mode, |
| 32 InitializationFlag init_flag, | 32 InitializationFlag init_flag, |
| 33 int slot_index); | 33 int slot_index); |
| 34 | 34 |
| 35 // Clear the cache. | 35 // Clear the cache. |
| 36 void Clear(); | 36 void Clear(); |
| 37 | 37 |
| 38 static const int kNotFound = -2; | 38 static const int kNotFound = -2; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 ContextSlotCache() { | 41 ContextSlotCache() { |
| 42 for (int i = 0; i < kLength; ++i) { | 42 for (int i = 0; i < kLength; ++i) { |
| 43 keys_[i].data = NULL; | 43 keys_[i].data = NULL; |
| 44 keys_[i].name = NULL; | 44 keys_[i].name = NULL; |
| 45 values_[i] = kNotFound; | 45 values_[i] = kNotFound; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 inline static int Hash(Object* data, String* name); | 49 inline static int Hash(Object* data, String* name); |
| 50 | 50 |
| 51 #ifdef DEBUG | 51 #ifdef DEBUG |
| 52 void ValidateEntry(Object* data, | 52 void ValidateEntry(Handle<Object> data, |
| 53 String* name, | 53 Handle<String> name, |
| 54 VariableMode mode, | 54 VariableMode mode, |
| 55 InitializationFlag init_flag, | 55 InitializationFlag init_flag, |
| 56 int slot_index); | 56 int slot_index); |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 static const int kLength = 256; | 59 static const int kLength = 256; |
| 60 struct Key { | 60 struct Key { |
| 61 Object* data; | 61 Object* data; |
| 62 String* name; | 62 String* name; |
| 63 }; | 63 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 void set_index(int i, int index) { | 165 void set_index(int i, int index) { |
| 166 set(index_offset(i), Smi::FromInt(index)); | 166 set(index_offset(i), Smi::FromInt(index)); |
| 167 } | 167 } |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 | 170 |
| 171 } } // namespace v8::internal | 171 } } // namespace v8::internal |
| 172 | 172 |
| 173 #endif // V8_SCOPEINFO_H_ | 173 #endif // V8_SCOPEINFO_H_ |
| OLD | NEW |