OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "lib/mirrors.h" | 9 #include "lib/mirrors.h" |
10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 620 } |
621 | 621 |
622 | 622 |
623 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 623 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
624 bool visit_prologue_weak_handles) { | 624 bool visit_prologue_weak_handles) { |
625 if (api_state() != NULL) { | 625 if (api_state() != NULL) { |
626 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 626 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
| 630 |
| 631 char* Isolate::GetStatus(const char* request) { |
| 632 char* p = const_cast<char*>(request); |
| 633 const char* service_type = "/isolate/"; |
| 634 ASSERT(strncmp(p, service_type, strlen(service_type)) == 0); |
| 635 p += strlen(service_type); |
| 636 |
| 637 // Extract isolate handle. |
| 638 int64_t addr; |
| 639 OS::StringToInt64(p, &addr); |
| 640 Isolate* isolate = reinterpret_cast<Isolate*>(addr); |
| 641 Heap* heap = isolate->heap(); |
| 642 |
| 643 char buffer[256]; |
| 644 int64_t port = isolate->main_port(); |
| 645 int64_t start_time = (isolate->start_time() / 1000L); |
| 646 #if defined(TARGET_ARCH_X64) |
| 647 const char* format = "{\n" |
| 648 " \"name\": \"%s\",\n" |
| 649 " \"port\": %ld,\n" |
| 650 " \"starttime\": %ld,\n" |
| 651 " \"stacklimit\": %ld,\n" |
| 652 " \"newspace\": {\n" |
| 653 " \"used\": %ld,\n" |
| 654 " \"capacity\": %ld\n" |
| 655 " },\n" |
| 656 " \"oldspace\": {\n" |
| 657 " \"used\": %ld,\n" |
| 658 " \"capacity\": %ld\n" |
| 659 " }\n" |
| 660 "}"; |
| 661 #else |
| 662 const char* format = "{\n" |
| 663 " \"name\": \"%s\",\n" |
| 664 " \"port\": %lld,\n" |
| 665 " \"starttime\": %lld,\n" |
| 666 " \"stacklimit\": %d,\n" |
| 667 " \"newspace\": {\n" |
| 668 " \"used\": %d,\n" |
| 669 " \"capacity\": %d\n" |
| 670 " },\n" |
| 671 " \"oldspace\": {\n" |
| 672 " \"used\": %d,\n" |
| 673 " \"capacity\": %d\n" |
| 674 " }\n" |
| 675 "}"; |
| 676 #endif |
| 677 int n = OS::SNPrint(buffer, 256, format, isolate->name(), port, start_time, |
| 678 isolate->saved_stack_limit(), |
| 679 heap->Used(Heap::kNew) / KB, |
| 680 heap->Capacity(Heap::kNew) / KB, |
| 681 heap->Used(Heap::kOld) / KB, |
| 682 heap->Capacity(Heap::kOld) / KB); |
| 683 ASSERT(n < 256); |
| 684 return strdup(buffer); |
| 685 } |
| 686 |
630 } // namespace dart | 687 } // namespace dart |
OLD | NEW |