| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/isolate.h" | 6 #include "vm/isolate.h" |
| 7 #include "vm/lockers.h" | 7 #include "vm/lockers.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
| 10 #include "vm/thread_pool.h" | 10 #include "vm/thread_pool.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 EXPECT(str.Equals("old")); | 127 EXPECT(str.Equals("old")); |
| 128 | 128 |
| 129 const intptr_t unique_smi = id_ + 928327281; | 129 const intptr_t unique_smi = id_ + 928327281; |
| 130 Smi& smi = Smi::Handle(zone, Smi::New(unique_smi)); | 130 Smi& smi = Smi::Handle(zone, Smi::New(unique_smi)); |
| 131 EXPECT(smi.Value() == unique_smi); | 131 EXPECT(smi.Value() == unique_smi); |
| 132 { | 132 { |
| 133 ObjectCounter counter(isolate_, &smi); | 133 ObjectCounter counter(isolate_, &smi); |
| 134 // Ensure that our particular zone is visited. | 134 // Ensure that our particular zone is visited. |
| 135 isolate_->IterateObjectPointers( | 135 isolate_->IterateObjectPointers( |
| 136 &counter, | 136 &counter, |
| 137 /* visit_prologue_weak_handles = */ true, | |
| 138 StackFrameIterator::kValidateFrames); | 137 StackFrameIterator::kValidateFrames); |
| 139 EXPECT_EQ(1, counter.count()); | 138 EXPECT_EQ(1, counter.count()); |
| 140 } | 139 } |
| 141 char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_); | 140 char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_); |
| 142 String& unique_str = String::Handle(zone); | 141 String& unique_str = String::Handle(zone); |
| 143 { | 142 { |
| 144 // String::New may create additional handles in the topmost scope that | 143 // String::New may create additional handles in the topmost scope that |
| 145 // we don't want to count, so wrap this in its own scope. | 144 // we don't want to count, so wrap this in its own scope. |
| 146 HANDLESCOPE(thread); | 145 HANDLESCOPE(thread); |
| 147 unique_str = String::New(unique_chars, Heap::kOld); | 146 unique_str = String::New(unique_chars, Heap::kOld); |
| 148 } | 147 } |
| 149 EXPECT(unique_str.Equals(unique_chars)); | 148 EXPECT(unique_str.Equals(unique_chars)); |
| 150 { | 149 { |
| 151 ObjectCounter str_counter(isolate_, &unique_str); | 150 ObjectCounter str_counter(isolate_, &unique_str); |
| 152 // Ensure that our particular zone is visited. | 151 // Ensure that our particular zone is visited. |
| 153 isolate_->IterateObjectPointers( | 152 isolate_->IterateObjectPointers( |
| 154 &str_counter, | 153 &str_counter, |
| 155 /* visit_prologue_weak_handles = */ true, | |
| 156 StackFrameIterator::kValidateFrames); | 154 StackFrameIterator::kValidateFrames); |
| 157 // We should visit the string object exactly once. | 155 // We should visit the string object exactly once. |
| 158 EXPECT_EQ(1, str_counter.count()); | 156 EXPECT_EQ(1, str_counter.count()); |
| 159 } | 157 } |
| 160 } | 158 } |
| 161 Thread::ExitIsolateAsHelper(); | 159 Thread::ExitIsolateAsHelper(); |
| 162 { | 160 { |
| 163 MonitorLocker ml(monitor_); | 161 MonitorLocker ml(monitor_); |
| 164 *done_ = true; | 162 *done_ = true; |
| 165 ml.Notify(); | 163 ml.Notify(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 Smi& smi = Smi::Handle(zone, Smi::New(kUniqueSmi)); | 270 Smi& smi = Smi::Handle(zone, Smi::New(kUniqueSmi)); |
| 273 if ((i % 100) != 0) { | 271 if ((i % 100) != 0) { |
| 274 // Usually, we just cooperate. | 272 // Usually, we just cooperate. |
| 275 isolate_->thread_registry()->CheckSafepoint(); | 273 isolate_->thread_registry()->CheckSafepoint(); |
| 276 } else { | 274 } else { |
| 277 // But occasionally, organize a rendezvous. | 275 // But occasionally, organize a rendezvous. |
| 278 isolate_->thread_registry()->SafepointThreads(); | 276 isolate_->thread_registry()->SafepointThreads(); |
| 279 ObjectCounter counter(isolate_, &smi); | 277 ObjectCounter counter(isolate_, &smi); |
| 280 isolate_->IterateObjectPointers( | 278 isolate_->IterateObjectPointers( |
| 281 &counter, | 279 &counter, |
| 282 /* visit_prologue_weak_handles = */ true, | |
| 283 StackFrameIterator::kValidateFrames); | 280 StackFrameIterator::kValidateFrames); |
| 284 { | 281 { |
| 285 MutexLocker ml(mutex_); | 282 MutexLocker ml(mutex_); |
| 286 EXPECT_EQ(*expected_count_, counter.count()); | 283 EXPECT_EQ(*expected_count_, counter.count()); |
| 287 } | 284 } |
| 288 UserTag& tag = UserTag::Handle(zone, isolate_->current_tag()); | 285 UserTag& tag = UserTag::Handle(zone, isolate_->current_tag()); |
| 289 if (tag.raw() != isolate_->default_tag()) { | 286 if (tag.raw() != isolate_->default_tag()) { |
| 290 String& label = String::Handle(zone, tag.label()); | 287 String& label = String::Handle(zone, tag.label()); |
| 291 EXPECT(label.Equals("foo")); | 288 EXPECT(label.Equals("foo")); |
| 292 MutexLocker ml(mutex_); | 289 MutexLocker ml(mutex_); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 isolate->thread_registry()->CheckSafepoint(); | 577 isolate->thread_registry()->CheckSafepoint(); |
| 581 MonitorLocker ml(&done_monitor); | 578 MonitorLocker ml(&done_monitor); |
| 582 if (done) { | 579 if (done) { |
| 583 break; | 580 break; |
| 584 } | 581 } |
| 585 } | 582 } |
| 586 } | 583 } |
| 587 } | 584 } |
| 588 | 585 |
| 589 } // namespace dart | 586 } // namespace dart |
| OLD | NEW |