OLD | NEW |
---|---|
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 // TODO(5411455): Use flag to override default value and Validate the | 642 // TODO(5411455): Use flag to override default value and Validate the |
643 // stack size by querying OS. | 643 // stack size by querying OS. |
644 uword Isolate::GetSpecifiedStackSize() { | 644 uword Isolate::GetSpecifiedStackSize() { |
645 ASSERT(Isolate::kStackSizeBuffer < Thread::GetMaxStackSize()); | 645 ASSERT(Isolate::kStackSizeBuffer < Thread::GetMaxStackSize()); |
646 uword stack_size = Thread::GetMaxStackSize() - Isolate::kStackSizeBuffer; | 646 uword stack_size = Thread::GetMaxStackSize() - Isolate::kStackSizeBuffer; |
647 return stack_size; | 647 return stack_size; |
648 } | 648 } |
649 | 649 |
650 | 650 |
651 void Isolate::SetStackLimitFromStackBase(uword stack_base) { | 651 void Isolate::SetStackLimitFromStackBase(uword stack_base) { |
652 // Set stack base. | |
653 stack_base_ = stack_base; | |
654 | |
655 // Set stack limit. | |
652 #if defined(USING_SIMULATOR) | 656 #if defined(USING_SIMULATOR) |
653 // Ignore passed-in native stack top and use Simulator stack top. | 657 // Ignore passed-in native stack top and use Simulator stack top. |
654 Simulator* sim = Simulator::Current(); // May allocate a simulator. | 658 Simulator* sim = Simulator::Current(); // May allocate a simulator. |
655 ASSERT(simulator() == sim); // This isolate's simulator is the current one. | 659 ASSERT(simulator() == sim); // This isolate's simulator is the current one. |
656 stack_base = sim->StackTop(); | 660 stack_base = sim->StackTop(); |
657 // The overflow area is accounted for by the simulator. | 661 // The overflow area is accounted for by the simulator. |
658 #endif | 662 #endif |
659 // Set stack base. | 663 SetStackLimit(stack_base - GetSpecifiedStackSize()); |
660 stack_base_ = stack_base; | |
661 // Set stack limit. | |
662 SetStackLimit(stack_base_ - GetSpecifiedStackSize()); | |
663 } | 664 } |
664 | 665 |
665 | 666 |
666 void Isolate::SetStackLimit(uword limit) { | 667 void Isolate::SetStackLimit(uword limit) { |
667 // The isolate setting the stack limit is not necessarily the isolate which | 668 // The isolate setting the stack limit is not necessarily the isolate which |
668 // the stack limit is being set on. | 669 // the stack limit is being set on. |
669 MutexLocker ml(mutex_); | 670 MutexLocker ml(mutex_); |
670 if (stack_limit_ == saved_stack_limit_) { | 671 if (stack_limit_ == saved_stack_limit_) { |
671 // No interrupt pending, set stack_limit_ too. | 672 // No interrupt pending, set stack_limit_ too. |
672 stack_limit_ = limit; | 673 stack_limit_ = limit; |
673 } | 674 } |
674 saved_stack_limit_ = limit; | 675 saved_stack_limit_ = limit; |
675 } | 676 } |
676 | 677 |
677 | 678 |
678 void Isolate::ClearStackLimit() { | 679 void Isolate::ClearStackLimit() { |
679 SetStackLimit(~static_cast<uword>(0)); | 680 SetStackLimit(~static_cast<uword>(0)); |
680 stack_base_ = 0; | 681 stack_base_ = 0; |
681 } | 682 } |
682 | 683 |
683 | 684 |
684 bool Isolate::GetProfilerStackBounds(uword* lower, uword* upper) const { | 685 bool Isolate::GetProfilerStackBounds(uword* lower, uword* upper) const { |
685 uword stack_lower = stack_limit(); | 686 uword stack_upper = stack_base_; |
686 if (stack_lower == kUwordMax) { | 687 if (stack_upper == 0) { |
687 stack_lower = saved_stack_limit(); | |
688 } | |
689 if (stack_lower == kUwordMax) { | |
690 return false; | 688 return false; |
691 } | 689 } |
692 uword stack_upper = stack_lower + GetSpecifiedStackSize(); | 690 uword stack_lower = stack_upper - GetSpecifiedStackSize(); |
693 *lower = stack_lower; | 691 *lower = stack_lower; |
694 *upper = stack_upper; | 692 *upper = stack_upper; |
695 return true; | 693 return true; |
696 } | 694 } |
siva
2014/11/14 18:02:51
When this function is called by Profiler::RecordSa
| |
697 | 695 |
698 | 696 |
699 void Isolate::ScheduleInterrupts(uword interrupt_bits) { | 697 void Isolate::ScheduleInterrupts(uword interrupt_bits) { |
700 MutexLocker ml(mutex_); | 698 MutexLocker ml(mutex_); |
701 ASSERT((interrupt_bits & ~kInterruptsMask) == 0); // Must fit in mask. | 699 ASSERT((interrupt_bits & ~kInterruptsMask) == 0); // Must fit in mask. |
702 if (stack_limit_ == saved_stack_limit_) { | 700 if (stack_limit_ == saved_stack_limit_) { |
703 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; | 701 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; |
704 } | 702 } |
705 stack_limit_ |= interrupt_bits; | 703 stack_limit_ |= interrupt_bits; |
706 } | 704 } |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 serialized_message_, serialized_message_len_); | 1579 serialized_message_, serialized_message_len_); |
1582 } | 1580 } |
1583 | 1581 |
1584 | 1582 |
1585 void IsolateSpawnState::Cleanup() { | 1583 void IsolateSpawnState::Cleanup() { |
1586 SwitchIsolateScope switch_scope(I); | 1584 SwitchIsolateScope switch_scope(I); |
1587 Dart::ShutdownIsolate(); | 1585 Dart::ShutdownIsolate(); |
1588 } | 1586 } |
1589 | 1587 |
1590 } // namespace dart | 1588 } // namespace dart |
OLD | NEW |