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

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

Issue 181503006: Add flag to pin and service command to release isolates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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) 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 "lib/mirrors.h" 10 #include "lib/mirrors.h"
(...skipping 23 matching lines...) Expand all
34 #include "vm/timer.h" 34 #include "vm/timer.h"
35 #include "vm/visitor.h" 35 #include "vm/visitor.h"
36 36
37 37
38 namespace dart { 38 namespace dart {
39 39
40 DEFINE_FLAG(bool, report_usage_count, false, 40 DEFINE_FLAG(bool, report_usage_count, false,
41 "Track function usage and report."); 41 "Track function usage and report.");
42 DEFINE_FLAG(bool, trace_isolates, false, 42 DEFINE_FLAG(bool, trace_isolates, false,
43 "Trace isolate creation and shut down."); 43 "Trace isolate creation and shut down.");
44 DEFINE_FLAG(bool, pin_isolates, false,
45 "Stop isolates from being destroyed automatically.");
44 46
45 47
46 void Isolate::RegisterClass(const Class& cls) { 48 void Isolate::RegisterClass(const Class& cls) {
47 class_table()->Register(cls); 49 class_table()->Register(cls);
48 if (object_histogram() != NULL) object_histogram()->RegisterClass(cls); 50 if (object_histogram() != NULL) object_histogram()->RegisterClass(cls);
49 } 51 }
50 52
51 53
52 class IsolateMessageHandler : public MessageHandler { 54 class IsolateMessageHandler : public MessageHandler {
53 public: 55 public:
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 277
276 278
277 #define REUSABLE_HANDLE_INITIALIZERS(object) \ 279 #define REUSABLE_HANDLE_INITIALIZERS(object) \
278 object##_handle_(NULL), 280 object##_handle_(NULL),
279 281
280 Isolate::Isolate() 282 Isolate::Isolate()
281 : store_buffer_(), 283 : store_buffer_(),
282 message_notify_callback_(NULL), 284 message_notify_callback_(NULL),
283 name_(NULL), 285 name_(NULL),
284 start_time_(OS::GetCurrentTimeMicros()), 286 start_time_(OS::GetCurrentTimeMicros()),
287 pin_port_(0),
285 main_port_(0), 288 main_port_(0),
286 heap_(NULL), 289 heap_(NULL),
287 object_store_(NULL), 290 object_store_(NULL),
288 top_context_(Context::null()), 291 top_context_(Context::null()),
289 top_exit_frame_info_(0), 292 top_exit_frame_info_(0),
290 init_callback_data_(NULL), 293 init_callback_data_(NULL),
291 environment_callback_(NULL), 294 environment_callback_(NULL),
292 library_tag_handler_(NULL), 295 library_tag_handler_(NULL),
293 api_state_(NULL), 296 api_state_(NULL),
294 stub_code_(NULL), 297 stub_code_(NULL),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ASSERT(state != NULL); 417 ASSERT(state != NULL);
415 result->set_api_state(state); 418 result->set_api_state(state);
416 419
417 // Initialize stack top and limit in case we are running the isolate in the 420 // Initialize stack top and limit in case we are running the isolate in the
418 // main thread. 421 // main thread.
419 // TODO(5411455): Need to figure out how to set the stack limit for the 422 // TODO(5411455): Need to figure out how to set the stack limit for the
420 // main thread. 423 // main thread.
421 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); 424 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result));
422 result->set_main_port(PortMap::CreatePort(result->message_handler())); 425 result->set_main_port(PortMap::CreatePort(result->message_handler()));
423 result->BuildName(name_prefix); 426 result->BuildName(name_prefix);
427 result->CreatePinPort();
Ivan Posva 2014/02/27 18:07:16 How about: if (FLAG_pin_isolates) { result->Crea
Cutch 2014/02/27 18:13:48 Done.
424 428
425 result->debugger_ = new Debugger(); 429 result->debugger_ = new Debugger();
426 result->debugger_->Initialize(result); 430 result->debugger_->Initialize(result);
427 if (FLAG_trace_isolates) { 431 if (FLAG_trace_isolates) {
428 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 432 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
429 OS::Print("[+] Starting isolate:\n" 433 OS::Print("[+] Starting isolate:\n"
430 "\tisolate: %s\n", result->name()); 434 "\tisolate: %s\n", result->name());
431 } 435 }
432 } 436 }
433 437
434 438
435 return result; 439 return result;
436 } 440 }
437 441
438 442
443 void Isolate::CreatePinPort() {
444 if (!FLAG_pin_isolates) {
Ivan Posva 2014/02/27 18:07:16 See above.
Cutch 2014/02/27 18:13:48 Done.
445 return;
446 }
447 ASSERT(pin_port_ == 0);
448 pin_port_ = PortMap::CreatePort(message_handler());
449 ASSERT(pin_port_ != 0);
450 PortMap::SetLive(pin_port_);
451 }
452
453
454 void Isolate::ClosePinPort() {
455 if (!FLAG_pin_isolates) {
Ivan Posva 2014/02/27 18:07:16 This is equivalent to the pin_port_ == 0 condition
Cutch 2014/02/27 18:13:48 Done.
456 return;
457 }
458 if (pin_port_ == 0) {
459 // Support multiple calls to close.
460 return;
461 }
462 ASSERT(pin_port_ != 0);
463 bool r = PortMap::ClosePort(pin_port_);
464 ASSERT(r);
465 pin_port_ = 0;
466 }
467
468
439 void Isolate::BuildName(const char* name_prefix) { 469 void Isolate::BuildName(const char* name_prefix) {
440 ASSERT(name_ == NULL); 470 ASSERT(name_ == NULL);
441 if (name_prefix == NULL) { 471 if (name_prefix == NULL) {
442 name_prefix = "isolate"; 472 name_prefix = "isolate";
443 } 473 }
444 const char* kFormat = "%s-%lld"; 474 const char* kFormat = "%s-%lld";
445 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; 475 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1;
446 name_ = new char[len]; 476 name_ = new char[len];
447 OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); 477 OS::SNPrint(name_, len, kFormat, name_prefix, main_port());
448 } 478 }
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 return func.raw(); 1081 return func.raw();
1052 } 1082 }
1053 1083
1054 1084
1055 void IsolateSpawnState::Cleanup() { 1085 void IsolateSpawnState::Cleanup() {
1056 SwitchIsolateScope switch_scope(isolate()); 1086 SwitchIsolateScope switch_scope(isolate());
1057 Dart::ShutdownIsolate(); 1087 Dart::ShutdownIsolate();
1058 } 1088 }
1059 1089
1060 } // namespace dart 1090 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/service.cc » ('j') | runtime/vm/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698