OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_COMPILATION_CACHE_H_ | 5 #ifndef V8_COMPILATION_CACHE_H_ |
6 #define V8_COMPILATION_CACHE_H_ | 6 #define V8_COMPILATION_CACHE_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/objects/compilation-cache.h" | 9 #include "src/objects/compilation-cache.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 template <typename T> | 14 template <typename T> |
15 class Handle; | 15 class Handle; |
16 | 16 |
| 17 class RootVisitor; |
| 18 |
17 // The compilation cache consists of several generational sub-caches which uses | 19 // The compilation cache consists of several generational sub-caches which uses |
18 // this class as a base class. A sub-cache contains a compilation cache tables | 20 // this class as a base class. A sub-cache contains a compilation cache tables |
19 // for each generation of the sub-cache. Since the same source code string has | 21 // for each generation of the sub-cache. Since the same source code string has |
20 // different compiled code for scripts and evals, we use separate sub-caches | 22 // different compiled code for scripts and evals, we use separate sub-caches |
21 // for different compilation modes, to avoid retrieving the wrong result. | 23 // for different compilation modes, to avoid retrieving the wrong result. |
22 class CompilationSubCache { | 24 class CompilationSubCache { |
23 public: | 25 public: |
24 CompilationSubCache(Isolate* isolate, int generations) | 26 CompilationSubCache(Isolate* isolate, int generations) |
25 : isolate_(isolate), | 27 : isolate_(isolate), |
26 generations_(generations) { | 28 generations_(generations) { |
(...skipping 15 matching lines...) Expand all Loading... |
42 void SetFirstTable(Handle<CompilationCacheTable> value) { | 44 void SetFirstTable(Handle<CompilationCacheTable> value) { |
43 DCHECK(kFirstGeneration < generations_); | 45 DCHECK(kFirstGeneration < generations_); |
44 tables_[kFirstGeneration] = *value; | 46 tables_[kFirstGeneration] = *value; |
45 } | 47 } |
46 | 48 |
47 // Age the sub-cache by evicting the oldest generation and creating a new | 49 // Age the sub-cache by evicting the oldest generation and creating a new |
48 // young generation. | 50 // young generation. |
49 void Age(); | 51 void Age(); |
50 | 52 |
51 // GC support. | 53 // GC support. |
52 void Iterate(ObjectVisitor* v); | 54 void Iterate(RootVisitor* v); |
53 void IterateFunctions(ObjectVisitor* v); | 55 void IterateFunctions(ObjectVisitor* v); |
54 | 56 |
55 // Clear this sub-cache evicting all its content. | 57 // Clear this sub-cache evicting all its content. |
56 void Clear(); | 58 void Clear(); |
57 | 59 |
58 // Remove given shared function info from sub-cache. | 60 // Remove given shared function info from sub-cache. |
59 void Remove(Handle<SharedFunctionInfo> function_info); | 61 void Remove(Handle<SharedFunctionInfo> function_info); |
60 | 62 |
61 // Number of generations in this sub-cache. | 63 // Number of generations in this sub-cache. |
62 inline int generations() { return generations_; } | 64 inline int generations() { return generations_; } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 JSRegExp::Flags flags, | 192 JSRegExp::Flags flags, |
191 Handle<FixedArray> data); | 193 Handle<FixedArray> data); |
192 | 194 |
193 // Clear the cache - also used to initialize the cache at startup. | 195 // Clear the cache - also used to initialize the cache at startup. |
194 void Clear(); | 196 void Clear(); |
195 | 197 |
196 // Remove given shared function info from all caches. | 198 // Remove given shared function info from all caches. |
197 void Remove(Handle<SharedFunctionInfo> function_info); | 199 void Remove(Handle<SharedFunctionInfo> function_info); |
198 | 200 |
199 // GC support. | 201 // GC support. |
200 void Iterate(ObjectVisitor* v); | 202 void Iterate(RootVisitor* v); |
201 void IterateFunctions(ObjectVisitor* v); | 203 void IterateFunctions(ObjectVisitor* v); |
202 | 204 |
203 // Notify the cache that a mark-sweep garbage collection is about to | 205 // Notify the cache that a mark-sweep garbage collection is about to |
204 // take place. This is used to retire entries from the cache to | 206 // take place. This is used to retire entries from the cache to |
205 // avoid keeping them alive too long without using them. | 207 // avoid keeping them alive too long without using them. |
206 void MarkCompactPrologue(); | 208 void MarkCompactPrologue(); |
207 | 209 |
208 // Enable/disable compilation cache. Used by debugger to disable compilation | 210 // Enable/disable compilation cache. Used by debugger to disable compilation |
209 // cache during debugging to make sure new scripts are always compiled. | 211 // cache during debugging to make sure new scripts are always compiled. |
210 void Enable(); | 212 void Enable(); |
(...skipping 26 matching lines...) Expand all Loading... |
237 friend class Isolate; | 239 friend class Isolate; |
238 | 240 |
239 DISALLOW_COPY_AND_ASSIGN(CompilationCache); | 241 DISALLOW_COPY_AND_ASSIGN(CompilationCache); |
240 }; | 242 }; |
241 | 243 |
242 | 244 |
243 } // namespace internal | 245 } // namespace internal |
244 } // namespace v8 | 246 } // namespace v8 |
245 | 247 |
246 #endif // V8_COMPILATION_CACHE_H_ | 248 #endif // V8_COMPILATION_CACHE_H_ |
OLD | NEW |