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

Side by Side Diff: src/heap.cc

Issue 1780001: Clean JS function results cache on each major GC. (Closed)
Patch Set: Reoworking the test Created 10 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
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (FLAG_heap_stats) ReportHeapStatistics("After GC"); 299 if (FLAG_heap_stats) ReportHeapStatistics("After GC");
300 #elif defined(ENABLE_LOGGING_AND_PROFILING) 300 #elif defined(ENABLE_LOGGING_AND_PROFILING)
301 if (FLAG_log_gc) new_space_.ReportStatistics(); 301 if (FLAG_log_gc) new_space_.ReportStatistics();
302 #endif 302 #endif
303 } 303 }
304 #endif // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) 304 #endif // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
305 305
306 306
307 void Heap::GarbageCollectionPrologue() { 307 void Heap::GarbageCollectionPrologue() {
308 TranscendentalCache::Clear(); 308 TranscendentalCache::Clear();
309 ClearJSFunctionResultCaches();
309 gc_count_++; 310 gc_count_++;
310 unflattened_strings_length_ = 0; 311 unflattened_strings_length_ = 0;
311 #ifdef DEBUG 312 #ifdef DEBUG
312 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); 313 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC);
313 allow_allocation(false); 314 allow_allocation(false);
314 315
315 if (FLAG_verify_heap) { 316 if (FLAG_verify_heap) {
316 Verify(); 317 Verify();
317 } 318 }
318 319
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // Try shrinking and try again. 535 // Try shrinking and try again.
535 Shrink(); 536 Shrink();
536 if (new_space_.CommitFromSpaceIfNeeded()) return; 537 if (new_space_.CommitFromSpaceIfNeeded()) return;
537 538
538 // Committing memory to from space failed again. 539 // Committing memory to from space failed again.
539 // Memory is exhausted and we will die. 540 // Memory is exhausted and we will die.
540 V8::FatalProcessOutOfMemory("Committing semi space failed."); 541 V8::FatalProcessOutOfMemory("Committing semi space failed.");
541 } 542 }
542 543
543 544
545 class ClearThreadJSFunctionResultCachesVisitor: public ThreadVisitor {
546 virtual void VisitThread(ThreadLocalTop* top) {
547 Context* context = top->context_;
548 if (context == NULL) return;
549
550 FixedArray* caches =
551 context->global()->global_context()->jsfunction_result_caches();
552 int length = caches->length();
553 for (int i = 0; i < length; i++) {
554 JSFunctionResultCache::cast(caches->get(i))->Clear();
555 }
556 }
557 };
558
559
560 void Heap::ClearJSFunctionResultCaches() {
561 if (Bootstrapper::IsActive()) return;
562 ClearThreadJSFunctionResultCachesVisitor visitor;
563 ThreadManager::IterateThreads(&visitor);
564 }
565
566
544 void Heap::PerformGarbageCollection(AllocationSpace space, 567 void Heap::PerformGarbageCollection(AllocationSpace space,
545 GarbageCollector collector, 568 GarbageCollector collector,
546 GCTracer* tracer) { 569 GCTracer* tracer) {
547 VerifySymbolTable(); 570 VerifySymbolTable();
548 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { 571 if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) {
549 ASSERT(!allocation_allowed_); 572 ASSERT(!allocation_allowed_);
550 GCTracer::ExternalScope scope(tracer); 573 GCTracer::ExternalScope scope(tracer);
551 global_gc_prologue_callback_(); 574 global_gc_prologue_callback_();
552 } 575 }
553 576
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 void ExternalStringTable::TearDown() { 4387 void ExternalStringTable::TearDown() {
4365 new_space_strings_.Free(); 4388 new_space_strings_.Free();
4366 old_space_strings_.Free(); 4389 old_space_strings_.Free();
4367 } 4390 }
4368 4391
4369 4392
4370 List<Object*> ExternalStringTable::new_space_strings_; 4393 List<Object*> ExternalStringTable::new_space_strings_;
4371 List<Object*> ExternalStringTable::old_space_strings_; 4394 List<Object*> ExternalStringTable::old_space_strings_;
4372 4395
4373 } } // namespace v8::internal 4396 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698