| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Wait until all spawned tasks finish their memory operations. | 306 // Wait until all spawned tasks finish their memory operations. |
| 307 { | 307 { |
| 308 MonitorLocker ml(&monitor); | 308 MonitorLocker ml(&monitor); |
| 309 while (done_count < kTaskCount) { | 309 while (done_count < kTaskCount) { |
| 310 ml.Wait(); | 310 ml.Wait(); |
| 311 } | 311 } |
| 312 // Reset the done counter for use later. | 312 // Reset the done counter for use later. |
| 313 done_count = 0; | 313 done_count = 0; |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Get the information for the current isolate. |
| 317 // We only need to check the current isolate since all tasks are spawned |
| 318 // inside this single isolate. |
| 316 JSONStream stream; | 319 JSONStream stream; |
| 317 Service::PrintJSONForVM(&stream, false); | 320 isolate->PrintJSON(&stream, false); |
| 318 const char* json = stream.ToCString(); | 321 const char* json = stream.ToCString(); |
| 319 | 322 |
| 320 // Confirm all expected entries are in the JSON output. | 323 // Confirm all expected entries are in the JSON output. |
| 321 for (intptr_t i = 0; i < kTaskCount + 1; i++) { | 324 for (intptr_t i = 0; i < kTaskCount + 1; i++) { |
| 322 Thread* thread = threads[i]; | 325 Thread* thread = threads[i]; |
| 323 Isolate* thread_isolate = thread->isolate(); | |
| 324 // Buffer can handle any possible input length given types. | |
| 325 // char thread_address_buf[96]; | |
| 326 // char isolate_address_buf[64]; | |
| 327 Zone* top_zone = thread->zone(); | 326 Zone* top_zone = thread->zone(); |
| 328 | 327 |
| 329 Thread* current_thread = Thread::Current(); | 328 Thread* current_thread = Thread::Current(); |
| 330 StackZone stack_zone(current_thread); | 329 StackZone stack_zone(current_thread); |
| 331 Zone* current_zone = current_thread->zone(); | 330 Zone* current_zone = current_thread->zone(); |
| 332 | 331 |
| 333 // Check that all zones are present with correct sizes. | 332 // Check that all zones are present with correct sizes. |
| 334 while (top_zone != NULL) { | 333 while (top_zone != NULL) { |
| 335 char* zone_info_buf = | 334 char* zone_info_buf = |
| 336 OS::SCreate(current_zone, | 335 OS::SCreate(current_zone, |
| 337 "\"type\":\"_Zone\"," | 336 "\"type\":\"_Zone\"," |
| 338 "\"capacity\":%" Pd | 337 "\"capacity\":%" Pd |
| 339 "," | 338 "," |
| 340 "\"used\":%" Pd "", | 339 "\"used\":%" Pd "", |
| 341 top_zone->SizeInBytes(), top_zone->UsedSizeInBytes()); | 340 top_zone->SizeInBytes(), top_zone->UsedSizeInBytes()); |
| 342 EXPECT_SUBSTRING(zone_info_buf, json); | 341 EXPECT_SUBSTRING(zone_info_buf, json); |
| 343 top_zone = top_zone->previous(); | 342 top_zone = top_zone->previous(); |
| 344 } | 343 } |
| 345 | 344 |
| 346 // Check the thread exists and is the correct size. | 345 // Check the thread exists and is the correct size. |
| 347 char* thread_info_buf = OS::SCreate( | 346 char* thread_info_buf = OS::SCreate( |
| 348 current_zone, | 347 current_zone, |
| 349 "\"type\":\"_Thread\"," | 348 "\"type\":\"_Thread\"," |
| 350 "\"id\":\"threads\\/%" Pd "", | 349 "\"id\":\"threads\\/%" Pd "", |
| 351 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id())); | 350 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id())); |
| 352 | 351 |
| 353 // Ensure the isolate for each thread is valid. | |
| 354 | |
| 355 char* isolate_info_buf = | |
| 356 OS::SCreate(current_zone, | |
| 357 "\"type\":\"Isolate\"," | |
| 358 "\"fixedId\":true," | |
| 359 "\"id\":\"isolates\\/%" Pd64 "", | |
| 360 static_cast<int64_t>(thread_isolate->main_port())); | |
| 361 | |
| 362 EXPECT_SUBSTRING(thread_info_buf, json); | 352 EXPECT_SUBSTRING(thread_info_buf, json); |
| 363 EXPECT_SUBSTRING(isolate_info_buf, json); | |
| 364 } | 353 } |
| 365 | 354 |
| 366 // Unblock the tasks so they can finish. | 355 // Unblock the tasks so they can finish. |
| 367 { | 356 { |
| 368 MonitorLocker sync_ml(&sync); | 357 MonitorLocker sync_ml(&sync); |
| 369 wait = false; | 358 wait = false; |
| 370 sync_ml.NotifyAll(); | 359 sync_ml.NotifyAll(); |
| 371 } | 360 } |
| 372 // Now wait for them all to exit before destroying the isolate. | 361 // Now wait for them all to exit before destroying the isolate. |
| 373 { | 362 { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 TransitionVMToBlocked transition(thread); | 789 TransitionVMToBlocked transition(thread); |
| 801 MonitorLocker ml(&done_monitor); | 790 MonitorLocker ml(&done_monitor); |
| 802 if (done) { | 791 if (done) { |
| 803 break; | 792 break; |
| 804 } | 793 } |
| 805 } | 794 } |
| 806 } | 795 } |
| 807 } | 796 } |
| 808 | 797 |
| 809 } // namespace dart | 798 } // namespace dart |
| OLD | NEW |