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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 } | 975 } |
976 | 976 |
977 return result; | 977 return result; |
978 } | 978 } |
979 | 979 |
980 | 980 |
981 /* static */ | 981 /* static */ |
982 uword Isolate::GetCurrentStackPointer() { | 982 uword Isolate::GetCurrentStackPointer() { |
983 // Since AddressSanitizer's detect_stack_use_after_return instruments the | 983 // Since AddressSanitizer's detect_stack_use_after_return instruments the |
984 // C++ code to give out fake stack addresses, we call a stub in that case. | 984 // C++ code to give out fake stack addresses, we call a stub in that case. |
985 uword (*func)() = reinterpret_cast<uword (*)()>( | 985 uword (*func)() = |
986 StubCode::GetStackPointer_entry()->EntryPoint()); | 986 #if !defined(TARGET_ARCH_DBC) |
987 reinterpret_cast<uword (*)()>( | |
988 StubCode::GetStackPointer_entry()->EntryPoint()); | |
989 #else | |
990 NULL; | |
991 #endif | |
987 // But for performance (and to support simulators), we normally use a local. | 992 // But for performance (and to support simulators), we normally use a local. |
988 #if defined(__has_feature) | 993 #if defined(__has_feature) |
989 #if __has_feature(address_sanitizer) | 994 #if __has_feature(address_sanitizer) |
990 uword current_sp = func(); | 995 uword current_sp = func(); |
991 return current_sp; | 996 return current_sp; |
992 #else | 997 #else |
993 uword stack_allocated_local_address = reinterpret_cast<uword>(&func); | 998 uword stack_allocated_local_address = reinterpret_cast<uword>(&func); |
994 return stack_allocated_local_address; | 999 return stack_allocated_local_address; |
995 #endif | 1000 #endif |
996 #else | 1001 #else |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1049 if (ServiceIsolate::NameEquals(name_prefix)) { | 1054 if (ServiceIsolate::NameEquals(name_prefix)) { |
1050 name_ = strdup(name_prefix); | 1055 name_ = strdup(name_prefix); |
1051 return; | 1056 return; |
1052 } | 1057 } |
1053 name_ = OS::SCreate(NULL, "%s-%" Pd64 "", name_prefix, main_port()); | 1058 name_ = OS::SCreate(NULL, "%s-%" Pd64 "", name_prefix, main_port()); |
1054 } | 1059 } |
1055 | 1060 |
1056 | 1061 |
1057 void Isolate::SetStackLimitFromStackBase(uword stack_base) { | 1062 void Isolate::SetStackLimitFromStackBase(uword stack_base) { |
1058 // Set stack limit. | 1063 // Set stack limit. |
1064 #if !defined(TARGET_ARCH_DBC) | |
1059 #if defined(USING_SIMULATOR) | 1065 #if defined(USING_SIMULATOR) |
1060 // Ignore passed-in native stack top and use Simulator stack top. | 1066 // Ignore passed-in native stack top and use Simulator stack top. |
1061 Simulator* sim = Simulator::Current(); // May allocate a simulator. | 1067 Simulator* sim = Simulator::Current(); // May allocate a simulator. |
1062 ASSERT(simulator() == sim); // This isolate's simulator is the current one. | 1068 ASSERT(simulator() == sim); // This isolate's simulator is the current one. |
1063 stack_base = sim->StackTop(); | 1069 stack_base = sim->StackTop(); |
1064 // The overflow area is accounted for by the simulator. | 1070 // The overflow area is accounted for by the simulator. |
1065 #endif | 1071 #endif // defined(USING_SIMULATOR) |
1066 SetStackLimit(stack_base - OSThread::GetSpecifiedStackSize()); | 1072 SetStackLimit(stack_base - OSThread::GetSpecifiedStackSize()); |
1073 #else | |
1074 SetStackLimit(Simulator::Current()->StackTop()); | |
1075 #endif // !defined(TARGET_ARCH_DBC) | |
1067 } | 1076 } |
1068 | 1077 |
1069 | 1078 |
1070 void Isolate::SetStackLimit(uword limit) { | 1079 void Isolate::SetStackLimit(uword limit) { |
1071 // The isolate setting the stack limit is not necessarily the isolate which | 1080 // The isolate setting the stack limit is not necessarily the isolate which |
1072 // the stack limit is being set on. | 1081 // the stack limit is being set on. |
1073 MutexLocker ml(mutex_); | 1082 MutexLocker ml(mutex_); |
1074 if (stack_limit_ == saved_stack_limit_) { | 1083 if (stack_limit_ == saved_stack_limit_) { |
1075 // No interrupt pending, set stack_limit_ too. | 1084 // No interrupt pending, set stack_limit_ too. |
1076 stack_limit_ = limit; | 1085 stack_limit_ = limit; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1495 uword defer_bits = interrupt_bits & deferred_interrupts_mask_; | 1504 uword defer_bits = interrupt_bits & deferred_interrupts_mask_; |
1496 if (defer_bits != 0) { | 1505 if (defer_bits != 0) { |
1497 deferred_interrupts_ |= defer_bits; | 1506 deferred_interrupts_ |= defer_bits; |
1498 interrupt_bits &= ~deferred_interrupts_mask_; | 1507 interrupt_bits &= ~deferred_interrupts_mask_; |
1499 if (interrupt_bits == 0) { | 1508 if (interrupt_bits == 0) { |
1500 return; | 1509 return; |
1501 } | 1510 } |
1502 } | 1511 } |
1503 | 1512 |
1504 if (stack_limit_ == saved_stack_limit_) { | 1513 if (stack_limit_ == saved_stack_limit_) { |
1514 // On DBC stack is growing upwards so interrupt limit is 0 unlike on all | |
1515 // other architectures. | |
1516 #if !defined(TARGET_ARCH_DBC) | |
zra
2016/04/14 18:27:49
Maybe instead of #if defined, add a function to s
Vyacheslav Egorov (Google)
2016/04/18 15:56:42
Done.
| |
1505 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; | 1517 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; |
1518 #else | |
1519 stack_limit_ = 0; | |
1520 #endif | |
1506 } | 1521 } |
1507 stack_limit_ |= interrupt_bits; | 1522 stack_limit_ |= interrupt_bits; |
1508 } | 1523 } |
1509 | 1524 |
1510 | 1525 |
1511 uword Isolate::GetAndClearInterrupts() { | 1526 uword Isolate::GetAndClearInterrupts() { |
1512 MutexLocker ml(mutex_); | 1527 MutexLocker ml(mutex_); |
1513 if (stack_limit_ == saved_stack_limit_) { | 1528 if (stack_limit_ == saved_stack_limit_) { |
1514 return 0; // No interrupt was requested. | 1529 return 0; // No interrupt was requested. |
1515 } | 1530 } |
(...skipping 26 matching lines...) Expand all Loading... | |
1542 } | 1557 } |
1543 } | 1558 } |
1544 | 1559 |
1545 | 1560 |
1546 void Isolate::RestoreOOBMessageInterrupts() { | 1561 void Isolate::RestoreOOBMessageInterrupts() { |
1547 MutexLocker ml(mutex_); | 1562 MutexLocker ml(mutex_); |
1548 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); | 1563 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); |
1549 deferred_interrupts_mask_ = 0; | 1564 deferred_interrupts_mask_ = 0; |
1550 if (deferred_interrupts_ != 0) { | 1565 if (deferred_interrupts_ != 0) { |
1551 if (stack_limit_ == saved_stack_limit_) { | 1566 if (stack_limit_ == saved_stack_limit_) { |
1567 // On DBC stack is growing upwards so interrupt limit is 0 unlike on all | |
1568 // other architectures. | |
1569 #if !defined(TARGET_ARCH_DBC) | |
zra
2016/04/14 18:27:48
ditto
Vyacheslav Egorov (Google)
2016/04/18 15:56:42
Done.
| |
1552 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; | 1570 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; |
1571 #else | |
1572 stack_limit_ = 0; | |
1573 #endif | |
1553 } | 1574 } |
1554 stack_limit_ |= deferred_interrupts_; | 1575 stack_limit_ |= deferred_interrupts_; |
1555 deferred_interrupts_ = 0; | 1576 deferred_interrupts_ = 0; |
1556 } | 1577 } |
1557 if (FLAG_trace_service && FLAG_trace_service_verbose) { | 1578 if (FLAG_trace_service && FLAG_trace_service_verbose) { |
1558 OS::Print("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n", | 1579 OS::Print("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n", |
1559 Dart::timestamp(), name()); | 1580 Dart::timestamp(), name()); |
1560 } | 1581 } |
1561 } | 1582 } |
1562 | 1583 |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2839 void IsolateSpawnState::DecrementSpawnCount() { | 2860 void IsolateSpawnState::DecrementSpawnCount() { |
2840 ASSERT(spawn_count_monitor_ != NULL); | 2861 ASSERT(spawn_count_monitor_ != NULL); |
2841 ASSERT(spawn_count_ != NULL); | 2862 ASSERT(spawn_count_ != NULL); |
2842 MonitorLocker ml(spawn_count_monitor_); | 2863 MonitorLocker ml(spawn_count_monitor_); |
2843 ASSERT(*spawn_count_ > 0); | 2864 ASSERT(*spawn_count_ > 0); |
2844 *spawn_count_ = *spawn_count_ - 1; | 2865 *spawn_count_ = *spawn_count_ - 1; |
2845 ml.Notify(); | 2866 ml.Notify(); |
2846 } | 2867 } |
2847 | 2868 |
2848 } // namespace dart | 2869 } // namespace dart |
OLD | NEW |