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

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

Issue 2567153002: Updated SimpleManyTasksWithZones test to not use PrintJSONForVM (Closed)
Patch Set: Created 4 years 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/tests/vm/vm.status ('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/safepoint.h" 10 #include "vm/safepoint.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
321 JSONArray arr(&stream);
322 arr.AddValue(isolate, false);
Cutch 2016/12/12 21:28:42 Just call it directly: isolate->PrintJSON(&stream
bkonyi 2016/12/12 21:33:23 Right... Done.
323 }
318 const char* json = stream.ToCString(); 324 const char* json = stream.ToCString();
319 325
320 // Confirm all expected entries are in the JSON output. 326 // Confirm all expected entries are in the JSON output.
321 for (intptr_t i = 0; i < kTaskCount + 1; i++) { 327 for (intptr_t i = 0; i < kTaskCount + 1; i++) {
322 Thread* thread = threads[i]; 328 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(); 329 Zone* top_zone = thread->zone();
328 330
329 Thread* current_thread = Thread::Current(); 331 Thread* current_thread = Thread::Current();
330 StackZone stack_zone(current_thread); 332 StackZone stack_zone(current_thread);
331 Zone* current_zone = current_thread->zone(); 333 Zone* current_zone = current_thread->zone();
332 334
333 // Check that all zones are present with correct sizes. 335 // Check that all zones are present with correct sizes.
334 while (top_zone != NULL) { 336 while (top_zone != NULL) {
335 char* zone_info_buf = 337 char* zone_info_buf =
336 OS::SCreate(current_zone, 338 OS::SCreate(current_zone,
337 "\"type\":\"_Zone\"," 339 "\"type\":\"_Zone\","
338 "\"capacity\":%" Pd 340 "\"capacity\":%" Pd
339 "," 341 ","
340 "\"used\":%" Pd "", 342 "\"used\":%" Pd "",
341 top_zone->SizeInBytes(), top_zone->UsedSizeInBytes()); 343 top_zone->SizeInBytes(), top_zone->UsedSizeInBytes());
342 EXPECT_SUBSTRING(zone_info_buf, json); 344 EXPECT_SUBSTRING(zone_info_buf, json);
343 top_zone = top_zone->previous(); 345 top_zone = top_zone->previous();
344 } 346 }
345 347
346 // Check the thread exists and is the correct size. 348 // Check the thread exists and is the correct size.
347 char* thread_info_buf = OS::SCreate( 349 char* thread_info_buf = OS::SCreate(
348 current_zone, 350 current_zone,
349 "\"type\":\"_Thread\"," 351 "\"type\":\"_Thread\","
350 "\"id\":\"threads\\/%" Pd "", 352 "\"id\":\"threads\\/%" Pd "",
351 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id())); 353 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id()));
352 354
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); 355 EXPECT_SUBSTRING(thread_info_buf, json);
363 EXPECT_SUBSTRING(isolate_info_buf, json);
364 } 356 }
365 357
366 // Unblock the tasks so they can finish. 358 // Unblock the tasks so they can finish.
367 { 359 {
368 MonitorLocker sync_ml(&sync); 360 MonitorLocker sync_ml(&sync);
369 wait = false; 361 wait = false;
370 sync_ml.NotifyAll(); 362 sync_ml.NotifyAll();
371 } 363 }
372 // Now wait for them all to exit before destroying the isolate. 364 // Now wait for them all to exit before destroying the isolate.
373 { 365 {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 TransitionVMToBlocked transition(thread); 792 TransitionVMToBlocked transition(thread);
801 MonitorLocker ml(&done_monitor); 793 MonitorLocker ml(&done_monitor);
802 if (done) { 794 if (done) {
803 break; 795 break;
804 } 796 }
805 } 797 }
806 } 798 }
807 } 799 }
808 800
809 } // namespace dart 801 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698