blob: 14252a589262640cc15f58b938e40062d84205e9 [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2008 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "compilation-cache.h"
Andrei Popescu31002712010-02-23 13:46:05 +000031#include "serialize.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000032
33namespace v8 {
34namespace internal {
35
Steve Blocka7e24c12009-10-30 11:49:00 +000036// The number of sub caches covering the different types to cache.
37static const int kSubCacheCount = 4;
38
39// The number of generations for each sub cache.
Steve Block3ce2e202009-11-05 08:53:23 +000040// The number of ScriptGenerations is carefully chosen based on histograms.
41// See issue 458: http://code.google.com/p/v8/issues/detail?id=458
Steve Blocka7e24c12009-10-30 11:49:00 +000042static const int kScriptGenerations = 5;
43static const int kEvalGlobalGenerations = 2;
44static const int kEvalContextualGenerations = 2;
45static const int kRegExpGenerations = 2;
Steve Blocka7e24c12009-10-30 11:49:00 +000046
Steve Block3ce2e202009-11-05 08:53:23 +000047// Initial size of each compilation cache table allocated.
Steve Blocka7e24c12009-10-30 11:49:00 +000048static const int kInitialCacheSize = 64;
49
Steve Block6ded16b2010-05-10 14:33:55 +010050// Index for the first generation in the cache.
51static const int kFirstGeneration = 0;
52
Steve Blocka7e24c12009-10-30 11:49:00 +000053// The compilation cache consists of several generational sub-caches which uses
54// this class as a base class. A sub-cache contains a compilation cache tables
Steve Block3ce2e202009-11-05 08:53:23 +000055// for each generation of the sub-cache. Since the same source code string has
56// different compiled code for scripts and evals, we use separate sub-caches
57// for different compilation modes, to avoid retrieving the wrong result.
Steve Blocka7e24c12009-10-30 11:49:00 +000058class CompilationSubCache {
59 public:
60 explicit CompilationSubCache(int generations): generations_(generations) {
61 tables_ = NewArray<Object*>(generations);
62 }
63
64 ~CompilationSubCache() { DeleteArray(tables_); }
65
66 // Get the compilation cache tables for a specific generation.
67 Handle<CompilationCacheTable> GetTable(int generation);
68
Steve Block6ded16b2010-05-10 14:33:55 +010069 // Accessors for first generation.
70 Handle<CompilationCacheTable> GetFirstTable() {
71 return GetTable(kFirstGeneration);
72 }
73 void SetFirstTable(Handle<CompilationCacheTable> value) {
74 ASSERT(kFirstGeneration < generations_);
75 tables_[kFirstGeneration] = *value;
76 }
77
Steve Blocka7e24c12009-10-30 11:49:00 +000078 // Age the sub-cache by evicting the oldest generation and creating a new
79 // young generation.
80 void Age();
81
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +010082 bool HasFunction(SharedFunctionInfo* function_info);
83
Steve Blocka7e24c12009-10-30 11:49:00 +000084 // GC support.
85 void Iterate(ObjectVisitor* v);
86
87 // Clear this sub-cache evicting all its content.
88 void Clear();
89
90 // Number of generations in this sub-cache.
91 inline int generations() { return generations_; }
92
93 private:
94 int generations_; // Number of generations.
95 Object** tables_; // Compilation cache tables - one for each generation.
96
97 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationSubCache);
98};
99
100
101// Sub-cache for scripts.
102class CompilationCacheScript : public CompilationSubCache {
103 public:
104 explicit CompilationCacheScript(int generations)
105 : CompilationSubCache(generations) { }
106
Steve Block6ded16b2010-05-10 14:33:55 +0100107 Handle<SharedFunctionInfo> Lookup(Handle<String> source,
108 Handle<Object> name,
109 int line_offset,
110 int column_offset);
111 void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000112
113 private:
Steve Block6ded16b2010-05-10 14:33:55 +0100114 // Note: Returns a new hash table if operation results in expansion.
115 Handle<CompilationCacheTable> TablePut(
116 Handle<String> source, Handle<SharedFunctionInfo> function_info);
117
118 bool HasOrigin(Handle<SharedFunctionInfo> function_info,
Steve Blocka7e24c12009-10-30 11:49:00 +0000119 Handle<Object> name,
120 int line_offset,
121 int column_offset);
122
123 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
124};
125
126
127// Sub-cache for eval scripts.
128class CompilationCacheEval: public CompilationSubCache {
129 public:
130 explicit CompilationCacheEval(int generations)
131 : CompilationSubCache(generations) { }
132
Steve Block6ded16b2010-05-10 14:33:55 +0100133 Handle<SharedFunctionInfo> Lookup(Handle<String> source,
134 Handle<Context> context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000135
136 void Put(Handle<String> source,
137 Handle<Context> context,
Steve Block6ded16b2010-05-10 14:33:55 +0100138 Handle<SharedFunctionInfo> function_info);
139
140 private:
141 // Note: Returns a new hash table if operation results in expansion.
142 Handle<CompilationCacheTable> TablePut(
143 Handle<String> source,
144 Handle<Context> context,
145 Handle<SharedFunctionInfo> function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000146
147 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
148};
149
150
151// Sub-cache for regular expressions.
152class CompilationCacheRegExp: public CompilationSubCache {
153 public:
154 explicit CompilationCacheRegExp(int generations)
155 : CompilationSubCache(generations) { }
156
157 Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags);
158
159 void Put(Handle<String> source,
160 JSRegExp::Flags flags,
161 Handle<FixedArray> data);
Steve Block6ded16b2010-05-10 14:33:55 +0100162 private:
163 // Note: Returns a new hash table if operation results in expansion.
164 Handle<CompilationCacheTable> TablePut(Handle<String> source,
165 JSRegExp::Flags flags,
166 Handle<FixedArray> data);
Steve Blocka7e24c12009-10-30 11:49:00 +0000167
168 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
169};
170
171
172// Statically allocate all the sub-caches.
173static CompilationCacheScript script(kScriptGenerations);
174static CompilationCacheEval eval_global(kEvalGlobalGenerations);
175static CompilationCacheEval eval_contextual(kEvalContextualGenerations);
176static CompilationCacheRegExp reg_exp(kRegExpGenerations);
177static CompilationSubCache* subcaches[kSubCacheCount] =
178 {&script, &eval_global, &eval_contextual, &reg_exp};
179
180
181// Current enable state of the compilation cache.
182static bool enabled = true;
183static inline bool IsEnabled() {
184 return FLAG_compilation_cache && enabled;
185}
186
187
188static Handle<CompilationCacheTable> AllocateTable(int size) {
189 CALL_HEAP_FUNCTION(CompilationCacheTable::Allocate(size),
190 CompilationCacheTable);
191}
192
193
194Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
195 ASSERT(generation < generations_);
196 Handle<CompilationCacheTable> result;
197 if (tables_[generation]->IsUndefined()) {
198 result = AllocateTable(kInitialCacheSize);
199 tables_[generation] = *result;
200 } else {
201 CompilationCacheTable* table =
202 CompilationCacheTable::cast(tables_[generation]);
203 result = Handle<CompilationCacheTable>(table);
204 }
205 return result;
206}
207
208
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100209bool CompilationSubCache::HasFunction(SharedFunctionInfo* function_info) {
210 if (function_info->script()->IsUndefined() ||
211 Script::cast(function_info->script())->source()->IsUndefined()) {
212 return false;
213 }
214
215 String* source =
216 String::cast(Script::cast(function_info->script())->source());
217 // Check all generations.
218 for (int generation = 0; generation < generations(); generation++) {
219 if (tables_[generation]->IsUndefined()) continue;
220
221 CompilationCacheTable* table =
222 CompilationCacheTable::cast(tables_[generation]);
223 Object* object = table->Lookup(source);
224 if (object->IsSharedFunctionInfo()) return true;
225 }
226 return false;
227}
228
229
Steve Blocka7e24c12009-10-30 11:49:00 +0000230void CompilationSubCache::Age() {
231 // Age the generations implicitly killing off the oldest.
232 for (int i = generations_ - 1; i > 0; i--) {
233 tables_[i] = tables_[i - 1];
234 }
235
236 // Set the first generation as unborn.
237 tables_[0] = Heap::undefined_value();
238}
239
240
241void CompilationSubCache::Iterate(ObjectVisitor* v) {
242 v->VisitPointers(&tables_[0], &tables_[generations_]);
243}
244
245
246void CompilationSubCache::Clear() {
Steve Block6ded16b2010-05-10 14:33:55 +0100247 MemsetPointer(tables_, Heap::undefined_value(), generations_);
Steve Blocka7e24c12009-10-30 11:49:00 +0000248}
249
250
251// We only re-use a cached function for some script source code if the
252// script originates from the same place. This is to avoid issues
253// when reporting errors, etc.
Steve Block6ded16b2010-05-10 14:33:55 +0100254bool CompilationCacheScript::HasOrigin(
255 Handle<SharedFunctionInfo> function_info,
256 Handle<Object> name,
257 int line_offset,
258 int column_offset) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000259 Handle<Script> script =
Steve Block6ded16b2010-05-10 14:33:55 +0100260 Handle<Script>(Script::cast(function_info->script()));
Steve Blocka7e24c12009-10-30 11:49:00 +0000261 // If the script name isn't set, the boilerplate script should have
262 // an undefined name to have the same origin.
263 if (name.is_null()) {
264 return script->name()->IsUndefined();
265 }
266 // Do the fast bailout checks first.
267 if (line_offset != script->line_offset()->value()) return false;
268 if (column_offset != script->column_offset()->value()) return false;
269 // Check that both names are strings. If not, no match.
270 if (!name->IsString() || !script->name()->IsString()) return false;
271 // Compare the two name strings for equality.
272 return String::cast(*name)->Equals(String::cast(script->name()));
273}
274
275
276// TODO(245): Need to allow identical code from different contexts to
277// be cached in the same script generation. Currently the first use
278// will be cached, but subsequent code from different source / line
279// won't.
Steve Block6ded16b2010-05-10 14:33:55 +0100280Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(Handle<String> source,
281 Handle<Object> name,
282 int line_offset,
283 int column_offset) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000284 Object* result = NULL;
285 int generation;
286
287 // Probe the script generation tables. Make sure not to leak handles
288 // into the caller's handle scope.
289 { HandleScope scope;
290 for (generation = 0; generation < generations(); generation++) {
291 Handle<CompilationCacheTable> table = GetTable(generation);
292 Handle<Object> probe(table->Lookup(*source));
Steve Block6ded16b2010-05-10 14:33:55 +0100293 if (probe->IsSharedFunctionInfo()) {
294 Handle<SharedFunctionInfo> function_info =
295 Handle<SharedFunctionInfo>::cast(probe);
296 // Break when we've found a suitable shared function info that
Steve Blocka7e24c12009-10-30 11:49:00 +0000297 // matches the origin.
Steve Block6ded16b2010-05-10 14:33:55 +0100298 if (HasOrigin(function_info, name, line_offset, column_offset)) {
299 result = *function_info;
Steve Blocka7e24c12009-10-30 11:49:00 +0000300 break;
301 }
302 }
303 }
304 }
305
306 static void* script_histogram = StatsTable::CreateHistogram(
307 "V8.ScriptCache",
308 0,
309 kScriptGenerations,
310 kScriptGenerations + 1);
311
312 if (script_histogram != NULL) {
313 // The level NUMBER_OF_SCRIPT_GENERATIONS is equivalent to a cache miss.
314 StatsTable::AddHistogramSample(script_histogram, generation);
315 }
316
317 // Once outside the manacles of the handle scope, we need to recheck
318 // to see if we actually found a cached script. If so, we return a
319 // handle created in the caller's handle scope.
320 if (result != NULL) {
Steve Block6ded16b2010-05-10 14:33:55 +0100321 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result));
322 ASSERT(HasOrigin(shared, name, line_offset, column_offset));
Steve Blocka7e24c12009-10-30 11:49:00 +0000323 // If the script was found in a later generation, we promote it to
324 // the first generation to let it survive longer in the cache.
Steve Block6ded16b2010-05-10 14:33:55 +0100325 if (generation != 0) Put(source, shared);
Steve Blocka7e24c12009-10-30 11:49:00 +0000326 Counters::compilation_cache_hits.Increment();
Steve Block6ded16b2010-05-10 14:33:55 +0100327 return shared;
Steve Blocka7e24c12009-10-30 11:49:00 +0000328 } else {
329 Counters::compilation_cache_misses.Increment();
Steve Block6ded16b2010-05-10 14:33:55 +0100330 return Handle<SharedFunctionInfo>::null();
Steve Blocka7e24c12009-10-30 11:49:00 +0000331 }
332}
333
334
Steve Block6ded16b2010-05-10 14:33:55 +0100335Handle<CompilationCacheTable> CompilationCacheScript::TablePut(
336 Handle<String> source,
337 Handle<SharedFunctionInfo> function_info) {
338 CALL_HEAP_FUNCTION(GetFirstTable()->Put(*source, *function_info),
339 CompilationCacheTable);
Steve Blocka7e24c12009-10-30 11:49:00 +0000340}
341
342
Steve Block6ded16b2010-05-10 14:33:55 +0100343void CompilationCacheScript::Put(Handle<String> source,
344 Handle<SharedFunctionInfo> function_info) {
345 HandleScope scope;
346 SetFirstTable(TablePut(source, function_info));
347}
348
349
350Handle<SharedFunctionInfo> CompilationCacheEval::Lookup(
351 Handle<String> source, Handle<Context> context) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000352 // Make sure not to leak the table into the surrounding handle
353 // scope. Otherwise, we risk keeping old tables around even after
354 // having cleared the cache.
355 Object* result = NULL;
356 int generation;
357 { HandleScope scope;
358 for (generation = 0; generation < generations(); generation++) {
359 Handle<CompilationCacheTable> table = GetTable(generation);
360 result = table->LookupEval(*source, *context);
Steve Block6ded16b2010-05-10 14:33:55 +0100361 if (result->IsSharedFunctionInfo()) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000362 break;
363 }
364 }
365 }
Steve Block6ded16b2010-05-10 14:33:55 +0100366 if (result->IsSharedFunctionInfo()) {
367 Handle<SharedFunctionInfo>
368 function_info(SharedFunctionInfo::cast(result));
Steve Blocka7e24c12009-10-30 11:49:00 +0000369 if (generation != 0) {
Steve Block6ded16b2010-05-10 14:33:55 +0100370 Put(source, context, function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000371 }
372 Counters::compilation_cache_hits.Increment();
Steve Block6ded16b2010-05-10 14:33:55 +0100373 return function_info;
Steve Blocka7e24c12009-10-30 11:49:00 +0000374 } else {
375 Counters::compilation_cache_misses.Increment();
Steve Block6ded16b2010-05-10 14:33:55 +0100376 return Handle<SharedFunctionInfo>::null();
Steve Blocka7e24c12009-10-30 11:49:00 +0000377 }
378}
379
380
Steve Block6ded16b2010-05-10 14:33:55 +0100381Handle<CompilationCacheTable> CompilationCacheEval::TablePut(
382 Handle<String> source,
383 Handle<Context> context,
384 Handle<SharedFunctionInfo> function_info) {
385 CALL_HEAP_FUNCTION(GetFirstTable()->PutEval(*source,
386 *context,
387 *function_info),
388 CompilationCacheTable);
389}
390
391
Steve Blocka7e24c12009-10-30 11:49:00 +0000392void CompilationCacheEval::Put(Handle<String> source,
393 Handle<Context> context,
Steve Block6ded16b2010-05-10 14:33:55 +0100394 Handle<SharedFunctionInfo> function_info) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000395 HandleScope scope;
Steve Block6ded16b2010-05-10 14:33:55 +0100396 SetFirstTable(TablePut(source, context, function_info));
Steve Blocka7e24c12009-10-30 11:49:00 +0000397}
398
399
400Handle<FixedArray> CompilationCacheRegExp::Lookup(Handle<String> source,
401 JSRegExp::Flags flags) {
402 // Make sure not to leak the table into the surrounding handle
403 // scope. Otherwise, we risk keeping old tables around even after
404 // having cleared the cache.
405 Object* result = NULL;
406 int generation;
407 { HandleScope scope;
408 for (generation = 0; generation < generations(); generation++) {
409 Handle<CompilationCacheTable> table = GetTable(generation);
410 result = table->LookupRegExp(*source, flags);
411 if (result->IsFixedArray()) {
412 break;
413 }
414 }
415 }
416 if (result->IsFixedArray()) {
417 Handle<FixedArray> data(FixedArray::cast(result));
418 if (generation != 0) {
419 Put(source, flags, data);
420 }
421 Counters::compilation_cache_hits.Increment();
422 return data;
423 } else {
424 Counters::compilation_cache_misses.Increment();
425 return Handle<FixedArray>::null();
426 }
427}
428
429
Steve Block6ded16b2010-05-10 14:33:55 +0100430Handle<CompilationCacheTable> CompilationCacheRegExp::TablePut(
431 Handle<String> source,
432 JSRegExp::Flags flags,
433 Handle<FixedArray> data) {
434 CALL_HEAP_FUNCTION(GetFirstTable()->PutRegExp(*source, flags, *data),
435 CompilationCacheTable);
436}
437
438
Steve Blocka7e24c12009-10-30 11:49:00 +0000439void CompilationCacheRegExp::Put(Handle<String> source,
440 JSRegExp::Flags flags,
441 Handle<FixedArray> data) {
442 HandleScope scope;
Steve Block6ded16b2010-05-10 14:33:55 +0100443 SetFirstTable(TablePut(source, flags, data));
Steve Blocka7e24c12009-10-30 11:49:00 +0000444}
445
446
Steve Block6ded16b2010-05-10 14:33:55 +0100447Handle<SharedFunctionInfo> CompilationCache::LookupScript(Handle<String> source,
448 Handle<Object> name,
449 int line_offset,
450 int column_offset) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000451 if (!IsEnabled()) {
Steve Block6ded16b2010-05-10 14:33:55 +0100452 return Handle<SharedFunctionInfo>::null();
Steve Blocka7e24c12009-10-30 11:49:00 +0000453 }
454
455 return script.Lookup(source, name, line_offset, column_offset);
456}
457
458
Steve Block6ded16b2010-05-10 14:33:55 +0100459Handle<SharedFunctionInfo> CompilationCache::LookupEval(Handle<String> source,
460 Handle<Context> context,
461 bool is_global) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000462 if (!IsEnabled()) {
Steve Block6ded16b2010-05-10 14:33:55 +0100463 return Handle<SharedFunctionInfo>::null();
Steve Blocka7e24c12009-10-30 11:49:00 +0000464 }
465
Steve Block6ded16b2010-05-10 14:33:55 +0100466 Handle<SharedFunctionInfo> result;
Steve Blocka7e24c12009-10-30 11:49:00 +0000467 if (is_global) {
468 result = eval_global.Lookup(source, context);
469 } else {
470 result = eval_contextual.Lookup(source, context);
471 }
472 return result;
473}
474
475
476Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source,
477 JSRegExp::Flags flags) {
478 if (!IsEnabled()) {
479 return Handle<FixedArray>::null();
480 }
481
482 return reg_exp.Lookup(source, flags);
483}
484
485
486void CompilationCache::PutScript(Handle<String> source,
Steve Block6ded16b2010-05-10 14:33:55 +0100487 Handle<SharedFunctionInfo> function_info) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000488 if (!IsEnabled()) {
489 return;
490 }
491
Steve Block6ded16b2010-05-10 14:33:55 +0100492 script.Put(source, function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000493}
494
495
496void CompilationCache::PutEval(Handle<String> source,
497 Handle<Context> context,
498 bool is_global,
Steve Block6ded16b2010-05-10 14:33:55 +0100499 Handle<SharedFunctionInfo> function_info) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000500 if (!IsEnabled()) {
501 return;
502 }
503
504 HandleScope scope;
Steve Blocka7e24c12009-10-30 11:49:00 +0000505 if (is_global) {
Steve Block6ded16b2010-05-10 14:33:55 +0100506 eval_global.Put(source, context, function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000507 } else {
Steve Block6ded16b2010-05-10 14:33:55 +0100508 eval_contextual.Put(source, context, function_info);
Steve Blocka7e24c12009-10-30 11:49:00 +0000509 }
510}
511
512
513
514void CompilationCache::PutRegExp(Handle<String> source,
515 JSRegExp::Flags flags,
516 Handle<FixedArray> data) {
517 if (!IsEnabled()) {
518 return;
519 }
520
521 reg_exp.Put(source, flags, data);
522}
523
524
525void CompilationCache::Clear() {
526 for (int i = 0; i < kSubCacheCount; i++) {
527 subcaches[i]->Clear();
528 }
529}
530
531
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100532bool CompilationCache::HasFunction(SharedFunctionInfo* function_info) {
533 return script.HasFunction(function_info);
534}
535
536
Steve Blocka7e24c12009-10-30 11:49:00 +0000537void CompilationCache::Iterate(ObjectVisitor* v) {
538 for (int i = 0; i < kSubCacheCount; i++) {
539 subcaches[i]->Iterate(v);
540 }
541}
542
543
544void CompilationCache::MarkCompactPrologue() {
545 for (int i = 0; i < kSubCacheCount; i++) {
546 subcaches[i]->Age();
547 }
548}
549
550
551void CompilationCache::Enable() {
552 enabled = true;
553}
554
555
556void CompilationCache::Disable() {
557 enabled = false;
558 Clear();
559}
560
561
562} } // namespace v8::internal