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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 // Lookup field offset for (map, name). If absent, -1 is returned. | 1141 // Lookup field offset for (map, name). If absent, -1 is returned. |
1142 static int Lookup(Map* map, String* name); | 1142 static int Lookup(Map* map, String* name); |
1143 | 1143 |
1144 // Update an element in the cache. | 1144 // Update an element in the cache. |
1145 static void Update(Map* map, String* name, int field_offset); | 1145 static void Update(Map* map, String* name, int field_offset); |
1146 | 1146 |
1147 // Clear the cache. | 1147 // Clear the cache. |
1148 static void Clear(); | 1148 static void Clear(); |
1149 private: | 1149 private: |
1150 inline static int Hash(Map* map, String* name); | 1150 inline static int Hash(Map* map, String* name); |
1151 static const int kLength = 128; | 1151 static const int kLength = 64; |
1152 struct Key { | 1152 struct Key { |
1153 Map* map; | 1153 Map* map; |
1154 String* name; | 1154 String* name; |
1155 }; | 1155 }; |
1156 static Key keys_[kLength]; | 1156 static Key keys_[kLength]; |
1157 static int field_offsets_[kLength]; | 1157 static int field_offsets_[kLength]; |
1158 }; | 1158 }; |
1159 | 1159 |
1160 | 1160 |
| 1161 |
| 1162 // Cache for mapping (array, property name) into descriptor index. |
| 1163 // The cache contains both positive and negative results. |
| 1164 // Descriptor index equals kNotFound means the property is absent. |
| 1165 // Cleared at startup and prior to any gc. |
| 1166 class DescriptorLookupCache { |
| 1167 public: |
| 1168 // Lookup descriptor index for (map, name). |
| 1169 // If absent, kAbsent is returned. |
| 1170 static int Lookup(DescriptorArray* array, String* name) { |
| 1171 if(!StringShape(name).IsSymbol()) return kAbsent; |
| 1172 int index = Hash(array, name); |
| 1173 Key& key = keys_[index]; |
| 1174 if ((key.array == array) && (key.name == name)) return results_[index]; |
| 1175 return kAbsent; |
| 1176 } |
| 1177 |
| 1178 // Update an element in the cache. |
| 1179 static void Update(DescriptorArray* array, String* name, int result) { |
| 1180 ASSERT(result != kAbsent); |
| 1181 if(StringShape(name).IsSymbol()) { |
| 1182 int index = Hash(array, name); |
| 1183 Key& key = keys_[index]; |
| 1184 key.array = array; |
| 1185 key.name = name; |
| 1186 results_[index] = result; |
| 1187 } |
| 1188 } |
| 1189 |
| 1190 // Clear the cache. |
| 1191 static void Clear(); |
| 1192 |
| 1193 static const int kAbsent = -2; |
| 1194 private: |
| 1195 static int Hash(DescriptorArray* array, String* name) { |
| 1196 // Uses only lower 32 bits if pointers are larger. |
| 1197 uintptr_t array_hash = |
| 1198 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(array)) >> 2; |
| 1199 uintptr_t name_hash = |
| 1200 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)) >> 2; |
| 1201 return (array_hash ^ name_hash) % kLength; |
| 1202 } |
| 1203 |
| 1204 static const int kLength = 64; |
| 1205 struct Key { |
| 1206 DescriptorArray* array; |
| 1207 String* name; |
| 1208 }; |
| 1209 |
| 1210 static Key keys_[kLength]; |
| 1211 static int results_[kLength]; |
| 1212 }; |
| 1213 |
| 1214 |
1161 // ---------------------------------------------------------------------------- | 1215 // ---------------------------------------------------------------------------- |
1162 // Marking stack for tracing live objects. | 1216 // Marking stack for tracing live objects. |
1163 | 1217 |
1164 class MarkingStack { | 1218 class MarkingStack { |
1165 public: | 1219 public: |
1166 void Initialize(Address low, Address high) { | 1220 void Initialize(Address low, Address high) { |
1167 top_ = low_ = reinterpret_cast<HeapObject**>(low); | 1221 top_ = low_ = reinterpret_cast<HeapObject**>(low); |
1168 high_ = reinterpret_cast<HeapObject**>(high); | 1222 high_ = reinterpret_cast<HeapObject**>(high); |
1169 overflowed_ = false; | 1223 overflowed_ = false; |
1170 } | 1224 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 int marked_count_; | 1381 int marked_count_; |
1328 | 1382 |
1329 // The count from the end of the previous full GC. Will be zero if there | 1383 // The count from the end of the previous full GC. Will be zero if there |
1330 // was no previous full GC. | 1384 // was no previous full GC. |
1331 int previous_marked_count_; | 1385 int previous_marked_count_; |
1332 }; | 1386 }; |
1333 | 1387 |
1334 } } // namespace v8::internal | 1388 } } // namespace v8::internal |
1335 | 1389 |
1336 #endif // V8_HEAP_H_ | 1390 #endif // V8_HEAP_H_ |
OLD | NEW |