Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/xmlstream.cpp @ 6197:d2a62e0f25eb
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking
Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd
Reviewed-by: acorn, coleenp, fparain
author | zgu |
---|---|
date | Thu, 28 Jun 2012 17:03:16 -0400 |
parents | 1ac084126285 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
6174:74533f63b116 | 6197:d2a62e0f25eb |
---|---|
41 _text = &_text_init; | 41 _text = &_text_init; |
42 | 42 |
43 #ifdef ASSERT | 43 #ifdef ASSERT |
44 _element_depth = 0; | 44 _element_depth = 0; |
45 int init_len = 100; | 45 int init_len = 100; |
46 char* init_buf = NEW_C_HEAP_ARRAY(char, init_len); | 46 char* init_buf = NEW_C_HEAP_ARRAY(char, init_len, mtInternal); |
47 _element_close_stack_low = init_buf; | 47 _element_close_stack_low = init_buf; |
48 _element_close_stack_high = init_buf + init_len; | 48 _element_close_stack_high = init_buf + init_len; |
49 _element_close_stack_ptr = init_buf + init_len - 1; | 49 _element_close_stack_ptr = init_buf + init_len - 1; |
50 _element_close_stack_ptr[0] = '\0'; | 50 _element_close_stack_ptr[0] = '\0'; |
51 #endif | 51 #endif |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 #ifdef ASSERT | 59 #ifdef ASSERT |
60 xmlStream::~xmlStream() { | 60 xmlStream::~xmlStream() { |
61 FREE_C_HEAP_ARRAY(char, _element_close_stack_low); | 61 FREE_C_HEAP_ARRAY(char, _element_close_stack_low, mtInternal); |
62 } | 62 } |
63 #endif | 63 #endif |
64 | 64 |
65 // Pass the given chars directly to _out. | 65 // Pass the given chars directly to _out. |
66 void xmlStream::write(const char* s, size_t len) { | 66 void xmlStream::write(const char* s, size_t len) { |
153 char* push_ptr = old_ptr - (tag_len+1); | 153 char* push_ptr = old_ptr - (tag_len+1); |
154 if (push_ptr < old_low) { | 154 if (push_ptr < old_low) { |
155 int old_len = _element_close_stack_high - old_ptr; | 155 int old_len = _element_close_stack_high - old_ptr; |
156 int new_len = old_len * 2; | 156 int new_len = old_len * 2; |
157 if (new_len < 100) new_len = 100; | 157 if (new_len < 100) new_len = 100; |
158 char* new_low = NEW_C_HEAP_ARRAY(char, new_len); | 158 char* new_low = NEW_C_HEAP_ARRAY(char, new_len, mtInternal); |
159 char* new_high = new_low + new_len; | 159 char* new_high = new_low + new_len; |
160 char* new_ptr = new_high - old_len; | 160 char* new_ptr = new_high - old_len; |
161 memcpy(new_ptr, old_ptr, old_len); | 161 memcpy(new_ptr, old_ptr, old_len); |
162 _element_close_stack_high = new_high; | 162 _element_close_stack_high = new_high; |
163 _element_close_stack_low = new_low; | 163 _element_close_stack_low = new_low; |
164 _element_close_stack_ptr = new_ptr; | 164 _element_close_stack_ptr = new_ptr; |
165 FREE_C_HEAP_ARRAY(char, old_low); | 165 FREE_C_HEAP_ARRAY(char, old_low, mtInternal); |
166 push_ptr = new_ptr - (tag_len+1); | 166 push_ptr = new_ptr - (tag_len+1); |
167 } | 167 } |
168 assert(push_ptr >= _element_close_stack_low, "in range"); | 168 assert(push_ptr >= _element_close_stack_low, "in range"); |
169 memcpy(push_ptr, tag, tag_len); | 169 memcpy(push_ptr, tag, tag_len); |
170 push_ptr[tag_len] = 0; | 170 push_ptr[tag_len] = 0; |