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

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

Issue 9242035: Give isolates names to be used during debugging. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
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 "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 "vm/bigint_store.h" 9 #include "vm/bigint_store.h"
10 #include "vm/code_index_table.h" 10 #include "vm/code_index_table.h"
(...skipping 10 matching lines...) Expand all
21 #include "vm/random.h" 21 #include "vm/random.h"
22 #include "vm/stack_frame.h" 22 #include "vm/stack_frame.h"
23 #include "vm/stub_code.h" 23 #include "vm/stub_code.h"
24 #include "vm/thread.h" 24 #include "vm/thread.h"
25 #include "vm/timer.h" 25 #include "vm/timer.h"
26 #include "vm/visitor.h" 26 #include "vm/visitor.h"
27 27
28 namespace dart { 28 namespace dart {
29 29
30 DEFINE_FLAG(bool, report_invocation_count, false, 30 DEFINE_FLAG(bool, report_invocation_count, false,
31 "Count function invocations and report."); 31 "Count function invocations and report.");
32 DEFINE_FLAG(bool, trace_isolates, false,
33 "Trace isolate creation and shut down.");
32 DECLARE_FLAG(bool, generate_gdb_symbols); 34 DECLARE_FLAG(bool, generate_gdb_symbols);
33 35
34 36
35 Isolate::Isolate() 37 Isolate::Isolate()
36 : store_buffer_(), 38 : store_buffer_(),
37 message_queue_(NULL), 39 message_queue_(NULL),
38 post_message_callback_(NULL), 40 post_message_callback_(NULL),
39 close_port_callback_(NULL), 41 close_port_callback_(NULL),
42 name_(NULL),
40 num_ports_(0), 43 num_ports_(0),
41 live_ports_(0), 44 live_ports_(0),
42 main_port_(0), 45 main_port_(0),
43 heap_(NULL), 46 heap_(NULL),
44 object_store_(NULL), 47 object_store_(NULL),
45 top_resource_(NULL), 48 top_resource_(NULL),
46 top_context_(Context::null()), 49 top_context_(Context::null()),
47 current_zone_(NULL), 50 current_zone_(NULL),
48 #if defined(DEBUG) 51 #if defined(DEBUG)
49 no_gc_scope_depth_(0), 52 no_gc_scope_depth_(0),
(...skipping 12 matching lines...) Expand all
62 long_jump_base_(NULL), 65 long_jump_base_(NULL),
63 timer_list_(), 66 timer_list_(),
64 ast_node_id_(AstNode::kNoId), 67 ast_node_id_(AstNode::kNoId),
65 mutex_(new Mutex()), 68 mutex_(new Mutex()),
66 stack_limit_(0), 69 stack_limit_(0),
67 saved_stack_limit_(0) { 70 saved_stack_limit_(0) {
68 } 71 }
69 72
70 73
71 Isolate::~Isolate() { 74 Isolate::~Isolate() {
75 delete [] name_;
72 delete message_queue_; 76 delete message_queue_;
73 delete heap_; 77 delete heap_;
74 delete object_store_; 78 delete object_store_;
75 // Do not delete stack resources: top_resource_ and current_zone_. 79 // Do not delete stack resources: top_resource_ and current_zone_.
76 delete bigint_store_; 80 delete bigint_store_;
77 delete api_state_; 81 delete api_state_;
78 delete stub_code_; 82 delete stub_code_;
79 delete code_index_table_; 83 delete code_index_table_;
80 delete mutex_; 84 delete mutex_;
81 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 85 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
(...skipping 18 matching lines...) Expand all
100 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); 104 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
101 ASSERT(isolate != NULL); 105 ASSERT(isolate != NULL);
102 if (port == kCloseAllPorts) { 106 if (port == kCloseAllPorts) {
103 isolate->message_queue()->FlushAll(); 107 isolate->message_queue()->FlushAll();
104 } else { 108 } else {
105 isolate->message_queue()->Flush(port); 109 isolate->message_queue()->Flush(port);
106 } 110 }
107 } 111 }
108 112
109 113
110 Isolate* Isolate::Init() { 114 Isolate* Isolate::Init(const char* name_prefix) {
111 Isolate* result = new Isolate(); 115 Isolate* result = new Isolate();
112 ASSERT(result != NULL); 116 ASSERT(result != NULL);
113 117
114 // TODO(5411455): For now just set the recently created isolate as 118 // TODO(5411455): For now just set the recently created isolate as
115 // the current isolate. 119 // the current isolate.
116 SetCurrent(result); 120 SetCurrent(result);
117 121
118 // Set up the isolate message queue. 122 // Set up the isolate message queue.
119 MessageQueue* queue = new MessageQueue(); 123 MessageQueue* queue = new MessageQueue();
120 ASSERT(queue != NULL); 124 ASSERT(queue != NULL);
121 result->set_message_queue(queue); 125 result->set_message_queue(queue);
122 result->set_post_message_callback(&StandardPostMessageCallback); 126 result->set_post_message_callback(&StandardPostMessageCallback);
123 result->set_close_port_callback(&StandardClosePortCallback); 127 result->set_close_port_callback(&StandardClosePortCallback);
124 128
125 // Setup the Dart API state. 129 // Setup the Dart API state.
126 ApiState* state = new ApiState(); 130 ApiState* state = new ApiState();
127 ASSERT(state != NULL); 131 ASSERT(state != NULL);
128 result->set_api_state(state); 132 result->set_api_state(state);
129 133
130 // Initialize stack top and limit in case we are running the isolate in the 134 // Initialize stack top and limit in case we are running the isolate in the
131 // main thread. 135 // main thread.
132 // TODO(5411455): Need to figure out how to set the stack limit for the 136 // TODO(5411455): Need to figure out how to set the stack limit for the
133 // main thread. 137 // main thread.
134 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); 138 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result));
135 result->set_main_port(PortMap::CreatePort()); 139 result->set_main_port(PortMap::CreatePort());
140 result->BuildName(name_prefix);
136 141
137 result->debugger_ = new Debugger(); 142 result->debugger_ = new Debugger();
138 result->debugger_->Initialize(result); 143 result->debugger_->Initialize(result);
144 if (FLAG_trace_isolates) {
145 if (strcmp(name_prefix, "vm-isolate") != 0) {
146 OS::Print("[+] Starting isolate:\n"
147 "\tisolate: %s\n", result->name());
148 }
149 }
150 return result;
151 }
139 152
140 return result; 153
154 void Isolate::BuildName(const char* name_prefix) {
155 ASSERT(name_ == NULL);
156 if (name_prefix == NULL) {
157 name_prefix = "isolate";
158 }
159 const char* kFormat = "%s-%lld";
160 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1;
161 name_ = new char[len];
162 OS::SNPrint(name_, len, kFormat, name_prefix, main_port());
141 } 163 }
142 164
143 165
144 // TODO(5411455): Use flag to override default value and Validate the 166 // TODO(5411455): Use flag to override default value and Validate the
145 // stack size by querying OS. 167 // stack size by querying OS.
146 uword Isolate::GetSpecifiedStackSize() { 168 uword Isolate::GetSpecifiedStackSize() {
147 uword stack_size = Isolate::kDefaultStackSize - Isolate::kStackSizeBuffer; 169 uword stack_size = Isolate::kDefaultStackSize - Isolate::kStackSizeBuffer;
148 return stack_size; 170 return stack_size;
149 } 171 }
150 172
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 271
250 // Dump all accumalated timer data for the isolate. 272 // Dump all accumalated timer data for the isolate.
251 timer_list_.ReportTimers(); 273 timer_list_.ReportTimers();
252 if (FLAG_report_invocation_count) { 274 if (FLAG_report_invocation_count) {
253 PrintInvokedFunctions(); 275 PrintInvokedFunctions();
254 } 276 }
255 CompilerStats::Print(); 277 CompilerStats::Print();
256 if (FLAG_generate_gdb_symbols) { 278 if (FLAG_generate_gdb_symbols) {
257 DebugInfo::UnregisterAllSections(); 279 DebugInfo::UnregisterAllSections();
258 } 280 }
259 281 if (FLAG_trace_isolates) {
282 OS::Print("[-] Stopping isolate:\n"
283 "\tisolate: %s\n", name());
284 }
260 // TODO(5411455): For now just make sure there are no current isolates 285 // TODO(5411455): For now just make sure there are no current isolates
261 // as we are shutting down the isolate. 286 // as we are shutting down the isolate.
262 SetCurrent(NULL); 287 SetCurrent(NULL);
263 } 288 }
264 289
265 290
266 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; 291 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL;
267 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; 292 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL;
268 293
269 294
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 394 }
370 395
371 396
372 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { 397 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) {
373 if (api_state() != NULL) { 398 if (api_state() != NULL) {
374 api_state()->VisitWeakHandles(visitor); 399 api_state()->VisitWeakHandles(visitor);
375 } 400 }
376 } 401 }
377 402
378 } // namespace dart 403 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698