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

Side by Side Diff: src/heap/heap.cc

Issue 1051833002: Reland: Fix JSON parser Handle leak (previous CL 1041483004) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix handling of stack overflow Created 5 years, 8 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 #endif 611 #endif
612 612
613 AllowHeapAllocation for_the_rest_of_the_epilogue; 613 AllowHeapAllocation for_the_rest_of_the_epilogue;
614 614
615 #ifdef DEBUG 615 #ifdef DEBUG
616 if (FLAG_print_global_handles) isolate_->global_handles()->Print(); 616 if (FLAG_print_global_handles) isolate_->global_handles()->Print();
617 if (FLAG_print_handles) PrintHandles(); 617 if (FLAG_print_handles) PrintHandles();
618 if (FLAG_gc_verbose) Print(); 618 if (FLAG_gc_verbose) Print();
619 if (FLAG_code_stats) ReportCodeStatistics("After GC"); 619 if (FLAG_code_stats) ReportCodeStatistics("After GC");
620 #endif 620 #endif
621 if (FLAG_check_handle_count) CheckHandleCount();
621 if (FLAG_deopt_every_n_garbage_collections > 0) { 622 if (FLAG_deopt_every_n_garbage_collections > 0) {
622 // TODO(jkummerow/ulan/jarin): This is not safe! We can't assume that 623 // TODO(jkummerow/ulan/jarin): This is not safe! We can't assume that
623 // the topmost optimized frame can be deoptimized safely, because it 624 // the topmost optimized frame can be deoptimized safely, because it
624 // might not have a lazy bailout point right after its current PC. 625 // might not have a lazy bailout point right after its current PC.
625 if (++gcs_since_last_deopt_ == FLAG_deopt_every_n_garbage_collections) { 626 if (++gcs_since_last_deopt_ == FLAG_deopt_every_n_garbage_collections) {
626 Deoptimizer::DeoptimizeAll(isolate()); 627 Deoptimizer::DeoptimizeAll(isolate());
627 gcs_since_last_deopt_ = 0; 628 gcs_since_last_deopt_ = 0;
628 } 629 }
629 } 630 }
630 631
(...skipping 5014 matching lines...) Expand 10 before | Expand all | Expand 10 after
5645 5646
5646 5647
5647 void Heap::PrintHandles() { 5648 void Heap::PrintHandles() {
5648 PrintF("Handles:\n"); 5649 PrintF("Handles:\n");
5649 PrintHandleVisitor v; 5650 PrintHandleVisitor v;
5650 isolate_->handle_scope_implementer()->Iterate(&v); 5651 isolate_->handle_scope_implementer()->Iterate(&v);
5651 } 5652 }
5652 5653
5653 #endif 5654 #endif
5654 5655
5656 class CheckHandleCountVisitor : public ObjectVisitor {
5657 public:
5658 CheckHandleCountVisitor() : handle_count_(0) {}
5659 ~CheckHandleCountVisitor() { CHECK(handle_count_ < 2000); }
5660 void VisitPointers(Object** start, Object** end) {
5661 handle_count_ += end - start;
5662 }
5663
5664 private:
5665 ptrdiff_t handle_count_;
5666 };
5667
5668
5669 void Heap::CheckHandleCount() {
5670 CheckHandleCountVisitor v;
5671 isolate_->handle_scope_implementer()->Iterate(&v);
5672 }
5673
5655 5674
5656 Space* AllSpaces::next() { 5675 Space* AllSpaces::next() {
5657 switch (counter_++) { 5676 switch (counter_++) {
5658 case NEW_SPACE: 5677 case NEW_SPACE:
5659 return heap_->new_space(); 5678 return heap_->new_space();
5660 case OLD_POINTER_SPACE: 5679 case OLD_POINTER_SPACE:
5661 return heap_->old_pointer_space(); 5680 return heap_->old_pointer_space();
5662 case OLD_DATA_SPACE: 5681 case OLD_DATA_SPACE:
5663 return heap_->old_data_space(); 5682 return heap_->old_data_space();
5664 case CODE_SPACE: 5683 case CODE_SPACE:
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
6397 static_cast<int>(object_sizes_last_time_[index])); 6416 static_cast<int>(object_sizes_last_time_[index]));
6398 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6417 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6399 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6418 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6400 6419
6401 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6420 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6402 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6421 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6403 ClearObjectStats(); 6422 ClearObjectStats();
6404 } 6423 }
6405 } 6424 }
6406 } // namespace v8::internal 6425 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/json-parser.h » ('j') | test/mjsunit/regress/regress-472504.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698