Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2393)

Unified Diff: runtime/vm/zone.cc

Issue 2650583014: Added tracking of memory usage within ApiNativeScopes. Usage to be displayed within Observatory. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_state.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/zone.cc
diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc
index 05e7eb75806ab7c1617d0f41e2d558236d39cdee..65ff636ed815de8f2f4995ac312354f07181346a 100644
--- a/runtime/vm/zone.cc
+++ b/runtime/vm/zone.cc
@@ -6,6 +6,7 @@
#include "platform/assert.h"
#include "platform/utils.h"
+#include "vm/dart_api_state.h"
#include "vm/flags.h"
#include "vm/handles_impl.h"
#include "vm/heap.h"
@@ -46,9 +47,10 @@ void Zone::Segment::DeleteSegmentList(Segment* head) {
Thread* current_thread = Thread::Current();
while (current != NULL) {
if (current_thread != NULL) {
- // TODO(bkonyi) Handle special case of segment deletion within native
- // isolate.
current_thread->DecrementMemoryUsage(current->size());
+ } else if (ApiNativeScope::Current() != NULL) {
+ // If there is no current thread, we might be iniside of a native scope.
siva 2017/01/26 03:02:05 iniside => inside
bkonyi 2017/01/26 22:34:27 Done.
+ ApiNativeScope::DecrementNativeScopeMemoryUsage(current->size());
}
Segment* next = current->next();
#ifdef DEBUG
@@ -74,10 +76,12 @@ Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) {
#endif
result->next_ = next;
result->size_ = size;
- if (Thread::Current() != NULL) {
- // TODO(bkonyi) Handle special case of segment creation within native
- // isolate.
- Thread::Current()->IncrementMemoryUsage(size);
+ Thread* current = Thread::Current();
+ if (current != NULL) {
+ current->IncrementMemoryUsage(size);
+ } else if (ApiNativeScope::Current() != NULL) {
+ // If there is no current thread, we might be inside of a native scope.
+ ApiNativeScope::IncrementNativeScopeMemoryUsage(size);
}
return result;
}
« no previous file with comments | « runtime/vm/dart_api_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698