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

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

Issue 205713004: Add isolate tag-profile and better handling of errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 stacktrace_(NULL), 331 stacktrace_(NULL),
332 stack_frame_index_(-1), 332 stack_frame_index_(-1),
333 cha_used_(false), 333 cha_used_(false),
334 object_id_ring_(NULL), 334 object_id_ring_(NULL),
335 profiler_data_(NULL), 335 profiler_data_(NULL),
336 thread_state_(NULL), 336 thread_state_(NULL),
337 next_(NULL), 337 next_(NULL),
338 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 338 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
339 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) 339 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT)
340 reusable_handles_() { 340 reusable_handles_() {
341 set_vm_tag(VMTag::kVMTagId); 341 set_vm_tag(VMTag::kIdleTagId);
342 } 342 }
343 #undef REUSABLE_HANDLE_SCOPE_INIT 343 #undef REUSABLE_HANDLE_SCOPE_INIT
344 #undef REUSABLE_HANDLE_INITIALIZERS 344 #undef REUSABLE_HANDLE_INITIALIZERS
345 345
346 346
347 Isolate::~Isolate() { 347 Isolate::~Isolate() {
348 delete [] name_; 348 delete [] name_;
349 delete heap_; 349 delete heap_;
350 delete object_store_; 350 delete object_store_;
351 delete api_state_; 351 delete api_state_;
352 delete stub_code_; 352 delete stub_code_;
353 delete debugger_; 353 delete debugger_;
354 #if defined(USING_SIMULATOR) 354 #if defined(USING_SIMULATOR)
355 delete simulator_; 355 delete simulator_;
356 #endif 356 #endif
357 delete mutex_; 357 delete mutex_;
358 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 358 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
359 delete message_handler_; 359 delete message_handler_;
360 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 360 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
361 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 361 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
362 delete spawn_state_; 362 delete spawn_state_;
363 } 363 }
364 364
365 365
366 void Isolate::SetCurrent(Isolate* current) { 366 void Isolate::SetCurrent(Isolate* current) {
367 Isolate* old_current = Current(); 367 Isolate* old_current = Current();
368 if (old_current != NULL) { 368 if (old_current != NULL) {
369 old_current->set_vm_tag(VMTag::kIdleTagId);
369 old_current->set_thread_state(NULL); 370 old_current->set_thread_state(NULL);
370 Profiler::EndExecution(old_current); 371 Profiler::EndExecution(old_current);
371 } 372 }
372 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); 373 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current));
373 if (current != NULL) { 374 if (current != NULL) {
374 ASSERT(current->thread_state() == NULL); 375 ASSERT(current->thread_state() == NULL);
375 InterruptableThreadState* thread_state = 376 InterruptableThreadState* thread_state =
376 ThreadInterrupter::GetCurrentThreadState(); 377 ThreadInterrupter::GetCurrentThreadState();
377 #if defined(DEBUG) 378 #if defined(DEBUG)
378 CheckForDuplicateThreadState(thread_state); 379 CheckForDuplicateThreadState(thread_state);
379 #endif 380 #endif
380 Profiler::BeginExecution(current); 381 Profiler::BeginExecution(current);
381 current->set_thread_state(thread_state); 382 current->set_thread_state(thread_state);
383 current->set_vm_tag(VMTag::kVMTagId);
382 } 384 }
383 } 385 }
384 386
385 387
386 // The single thread local key which stores all the thread local data 388 // The single thread local key which stores all the thread local data
387 // for a thread. Since an Isolate is the central repository for 389 // for a thread. Since an Isolate is the central repository for
388 // storing all isolate specific information a single thread local key 390 // storing all isolate specific information a single thread local key
389 // is sufficient. 391 // is sufficient.
390 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey; 392 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey;
391 393
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 jsobj.AddProperty("controlPorts", control_ports); 918 jsobj.AddProperty("controlPorts", control_ports);
917 jsobj.AddProperty("pausedOnStart", pause_on_start); 919 jsobj.AddProperty("pausedOnStart", pause_on_start);
918 jsobj.AddProperty("pausedOnExit", paused_on_exit); 920 jsobj.AddProperty("pausedOnExit", paused_on_exit);
919 jsobj.AddProperty("pauseOnExit", pause_on_exit); 921 jsobj.AddProperty("pauseOnExit", pause_on_exit);
920 const Library& lib = 922 const Library& lib =
921 Library::Handle(object_store()->root_library()); 923 Library::Handle(object_store()->root_library());
922 jsobj.AddProperty("rootLib", lib); 924 jsobj.AddProperty("rootLib", lib);
923 925
924 timer_list().PrintTimersToJSONProperty(&jsobj); 926 timer_list().PrintTimersToJSONProperty(&jsobj);
925 927
928 if (object_store()->sticky_error() != Object::null()) {
929 Error& error = Error::Handle(this, object_store()->sticky_error());
930 ASSERT(!error.IsNull());
931 jsobj.AddProperty("error", error, false);
932 }
933
926 { 934 {
927 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments"); 935 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments");
928 typeargsRef.AddProperty("type", "@TypeArgumentsList"); 936 typeargsRef.AddProperty("type", "@TypeArgumentsList");
929 typeargsRef.AddProperty("id", "typearguments"); 937 typeargsRef.AddProperty("id", "typearguments");
930 typeargsRef.AddProperty("name", "canonical type arguments"); 938 typeargsRef.AddProperty("name", "canonical type arguments");
931 } 939 }
932 } 940 }
933 941
934 942
943 void Isolate::ProfileInterrupt() {
944 InterruptableThreadState* state = thread_state();
945 if (state == NULL) {
946 // Isolate is not scheduled on a thread.
947 ProfileIdle();
948 return;
949 }
950 ASSERT(state->id != Thread::kInvalidThreadId);
951 ThreadInterrupter::InterruptThread(state);
952 }
953
954
955 void Isolate::ProfileIdle() {
956 vm_tag_counters_.Increment(vm_tag());
957 }
958
959
935 void Isolate::VisitIsolates(IsolateVisitor* visitor) { 960 void Isolate::VisitIsolates(IsolateVisitor* visitor) {
936 if (visitor == NULL) { 961 if (visitor == NULL) {
937 return; 962 return;
938 } 963 }
939 MonitorLocker ml(isolates_list_monitor_); 964 MonitorLocker ml(isolates_list_monitor_);
940 Isolate* current = isolates_list_head_; 965 Isolate* current = isolates_list_head_;
941 while (current) { 966 while (current) {
942 visitor->VisitIsolate(current); 967 visitor->VisitIsolate(current);
943 current = current->next_; 968 current = current->next_;
944 } 969 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 return func.raw(); 1119 return func.raw();
1095 } 1120 }
1096 1121
1097 1122
1098 void IsolateSpawnState::Cleanup() { 1123 void IsolateSpawnState::Cleanup() {
1099 SwitchIsolateScope switch_scope(isolate()); 1124 SwitchIsolateScope switch_scope(isolate());
1100 Dart::ShutdownIsolate(); 1125 Dart::ShutdownIsolate();
1101 } 1126 }
1102 1127
1103 } // namespace dart 1128 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698