| 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 #if !defined(TARGET_ARCH_DBC) |
| 1505 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; | 1515 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; |
| 1516 #else |
| 1517 stack_limit_ = 0; |
| 1518 #endif |
| 1506 } | 1519 } |
| 1507 stack_limit_ |= interrupt_bits; | 1520 stack_limit_ |= interrupt_bits; |
| 1508 } | 1521 } |
| 1509 | 1522 |
| 1510 | 1523 |
| 1511 uword Isolate::GetAndClearInterrupts() { | 1524 uword Isolate::GetAndClearInterrupts() { |
| 1512 MutexLocker ml(mutex_); | 1525 MutexLocker ml(mutex_); |
| 1513 if (stack_limit_ == saved_stack_limit_) { | 1526 if (stack_limit_ == saved_stack_limit_) { |
| 1514 return 0; // No interrupt was requested. | 1527 return 0; // No interrupt was requested. |
| 1515 } | 1528 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1542 } | 1555 } |
| 1543 } | 1556 } |
| 1544 | 1557 |
| 1545 | 1558 |
| 1546 void Isolate::RestoreOOBMessageInterrupts() { | 1559 void Isolate::RestoreOOBMessageInterrupts() { |
| 1547 MutexLocker ml(mutex_); | 1560 MutexLocker ml(mutex_); |
| 1548 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); | 1561 ASSERT(deferred_interrupts_mask_ == kMessageInterrupt); |
| 1549 deferred_interrupts_mask_ = 0; | 1562 deferred_interrupts_mask_ = 0; |
| 1550 if (deferred_interrupts_ != 0) { | 1563 if (deferred_interrupts_ != 0) { |
| 1551 if (stack_limit_ == saved_stack_limit_) { | 1564 if (stack_limit_ == saved_stack_limit_) { |
| 1565 #if !defined(TARGET_ARCH_DBC) |
| 1552 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; | 1566 stack_limit_ = (~static_cast<uword>(0)) & ~kInterruptsMask; |
| 1567 #else |
| 1568 stack_limit_ = 0; |
| 1569 #endif |
| 1553 } | 1570 } |
| 1554 stack_limit_ |= deferred_interrupts_; | 1571 stack_limit_ |= deferred_interrupts_; |
| 1555 deferred_interrupts_ = 0; | 1572 deferred_interrupts_ = 0; |
| 1556 } | 1573 } |
| 1557 if (FLAG_trace_service && FLAG_trace_service_verbose) { | 1574 if (FLAG_trace_service && FLAG_trace_service_verbose) { |
| 1558 OS::Print("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n", | 1575 OS::Print("[+%" Pd64 "ms] Isolate %s restoring OOB interrupts\n", |
| 1559 Dart::timestamp(), name()); | 1576 Dart::timestamp(), name()); |
| 1560 } | 1577 } |
| 1561 } | 1578 } |
| 1562 | 1579 |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2839 void IsolateSpawnState::DecrementSpawnCount() { | 2856 void IsolateSpawnState::DecrementSpawnCount() { |
| 2840 ASSERT(spawn_count_monitor_ != NULL); | 2857 ASSERT(spawn_count_monitor_ != NULL); |
| 2841 ASSERT(spawn_count_ != NULL); | 2858 ASSERT(spawn_count_ != NULL); |
| 2842 MonitorLocker ml(spawn_count_monitor_); | 2859 MonitorLocker ml(spawn_count_monitor_); |
| 2843 ASSERT(*spawn_count_ > 0); | 2860 ASSERT(*spawn_count_ > 0); |
| 2844 *spawn_count_ = *spawn_count_ - 1; | 2861 *spawn_count_ = *spawn_count_ - 1; |
| 2845 ml.Notify(); | 2862 ml.Notify(); |
| 2846 } | 2863 } |
| 2847 | 2864 |
| 2848 } // namespace dart | 2865 } // namespace dart |
| OLD | NEW |