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