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

Side by Side Diff: runtime/vm/thread_test.cc

Issue 1280013004: Restore frame validation (fixes to CL faaf60801f72). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Clean up test. Created 5 years, 4 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 | « runtime/vm/thread_registry.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 a0->Add(true); 124 a0->Add(true);
125 a1.Add(true); 125 a1.Add(true);
126 } 126 }
127 // Check that we can create handles and allocate in old space. 127 // Check that we can create handles and allocate in old space.
128 String& str = String::Handle(zone, String::New("old", Heap::kOld)); 128 String& str = String::Handle(zone, String::New("old", Heap::kOld));
129 EXPECT(str.Equals("old")); 129 EXPECT(str.Equals("old"));
130 130
131 const intptr_t unique_smi = id_ + 928327281; 131 const intptr_t unique_smi = id_ + 928327281;
132 Smi& smi = Smi::Handle(zone, Smi::New(unique_smi)); 132 Smi& smi = Smi::Handle(zone, Smi::New(unique_smi));
133 EXPECT(smi.Value() == unique_smi); 133 EXPECT(smi.Value() == unique_smi);
134 ObjectCounter counter(isolate_, &smi); 134 {
135 // Ensure that our particular zone is visited. 135 ObjectCounter counter(isolate_, &smi);
136 isolate_->IterateObjectPointers(&counter, 136 // Ensure that our particular zone is visited.
137 /* visit_prologue_weak_handles = */ true, 137 isolate_->IterateObjectPointers(
138 /* validate_frames = */ true); 138 &counter,
139 EXPECT_EQ(1, counter.count()); 139 /* visit_prologue_weak_handles = */ true,
140 140 StackFrameIterator::kValidateFrames);
141 EXPECT_EQ(1, counter.count());
142 }
141 char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_); 143 char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_);
142 String& unique_str = String::Handle(zone); 144 String& unique_str = String::Handle(zone);
143 { 145 {
144 // String::New may create additional handles in the topmost scope that 146 // 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. 147 // we don't want to count, so wrap this in its own scope.
146 HANDLESCOPE(thread); 148 HANDLESCOPE(thread);
147 unique_str = String::New(unique_chars, Heap::kOld); 149 unique_str = String::New(unique_chars, Heap::kOld);
148 } 150 }
149 EXPECT(unique_str.Equals(unique_chars)); 151 EXPECT(unique_str.Equals(unique_chars));
150 ObjectCounter str_counter(isolate_, &unique_str); 152 {
151 // Ensure that our particular zone is visited. 153 ObjectCounter str_counter(isolate_, &unique_str);
152 // TODO(koda): Remove "->thread_registry()" after updating stack walker. 154 // Ensure that our particular zone is visited.
153 isolate_->thread_registry()->VisitObjectPointers(&str_counter); 155 isolate_->IterateObjectPointers(
154 // We should visit the string object exactly once. 156 &str_counter,
155 EXPECT_EQ(1, str_counter.count()); 157 /* visit_prologue_weak_handles = */ true,
158 StackFrameIterator::kValidateFrames);
159 // We should visit the string object exactly once.
160 EXPECT_EQ(1, str_counter.count());
161 }
156 } 162 }
157 Thread::ExitIsolateAsHelper(); 163 Thread::ExitIsolateAsHelper();
158 { 164 {
159 MonitorLocker ml(monitor_); 165 MonitorLocker ml(monitor_);
160 *done_ = true; 166 *done_ = true;
161 ml.Notify(); 167 ml.Notify();
162 } 168 }
163 } 169 }
164 170
165 private: 171 private:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 HANDLESCOPE(thread); 272 HANDLESCOPE(thread);
267 const intptr_t kUniqueSmi = 928327281; 273 const intptr_t kUniqueSmi = 928327281;
268 Smi& smi = Smi::Handle(zone, Smi::New(kUniqueSmi)); 274 Smi& smi = Smi::Handle(zone, Smi::New(kUniqueSmi));
269 if ((i % 100) != 0) { 275 if ((i % 100) != 0) {
270 // Usually, we just cooperate. 276 // Usually, we just cooperate.
271 isolate_->thread_registry()->CheckSafepoint(); 277 isolate_->thread_registry()->CheckSafepoint();
272 } else { 278 } else {
273 // But occasionally, organize a rendezvous. 279 // But occasionally, organize a rendezvous.
274 isolate_->thread_registry()->SafepointThreads(); 280 isolate_->thread_registry()->SafepointThreads();
275 ObjectCounter counter(isolate_, &smi); 281 ObjectCounter counter(isolate_, &smi);
276 isolate_->thread_registry()->VisitObjectPointers(&counter); 282 isolate_->IterateObjectPointers(
283 &counter,
284 /* visit_prologue_weak_handles = */ true,
285 StackFrameIterator::kValidateFrames);
277 { 286 {
278 MutexLocker ml(mutex_); 287 MutexLocker ml(mutex_);
279 EXPECT_EQ(*expected_count_, counter.count()); 288 EXPECT_EQ(*expected_count_, counter.count());
280 } 289 }
281 UserTag& tag = UserTag::Handle(zone, isolate_->current_tag()); 290 UserTag& tag = UserTag::Handle(zone, isolate_->current_tag());
282 if (tag.raw() != isolate_->default_tag()) { 291 if (tag.raw() != isolate_->default_tag()) {
283 String& label = String::Handle(zone, tag.label()); 292 String& label = String::Handle(zone, tag.label());
284 EXPECT(label.Equals("foo")); 293 EXPECT(label.Equals("foo"));
285 MutexLocker ml(mutex_); 294 MutexLocker ml(mutex_);
286 if (*expected_count_ == kTaskCount && !local_done_) { 295 if (*expected_count_ == kTaskCount && !local_done_) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 while (true) { 442 while (true) {
434 isolate->thread_registry()->CheckSafepoint(); 443 isolate->thread_registry()->CheckSafepoint();
435 MutexLocker ml(&mutex); 444 MutexLocker ml(&mutex);
436 if (exited == SafepointTestTask::kTaskCount) { 445 if (exited == SafepointTestTask::kTaskCount) {
437 break; 446 break;
438 } 447 }
439 } 448 }
440 } 449 }
441 450
442 } // namespace dart 451 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread_registry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698