OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "compilation-cache.h" | 30 #include "compilation-cache.h" |
31 | 31 |
32 namespace v8 { | 32 namespace v8 { |
33 namespace internal { | 33 namespace internal { |
34 | 34 |
35 enum { | 35 enum { |
36 // The number of script generations tell how many GCs a script can | 36 // The number of script generations tell how many GCs a script can |
37 // survive in the compilation cache, before it will be flushed if it | 37 // survive in the compilation cache, before it will be flushed if it |
38 // hasn't been used. | 38 // hasn't been used. |
39 NUMBER_OF_SCRIPT_GENERATIONS = 5, | 39 NUMBER_OF_SCRIPT_GENERATIONS = 8, |
40 | 40 |
41 // The compilation cache consists of tables - one for each entry | 41 // The compilation cache consists of tables - one for each entry |
42 // kind plus extras for the script generations. | 42 // kind plus extras for the script generations. |
43 NUMBER_OF_TABLE_ENTRIES = | 43 NUMBER_OF_TABLE_ENTRIES = |
44 CompilationCache::LAST_ENTRY + NUMBER_OF_SCRIPT_GENERATIONS | 44 CompilationCache::LAST_ENTRY + NUMBER_OF_SCRIPT_GENERATIONS |
45 }; | 45 }; |
46 | 46 |
47 | 47 |
48 // Current enable state of the compilation cache. | 48 // Current enable state of the compilation cache. |
49 static bool enabled = true; | 49 static bool enabled = true; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (HasOrigin(boilerplate, name, line_offset, column_offset)) { | 168 if (HasOrigin(boilerplate, name, line_offset, column_offset)) { |
169 result = *boilerplate; | 169 result = *boilerplate; |
170 break; | 170 break; |
171 } | 171 } |
172 } | 172 } |
173 // Go to the next generation. | 173 // Go to the next generation. |
174 generation++; | 174 generation++; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
| 178 static void* script_histogram_ = StatsTable::CreateHistogram( |
| 179 "V8.ScriptCache", |
| 180 0, |
| 181 NUMBER_OF_SCRIPT_GENERATIONS, |
| 182 NUMBER_OF_SCRIPT_GENERATIONS + 1); |
| 183 |
| 184 if (script_histogram_ != NULL) { |
| 185 // The level NUMBER_OF_SCRIPT_GENERATIONS is equivalent to a cache miss. |
| 186 StatsTable::AddHistogramSample(script_histogram_, generation - SCRIPT); |
| 187 } |
| 188 |
178 // Once outside the manacles of the handle scope, we need to recheck | 189 // Once outside the manacles of the handle scope, we need to recheck |
179 // to see if we actually found a cached script. If so, we return a | 190 // to see if we actually found a cached script. If so, we return a |
180 // handle created in the caller's handle scope. | 191 // handle created in the caller's handle scope. |
181 if (result != NULL) { | 192 if (result != NULL) { |
182 Handle<JSFunction> boilerplate(JSFunction::cast(result)); | 193 Handle<JSFunction> boilerplate(JSFunction::cast(result)); |
183 ASSERT(HasOrigin(boilerplate, name, line_offset, column_offset)); | 194 ASSERT(HasOrigin(boilerplate, name, line_offset, column_offset)); |
184 // If the script was found in a later generation, we promote it to | 195 // If the script was found in a later generation, we promote it to |
185 // the first generation to let it survive longer in the cache. | 196 // the first generation to let it survive longer in the cache. |
186 if (generation != SCRIPT) PutScript(source, boilerplate); | 197 if (generation != SCRIPT) PutScript(source, boilerplate); |
187 Counters::compilation_cache_hits.Increment(); | 198 Counters::compilation_cache_hits.Increment(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 308 } |
298 | 309 |
299 | 310 |
300 void CompilationCache::Disable() { | 311 void CompilationCache::Disable() { |
301 enabled = false; | 312 enabled = false; |
302 Clear(); | 313 Clear(); |
303 } | 314 } |
304 | 315 |
305 | 316 |
306 } } // namespace v8::internal | 317 } } // namespace v8::internal |
OLD | NEW |