89 if (id >= _identities_capacity) {
90 int new_cap = _identities_capacity * 2;
91 if (new_cap <= id) new_cap = id + 100;
92 _identities = REALLOC_C_HEAP_ARRAY(char, _identities, new_cap, mtCompiler);
93 _identities_capacity = new_cap;
94 }
95 while (id >= _identities_limit) {
96 _identities[_identities_limit++] = 0;
97 }
98 assert(id < _identities_limit, "oob");
99 // Mark this id as processed.
100 // (Be sure to do this before any recursive calls to identify.)
101 _identities[id] = 1; // mark
102
103 // Now, print the object's identity once, in detail.
104 if (obj->is_metadata()) {
105 ciMetadata* mobj = obj->as_metadata();
106 if (mobj->is_klass()) {
107 ciKlass* klass = mobj->as_klass();
108 begin_elem("klass id='%d'", id);
109 name(klass->name());
110 if (!klass->is_loaded()) {
111 print(" unloaded='1'");
112 } else {
113 print(" flags='%d'", klass->modifier_flags());
114 }
115 end_elem();
116 } else if (mobj->is_method()) {
117 ciMethod* method = mobj->as_method();
118 ciSignature* sig = method->signature();
119 // Pre-identify items that we will need!
120 identify(sig->return_type());
121 for (int i = 0; i < sig->count(); i++) {
122 identify(sig->type_at(i));
123 }
124 begin_elem("method id='%d' holder='%d'",
125 id, identify(method->holder()));
126 name(method->name());
127 print(" return='%d'", identify(sig->return_type()));
128 if (sig->count() > 0) {
129 print(" arguments='");
154 ShouldNotReachHere();
155 }
156 } else if (obj->is_symbol()) {
157 begin_elem("symbol id='%d'", id);
158 name(obj->as_symbol());
159 end_elem();
160 } else {
161 // Should not happen.
162 elem("unknown id='%d'", id);
163 }
164 return id;
165 }
166
167 void CompileLog::name(ciSymbol* name) {
168 if (name == NULL) return;
169 print(" name='");
170 name->print_symbol_on(text()); // handles quoting conventions
171 print("'");
172 }
173
174
175 // ------------------------------------------------------------------
176 // CompileLog::clear_identities
177 // Forget which identities have been printed.
178 void CompileLog::clear_identities() {
179 _identities_limit = 0;
180 }
181
182 // ------------------------------------------------------------------
183 // CompileLog::finish_log_on_error
184 //
185 // Note: This function is called after fatal error, avoid unnecessary memory
186 // or stack allocation, use only async-safe functions. It's possible JVM is
187 // only partially initialized.
188 void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) {
189 static bool called_exit = false;
190 if (called_exit) return;
191 called_exit = true;
192
193 CompileLog* log = _first;
|
89 if (id >= _identities_capacity) {
90 int new_cap = _identities_capacity * 2;
91 if (new_cap <= id) new_cap = id + 100;
92 _identities = REALLOC_C_HEAP_ARRAY(char, _identities, new_cap, mtCompiler);
93 _identities_capacity = new_cap;
94 }
95 while (id >= _identities_limit) {
96 _identities[_identities_limit++] = 0;
97 }
98 assert(id < _identities_limit, "oob");
99 // Mark this id as processed.
100 // (Be sure to do this before any recursive calls to identify.)
101 _identities[id] = 1; // mark
102
103 // Now, print the object's identity once, in detail.
104 if (obj->is_metadata()) {
105 ciMetadata* mobj = obj->as_metadata();
106 if (mobj->is_klass()) {
107 ciKlass* klass = mobj->as_klass();
108 begin_elem("klass id='%d'", id);
109 name(klass);
110 if (!klass->is_loaded()) {
111 print(" unloaded='1'");
112 } else {
113 print(" flags='%d'", klass->modifier_flags());
114 }
115 end_elem();
116 } else if (mobj->is_method()) {
117 ciMethod* method = mobj->as_method();
118 ciSignature* sig = method->signature();
119 // Pre-identify items that we will need!
120 identify(sig->return_type());
121 for (int i = 0; i < sig->count(); i++) {
122 identify(sig->type_at(i));
123 }
124 begin_elem("method id='%d' holder='%d'",
125 id, identify(method->holder()));
126 name(method->name());
127 print(" return='%d'", identify(sig->return_type()));
128 if (sig->count() > 0) {
129 print(" arguments='");
154 ShouldNotReachHere();
155 }
156 } else if (obj->is_symbol()) {
157 begin_elem("symbol id='%d'", id);
158 name(obj->as_symbol());
159 end_elem();
160 } else {
161 // Should not happen.
162 elem("unknown id='%d'", id);
163 }
164 return id;
165 }
166
167 void CompileLog::name(ciSymbol* name) {
168 if (name == NULL) return;
169 print(" name='");
170 name->print_symbol_on(text()); // handles quoting conventions
171 print("'");
172 }
173
174 void CompileLog::name(ciKlass* k) {
175 print(" name='");
176 if (!k->is_loaded()) {
177 text()->print(k->name()->as_klass_external_name());
178 } else {
179 text()->print(k->external_name());
180 }
181 print("'");
182 }
183
184 // ------------------------------------------------------------------
185 // CompileLog::clear_identities
186 // Forget which identities have been printed.
187 void CompileLog::clear_identities() {
188 _identities_limit = 0;
189 }
190
191 // ------------------------------------------------------------------
192 // CompileLog::finish_log_on_error
193 //
194 // Note: This function is called after fatal error, avoid unnecessary memory
195 // or stack allocation, use only async-safe functions. It's possible JVM is
196 // only partially initialized.
197 void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) {
198 static bool called_exit = false;
199 if (called_exit) return;
200 called_exit = true;
201
202 CompileLog* log = _first;
|