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

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

Issue 1314673008: Migrate logging infrastructure Isolate->Thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix test. Created 5 years, 3 months 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
OLDNEW
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 "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 DEFINE_FLAG(bool, trace_isolates, false, 50 DEFINE_FLAG(bool, trace_isolates, false,
51 "Trace isolate creation and shut down."); 51 "Trace isolate creation and shut down.");
52 DEFINE_FLAG(bool, pause_isolates_on_start, false, 52 DEFINE_FLAG(bool, pause_isolates_on_start, false,
53 "Pause isolates before starting."); 53 "Pause isolates before starting.");
54 DEFINE_FLAG(bool, pause_isolates_on_exit, false, 54 DEFINE_FLAG(bool, pause_isolates_on_exit, false,
55 "Pause isolates exiting."); 55 "Pause isolates exiting.");
56 DEFINE_FLAG(bool, break_at_isolate_spawn, false, 56 DEFINE_FLAG(bool, break_at_isolate_spawn, false,
57 "Insert a one-time breakpoint at the entrypoint for all spawned " 57 "Insert a one-time breakpoint at the entrypoint for all spawned "
58 "isolates"); 58 "isolates");
59 DEFINE_FLAG(charp, isolate_log_filter, NULL,
60 "Log isolates whose name include the filter. "
61 "Default: service isolate log messages are suppressed.");
62 59
63 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32, 60 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32,
64 "Max size of new gen semi space in MB"); 61 "Max size of new gen semi space in MB");
65 DEFINE_FLAG(int, old_gen_heap_size, 0, 62 DEFINE_FLAG(int, old_gen_heap_size, 0,
66 "Max size of old gen heap size in MB, or 0 for unlimited," 63 "Max size of old gen heap size in MB, or 0 for unlimited,"
67 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap"); 64 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap");
68 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024, 65 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024,
69 "Max total size of external allocations in MB, or 0 for unlimited," 66 "Max total size of external allocations in MB, or 0 for unlimited,"
70 "e.g: --external_max_size=1024 allows up to 1024MB of externals"); 67 "e.g: --external_max_size=1024 allows up to 1024MB of externals");
71 68
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 message_handler_(NULL), 689 message_handler_(NULL),
693 spawn_state_(NULL), 690 spawn_state_(NULL),
694 is_runnable_(false), 691 is_runnable_(false),
695 gc_prologue_callback_(NULL), 692 gc_prologue_callback_(NULL),
696 gc_epilogue_callback_(NULL), 693 gc_epilogue_callback_(NULL),
697 defer_finalization_count_(0), 694 defer_finalization_count_(0),
698 deopt_context_(NULL), 695 deopt_context_(NULL),
699 edge_counter_increment_size_(-1), 696 edge_counter_increment_size_(-1),
700 compiler_stats_(NULL), 697 compiler_stats_(NULL),
701 is_service_isolate_(false), 698 is_service_isolate_(false),
702 log_(new class Log()),
703 stacktrace_(NULL), 699 stacktrace_(NULL),
704 stack_frame_index_(-1), 700 stack_frame_index_(-1),
705 last_allocationprofile_accumulator_reset_timestamp_(0), 701 last_allocationprofile_accumulator_reset_timestamp_(0),
706 last_allocationprofile_gc_timestamp_(0), 702 last_allocationprofile_gc_timestamp_(0),
707 object_id_ring_(NULL), 703 object_id_ring_(NULL),
708 trace_buffer_(NULL), 704 trace_buffer_(NULL),
709 profiler_data_(NULL), 705 profiler_data_(NULL),
710 tag_table_(GrowableObjectArray::null()), 706 tag_table_(GrowableObjectArray::null()),
711 current_tag_(UserTag::null()), 707 current_tag_(UserTag::null()),
712 default_tag_(UserTag::null()), 708 default_tag_(UserTag::null()),
(...skipping 27 matching lines...) Expand all
740 delete debugger_; 736 delete debugger_;
741 #if defined(USING_SIMULATOR) 737 #if defined(USING_SIMULATOR)
742 delete simulator_; 738 delete simulator_;
743 #endif 739 #endif
744 delete mutex_; 740 delete mutex_;
745 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 741 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
746 delete message_handler_; 742 delete message_handler_;
747 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 743 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
748 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 744 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
749 delete spawn_state_; 745 delete spawn_state_;
750 delete log_;
751 log_ = NULL;
752 delete object_id_ring_; 746 delete object_id_ring_;
753 object_id_ring_ = NULL; 747 object_id_ring_ = NULL;
754 delete pause_loop_monitor_; 748 delete pause_loop_monitor_;
755 pause_loop_monitor_ = NULL; 749 pause_loop_monitor_ = NULL;
756 if (compiler_stats_ != NULL) { 750 if (compiler_stats_ != NULL) {
757 delete compiler_stats_; 751 delete compiler_stats_;
758 compiler_stats_ = NULL; 752 compiler_stats_ = NULL;
759 } 753 }
760 delete thread_registry_; 754 delete thread_registry_;
761 } 755 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 name_ = strdup(name_prefix); 894 name_ = strdup(name_prefix);
901 return; 895 return;
902 } 896 }
903 const char* kFormat = "%s-%lld"; 897 const char* kFormat = "%s-%lld";
904 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; 898 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1;
905 name_ = reinterpret_cast<char*>(malloc(len)); 899 name_ = reinterpret_cast<char*>(malloc(len));
906 OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); 900 OS::SNPrint(name_, len, kFormat, name_prefix, main_port());
907 } 901 }
908 902
909 903
910 Log* Isolate::Log() const {
911 if (FLAG_isolate_log_filter == NULL) {
912 if (is_service_isolate_) {
913 // By default, do not log for the service isolate.
914 return Log::NoOpLog();
915 }
916 return log_;
917 }
918 ASSERT(name_ != NULL);
919 if (strstr(name_, FLAG_isolate_log_filter) == NULL) {
920 // Filter does not match, do not log for this isolate.
921 return Log::NoOpLog();
922 }
923 return log_;
924 }
925
926
927 // TODO(5411455): Use flag to override default value and Validate the 904 // TODO(5411455): Use flag to override default value and Validate the
928 // stack size by querying OS. 905 // stack size by querying OS.
929 uword Isolate::GetSpecifiedStackSize() { 906 uword Isolate::GetSpecifiedStackSize() {
930 ASSERT(Isolate::kStackSizeBuffer < OSThread::GetMaxStackSize()); 907 ASSERT(Isolate::kStackSizeBuffer < OSThread::GetMaxStackSize());
931 uword stack_size = OSThread::GetMaxStackSize() - Isolate::kStackSizeBuffer; 908 uword stack_size = OSThread::GetMaxStackSize() - Isolate::kStackSizeBuffer;
932 return stack_size; 909 return stack_size;
933 } 910 }
934 911
935 912
936 void Isolate::SetStackLimitFromStackBase(uword stack_base) { 913 void Isolate::SetStackLimitFromStackBase(uword stack_base) {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); 1535 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1559 1536
1560 if (FLAG_trace_isolates) { 1537 if (FLAG_trace_isolates) {
1561 heap()->PrintSizes(); 1538 heap()->PrintSizes();
1562 megamorphic_cache_table()->PrintSizes(); 1539 megamorphic_cache_table()->PrintSizes();
1563 Symbols::DumpStats(); 1540 Symbols::DumpStats();
1564 OS::Print("[-] Stopping isolate:\n" 1541 OS::Print("[-] Stopping isolate:\n"
1565 "\tisolate: %s\n", name()); 1542 "\tisolate: %s\n", name());
1566 } 1543 }
1567 if (FLAG_print_metrics) { 1544 if (FLAG_print_metrics) {
1568 LogBlock lb(this); 1545 LogBlock lb;
1569 ISL_Print("Printing metrics for %s\n", name()); 1546 THR_Print("Printing metrics for %s\n", name());
1570 #define ISOLATE_METRIC_PRINT(type, variable, name, unit) \ 1547 #define ISOLATE_METRIC_PRINT(type, variable, name, unit) \
1571 ISL_Print("%s\n", metric_##variable##_.ToString()); 1548 THR_Print("%s\n", metric_##variable##_.ToString());
1572 ISOLATE_METRIC_LIST(ISOLATE_METRIC_PRINT); 1549 ISOLATE_METRIC_LIST(ISOLATE_METRIC_PRINT);
1573 #undef ISOLATE_METRIC_PRINT 1550 #undef ISOLATE_METRIC_PRINT
1574 ISL_Print("\n"); 1551 THR_Print("\n");
1575 } 1552 }
1576 } 1553 }
1577 1554
1578 #if defined(DEBUG) 1555 #if defined(DEBUG)
1579 // No concurrent sweeper tasks should be running at this point. 1556 // No concurrent sweeper tasks should be running at this point.
1580 if (heap_ != NULL) { 1557 if (heap_ != NULL) {
1581 PageSpace* old_space = heap_->old_space(); 1558 PageSpace* old_space = heap_->old_space();
1582 MonitorLocker ml(old_space->tasks_lock()); 1559 MonitorLocker ml(old_space->tasks_lock());
1583 ASSERT(old_space->tasks() == 0); 1560 ASSERT(old_space->tasks() == 0);
1584 } 1561 }
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 serialized_message_, serialized_message_len_); 2330 serialized_message_, serialized_message_len_);
2354 } 2331 }
2355 2332
2356 2333
2357 void IsolateSpawnState::Cleanup() { 2334 void IsolateSpawnState::Cleanup() {
2358 SwitchIsolateScope switch_scope(I); 2335 SwitchIsolateScope switch_scope(I);
2359 Dart::ShutdownIsolate(); 2336 Dart::ShutdownIsolate();
2360 } 2337 }
2361 2338
2362 } // namespace dart 2339 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/locations.h » ('j') | runtime/vm/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698