OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/zone.h" | 5 #include "vm/zone.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 OUT_OF_MEMORY(); | 70 OUT_OF_MEMORY(); |
71 } | 71 } |
72 ASSERT(Utils::IsAligned(result->start(), Zone::kAlignment)); | 72 ASSERT(Utils::IsAligned(result->start(), Zone::kAlignment)); |
73 #ifdef DEBUG | 73 #ifdef DEBUG |
74 // Zap the entire allocated segment (including the header). | 74 // Zap the entire allocated segment (including the header). |
75 memset(result, kZapUninitializedByte, size); | 75 memset(result, kZapUninitializedByte, size); |
76 #endif | 76 #endif |
77 result->next_ = next; | 77 result->next_ = next; |
78 result->size_ = size; | 78 result->size_ = size; |
79 Thread* current = Thread::Current(); | 79 Thread* current = Thread::Current(); |
80 | |
80 if (current != NULL) { | 81 if (current != NULL) { |
81 current->IncrementMemoryUsage(size); | 82 current->IncrementMemoryUsage(size); |
83 // In case the other thread is waiting to do a scavenge. | |
84 current->CheckForSafepoint(); | |
siva
2017/03/23 18:05:01
Why is this check needed here? We may run into iss
erikcorry
2017/03/27 10:23:28
Good catch. This one was great for keeping down t
| |
82 } else if (ApiNativeScope::Current() != NULL) { | 85 } else if (ApiNativeScope::Current() != NULL) { |
83 // If there is no current thread, we might be inside of a native scope. | 86 // If there is no current thread, we might be inside of a native scope. |
84 ApiNativeScope::IncrementNativeScopeMemoryUsage(size); | 87 ApiNativeScope::IncrementNativeScopeMemoryUsage(size); |
85 } | 88 } |
86 return result; | 89 return result; |
87 } | 90 } |
88 | 91 |
89 // TODO(bkonyi): We need to account for the initial chunk size when a new zone | 92 // TODO(bkonyi): We need to account for the initial chunk size when a new zone |
90 // is created within a new thread or ApiNativeScope when calculating high | 93 // is created within a new thread or ApiNativeScope when calculating high |
91 // watermarks or memory consumption. | 94 // watermarks or memory consumption. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 ASSERT(thread()->zone() == &zone_); | 331 ASSERT(thread()->zone() == &zone_); |
329 thread()->set_zone(zone_.previous_); | 332 thread()->set_zone(zone_.previous_); |
330 if (FLAG_trace_zones) { | 333 if (FLAG_trace_zones) { |
331 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", | 334 OS::PrintErr("*** Deleting Stack zone 0x%" Px "(0x%" Px ")\n", |
332 reinterpret_cast<intptr_t>(this), | 335 reinterpret_cast<intptr_t>(this), |
333 reinterpret_cast<intptr_t>(&zone_)); | 336 reinterpret_cast<intptr_t>(&zone_)); |
334 } | 337 } |
335 } | 338 } |
336 | 339 |
337 } // namespace dart | 340 } // namespace dart |
OLD | NEW |