[cctests] Check for stray Isolates in DEBUG builds
Bug: Change-Id: Id3373279f2d985f7899cf893c1f63692b97166b7 Reviewed-on: https://chromium-review.googlesource.com/704655 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#48456}
This commit is contained in:
parent
a8590f9d6c
commit
777ca5eb3b
@ -2320,6 +2320,10 @@ class VerboseAccountingAllocator : public AccountingAllocator {
|
||||
size_t allocation_sample_bytes_, pool_sample_bytes_;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
base::AtomicNumber<size_t> Isolate::non_disposed_isolates_;
|
||||
#endif // DEBUG
|
||||
|
||||
Isolate::Isolate(bool enable_serializer)
|
||||
: embedder_data_(),
|
||||
entry_stack_(NULL),
|
||||
@ -2403,7 +2407,9 @@ Isolate::Isolate(bool enable_serializer)
|
||||
#ifdef DEBUG
|
||||
// heap_histograms_ initializes itself.
|
||||
memset(&js_spill_information_, 0, sizeof(js_spill_information_));
|
||||
#endif
|
||||
|
||||
non_disposed_isolates_.Increment(1);
|
||||
#endif // DEBUG
|
||||
|
||||
handle_scope_data_.Initialize();
|
||||
|
||||
@ -2444,6 +2450,10 @@ void Isolate::TearDown() {
|
||||
thread_data_table_->RemoveAllThreads(this);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
non_disposed_isolates_.Decrement(1);
|
||||
#endif // DEBUG
|
||||
|
||||
delete this;
|
||||
|
||||
// Restore the previous current isolate.
|
||||
|
@ -980,6 +980,10 @@ class Isolate {
|
||||
HeapProfiler* heap_profiler() const { return heap_profiler_; }
|
||||
|
||||
#ifdef DEBUG
|
||||
static size_t non_disposed_isolates() {
|
||||
return non_disposed_isolates_.Value();
|
||||
}
|
||||
|
||||
HistogramInfo* heap_histograms() { return heap_histograms_; }
|
||||
|
||||
JSObject::SpillInformation* js_spill_information() {
|
||||
@ -1523,6 +1527,8 @@ class Isolate {
|
||||
double time_millis_at_init_;
|
||||
|
||||
#ifdef DEBUG
|
||||
static base::AtomicNumber<size_t> non_disposed_isolates_;
|
||||
|
||||
// A static array of histogram info for each type.
|
||||
HistogramInfo heap_histograms_[LAST_TYPE + 1];
|
||||
JSObject::SpillInformation js_spill_information_;
|
||||
|
@ -95,7 +95,17 @@ void CcTest::Run() {
|
||||
}
|
||||
isolate_->Enter();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
const size_t active_isolates = i::Isolate::non_disposed_isolates();
|
||||
#endif // DEBUG
|
||||
callback_();
|
||||
#ifdef DEBUG
|
||||
// This DCHECK ensures that all Isolates are properly disposed after finishing
|
||||
// the test. Stray Isolates lead to stray tasks in the platform which can
|
||||
// interact weirdly when swapping in new platforms (for testing) or during
|
||||
// shutdown.
|
||||
DCHECK_EQ(active_isolates, i::Isolate::non_disposed_isolates());
|
||||
#endif // DEBUG
|
||||
if (initialize_) {
|
||||
if (v8::Locker::IsActive()) {
|
||||
v8::Locker locker(isolate_);
|
||||
|
Loading…
Reference in New Issue
Block a user