src/hotspot/share/utilities/xmlstream.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 53908 45a23c64d0f6
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
     2
 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "code/nmethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.inline.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 33794
diff changeset
    29
#include "memory/resourceArea.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    30
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    31
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/deoptimization.hpp"
49361
1956d0ec092a 8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents: 47216
diff changeset
    34
#include "runtime/handles.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "runtime/vmThread.hpp"
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46329
diff changeset
    36
#include "utilities/vmError.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "utilities/xmlstream.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
28477
157314902d78 8068396: Rename assert() to vmassert()
kbarrett
parents: 27880
diff changeset
    39
// Do not assert this condition if there's already another error reported.
157314902d78 8068396: Rename assert() to vmassert()
kbarrett
parents: 27880
diff changeset
    40
#define assert_if_no_error(cond, msg) \
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46329
diff changeset
    41
  vmassert((cond) || VMError::is_error_reported(), msg)
28477
157314902d78 8068396: Rename assert() to vmassert()
kbarrett
parents: 27880
diff changeset
    42
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
void xmlStream::initialize(outputStream* out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  _out = out;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  _last_flush = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  _text_init._outer_xmlStream = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  _text = &_text_init;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  _element_depth = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  int   init_len = 100;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11727
diff changeset
    53
  char* init_buf = NEW_C_HEAP_ARRAY(char, init_len, mtInternal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _element_close_stack_low  = init_buf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  _element_close_stack_high = init_buf + init_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  _element_close_stack_ptr  = init_buf + init_len - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  _element_close_stack_ptr[0] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Make sure each log uses the same base for time stamps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  if (is_open()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    _out->time_stamp().update_to(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
xmlStream::~xmlStream() {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 24424
diff changeset
    68
  FREE_C_HEAP_ARRAY(char, _element_close_stack_low);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// Pass the given chars directly to _out.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
void xmlStream::write(const char* s, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if (!is_open())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  out()->write(s, len);
768
d0bebc7eefc2 6718676: putback for 6604014 is incomplete
never
parents: 1
diff changeset
    77
  update_position(s, len);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// Pass the given chars directly to _out, except that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// we watch for special "<&>" chars.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// This is suitable for either attribute text or for body text.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// We don't fool with "<![CDATA[" quotes, just single-character entities.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// This makes it easier for dumb tools to parse the output.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
void xmlStream::write_text(const char* s, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  if (!is_open())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  size_t written = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // All normally printed material goes inside XML quotes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // This leaves the output free to include markup also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Scan the string looking for inadvertant "<&>" chars
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  for (size_t i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    char ch = s[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    // Escape special chars.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    const char* esc = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    switch (ch) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      // These are important only in attrs, but we do them always:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    case '\'': esc = "&apos;"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    case '"':  esc = "&quot;"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    case '<':  esc = "&lt;";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    case '&':  esc = "&amp;";  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      // This is a freebie.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    case '>':  esc = "&gt;";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    if (esc != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      if (written < i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
        out()->write(&s[written], i - written);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
        written = i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      out()->print_raw(esc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      written++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // Print the clean remainder.  Usually, it is all of s.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  if (written < len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    out()->write(&s[written], len - written);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
// Outputs XML text, with special characters quoted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
void xmlStream::text(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  va_text(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
#define BUFLEN 2*K   /* max size of output of individual print methods */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
void xmlStream::va_tag(bool push, const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  assert_if_no_error(!inside_attrs(), "cannot print tag inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  char buffer[BUFLEN];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  size_t len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  const char* kind = do_vsnprintf(buffer, BUFLEN, format, ap, false, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  see_tag(kind, push);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  print_raw("<");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  write(kind, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  _markup_state = (push ? HEAD : ELEM);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
/// Debugging goo to make sure element tags nest properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
void xmlStream::see_tag(const char* tag, bool push) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  assert_if_no_error(!inside_attrs(), "cannot start new element inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  if (!push)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // tag goes up until either null or space:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  const char* tag_end = strchr(tag, ' ');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  size_t tag_len = (tag_end == NULL) ? strlen(tag) : tag_end - tag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  assert(tag_len > 0, "tag must not be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // push the tag onto the stack, pulling down the pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  char* old_ptr  = _element_close_stack_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  char* old_low  = _element_close_stack_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  char* push_ptr = old_ptr - (tag_len+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  if (push_ptr < old_low) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    int old_len = _element_close_stack_high - old_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    int new_len = old_len * 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    if (new_len < 100)  new_len = 100;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11727
diff changeset
   165
    char* new_low  = NEW_C_HEAP_ARRAY(char, new_len, mtInternal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    char* new_high = new_low + new_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    char* new_ptr  = new_high - old_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    memcpy(new_ptr, old_ptr, old_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    _element_close_stack_high = new_high;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    _element_close_stack_low  = new_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    _element_close_stack_ptr  = new_ptr;
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 24424
diff changeset
   172
    FREE_C_HEAP_ARRAY(char, old_low);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    push_ptr = new_ptr - (tag_len+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  assert(push_ptr >= _element_close_stack_low, "in range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  memcpy(push_ptr, tag, tag_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  push_ptr[tag_len] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  _element_close_stack_ptr = push_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  _element_depth += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
void xmlStream::pop_tag(const char* tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  assert_if_no_error(!inside_attrs(), "cannot close element inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  assert(_element_depth > 0, "must be in an element to close");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  assert(*tag != 0, "tag must not be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  char* cur_tag = _element_close_stack_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  bool  bad_tag = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  while (*cur_tag != 0 && strcmp(cur_tag, tag) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    this->print_cr("</%s> <!-- missing closing tag -->", cur_tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    _element_close_stack_ptr = (cur_tag += strlen(cur_tag) + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    _element_depth -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    bad_tag = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  if (*cur_tag == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    bad_tag = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    // Pop the stack, by skipping over the tag and its null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    _element_depth -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  }
11727
c5dfa2639359 7130319: C2: running with -XX:+PrintOptoAssembly crashes the VM with assert(false) failed: bad tag in log
dlong
parents: 8921
diff changeset
   202
  if (bad_tag && !VMThread::should_terminate() && !VM_Exit::vm_exited() &&
46589
f1c04490ded1 8182848: Some functions misplaced in debug.hpp
coleenp
parents: 46329
diff changeset
   203
      !VMError::is_error_reported())
11727
c5dfa2639359 7130319: C2: running with -XX:+PrintOptoAssembly crashes the VM with assert(false) failed: bad tag in log
dlong
parents: 8921
diff changeset
   204
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    assert(false, "bad tag in log");
11727
c5dfa2639359 7130319: C2: running with -XX:+PrintOptoAssembly crashes the VM with assert(false) failed: bad tag in log
dlong
parents: 8921
diff changeset
   206
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// words must be XML attributes.  Outputs "<kind .../>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
void xmlStream::elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  va_elem(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
void xmlStream::va_elem(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  va_begin_elem(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// words must be XML attributes.  Outputs "<kind ...", not including "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
void xmlStream::begin_elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  va_tag(false, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
void xmlStream::va_begin_elem(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  va_tag(false, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// Outputs "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
void xmlStream::end_elem() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  assert(_markup_state == ELEM, "misplaced end_elem");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  print_raw("/>\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
// Outputs formatted text, followed by "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
void xmlStream::end_elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  out()->vprint(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
// words must be XML attributes.  Outputs "<kind ...>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
void xmlStream::head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  va_head(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
void xmlStream::va_head(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  va_begin_head(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  end_head();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// words must be XML attributes.  Outputs "<kind ...", not including ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
void xmlStream::begin_head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  va_tag(true, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
void xmlStream::va_begin_head(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  va_tag(true, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// Outputs ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
void xmlStream::end_head() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  assert(_markup_state == HEAD, "misplaced end_head");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  print_raw(">\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// Outputs formatted text, followed by ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
void xmlStream::end_head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  out()->vprint(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  end_head();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
// Outputs "</kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
void xmlStream::tail(const char* kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  pop_tag(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  print_raw("</");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  print_raw(">\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
// Outputs "<kind_done ... stamp='D.DD'/> </kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
void xmlStream::done(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  va_done(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// Outputs "<kind_done stamp='D.DD'/> </kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// Because done_raw() doesn't need to format strings, it's simpler than
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
// done(), and can be called safely by fatal error handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
void xmlStream::done_raw(const char* kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  print_raw("<");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  print_raw("_done stamp='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  out()->stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  print_raw_cr("'/>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  print_raw("</");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  print_raw_cr(">");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
33604
ad1cd9269bd4 8139116: Fixes for warning "format not a string literal"
goetz
parents: 28477
diff changeset
   346
// If you remove the PRAGMA, this fails to compile with clang-503.0.40.
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24002
diff changeset
   347
PRAGMA_DIAG_PUSH
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24002
diff changeset
   348
PRAGMA_FORMAT_NONLITERAL_IGNORED
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
void xmlStream::va_done(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  char buffer[200];
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33604
diff changeset
   352
  size_t format_len = strlen(format);
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33604
diff changeset
   353
  guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  const char* kind = format;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  const char* kind_end = strchr(kind, ' ');
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   356
  size_t kind_len;
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33604
diff changeset
   357
  if (kind_end != NULL) {
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   358
    kind_len = kind_end - kind;
53908
45a23c64d0f6 8219583: Windows build failure after JDK-8214777 (Avoid some GCC 8.X strncpy() errors in HotSpot)
shade
parents: 53882
diff changeset
   359
    int n = os::snprintf(buffer, sizeof(buffer), "%.*s_done", (int)kind_len, kind);
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   360
    assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string");
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   361
  } else {
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   362
    kind_len = format_len;
53908
45a23c64d0f6 8219583: Windows build failure after JDK-8214777 (Avoid some GCC 8.X strncpy() errors in HotSpot)
shade
parents: 53882
diff changeset
   363
    int n = os::snprintf(buffer, sizeof(buffer), "%s_done%s", kind, kind + kind_len);
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 49361
diff changeset
   364
    assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string");
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33604
diff changeset
   365
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  // Output the trailing event with the timestamp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  va_begin_elem(buffer, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  // Output the tail-tag of the enclosing element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  buffer[kind_len] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  tail(buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
}
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24002
diff changeset
   374
PRAGMA_DIAG_POP
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
// Output a timestamp attribute.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
void xmlStream::stamp() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  assert_if_no_error(inside_attrs(), "stamp must be an attribute");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  print_raw(" stamp='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  out()->stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
// Output a method attribute, in the form " method='pkg/cls name sig'".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
// This is used only when there is no ciMethod available.
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53908
diff changeset
   388
void xmlStream::method(Method* method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  assert_if_no_error(inside_attrs(), "printing attributes");
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53908
diff changeset
   390
  if (method == NULL)  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  print_raw(" method='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  method_text(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  print("' bytes='%d'", method->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  print(" count='%d'", method->invocation_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  int bec = method->backedge_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  if (bec != 0)  print(" backedge_count='%d'", bec);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  print(" iicount='%d'", method->interpreter_invocation_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  int throwouts = method->interpreter_throwout_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  if (throwouts != 0)  print(" throwouts='%d'", throwouts);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   400
  MethodData* mdo = method->method_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  if (mdo != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    uint cnt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    cnt = mdo->decompile_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    if (cnt != 0)  print(" decompiles='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    for (uint reason = 0; reason < mdo->trap_reason_limit(); reason++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
      cnt = mdo->trap_count(reason);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      if (cnt != 0)  print(" %s_traps='%d'", Deoptimization::trap_reason_name(reason), cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    cnt = mdo->overflow_trap_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    if (cnt != 0)  print(" overflow_traps='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    cnt = mdo->overflow_recompile_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    if (cnt != 0)  print(" overflow_recompiles='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53908
diff changeset
   416
void xmlStream::method_text(Method* method) {
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 13728
diff changeset
   417
  ResourceMark rm;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  assert_if_no_error(inside_attrs(), "printing attributes");
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53908
diff changeset
   419
  if (method == NULL)  return;
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24002
diff changeset
   420
  text()->print("%s", method->method_holder()->external_name());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  print_raw(" ");  // " " is easier for tools to parse than "::"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  method->name()->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  print_raw(" ");  // separator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  method->signature()->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
// Output a klass attribute, in the form " klass='pkg/cls'".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
// This is used only when there is no ciKlass available.
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 37248
diff changeset
   431
void xmlStream::klass(Klass* klass) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  assert_if_no_error(inside_attrs(), "printing attributes");
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 37248
diff changeset
   433
  if (klass == NULL) return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  print_raw(" klass='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  klass_text(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 37248
diff changeset
   439
void xmlStream::klass_text(Klass* klass) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  assert_if_no_error(inside_attrs(), "printing attributes");
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 37248
diff changeset
   441
  if (klass == NULL) return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  //klass->print_short_name(log->out());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  klass->name()->print_symbol_on(out());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   446
void xmlStream::name(const Symbol* name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  assert_if_no_error(inside_attrs(), "printing attributes");
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   448
  if (name == NULL)  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  print_raw(" name='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  name_text(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   454
void xmlStream::name_text(const Symbol* name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  assert_if_no_error(inside_attrs(), "printing attributes");
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   456
  if (name == NULL)  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  //name->print_short_name(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  name->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
void xmlStream::object(const char* attr, Handle x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  assert_if_no_error(inside_attrs(), "printing attributes");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   463
  if (x == NULL)  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  print_raw(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  print_raw(attr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  print_raw("='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  object_text(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
void xmlStream::object_text(Handle x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  assert_if_no_error(inside_attrs(), "printing attributes");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   473
  if (x == NULL)  return;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   474
  x->print_value_on(text());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   475
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   476
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   477
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   478
void xmlStream::object(const char* attr, Metadata* x) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   479
  assert_if_no_error(inside_attrs(), "printing attributes");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   480
  if (x == NULL)  return;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   481
  print_raw(" ");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   482
  print_raw(attr);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   483
  print_raw("='");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   484
  object_text(x);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   485
  print_raw("'");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   486
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   487
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   488
void xmlStream::object_text(Metadata* x) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   489
  assert_if_no_error(inside_attrs(), "printing attributes");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   490
  if (x == NULL)  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  //x->print_value_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  if (x->is_method())
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   493
    method_text((Method*)x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  else if (x->is_klass())
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   495
    klass_text((Klass*)x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  else
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   497
    ShouldNotReachHere(); // Add impl if this is reached.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
void xmlStream::flush() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  out()->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  _last_flush = count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
void xmlTextStream::flush() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  if (_outer_xmlStream == NULL)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  _outer_xmlStream->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
void xmlTextStream::write(const char* str, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  if (_outer_xmlStream == NULL)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  _outer_xmlStream->write_text(str, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  update_position(str, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
}