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/safepoint.h" | 10 #include "vm/safepoint.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 // inside this single isolate. | 318 // inside this single isolate. |
319 JSONStream stream; | 319 JSONStream stream; |
320 isolate->PrintJSON(&stream, false); | 320 isolate->PrintJSON(&stream, false); |
321 const char* json = stream.ToCString(); | 321 const char* json = stream.ToCString(); |
322 | 322 |
323 Thread* current_thread = Thread::Current(); | 323 Thread* current_thread = Thread::Current(); |
324 | 324 |
325 // Confirm all expected entries are in the JSON output. | 325 // Confirm all expected entries are in the JSON output. |
326 for (intptr_t i = 0; i < kTaskCount + 1; i++) { | 326 for (intptr_t i = 0; i < kTaskCount + 1; i++) { |
327 Thread* thread = threads[i]; | 327 Thread* thread = threads[i]; |
328 | |
329 // Skip checking the current thread since we'll be allocating | |
330 // thread_info_buf into the current thread's zone, messing with the test | |
331 // values. | |
332 if (thread == current_thread) { | |
333 continue; | |
334 } | |
siva
2017/03/22 17:50:55
How did the current_thread get into the threads ar
bkonyi
2017/03/22 18:01:48
Good catch. I guess when I originally wrote this t
| |
335 | |
328 StackZone stack_zone(current_thread); | 336 StackZone stack_zone(current_thread); |
329 Zone* current_zone = current_thread->zone(); | 337 Zone* current_zone = current_thread->zone(); |
330 | 338 |
331 // Check the thread exists and is the correct size. | 339 // Check the thread exists and is the correct size. |
332 char* thread_info_buf = | 340 char* thread_info_buf = OS::SCreate( |
333 OS::SCreate(current_zone, | 341 current_zone, |
334 "\"type\":\"_Thread\"," | 342 "\"type\":\"_Thread\"," |
335 "\"id\":\"threads\\/%" Pd | 343 "\"id\":\"threads\\/%" Pd |
336 "\"," | 344 "\"," |
337 "\"kind\":\"%s\"," | 345 "\"kind\":\"%s\"," |
338 "\"_memoryHighWatermark\":\"%" Pu "\"", | 346 "\"_zoneHighWatermark\":\"%" Pu |
339 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id()), | 347 "\"," |
340 Thread::TaskKindToCString(thread->task_kind()), | 348 "\"_zoneCapacity\":\"%" Pu |
341 thread->memory_high_watermark()); | 349 "\"," |
342 | 350 "\"_zoneUsage\":\"%" Pu "\"", |
351 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id()), | |
352 Thread::TaskKindToCString(thread->task_kind()), | |
353 thread->zone_high_watermark(), thread->current_zone_capacity(), | |
354 thread->current_zone_memory_usage()); | |
343 EXPECT_SUBSTRING(thread_info_buf, json); | 355 EXPECT_SUBSTRING(thread_info_buf, json); |
344 } | 356 } |
345 | 357 |
346 // Unblock the tasks so they can finish. | 358 // Unblock the tasks so they can finish. |
347 { | 359 { |
348 MonitorLocker sync_ml(&sync); | 360 MonitorLocker sync_ml(&sync); |
349 wait = false; | 361 wait = false; |
350 sync_ml.NotifyAll(); | 362 sync_ml.NotifyAll(); |
351 } | 363 } |
352 // Now wait for them all to exit before destroying the isolate. | 364 // Now wait for them all to exit before destroying the isolate. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 TransitionVMToBlocked transition(thread); | 792 TransitionVMToBlocked transition(thread); |
781 MonitorLocker ml(&done_monitor); | 793 MonitorLocker ml(&done_monitor); |
782 if (done) { | 794 if (done) { |
783 break; | 795 break; |
784 } | 796 } |
785 } | 797 } |
786 } | 798 } |
787 } | 799 } |
788 | 800 |
789 } // namespace dart | 801 } // namespace dart |
OLD | NEW |