Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/compilation-cache.cc

Issue 113625: Disable compilation cache when debugger is active (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compilation-cache.h ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 // hasn't been used. 37 // hasn't been used.
38 NUMBER_OF_SCRIPT_GENERATIONS = 5, 38 NUMBER_OF_SCRIPT_GENERATIONS = 5,
39 39
40 // The compilation cache consists of tables - one for each entry 40 // The compilation cache consists of tables - one for each entry
41 // kind plus extras for the script generations. 41 // kind plus extras for the script generations.
42 NUMBER_OF_TABLE_ENTRIES = 42 NUMBER_OF_TABLE_ENTRIES =
43 CompilationCache::LAST_ENTRY + NUMBER_OF_SCRIPT_GENERATIONS 43 CompilationCache::LAST_ENTRY + NUMBER_OF_SCRIPT_GENERATIONS
44 }; 44 };
45 45
46 46
47 // Current enable state of the compilation cache.
48 static bool enabled = true;
49 static inline bool IsEnabled() {
50 return FLAG_compilation_cache && enabled;
51 }
52
47 // Keep separate tables for the different entry kinds. 53 // Keep separate tables for the different entry kinds.
48 static Object* tables[NUMBER_OF_TABLE_ENTRIES] = { 0, }; 54 static Object* tables[NUMBER_OF_TABLE_ENTRIES] = { 0, };
49 55
50 56
51 static Handle<CompilationCacheTable> AllocateTable(int size) { 57 static Handle<CompilationCacheTable> AllocateTable(int size) {
52 CALL_HEAP_FUNCTION(CompilationCacheTable::Allocate(size), 58 CALL_HEAP_FUNCTION(CompilationCacheTable::Allocate(size),
53 CompilationCacheTable); 59 CompilationCacheTable);
54 } 60 }
55 61
56 62
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 137
132 138
133 // TODO(245): Need to allow identical code from different contexts to 139 // TODO(245): Need to allow identical code from different contexts to
134 // be cached in the same script generation. Currently the first use 140 // be cached in the same script generation. Currently the first use
135 // will be cached, but subsequent code from different source / line 141 // will be cached, but subsequent code from different source / line
136 // won't. 142 // won't.
137 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source, 143 Handle<JSFunction> CompilationCache::LookupScript(Handle<String> source,
138 Handle<Object> name, 144 Handle<Object> name,
139 int line_offset, 145 int line_offset,
140 int column_offset) { 146 int column_offset) {
147 if (!IsEnabled()) {
148 return Handle<JSFunction>::null();
149 }
150
141 // Use an int for the generation index, so value range propagation 151 // Use an int for the generation index, so value range propagation
142 // in gcc 4.3+ won't assume it can only go up to LAST_ENTRY when in 152 // in gcc 4.3+ won't assume it can only go up to LAST_ENTRY when in
143 // fact it can go up to SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS. 153 // fact it can go up to SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS.
144 int generation = SCRIPT; 154 int generation = SCRIPT;
145 Object* result = NULL; 155 Object* result = NULL;
146 156
147 // Probe the script generation tables. Make sure not to leak handles 157 // Probe the script generation tables. Make sure not to leak handles
148 // into the caller's handle scope. 158 // into the caller's handle scope.
149 { HandleScope scope; 159 { HandleScope scope;
150 while (generation < SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS) { 160 while (generation < SCRIPT + NUMBER_OF_SCRIPT_GENERATIONS) {
(...skipping 27 matching lines...) Expand all
178 } else { 188 } else {
179 Counters::compilation_cache_misses.Increment(); 189 Counters::compilation_cache_misses.Increment();
180 return Handle<JSFunction>::null(); 190 return Handle<JSFunction>::null();
181 } 191 }
182 } 192 }
183 193
184 194
185 Handle<JSFunction> CompilationCache::LookupEval(Handle<String> source, 195 Handle<JSFunction> CompilationCache::LookupEval(Handle<String> source,
186 Handle<Context> context, 196 Handle<Context> context,
187 Entry entry) { 197 Entry entry) {
198 if (!IsEnabled()) {
199 return Handle<JSFunction>::null();
200 }
201
188 ASSERT(entry == EVAL_GLOBAL || entry == EVAL_CONTEXTUAL); 202 ASSERT(entry == EVAL_GLOBAL || entry == EVAL_CONTEXTUAL);
189 Handle<JSFunction> result = Lookup(source, context, entry); 203 Handle<JSFunction> result = Lookup(source, context, entry);
190 if (result.is_null()) { 204 if (result.is_null()) {
191 Counters::compilation_cache_misses.Increment(); 205 Counters::compilation_cache_misses.Increment();
192 } else { 206 } else {
193 Counters::compilation_cache_hits.Increment(); 207 Counters::compilation_cache_hits.Increment();
194 } 208 }
195 return result; 209 return result;
196 } 210 }
197 211
198 212
199 Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source, 213 Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source,
200 JSRegExp::Flags flags) { 214 JSRegExp::Flags flags) {
215 if (!IsEnabled()) {
216 return Handle<FixedArray>::null();
217 }
218
201 Handle<FixedArray> result = Lookup(source, flags); 219 Handle<FixedArray> result = Lookup(source, flags);
202 if (result.is_null()) { 220 if (result.is_null()) {
203 Counters::compilation_cache_misses.Increment(); 221 Counters::compilation_cache_misses.Increment();
204 } else { 222 } else {
205 Counters::compilation_cache_hits.Increment(); 223 Counters::compilation_cache_hits.Increment();
206 } 224 }
207 return result; 225 return result;
208 } 226 }
209 227
210 228
211 void CompilationCache::PutScript(Handle<String> source, 229 void CompilationCache::PutScript(Handle<String> source,
212 Handle<JSFunction> boilerplate) { 230 Handle<JSFunction> boilerplate) {
231 if (!IsEnabled()) {
232 return;
233 }
234
213 HandleScope scope; 235 HandleScope scope;
214 ASSERT(boilerplate->IsBoilerplate()); 236 ASSERT(boilerplate->IsBoilerplate());
215 Handle<CompilationCacheTable> table = GetTable(SCRIPT); 237 Handle<CompilationCacheTable> table = GetTable(SCRIPT);
216 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate)); 238 CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate));
217 } 239 }
218 240
219 241
220 void CompilationCache::PutEval(Handle<String> source, 242 void CompilationCache::PutEval(Handle<String> source,
221 Handle<Context> context, 243 Handle<Context> context,
222 Entry entry, 244 Entry entry,
223 Handle<JSFunction> boilerplate) { 245 Handle<JSFunction> boilerplate) {
246 if (!IsEnabled()) {
247 return;
248 }
249
224 HandleScope scope; 250 HandleScope scope;
225 ASSERT(boilerplate->IsBoilerplate()); 251 ASSERT(boilerplate->IsBoilerplate());
226 Handle<CompilationCacheTable> table = GetTable(entry); 252 Handle<CompilationCacheTable> table = GetTable(entry);
227 CALL_HEAP_FUNCTION_VOID(table->PutEval(*source, *context, *boilerplate)); 253 CALL_HEAP_FUNCTION_VOID(table->PutEval(*source, *context, *boilerplate));
228 } 254 }
229 255
230 256
231 257
232 void CompilationCache::PutRegExp(Handle<String> source, 258 void CompilationCache::PutRegExp(Handle<String> source,
233 JSRegExp::Flags flags, 259 JSRegExp::Flags flags,
234 Handle<FixedArray> data) { 260 Handle<FixedArray> data) {
261 if (!IsEnabled()) {
262 return;
263 }
264
235 HandleScope scope; 265 HandleScope scope;
236 Handle<CompilationCacheTable> table = GetTable(REGEXP); 266 Handle<CompilationCacheTable> table = GetTable(REGEXP);
237 CALL_HEAP_FUNCTION_VOID(table->PutRegExp(*source, flags, *data)); 267 CALL_HEAP_FUNCTION_VOID(table->PutRegExp(*source, flags, *data));
238 } 268 }
239 269
240 270
241 void CompilationCache::Clear() { 271 void CompilationCache::Clear() {
242 for (int i = 0; i < NUMBER_OF_TABLE_ENTRIES; i++) { 272 for (int i = 0; i < NUMBER_OF_TABLE_ENTRIES; i++) {
243 tables[i] = Heap::undefined_value(); 273 tables[i] = Heap::undefined_value();
244 } 274 }
245 } 275 }
246 276
247 277
248 void CompilationCache::Iterate(ObjectVisitor* v) { 278 void CompilationCache::Iterate(ObjectVisitor* v) {
249 v->VisitPointers(&tables[0], &tables[NUMBER_OF_TABLE_ENTRIES]); 279 v->VisitPointers(&tables[0], &tables[NUMBER_OF_TABLE_ENTRIES]);
250 } 280 }
251 281
252 282
253 void CompilationCache::MarkCompactPrologue() { 283 void CompilationCache::MarkCompactPrologue() {
254 ASSERT(LAST_ENTRY == SCRIPT); 284 ASSERT(LAST_ENTRY == SCRIPT);
255 for (int i = NUMBER_OF_TABLE_ENTRIES - 1; i > SCRIPT; i--) { 285 for (int i = NUMBER_OF_TABLE_ENTRIES - 1; i > SCRIPT; i--) {
256 tables[i] = tables[i - 1]; 286 tables[i] = tables[i - 1];
257 } 287 }
258 for (int j = 0; j <= LAST_ENTRY; j++) { 288 for (int j = 0; j <= LAST_ENTRY; j++) {
259 tables[j] = Heap::undefined_value(); 289 tables[j] = Heap::undefined_value();
260 } 290 }
261 } 291 }
262 292
263 293
294 void CompilationCache::Enable() {
295 enabled = true;
296 }
297
298
299 void CompilationCache::Disable() {
300 enabled = false;
301 Clear();
302 }
303
304
264 } } // namespace v8::internal 305 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698