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 <sstream> | |
8 | |
7 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 10 #include "platform/assert.h" |
9 #include "lib/mirrors.h" | 11 #include "lib/mirrors.h" |
10 #include "vm/code_observers.h" | 12 #include "vm/code_observers.h" |
11 #include "vm/compiler_stats.h" | 13 #include "vm/compiler_stats.h" |
12 #include "vm/dart_api_state.h" | 14 #include "vm/dart_api_state.h" |
13 #include "vm/dart_entry.h" | 15 #include "vm/dart_entry.h" |
14 #include "vm/debugger.h" | 16 #include "vm/debugger.h" |
15 #include "vm/heap.h" | 17 #include "vm/heap.h" |
16 #include "vm/message_handler.h" | 18 #include "vm/message_handler.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 } | 622 } |
621 | 623 |
622 | 624 |
623 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 625 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
624 bool visit_prologue_weak_handles) { | 626 bool visit_prologue_weak_handles) { |
625 if (api_state() != NULL) { | 627 if (api_state() != NULL) { |
626 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 628 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
627 } | 629 } |
628 } | 630 } |
629 | 631 |
632 | |
633 char* Isolate::GetStatus(const char* request) { | |
634 char* p = const_cast<char*>(request); | |
635 const char* service_type = "/isolate/"; | |
636 ASSERT(strncmp(p, service_type, strlen(service_type)) == 0); | |
637 p += strlen(service_type); | |
638 | |
639 // Extract isolate handle. | |
640 int64_t addr; | |
641 OS::StringToInt64(p, &addr); | |
642 Isolate* isolate = reinterpret_cast<Isolate*>(addr); | |
643 Heap* heap = isolate->heap(); | |
644 | |
645 std::ostringstream stream; | |
646 stream << '{' << std::endl; | |
647 stream << " \"name\": \"" << isolate->name() << "\"," << std::endl; | |
648 stream << " \"port\": " << isolate->main_port() << ',' << std::endl; | |
649 stream << " \"starttime\": " << (isolate->start_time() / 1000) | |
650 << ',' << std::endl; | |
651 stream << " \"stacklimit\": " << isolate->saved_stack_limit() | |
652 << ',' << std::endl; | |
653 stream << " \"newspace\": {" << std::endl; | |
654 stream << " \"used\": " << | |
655 heap->Used(Heap::kNew) / KB << ',' << std::endl; | |
656 stream << " \"capacity\": " << | |
657 heap->Capacity(Heap::kNew) / KB << std::endl; | |
658 stream << " }," << std::endl; | |
659 stream << " \"oldspace\": {" << std::endl; | |
660 stream << " \"used\": " << | |
661 heap->Used(Heap::kOld) / KB << ',' << std::endl; | |
662 stream << " \"capacity\": " << | |
663 heap->Capacity(Heap::kOld) / KB << std::endl; | |
664 stream << " }" << std::endl << "}"; | |
siva
2013/02/09 01:00:57
Can this whole sequence be constructed using OS::S
Tom Ball
2013/02/14 23:45:16
Done.
| |
665 return strdup(stream.str().c_str()); | |
666 } | |
667 | |
630 } // namespace dart | 668 } // namespace dart |
OLD | NEW |