annotate src/share/vm/utilities/xmlstream.hpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 78bbf4d43a14
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_UTILITIES_XMLSTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_UTILITIES_XMLSTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/handles.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "utilities/ostream.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class xmlStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class defaultStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Sub-stream for writing quoted text, as opposed to markup.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Characters written to this stream are subject to quoting,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // as '<' => "&lt;", etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class xmlTextStream : public outputStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 friend class xmlStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 friend class defaultStream; // tty
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 xmlStream* _outer_xmlStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 xmlTextStream() { _outer_xmlStream = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 virtual void flush(); // _outer.flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 virtual void write(const char* str, size_t len); // _outer->write_text()
a61af66fc99e Initial load
duke
parents:
diff changeset
49 };
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Output stream for writing XML-structured logs.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // To write markup, use special calls elem, head/tail, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Use the xmlStream::text() stream to write unmarked text.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Text written that way will be quoted as necessary using '&lt;', etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Characters written directly to an xmlStream via print_cr, etc.,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // are directly written to the encapsulated stream, xmlStream::out().
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // This can be used to produce markup directly, character by character.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // (Such writes are not checked for markup syntax errors.)
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 class xmlStream : public outputStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 friend class defaultStream; // tty
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 enum MarkupState { BODY, // after end_head() call, in text
a61af66fc99e Initial load
duke
parents:
diff changeset
65 HEAD, // after begin_head() call, in attrs
a61af66fc99e Initial load
duke
parents:
diff changeset
66 ELEM }; // after begin_elem() call, in attrs
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
69 outputStream* _out; // file stream by which it goes
a61af66fc99e Initial load
duke
parents:
diff changeset
70 julong _last_flush; // last position of flush
a61af66fc99e Initial load
duke
parents:
diff changeset
71 MarkupState _markup_state; // where in the elem/head/tail dance
a61af66fc99e Initial load
duke
parents:
diff changeset
72 outputStream* _text; // text stream
a61af66fc99e Initial load
duke
parents:
diff changeset
73 xmlTextStream _text_init;
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // for subclasses
a61af66fc99e Initial load
duke
parents:
diff changeset
76 xmlStream() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
77 void initialize(outputStream* out);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // protect this from public use:
a61af66fc99e Initial load
duke
parents:
diff changeset
80 outputStream* out() { return _out; }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // helpers for writing XML elements
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
83 void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 virtual void see_tag(const char* tag, bool push) NOT_DEBUG({});
a61af66fc99e Initial load
duke
parents:
diff changeset
85 virtual void pop_tag(const char* tag) NOT_DEBUG({});
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // in debug mode, we verify matching of opening and closing tags
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int _element_depth; // number of unfinished elements
a61af66fc99e Initial load
duke
parents:
diff changeset
90 char* _element_close_stack_high; // upper limit of down-growing stack
a61af66fc99e Initial load
duke
parents:
diff changeset
91 char* _element_close_stack_low; // upper limit of down-growing stack
a61af66fc99e Initial load
duke
parents:
diff changeset
92 char* _element_close_stack_ptr; // pointer of down-growing stack
a61af66fc99e Initial load
duke
parents:
diff changeset
93 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // creation
a61af66fc99e Initial load
duke
parents:
diff changeset
97 xmlStream(outputStream* out) { initialize(out); }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 DEBUG_ONLY(virtual ~xmlStream();)
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 bool is_open() { return _out != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // text output
a61af66fc99e Initial load
duke
parents:
diff changeset
103 bool inside_attrs() { return _markup_state != BODY; }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // flushing
a61af66fc99e Initial load
duke
parents:
diff changeset
106 virtual void flush(); // flushes out, sets _last_flush = count()
a61af66fc99e Initial load
duke
parents:
diff changeset
107 virtual void write(const char* s, size_t len);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void write_text(const char* s, size_t len); // used by xmlTextStream
a61af66fc99e Initial load
duke
parents:
diff changeset
109 int unflushed_count() { return (int)(out()->count() - _last_flush); }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // writing complete XML elements
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
112 void elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
113 void begin_elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
114 void end_elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void end_elem();
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
116 void head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
117 void begin_head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
118 void end_head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void end_head();
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
120 void done(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); // xxx_done event, plus tail
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void done_raw(const char * kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void tail(const char* kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // va_list versions
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
125 void va_elem(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
126 void va_begin_elem(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
127 void va_head(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
128 void va_begin_head(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
129 void va_done(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // write text (with quoting of special XML characters <>&'" etc.)
a61af66fc99e Initial load
duke
parents:
diff changeset
132 outputStream* text() { return _text; }
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
133 void text(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 6725
diff changeset
134 void va_text(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 text()->vprint(format, ap);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // commonly used XML attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void stamp(); // stamp='1.234'
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void method(methodHandle m); // method='k n s' ...
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void klass(KlassHandle k); // klass='name'
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
142 void name(const Symbol* s); // name='name'
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2426
diff changeset
143 void object(const char* attr, Metadata* val);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void object(const char* attr, Handle val);
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // print the text alone (sans ''):
a61af66fc99e Initial load
duke
parents:
diff changeset
147 void method_text(methodHandle m);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 void klass_text(KlassHandle k); // klass='name'
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
149 void name_text(const Symbol* s); // name='name'
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2426
diff changeset
150 void object_text(Metadata* x);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void object_text(Handle x);
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 /* Example uses:
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Empty element, simple case.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 elem("X Y='Z'"); <X Y='Z'/> \n
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Empty element, general case.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 begin_elem("X Y='Z'"); <X Y='Z'
a61af66fc99e Initial load
duke
parents:
diff changeset
160 ...attrs... ...attrs...
a61af66fc99e Initial load
duke
parents:
diff changeset
161 end_elem(); />
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // Compound element, simple case.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 head("X Y='Z'"); <X Y='Z'> \n
a61af66fc99e Initial load
duke
parents:
diff changeset
165 ...body... ...body...
a61af66fc99e Initial load
duke
parents:
diff changeset
166 tail("X"); </X> \n
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Compound element, general case.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 begin_head("X Y='Z'"); <X Y='Z'
a61af66fc99e Initial load
duke
parents:
diff changeset
170 ...attrs... ...attrs...
a61af66fc99e Initial load
duke
parents:
diff changeset
171 end_head(); > \n
a61af66fc99e Initial load
duke
parents:
diff changeset
172 ...body... ...body...
a61af66fc99e Initial load
duke
parents:
diff changeset
173 tail("X"); </X> \n
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Printf-style formatting:
a61af66fc99e Initial load
duke
parents:
diff changeset
176 elem("X Y='%s'", "Z"); <X Y='Z'/> \n
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 */
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 };
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Standard log file, null if no logging is happening.
a61af66fc99e Initial load
duke
parents:
diff changeset
183 extern xmlStream* xtty;
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Note: If ::xtty != NULL, ::tty == ::xtty->text().
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
186
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
187 #endif // SHARE_VM_UTILITIES_XMLSTREAM_HPP