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

Unified Diff: runtime/vm/zone.cc

Issue 2650583014: Added tracking of memory usage within ApiNativeScopes. Usage to be displayed within Observatory. (Closed)
Patch Set: Added unit test + fixed typo 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') | runtime/vm/zone_test.cc » ('j') | 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..b4c8e312cd1a4f08c6bb36d89361d174f99286a8 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 inside of a native scope.
+ ApiNativeScope::DecrementNativeScopeMemoryUsage(current->size());
}
Segment* next = current->next();
#ifdef DEBUG
@@ -74,15 +76,19 @@ 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;
}
-
+// TODO(bkonyi): We need to account for the initial chunk size when a new zone
+// is created within a new thread or ApiNativeScope when calculating high
+// watermarks or memory consumption.
bkonyi 2017/01/26 22:34:27 I'm going to address this in a future change. Shou
Zone::Zone()
: initial_buffer_(buffer_, kInitialChunkSize),
position_(initial_buffer_.start()),
@@ -117,7 +123,6 @@ void Zone::DeleteAll() {
if (large_segments_ != NULL) {
Segment::DeleteSegmentList(large_segments_);
}
-
// Reset zone state.
#ifdef DEBUG
memset(initial_buffer_.pointer(), kZapDeletedByte, initial_buffer_.size());
« no previous file with comments | « runtime/vm/dart_api_state.cc ('k') | runtime/vm/zone_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698