179 }
180
181 template <typename BE, typename IE, typename WriterPolicyImpl>
182 template <typename T>
183 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(T value) {
184 write(&value, 1);
185 }
186
187 template <typename BE, typename IE, typename WriterPolicyImpl>
188 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(bool value) {
189 be_write((u1)value);
190 }
191
192 template <typename BE, typename IE, typename WriterPolicyImpl>
193 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(float value) {
194 be_write(*(u4*)&(value));
195 }
196
197 template <typename BE, typename IE, typename WriterPolicyImpl>
198 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(double value) {
199 be_write(*(uintptr_t*)&(value));
200 }
201
202 template <typename BE, typename IE, typename WriterPolicyImpl>
203 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(const char* value) {
204 // UTF-8, max_jint len
205 write_utf8(value);
206 }
207
208 template <typename BE, typename IE, typename WriterPolicyImpl>
209 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(char* value) {
210 write(const_cast<const char*>(value));
211 }
212
213 template <typename BE, typename IE, typename WriterPolicyImpl>
214 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(jstring string) {
215 if (string == NULL) {
216 write<u1>(NULL_STRING);
217 return;
218 }
219 const oop string_oop = JNIHandles::resolve_external_guard(string);
260 }
261
262 template <typename BE, typename IE, typename WriterPolicyImpl>
263 void WriterHost<BE, IE, WriterPolicyImpl>::write(const ModuleEntry* module) {
264 tag_write(this, module);
265 }
266
267 template <typename BE, typename IE, typename WriterPolicyImpl>
268 void WriterHost<BE, IE, WriterPolicyImpl>::write(const PackageEntry* package) {
269 tag_write(this, package);
270 }
271
272 template <typename BE, typename IE, typename WriterPolicyImpl>
273 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Symbol* symbol) {
274 ResourceMark rm;
275 write_utf8(symbol != NULL ? symbol->as_C_string() : NULL);
276 }
277
278 template <typename BE, typename IE, typename WriterPolicyImpl>
279 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Ticks& time) {
280 write((uintptr_t)JfrTime::is_ft_enabled() ? time.ft_value() : time.value());
281 }
282
283 template <typename BE, typename IE, typename WriterPolicyImpl>
284 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Tickspan& time) {
285 write((uintptr_t)JfrTime::is_ft_enabled() ? time.ft_value() : time.value());
286 }
287
288 template <typename BE, typename IE, typename WriterPolicyImpl>
289 void WriterHost<BE, IE, WriterPolicyImpl>::write(const JfrTicks& time) {
290 write((uintptr_t)time.value());
291 }
292
293 template <typename BE, typename IE, typename WriterPolicyImpl>
294 void WriterHost<BE, IE, WriterPolicyImpl>::write(const JfrTickspan& time) {
295 write((uintptr_t)time.value());
296 }
297
298 template <typename BE, typename IE, typename WriterPolicyImpl>
299 void WriterHost<BE, IE, WriterPolicyImpl>::bytes(const void* buf, size_t len) {
300 u1* const pos = this->ensure_size(len);
301 if (pos != NULL) {
302 WriterPolicyImpl::bytes(pos, buf, len); // WriterPolicyImpl responsible for position update
303 }
304 }
305
306 // UTF-8 for use with classfile/bytecodes
307 template <typename BE, typename IE, typename WriterPolicyImpl>
308 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_utf8_u2_len(const char* value) {
309 u2 len = 0;
310 if (value != NULL) {
311 len = MIN2<u2>(max_jushort, (u2)strlen(value));
312 }
313 write(len);
314 if (len > 0) {
315 be_write(value, len);
|
179 }
180
181 template <typename BE, typename IE, typename WriterPolicyImpl>
182 template <typename T>
183 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(T value) {
184 write(&value, 1);
185 }
186
187 template <typename BE, typename IE, typename WriterPolicyImpl>
188 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(bool value) {
189 be_write((u1)value);
190 }
191
192 template <typename BE, typename IE, typename WriterPolicyImpl>
193 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(float value) {
194 be_write(*(u4*)&(value));
195 }
196
197 template <typename BE, typename IE, typename WriterPolicyImpl>
198 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(double value) {
199 be_write(*(u8*)&(value));
200 }
201
202 template <typename BE, typename IE, typename WriterPolicyImpl>
203 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(const char* value) {
204 // UTF-8, max_jint len
205 write_utf8(value);
206 }
207
208 template <typename BE, typename IE, typename WriterPolicyImpl>
209 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(char* value) {
210 write(const_cast<const char*>(value));
211 }
212
213 template <typename BE, typename IE, typename WriterPolicyImpl>
214 inline void WriterHost<BE, IE, WriterPolicyImpl>::write(jstring string) {
215 if (string == NULL) {
216 write<u1>(NULL_STRING);
217 return;
218 }
219 const oop string_oop = JNIHandles::resolve_external_guard(string);
260 }
261
262 template <typename BE, typename IE, typename WriterPolicyImpl>
263 void WriterHost<BE, IE, WriterPolicyImpl>::write(const ModuleEntry* module) {
264 tag_write(this, module);
265 }
266
267 template <typename BE, typename IE, typename WriterPolicyImpl>
268 void WriterHost<BE, IE, WriterPolicyImpl>::write(const PackageEntry* package) {
269 tag_write(this, package);
270 }
271
272 template <typename BE, typename IE, typename WriterPolicyImpl>
273 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Symbol* symbol) {
274 ResourceMark rm;
275 write_utf8(symbol != NULL ? symbol->as_C_string() : NULL);
276 }
277
278 template <typename BE, typename IE, typename WriterPolicyImpl>
279 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Ticks& time) {
280 write((u8)JfrTime::is_ft_enabled() ? time.ft_value() : time.value());
281 }
282
283 template <typename BE, typename IE, typename WriterPolicyImpl>
284 void WriterHost<BE, IE, WriterPolicyImpl>::write(const Tickspan& time) {
285 write((u8)JfrTime::is_ft_enabled() ? time.ft_value() : time.value());
286 }
287
288 template <typename BE, typename IE, typename WriterPolicyImpl>
289 void WriterHost<BE, IE, WriterPolicyImpl>::write(const JfrTicks& time) {
290 write((u8)time.value());
291 }
292
293 template <typename BE, typename IE, typename WriterPolicyImpl>
294 void WriterHost<BE, IE, WriterPolicyImpl>::write(const JfrTickspan& time) {
295 write((u8)time.value());
296 }
297
298 template <typename BE, typename IE, typename WriterPolicyImpl>
299 void WriterHost<BE, IE, WriterPolicyImpl>::bytes(const void* buf, size_t len) {
300 u1* const pos = this->ensure_size(len);
301 if (pos != NULL) {
302 WriterPolicyImpl::bytes(pos, buf, len); // WriterPolicyImpl responsible for position update
303 }
304 }
305
306 // UTF-8 for use with classfile/bytecodes
307 template <typename BE, typename IE, typename WriterPolicyImpl>
308 inline void WriterHost<BE, IE, WriterPolicyImpl>::write_utf8_u2_len(const char* value) {
309 u2 len = 0;
310 if (value != NULL) {
311 len = MIN2<u2>(max_jushort, (u2)strlen(value));
312 }
313 write(len);
314 if (len > 0) {
315 be_write(value, len);
|