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

Side by Side Diff: src/isolate.cc

Issue 1009603003: Add debug checks to catch crashes with WeakCell::cast(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/mark-compact.cc ('k') | src/objects.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 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 2562
2563 2563
2564 void Isolate::CheckDetachedContextsAfterGC() { 2564 void Isolate::CheckDetachedContextsAfterGC() {
2565 HandleScope scope(this); 2565 HandleScope scope(this);
2566 Handle<FixedArray> detached_contexts(heap()->detached_contexts()); 2566 Handle<FixedArray> detached_contexts(heap()->detached_contexts());
2567 int length = detached_contexts->length(); 2567 int length = detached_contexts->length();
2568 if (length == 0) return; 2568 if (length == 0) return;
2569 int new_length = 0; 2569 int new_length = 0;
2570 for (int i = 0; i < length; i += 2) { 2570 for (int i = 0; i < length; i += 2) {
2571 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value(); 2571 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
2572 DCHECK(detached_contexts->get(i + 1)->IsWeakCell());
2572 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1)); 2573 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
2573 if (!cell->cleared()) { 2574 if (!cell->cleared()) {
2574 detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1)); 2575 detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1));
2575 detached_contexts->set(new_length + 1, cell); 2576 detached_contexts->set(new_length + 1, cell);
2576 new_length += 2; 2577 new_length += 2;
2577 } 2578 }
2578 counters()->detached_context_age_in_gc()->AddSample(mark_sweeps + 1); 2579 counters()->detached_context_age_in_gc()->AddSample(mark_sweeps + 1);
2579 } 2580 }
2580 if (FLAG_trace_detached_contexts) { 2581 if (FLAG_trace_detached_contexts) {
2581 PrintF("%d detached contexts are collected out of %d\n", 2582 PrintF("%d detached contexts are collected out of %d\n",
2582 length - new_length, length); 2583 length - new_length, length);
2583 for (int i = 0; i < new_length; i += 2) { 2584 for (int i = 0; i < new_length; i += 2) {
2584 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value(); 2585 int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
2586 DCHECK(detached_contexts->get(i + 1)->IsWeakCell());
2585 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1)); 2587 WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
2586 if (mark_sweeps > 3) { 2588 if (mark_sweeps > 3) {
2587 PrintF("detached context 0x%p\n survived %d GCs (leak?)\n", 2589 PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
2588 static_cast<void*>(cell->value()), mark_sweeps); 2590 static_cast<void*>(cell->value()), mark_sweeps);
2589 } 2591 }
2590 } 2592 }
2591 } 2593 }
2592 if (new_length == 0) { 2594 if (new_length == 0) {
2593 heap()->set_detached_contexts(heap()->empty_fixed_array()); 2595 heap()->set_detached_contexts(heap()->empty_fixed_array());
2594 } else if (new_length < length) { 2596 } else if (new_length < length) {
(...skipping 20 matching lines...) Expand all
2615 if (prev_ && prev_->Intercept(flag)) return true; 2617 if (prev_ && prev_->Intercept(flag)) return true;
2616 // Then check whether this scope intercepts. 2618 // Then check whether this scope intercepts.
2617 if ((flag & intercept_mask_)) { 2619 if ((flag & intercept_mask_)) {
2618 intercepted_flags_ |= flag; 2620 intercepted_flags_ |= flag;
2619 return true; 2621 return true;
2620 } 2622 }
2621 return false; 2623 return false;
2622 } 2624 }
2623 2625
2624 } } // namespace v8::internal 2626 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698