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

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

Issue 796063006: Rename Thread -> OSThread. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/lockers.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 "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 11 matching lines...) Expand all
22 #include "vm/parser.h" 22 #include "vm/parser.h"
23 #include "vm/port.h" 23 #include "vm/port.h"
24 #include "vm/profiler.h" 24 #include "vm/profiler.h"
25 #include "vm/reusable_handles.h" 25 #include "vm/reusable_handles.h"
26 #include "vm/service.h" 26 #include "vm/service.h"
27 #include "vm/simulator.h" 27 #include "vm/simulator.h"
28 #include "vm/stack_frame.h" 28 #include "vm/stack_frame.h"
29 #include "vm/stub_code.h" 29 #include "vm/stub_code.h"
30 #include "vm/symbols.h" 30 #include "vm/symbols.h"
31 #include "vm/tags.h" 31 #include "vm/tags.h"
32 #include "vm/thread.h" 32 #include "vm/os_thread.h"
33 #include "vm/thread_interrupter.h" 33 #include "vm/thread_interrupter.h"
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, trace_isolates, false, 40 DEFINE_FLAG(bool, trace_isolates, false,
41 "Trace isolate creation and shut down."); 41 "Trace isolate creation and shut down.");
42 DEFINE_FLAG(bool, pause_isolates_on_start, false, 42 DEFINE_FLAG(bool, pause_isolates_on_start, false,
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 574
575 575
576 void Isolate::SetCurrent(Isolate* current) { 576 void Isolate::SetCurrent(Isolate* current) {
577 Isolate* old_current = Current(); 577 Isolate* old_current = Current();
578 if (old_current != NULL) { 578 if (old_current != NULL) {
579 old_current->set_vm_tag(VMTag::kIdleTagId); 579 old_current->set_vm_tag(VMTag::kIdleTagId);
580 old_current->set_thread_state(NULL); 580 old_current->set_thread_state(NULL);
581 Profiler::EndExecution(old_current); 581 Profiler::EndExecution(old_current);
582 } 582 }
583 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); 583 OSThread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current));
584 if (current != NULL) { 584 if (current != NULL) {
585 ASSERT(current->thread_state() == NULL); 585 ASSERT(current->thread_state() == NULL);
586 InterruptableThreadState* thread_state = 586 InterruptableThreadState* thread_state =
587 ThreadInterrupter::GetCurrentThreadState(); 587 ThreadInterrupter::GetCurrentThreadState();
588 #if defined(DEBUG) 588 #if defined(DEBUG)
589 CheckForDuplicateThreadState(thread_state); 589 CheckForDuplicateThreadState(thread_state);
590 #endif 590 #endif
591 ASSERT(thread_state != NULL); 591 ASSERT(thread_state != NULL);
592 Profiler::BeginExecution(current); 592 Profiler::BeginExecution(current);
593 current->set_thread_state(thread_state); 593 current->set_thread_state(thread_state);
594 current->set_vm_tag(VMTag::kVMTagId); 594 current->set_vm_tag(VMTag::kVMTagId);
595 } 595 }
596 } 596 }
597 597
598 598
599 // The single thread local key which stores all the thread local data 599 // The single thread local key which stores all the thread local data
600 // for a thread. Since an Isolate is the central repository for 600 // for a thread. Since an Isolate is the central repository for
601 // storing all isolate specific information a single thread local key 601 // storing all isolate specific information a single thread local key
602 // is sufficient. 602 // is sufficient.
603 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey; 603 ThreadLocalKey Isolate::isolate_key = OSThread::kUnsetThreadLocalKey;
604 604
605 605
606 void Isolate::InitOnce() { 606 void Isolate::InitOnce() {
607 ASSERT(isolate_key == Thread::kUnsetThreadLocalKey); 607 ASSERT(isolate_key == OSThread::kUnsetThreadLocalKey);
608 isolate_key = Thread::CreateThreadLocal(); 608 isolate_key = OSThread::CreateThreadLocal();
609 ASSERT(isolate_key != Thread::kUnsetThreadLocalKey); 609 ASSERT(isolate_key != OSThread::kUnsetThreadLocalKey);
610 create_callback_ = NULL; 610 create_callback_ = NULL;
611 isolates_list_monitor_ = new Monitor(); 611 isolates_list_monitor_ = new Monitor();
612 ASSERT(isolates_list_monitor_ != NULL); 612 ASSERT(isolates_list_monitor_ != NULL);
613 } 613 }
614 614
615 615
616 Isolate* Isolate::Init(const char* name_prefix) { 616 Isolate* Isolate::Init(const char* name_prefix) {
617 Isolate* result = new Isolate(); 617 Isolate* result = new Isolate();
618 ASSERT(result != NULL); 618 ASSERT(result != NULL);
619 619
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 const char* kFormat = "%s-%lld"; 686 const char* kFormat = "%s-%lld";
687 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; 687 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1;
688 name_ = new char[len]; 688 name_ = new char[len];
689 OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); 689 OS::SNPrint(name_, len, kFormat, name_prefix, main_port());
690 } 690 }
691 691
692 692
693 // TODO(5411455): Use flag to override default value and Validate the 693 // TODO(5411455): Use flag to override default value and Validate the
694 // stack size by querying OS. 694 // stack size by querying OS.
695 uword Isolate::GetSpecifiedStackSize() { 695 uword Isolate::GetSpecifiedStackSize() {
696 ASSERT(Isolate::kStackSizeBuffer < Thread::GetMaxStackSize()); 696 ASSERT(Isolate::kStackSizeBuffer < OSThread::GetMaxStackSize());
697 uword stack_size = Thread::GetMaxStackSize() - Isolate::kStackSizeBuffer; 697 uword stack_size = OSThread::GetMaxStackSize() - Isolate::kStackSizeBuffer;
698 return stack_size; 698 return stack_size;
699 } 699 }
700 700
701 701
702 void Isolate::SetStackLimitFromStackBase(uword stack_base) { 702 void Isolate::SetStackLimitFromStackBase(uword stack_base) {
703 // Set stack base. 703 // Set stack base.
704 stack_base_ = stack_base; 704 stack_base_ = stack_base;
705 705
706 // Set stack limit. 706 // Set stack limit.
707 #if defined(USING_SIMULATOR) 707 #if defined(USING_SIMULATOR)
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 msg_handler->paused_on_exit())) { 1358 msg_handler->paused_on_exit())) {
1359 // Paused at start / exit . Don't tick. 1359 // Paused at start / exit . Don't tick.
1360 return 0; 1360 return 0;
1361 } 1361 }
1362 InterruptableThreadState* state = thread_state(); 1362 InterruptableThreadState* state = thread_state();
1363 if (state == NULL) { 1363 if (state == NULL) {
1364 // Isolate is not scheduled on a thread. 1364 // Isolate is not scheduled on a thread.
1365 ProfileIdle(); 1365 ProfileIdle();
1366 return 1; 1366 return 1;
1367 } 1367 }
1368 ASSERT(state->id != Thread::kInvalidThreadId); 1368 ASSERT(state->id != OSThread::kInvalidThreadId);
1369 ThreadInterrupter::InterruptThread(state); 1369 ThreadInterrupter::InterruptThread(state);
1370 return 1; 1370 return 1;
1371 } 1371 }
1372 1372
1373 1373
1374 void Isolate::ProfileIdle() { 1374 void Isolate::ProfileIdle() {
1375 vm_tag_counters_.Increment(vm_tag()); 1375 vm_tag_counters_.Increment(vm_tag());
1376 } 1376 }
1377 1377
1378 1378
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 serialized_message_, serialized_message_len_); 1631 serialized_message_, serialized_message_len_);
1632 } 1632 }
1633 1633
1634 1634
1635 void IsolateSpawnState::Cleanup() { 1635 void IsolateSpawnState::Cleanup() {
1636 SwitchIsolateScope switch_scope(I); 1636 SwitchIsolateScope switch_scope(I);
1637 Dart::ShutdownIsolate(); 1637 Dart::ShutdownIsolate();
1638 } 1638 }
1639 1639
1640 } // namespace dart 1640 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/lockers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698