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

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

Issue 3398014: Fix possible evaluation order problems. (Closed)
Patch Set: fixed more places Created 10 years, 3 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 explicit CompilationCacheScript(int generations) 103 explicit CompilationCacheScript(int generations)
104 : CompilationSubCache(generations) { } 104 : CompilationSubCache(generations) { }
105 105
106 Handle<SharedFunctionInfo> Lookup(Handle<String> source, 106 Handle<SharedFunctionInfo> Lookup(Handle<String> source,
107 Handle<Object> name, 107 Handle<Object> name,
108 int line_offset, 108 int line_offset,
109 int column_offset); 109 int column_offset);
110 void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info); 110 void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info);
111 111
112 private: 112 private:
113 MUST_USE_RESULT Object* TryTablePut(
114 Handle<String> source, Handle<SharedFunctionInfo> function_info);
115
113 // Note: Returns a new hash table if operation results in expansion. 116 // Note: Returns a new hash table if operation results in expansion.
114 Handle<CompilationCacheTable> TablePut( 117 Handle<CompilationCacheTable> TablePut(
115 Handle<String> source, Handle<SharedFunctionInfo> function_info); 118 Handle<String> source, Handle<SharedFunctionInfo> function_info);
116 119
117 bool HasOrigin(Handle<SharedFunctionInfo> function_info, 120 bool HasOrigin(Handle<SharedFunctionInfo> function_info,
118 Handle<Object> name, 121 Handle<Object> name,
119 int line_offset, 122 int line_offset,
120 int column_offset); 123 int column_offset);
121 124
122 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript); 125 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
123 }; 126 };
124 127
125 128
126 // Sub-cache for eval scripts. 129 // Sub-cache for eval scripts.
127 class CompilationCacheEval: public CompilationSubCache { 130 class CompilationCacheEval: public CompilationSubCache {
128 public: 131 public:
129 explicit CompilationCacheEval(int generations) 132 explicit CompilationCacheEval(int generations)
130 : CompilationSubCache(generations) { } 133 : CompilationSubCache(generations) { }
131 134
132 Handle<SharedFunctionInfo> Lookup(Handle<String> source, 135 Handle<SharedFunctionInfo> Lookup(Handle<String> source,
133 Handle<Context> context); 136 Handle<Context> context);
134 137
135 void Put(Handle<String> source, 138 void Put(Handle<String> source,
136 Handle<Context> context, 139 Handle<Context> context,
137 Handle<SharedFunctionInfo> function_info); 140 Handle<SharedFunctionInfo> function_info);
138 141
139 private: 142 private:
143 MUST_USE_RESULT Object* TryTablePut(
144 Handle<String> source,
145 Handle<Context> context,
146 Handle<SharedFunctionInfo> function_info);
147
148
140 // Note: Returns a new hash table if operation results in expansion. 149 // Note: Returns a new hash table if operation results in expansion.
141 Handle<CompilationCacheTable> TablePut( 150 Handle<CompilationCacheTable> TablePut(
142 Handle<String> source, 151 Handle<String> source,
143 Handle<Context> context, 152 Handle<Context> context,
144 Handle<SharedFunctionInfo> function_info); 153 Handle<SharedFunctionInfo> function_info);
145 154
146 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval); 155 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
147 }; 156 };
148 157
149 158
150 // Sub-cache for regular expressions. 159 // Sub-cache for regular expressions.
151 class CompilationCacheRegExp: public CompilationSubCache { 160 class CompilationCacheRegExp: public CompilationSubCache {
152 public: 161 public:
153 explicit CompilationCacheRegExp(int generations) 162 explicit CompilationCacheRegExp(int generations)
154 : CompilationSubCache(generations) { } 163 : CompilationSubCache(generations) { }
155 164
156 Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags); 165 Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags);
157 166
158 void Put(Handle<String> source, 167 void Put(Handle<String> source,
159 JSRegExp::Flags flags, 168 JSRegExp::Flags flags,
160 Handle<FixedArray> data); 169 Handle<FixedArray> data);
161 private: 170 private:
171 MUST_USE_RESULT Object* TryTablePut(Handle<String> source,
172 JSRegExp::Flags flags,
173 Handle<FixedArray> data);
174
162 // Note: Returns a new hash table if operation results in expansion. 175 // Note: Returns a new hash table if operation results in expansion.
163 Handle<CompilationCacheTable> TablePut(Handle<String> source, 176 Handle<CompilationCacheTable> TablePut(Handle<String> source,
164 JSRegExp::Flags flags, 177 JSRegExp::Flags flags,
165 Handle<FixedArray> data); 178 Handle<FixedArray> data);
166 179
167 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp); 180 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
168 }; 181 };
169 182
170 183
171 // Statically allocate all the sub-caches. 184 // Statically allocate all the sub-caches.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (generation != 0) Put(source, shared); 326 if (generation != 0) Put(source, shared);
314 Counters::compilation_cache_hits.Increment(); 327 Counters::compilation_cache_hits.Increment();
315 return shared; 328 return shared;
316 } else { 329 } else {
317 Counters::compilation_cache_misses.Increment(); 330 Counters::compilation_cache_misses.Increment();
318 return Handle<SharedFunctionInfo>::null(); 331 return Handle<SharedFunctionInfo>::null();
319 } 332 }
320 } 333 }
321 334
322 335
336 Object* CompilationCacheScript::TryTablePut(
337 Handle<String> source,
338 Handle<SharedFunctionInfo> function_info) {
339 Handle<CompilationCacheTable> table = GetFirstTable();
340 return table->Put(*source, *function_info);
341 }
342
343
323 Handle<CompilationCacheTable> CompilationCacheScript::TablePut( 344 Handle<CompilationCacheTable> CompilationCacheScript::TablePut(
324 Handle<String> source, 345 Handle<String> source,
325 Handle<SharedFunctionInfo> function_info) { 346 Handle<SharedFunctionInfo> function_info) {
326 CALL_HEAP_FUNCTION(GetFirstTable()->Put(*source, *function_info), 347 CALL_HEAP_FUNCTION(TryTablePut(source, function_info), CompilationCacheTable);
327 CompilationCacheTable);
328 } 348 }
329 349
330 350
331 void CompilationCacheScript::Put(Handle<String> source, 351 void CompilationCacheScript::Put(Handle<String> source,
332 Handle<SharedFunctionInfo> function_info) { 352 Handle<SharedFunctionInfo> function_info) {
333 HandleScope scope; 353 HandleScope scope;
334 SetFirstTable(TablePut(source, function_info)); 354 SetFirstTable(TablePut(source, function_info));
335 } 355 }
336 356
337 357
(...skipping 21 matching lines...) Expand all
359 } 379 }
360 Counters::compilation_cache_hits.Increment(); 380 Counters::compilation_cache_hits.Increment();
361 return function_info; 381 return function_info;
362 } else { 382 } else {
363 Counters::compilation_cache_misses.Increment(); 383 Counters::compilation_cache_misses.Increment();
364 return Handle<SharedFunctionInfo>::null(); 384 return Handle<SharedFunctionInfo>::null();
365 } 385 }
366 } 386 }
367 387
368 388
389 Object* CompilationCacheEval::TryTablePut(
390 Handle<String> source,
391 Handle<Context> context,
392 Handle<SharedFunctionInfo> function_info) {
393 Handle<CompilationCacheTable> table = GetFirstTable();
394 return table->PutEval(*source, *context, *function_info);
395 }
396
397
369 Handle<CompilationCacheTable> CompilationCacheEval::TablePut( 398 Handle<CompilationCacheTable> CompilationCacheEval::TablePut(
370 Handle<String> source, 399 Handle<String> source,
371 Handle<Context> context, 400 Handle<Context> context,
372 Handle<SharedFunctionInfo> function_info) { 401 Handle<SharedFunctionInfo> function_info) {
373 CALL_HEAP_FUNCTION(GetFirstTable()->PutEval(*source, 402 CALL_HEAP_FUNCTION(TryTablePut(source, context, function_info),
374 *context,
375 *function_info),
376 CompilationCacheTable); 403 CompilationCacheTable);
377 } 404 }
378 405
379 406
380 void CompilationCacheEval::Put(Handle<String> source, 407 void CompilationCacheEval::Put(Handle<String> source,
381 Handle<Context> context, 408 Handle<Context> context,
382 Handle<SharedFunctionInfo> function_info) { 409 Handle<SharedFunctionInfo> function_info) {
383 HandleScope scope; 410 HandleScope scope;
384 SetFirstTable(TablePut(source, context, function_info)); 411 SetFirstTable(TablePut(source, context, function_info));
385 } 412 }
(...skipping 22 matching lines...) Expand all
408 } 435 }
409 Counters::compilation_cache_hits.Increment(); 436 Counters::compilation_cache_hits.Increment();
410 return data; 437 return data;
411 } else { 438 } else {
412 Counters::compilation_cache_misses.Increment(); 439 Counters::compilation_cache_misses.Increment();
413 return Handle<FixedArray>::null(); 440 return Handle<FixedArray>::null();
414 } 441 }
415 } 442 }
416 443
417 444
445 Object* CompilationCacheRegExp::TryTablePut(
446 Handle<String> source,
447 JSRegExp::Flags flags,
448 Handle<FixedArray> data) {
449 Handle<CompilationCacheTable> table = GetFirstTable();
450 return table->PutRegExp(*source, flags, *data);
451 }
452
453
418 Handle<CompilationCacheTable> CompilationCacheRegExp::TablePut( 454 Handle<CompilationCacheTable> CompilationCacheRegExp::TablePut(
419 Handle<String> source, 455 Handle<String> source,
420 JSRegExp::Flags flags, 456 JSRegExp::Flags flags,
421 Handle<FixedArray> data) { 457 Handle<FixedArray> data) {
422 CALL_HEAP_FUNCTION(GetFirstTable()->PutRegExp(*source, flags, *data), 458 CALL_HEAP_FUNCTION(TryTablePut(source, flags, data), CompilationCacheTable);
423 CompilationCacheTable);
424 } 459 }
425 460
426 461
427 void CompilationCacheRegExp::Put(Handle<String> source, 462 void CompilationCacheRegExp::Put(Handle<String> source,
428 JSRegExp::Flags flags, 463 JSRegExp::Flags flags,
429 Handle<FixedArray> data) { 464 Handle<FixedArray> data) {
430 HandleScope scope; 465 HandleScope scope;
431 SetFirstTable(TablePut(source, flags, data)); 466 SetFirstTable(TablePut(source, flags, data));
432 } 467 }
433 468
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 577 }
543 578
544 579
545 void CompilationCache::Disable() { 580 void CompilationCache::Disable() {
546 enabled = false; 581 enabled = false;
547 Clear(); 582 Clear();
548 } 583 }
549 584
550 585
551 } } // namespace v8::internal 586 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.cc ('K') | « src/bootstrapper.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698