src/hotspot/share/ci/ciReplay.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 58722 cba8afa5cfed
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:
37129
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents: 35143
diff changeset
     1
/*
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 51554
diff changeset
     2
 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     4
 *
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     8
 *
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    13
 * accompanied this code).
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    14
 *
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    18
 *
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    21
 * questions.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    22
 *
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    23
 */
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    24
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    25
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    26
#include "jvm.h"
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    27
#include "ci/ciMethodData.hpp"
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    28
#include "ci/ciReplay.hpp"
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    29
#include "ci/ciSymbol.hpp"
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    30
#include "ci/ciKlass.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49340
diff changeset
    31
#include "ci/ciUtilities.inline.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54347
diff changeset
    32
#include "classfile/symbolTable.hpp"
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    33
#include "compiler/compileBroker.hpp"
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    34
#include "memory/allocation.inline.hpp"
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    35
#include "memory/oopFactory.hpp"
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    36
#include "memory/resourceArea.hpp"
53838
c8c9bd65c198 8219229: Make ConstantPool::tag_at and release_tag_at_put inlineable
redestad
parents: 53582
diff changeset
    37
#include "oops/constantPool.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48826
diff changeset
    38
#include "oops/method.inline.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27680
diff changeset
    39
#include "oops/oop.inline.hpp"
51467
12997ebbc0d8 8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled
iklam
parents: 49449
diff changeset
    40
#include "runtime/fieldDescriptor.inline.hpp"
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 51554
diff changeset
    41
#include "runtime/handles.inline.hpp"
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    42
#include "utilities/copy.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14588
diff changeset
    43
#include "utilities/macros.hpp"
54347
235883996bc7 8221698: Remove redundant includes from popular header files
iklam
parents: 54036
diff changeset
    44
#include "utilities/utf8.hpp"
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    45
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 14477
diff changeset
    46
#ifndef PRODUCT
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    47
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    48
// ciReplay
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    49
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    50
typedef struct _ciMethodDataRecord {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    51
  const char* _klass_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    52
  const char* _method_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    53
  const char* _signature;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    54
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    55
  int _state;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    56
  int _current_mileage;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    57
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    58
  intptr_t* _data;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    59
  char*     _orig_data;
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    60
  Klass**   _classes;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    61
  Method**  _methods;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    62
  int*      _classes_offsets;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    63
  int*      _methods_offsets;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    64
  int       _data_length;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    65
  int       _orig_data_length;
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    66
  int       _classes_length;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
    67
  int       _methods_length;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    68
} ciMethodDataRecord;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    69
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    70
typedef struct _ciMethodRecord {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    71
  const char* _klass_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    72
  const char* _method_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    73
  const char* _signature;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    74
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    75
  int _instructions_size;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    76
  int _interpreter_invocation_count;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    77
  int _interpreter_throwout_count;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    78
  int _invocation_counter;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    79
  int _backedge_counter;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    80
} ciMethodRecord;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    81
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    82
typedef struct _ciInlineRecord {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    83
  const char* _klass_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    84
  const char* _method_name;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    85
  const char* _signature;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    86
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    87
  int _inline_depth;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    88
  int _inline_bci;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    89
} ciInlineRecord;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    90
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    91
class  CompileReplay;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    92
static CompileReplay* replay_state;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    93
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    94
class CompileReplay : public StackObj {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
    95
 private:
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    96
  FILE*   _stream;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    97
  Thread* _thread;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    98
  Handle  _protection_domain;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
    99
  Handle  _loader;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   100
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   101
  GrowableArray<ciMethodRecord*>     _ci_method_records;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   102
  GrowableArray<ciMethodDataRecord*> _ci_method_data_records;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   103
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   104
  // Use pointer because we may need to return inline records
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   105
  // without destroying them.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   106
  GrowableArray<ciInlineRecord*>*    _ci_inline_records;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   107
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   108
  const char* _error_message;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   109
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   110
  char* _bufptr;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   111
  char* _buffer;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   112
  int   _buffer_length;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   113
  int   _buffer_pos;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   114
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   115
  // "compile" data
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   116
  ciKlass* _iklass;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   117
  Method*  _imethod;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   118
  int      _entry_bci;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   119
  int      _comp_level;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   120
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   121
 public:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   122
  CompileReplay(const char* filename, TRAPS) {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   123
    _thread = THREAD;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   124
    _loader = Handle(_thread, SystemDictionary::java_system_loader());
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   125
    _protection_domain = Handle();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   126
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   127
    _stream = fopen(filename, "rt");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   128
    if (_stream == NULL) {
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
   129
      fprintf(stderr, "ERROR: Can't open replay file %s\n", filename);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   130
    }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   131
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   132
    _ci_inline_records = NULL;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   133
    _error_message = NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   134
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   135
    _buffer_length = 32;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   136
    _buffer = NEW_RESOURCE_ARRAY(char, _buffer_length);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   137
    _bufptr = _buffer;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   138
    _buffer_pos = 0;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   139
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   140
    _imethod = NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   141
    _iklass  = NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   142
    _entry_bci  = 0;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   143
    _comp_level = 0;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   144
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   145
    test();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   146
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   147
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   148
  ~CompileReplay() {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   149
    if (_stream != NULL) fclose(_stream);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   150
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   151
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   152
  void test() {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   153
    strcpy(_buffer, "1 2 foo 4 bar 0x9 \"this is it\"");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   154
    _bufptr = _buffer;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   155
    assert(parse_int("test") == 1, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   156
    assert(parse_int("test") == 2, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   157
    assert(strcmp(parse_string(), "foo") == 0, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   158
    assert(parse_int("test") == 4, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   159
    assert(strcmp(parse_string(), "bar") == 0, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   160
    assert(parse_intptr_t("test") == 9, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   161
    assert(strcmp(parse_quoted_string(), "this is it") == 0, "what");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   162
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   163
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   164
  bool had_error() {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   165
    return _error_message != NULL || _thread->has_pending_exception();
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   166
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   167
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   168
  bool can_replay() {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   169
    return !(_stream == NULL || had_error());
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   170
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   171
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   172
  void report_error(const char* msg) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   173
    _error_message = msg;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   174
    // Restore the _buffer contents for error reporting
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   175
    for (int i = 0; i < _buffer_pos; i++) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   176
      if (_buffer[i] == '\0') _buffer[i] = ' ';
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   177
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   178
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   179
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   180
  int parse_int(const char* label) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   181
    if (had_error()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   182
      return 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   183
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   184
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   185
    int v = 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   186
    int read;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   187
    if (sscanf(_bufptr, "%i%n", &v, &read) != 1) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   188
      report_error(label);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   189
    } else {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   190
      _bufptr += read;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   191
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   192
    return v;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   193
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   194
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   195
  intptr_t parse_intptr_t(const char* label) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   196
    if (had_error()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   197
      return 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   198
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   199
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   200
    intptr_t v = 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   201
    int read;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   202
    if (sscanf(_bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   203
      report_error(label);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   204
    } else {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   205
      _bufptr += read;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   206
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   207
    return v;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   208
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   209
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   210
  void skip_ws() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   211
    // Skip any leading whitespace
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   212
    while (*_bufptr == ' ' || *_bufptr == '\t') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   213
      _bufptr++;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   214
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   215
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   216
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   217
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   218
  char* scan_and_terminate(char delim) {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   219
    char* str = _bufptr;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   220
    while (*_bufptr != delim && *_bufptr != '\0') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   221
      _bufptr++;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   222
    }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   223
    if (*_bufptr != '\0') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   224
      *_bufptr++ = '\0';
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   225
    }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   226
    if (_bufptr == str) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   227
      // nothing here
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   228
      return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   229
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   230
    return str;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   231
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   232
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   233
  char* parse_string() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   234
    if (had_error()) return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   235
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   236
    skip_ws();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   237
    return scan_and_terminate(' ');
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   238
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   239
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   240
  char* parse_quoted_string() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   241
    if (had_error()) return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   242
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   243
    skip_ws();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   244
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   245
    if (*_bufptr == '"') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   246
      _bufptr++;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   247
      return scan_and_terminate('"');
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   248
    } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   249
      return scan_and_terminate(' ');
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   250
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   251
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   252
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   253
  const char* parse_escaped_string() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   254
    char* result = parse_quoted_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   255
    if (result != NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   256
      unescape_string(result);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   257
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   258
    return result;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   259
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   260
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   261
  // Look for the tag 'tag' followed by an
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   262
  bool parse_tag_and_count(const char* tag, int& length) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   263
    const char* t = parse_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   264
    if (t == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   265
      return false;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   266
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   267
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   268
    if (strcmp(tag, t) != 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   269
      report_error(tag);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   270
      return false;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   271
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   272
    length = parse_int("parse_tag_and_count");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   273
    return !had_error();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   274
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   275
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   276
  // Parse a sequence of raw data encoded as bytes and return the
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   277
  // resulting data.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   278
  char* parse_data(const char* tag, int& length) {
54036
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   279
    int read_size = 0;
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   280
    if (!parse_tag_and_count(tag, read_size)) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   281
      return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   282
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   283
54036
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   284
    int actual_size = sizeof(MethodData);
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   285
    char *result = NEW_RESOURCE_ARRAY(char, actual_size);
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   286
    int i = 0;
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   287
    if (read_size != actual_size) {
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   288
      tty->print_cr("Warning: ciMethodData parsing sees MethodData size %i in file, current is %i", read_size,
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   289
                    actual_size);
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   290
      // Replay serializes the entire MethodData, but the data is at the end.
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   291
      // If the MethodData instance size has changed, we can pad or truncate in the beginning
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   292
      int padding = actual_size - read_size;
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   293
      if (padding > 0) {
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   294
        // pad missing data with zeros
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   295
        tty->print_cr("- Padding MethodData");
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   296
        for (; i < padding; i++) {
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   297
          result[i] = 0;
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   298
        }
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   299
      } else if (padding < 0) {
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   300
        // drop some data
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   301
        tty->print_cr("- Truncating MethodData");
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   302
        for (int j = 0; j < -padding; j++) {
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   303
          int val = parse_int("data");
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   304
          // discard val
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   305
        }
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   306
      }
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   307
    }
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   308
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   309
    assert(i < actual_size, "At least some data must remain to be copied");
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   310
    for (; i < actual_size; i++) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   311
      int val = parse_int("data");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   312
      result[i] = val;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   313
    }
54036
c70747878f6f 8219642: ciReplay loads wrong data when MethodData size changes
neliasso
parents: 53838
diff changeset
   314
    length = actual_size;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   315
    return result;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   316
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   317
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   318
  // Parse a standard chunk of data emitted as:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   319
  //   'tag' <length> # # ...
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   320
  // Where each # is an intptr_t item
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   321
  intptr_t* parse_intptr_data(const char* tag, int& length) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   322
    if (!parse_tag_and_count(tag, length)) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   323
      return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   324
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   325
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   326
    intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   327
    for (int i = 0; i < length; i++) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   328
      skip_ws();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   329
      intptr_t val = parse_intptr_t("data");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   330
      result[i] = val;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   331
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   332
    return result;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   333
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   334
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   335
  // Parse a possibly quoted version of a symbol into a symbolOop
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   336
  Symbol* parse_symbol(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   337
    const char* str = parse_escaped_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   338
    if (str != NULL) {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   339
      Symbol* sym = SymbolTable::new_symbol(str);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   340
      return sym;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   341
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   342
    return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   343
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   344
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   345
  // Parse a valid klass name and look it up
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   346
  Klass* parse_klass(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   347
    const char* str = parse_escaped_string();
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   348
    Symbol* klass_name = SymbolTable::new_symbol(str);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   349
    if (klass_name != NULL) {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   350
      Klass* k = NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   351
      if (_iklass != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   352
        k = (Klass*)_iklass->find_klass(ciSymbol::make(klass_name->as_C_string()))->constant_encoding();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   353
      } else {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   354
        k = SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   355
      }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   356
      if (HAS_PENDING_EXCEPTION) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   357
        oop throwable = PENDING_EXCEPTION;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   358
        java_lang_Throwable::print(throwable, tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   359
        tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   360
        report_error(str);
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   361
        if (ReplayIgnoreInitErrors) {
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   362
          CLEAR_PENDING_EXCEPTION;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   363
          _error_message = NULL;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   364
        }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   365
        return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   366
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   367
      return k;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   368
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   369
    return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   370
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   371
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   372
  // Lookup a klass
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   373
  Klass* resolve_klass(const char* klass, TRAPS) {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   374
    Symbol* klass_name = SymbolTable::new_symbol(klass);
27680
8ecc0871c18e 8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents: 25325
diff changeset
   375
    return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   376
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   377
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   378
  // Parse the standard tuple of <klass> <name> <signature>
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   379
  Method* parse_method(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   380
    InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL);
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   381
    if (k == NULL) {
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   382
      report_error("Can't find holder klass");
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   383
      return NULL;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   384
    }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   385
    Symbol* method_name = parse_symbol(CHECK_NULL);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   386
    Symbol* method_signature = parse_symbol(CHECK_NULL);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   387
    Method* m = k->find_method(method_name, method_signature);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   388
    if (m == NULL) {
18984
a0fce9081603 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 17376
diff changeset
   389
      report_error("Can't find method");
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   390
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   391
    return m;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   392
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   393
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   394
  int get_line(int c) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   395
    while(c != EOF) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   396
      if (_buffer_pos + 1 >= _buffer_length) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   397
        int new_length = _buffer_length * 2;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   398
        // Next call will throw error in case of OOM.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   399
        _buffer = REALLOC_RESOURCE_ARRAY(char, _buffer, _buffer_length, new_length);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   400
        _buffer_length = new_length;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   401
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   402
      if (c == '\n') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   403
        c = getc(_stream); // get next char
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   404
        break;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   405
      } else if (c == '\r') {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   406
        // skip LF
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   407
      } else {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   408
        _buffer[_buffer_pos++] = c;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   409
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   410
      c = getc(_stream);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   411
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   412
    // null terminate it, reset the pointer
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   413
    _buffer[_buffer_pos] = '\0'; // NL or EOF
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   414
    _buffer_pos = 0;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   415
    _bufptr = _buffer;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   416
    return c;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   417
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   418
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   419
  // Process each line of the replay file executing each command until
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   420
  // the file ends.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   421
  void process(TRAPS) {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   422
    int line_no = 1;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   423
    int c = getc(_stream);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   424
    while(c != EOF) {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   425
      c = get_line(c);
24324
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   426
      process_command(THREAD);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   427
      if (had_error()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   428
        tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message);
24324
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   429
        if (ReplayIgnoreInitErrors) {
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   430
          CLEAR_PENDING_EXCEPTION;
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   431
          _error_message = NULL;
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   432
        } else {
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   433
          return;
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   434
        }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   435
      }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   436
      line_no++;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   437
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   438
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   439
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   440
  void process_command(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   441
    char* cmd = parse_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   442
    if (cmd == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   443
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   444
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   445
    if (strcmp("#", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   446
      // ignore
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   447
    } else if (strcmp("compile", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   448
      process_compile(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   449
    } else if (strcmp("ciMethod", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   450
      process_ciMethod(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   451
    } else if (strcmp("ciMethodData", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   452
      process_ciMethodData(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   453
    } else if (strcmp("staticfield", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   454
      process_staticfield(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   455
    } else if (strcmp("ciInstanceKlass", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   456
      process_ciInstanceKlass(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   457
    } else if (strcmp("instanceKlass", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   458
      process_instanceKlass(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   459
#if INCLUDE_JVMTI
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   460
    } else if (strcmp("JvmtiExport", cmd) == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   461
      process_JvmtiExport(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   462
#endif // INCLUDE_JVMTI
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   463
    } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   464
      report_error("unknown command");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   465
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   466
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   467
17123
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   468
  // validation of comp_level
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   469
  bool is_valid_comp_level(int comp_level) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   470
    const int msg_len = 256;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   471
    char* msg = NULL;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   472
    if (!is_compile(comp_level)) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   473
      msg = NEW_RESOURCE_ARRAY(char, msg_len);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   474
      jio_snprintf(msg, msg_len, "%d isn't compilation level", comp_level);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   475
    } else if (!TieredCompilation && (comp_level != CompLevel_highest_tier)) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   476
      msg = NEW_RESOURCE_ARRAY(char, msg_len);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   477
      switch (comp_level) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   478
        case CompLevel_simple:
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   479
          jio_snprintf(msg, msg_len, "compilation level %d requires Client VM or TieredCompilation", comp_level);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   480
          break;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   481
        case CompLevel_full_optimization:
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   482
          jio_snprintf(msg, msg_len, "compilation level %d requires Server VM", comp_level);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   483
          break;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   484
        default:
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   485
          jio_snprintf(msg, msg_len, "compilation level %d requires TieredCompilation", comp_level);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   486
      }
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   487
    }
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   488
    if (msg != NULL) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   489
      report_error(msg);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   490
      return false;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   491
    }
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   492
    return true;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   493
  }
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   494
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   495
  // compile <klass> <name> <signature> <entry_bci> <comp_level> inline <count> <depth> <bci> <klass> <name> <signature> ...
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   496
  void* process_inline(ciMethod* imethod, Method* m, int entry_bci, int comp_level, TRAPS) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   497
    _imethod    = m;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   498
    _iklass     = imethod->holder();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   499
    _entry_bci  = entry_bci;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   500
    _comp_level = comp_level;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   501
    int line_no = 1;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   502
    int c = getc(_stream);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   503
    while(c != EOF) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   504
      c = get_line(c);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   505
      // Expecting only lines with "compile" command in inline replay file.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   506
      char* cmd = parse_string();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   507
      if (cmd == NULL || strcmp("compile", cmd) != 0) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   508
        return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   509
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   510
      process_compile(CHECK_NULL);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   511
      if (had_error()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   512
        tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   513
        tty->print_cr("%s", _buffer);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   514
        return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   515
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   516
      if (_ci_inline_records != NULL && _ci_inline_records->length() > 0) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   517
        // Found inlining record for the requested method.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   518
        return _ci_inline_records;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   519
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   520
      line_no++;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   521
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   522
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   523
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   524
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   525
  // compile <klass> <name> <signature> <entry_bci> <comp_level> inline <count> <depth> <bci> <klass> <name> <signature> ...
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   526
  void process_compile(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   527
    Method* method = parse_method(CHECK);
18984
a0fce9081603 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 17376
diff changeset
   528
    if (had_error()) return;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   529
    int entry_bci = parse_int("entry_bci");
17123
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   530
    const char* comp_level_label = "comp_level";
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   531
    int comp_level = parse_int(comp_level_label);
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   532
    // old version w/o comp_level
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   533
    if (had_error() && (error_message() == comp_level_label)) {
40056
6bdd3da90181 8160898: assert while replaying ciReplay file created using TieredStopAtLevel=1
thartmann
parents: 38656
diff changeset
   534
      // use highest available tier
55050
feba48c5dfb4 8213416: Replace some enums with static const members in hotspot/compiler
rraghavan
parents: 54847
diff changeset
   535
      if (TieredCompilation) {
feba48c5dfb4 8213416: Replace some enums with static const members in hotspot/compiler
rraghavan
parents: 54847
diff changeset
   536
        comp_level = TieredStopAtLevel;
feba48c5dfb4 8213416: Replace some enums with static const members in hotspot/compiler
rraghavan
parents: 54847
diff changeset
   537
      } else {
feba48c5dfb4 8213416: Replace some enums with static const members in hotspot/compiler
rraghavan
parents: 54847
diff changeset
   538
        comp_level = CompLevel_highest_tier;
feba48c5dfb4 8213416: Replace some enums with static const members in hotspot/compiler
rraghavan
parents: 54847
diff changeset
   539
      }
17123
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   540
    }
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   541
    if (!is_valid_comp_level(comp_level)) {
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   542
      return;
a8e62eed2e3e 8011675: adding compilation level to replay data
iignatyev
parents: 17121
diff changeset
   543
    }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   544
    if (_imethod != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   545
      // Replay Inlining
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   546
      if (entry_bci != _entry_bci || comp_level != _comp_level) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   547
        return;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   548
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   549
      const char* iklass_name  = _imethod->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   550
      const char* imethod_name = _imethod->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   551
      const char* isignature   = _imethod->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   552
      const char* klass_name   = method->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   553
      const char* method_name  = method->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   554
      const char* signature    = method->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   555
      if (strcmp(iklass_name,  klass_name)  != 0 ||
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   556
          strcmp(imethod_name, method_name) != 0 ||
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   557
          strcmp(isignature,   signature)   != 0) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   558
        return;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   559
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   560
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   561
    int inline_count = 0;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   562
    if (parse_tag_and_count("inline", inline_count)) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   563
      // Record inlining data
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   564
      _ci_inline_records = new GrowableArray<ciInlineRecord*>();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   565
      for (int i = 0; i < inline_count; i++) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   566
        int depth = parse_int("inline_depth");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   567
        int bci = parse_int("inline_bci");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   568
        if (had_error()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   569
          break;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   570
        }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   571
        Method* inl_method = parse_method(CHECK);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   572
        if (had_error()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   573
          break;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   574
        }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   575
        new_ciInlineRecord(inl_method, bci, depth);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   576
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   577
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   578
    if (_imethod != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   579
      return; // Replay Inlining
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   580
    }
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33105
diff changeset
   581
    InstanceKlass* ik = method->method_holder();
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33105
diff changeset
   582
    ik->initialize(THREAD);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   583
    if (HAS_PENDING_EXCEPTION) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   584
      oop throwable = PENDING_EXCEPTION;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   585
      java_lang_Throwable::print(throwable, tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   586
      tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   587
      if (ReplayIgnoreInitErrors) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   588
        CLEAR_PENDING_EXCEPTION;
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33105
diff changeset
   589
        ik->set_init_state(InstanceKlass::fully_initialized);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   590
      } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   591
        return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   592
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   593
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   594
    // Make sure the existence of a prior compile doesn't stop this one
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37237
diff changeset
   595
    CompiledMethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   596
    if (nm != NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   597
      nm->make_not_entrant();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   598
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   599
    replay_state = this;
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58722
diff changeset
   600
    CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,
38218
f5ba1dea04eb 8153013: BlockingCompilation test times out
neliasso
parents: 38133
diff changeset
   601
                                  methodHandle(), 0, CompileTask::Reason_Replay, THREAD);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   602
    replay_state = NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   603
    reset();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   604
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   605
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   606
  // ciMethod <klass> <name> <signature> <invocation_counter> <backedge_counter> <interpreter_invocation_count> <interpreter_throwout_count> <instructions_size>
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   607
  //
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   608
  //
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   609
  void process_ciMethod(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   610
    Method* method = parse_method(CHECK);
18984
a0fce9081603 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 17376
diff changeset
   611
    if (had_error()) return;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   612
    ciMethodRecord* rec = new_ciMethod(method);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   613
    rec->_invocation_counter = parse_int("invocation_counter");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   614
    rec->_backedge_counter = parse_int("backedge_counter");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   615
    rec->_interpreter_invocation_count = parse_int("interpreter_invocation_count");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   616
    rec->_interpreter_throwout_count = parse_int("interpreter_throwout_count");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   617
    rec->_instructions_size = parse_int("instructions_size");
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   618
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   619
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   620
  // ciMethodData <klass> <name> <signature> <state> <current mileage> orig <length> # # ... data <length> # # ... oops <length> # ... methods <length>
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   621
  void process_ciMethodData(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   622
    Method* method = parse_method(CHECK);
18984
a0fce9081603 8012263: ciReplay: gracefully exit & report meaningful error when replay data parsing fails
minqi
parents: 17376
diff changeset
   623
    if (had_error()) return;
24324
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   624
    /* just copied from Method, to build interpret data*/
40892
330a02d935ad 8156500: Move Reference pending list into VM to prevent deadlocks
kbarrett
parents: 40056
diff changeset
   625
24324
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   626
    // To be properly initialized, some profiling in the MDO needs the
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   627
    // method to be rewritten (number of arguments at a call for
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   628
    // instance)
e18584aa83e2 8041959: Skip replay parsing errors with ReplayIgnoreInitErrors
kvn
parents: 22243
diff changeset
   629
    method->method_holder()->link_class(CHECK);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   630
    // methodOopDesc::build_interpreter_method_data(method, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   631
    {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   632
      // Grab a lock here to prevent multiple
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   633
      // MethodData*s from being created.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   634
      MutexLocker ml(MethodData_lock, THREAD);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   635
      if (method->method_data() == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   636
        ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58722
diff changeset
   637
        MethodData* method_data = MethodData::allocate(loader_data, methodHandle(THREAD, method), CHECK);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   638
        method->set_method_data(method_data);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   639
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   640
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   641
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   642
    // collect and record all the needed information for later
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   643
    ciMethodDataRecord* rec = new_ciMethodData(method);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   644
    rec->_state = parse_int("state");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   645
    rec->_current_mileage = parse_int("current_mileage");
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   646
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   647
    rec->_orig_data = parse_data("orig", rec->_orig_data_length);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   648
    if (rec->_orig_data == NULL) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   649
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   650
    }
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   651
    rec->_data = parse_intptr_data("data", rec->_data_length);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   652
    if (rec->_data == NULL) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   653
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   654
    }
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   655
    if (!parse_tag_and_count("oops", rec->_classes_length)) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   656
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   657
    }
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   658
    rec->_classes = NEW_RESOURCE_ARRAY(Klass*, rec->_classes_length);
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   659
    rec->_classes_offsets = NEW_RESOURCE_ARRAY(int, rec->_classes_length);
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   660
    for (int i = 0; i < rec->_classes_length; i++) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   661
      int offset = parse_int("offset");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   662
      if (had_error()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   663
        return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   664
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   665
      Klass* k = parse_klass(CHECK);
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   666
      rec->_classes_offsets[i] = offset;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   667
      rec->_classes[i] = k;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   668
    }
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   669
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   670
    if (!parse_tag_and_count("methods", rec->_methods_length)) {
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   671
      return;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   672
    }
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   673
    rec->_methods = NEW_RESOURCE_ARRAY(Method*, rec->_methods_length);
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   674
    rec->_methods_offsets = NEW_RESOURCE_ARRAY(int, rec->_methods_length);
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   675
    for (int i = 0; i < rec->_methods_length; i++) {
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   676
      int offset = parse_int("offset");
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   677
      if (had_error()) {
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   678
        return;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   679
      }
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   680
      Method* m = parse_method(CHECK);
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   681
      rec->_methods_offsets[i] = offset;
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
   682
      rec->_methods[i] = m;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   683
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   684
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   685
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   686
  // instanceKlass <name>
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   687
  //
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   688
  // Loads and initializes the klass 'name'.  This can be used to
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   689
  // create particular class loading environments
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   690
  void process_instanceKlass(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   691
    // just load the referenced class
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   692
    Klass* k = parse_klass(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   693
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   694
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   695
  // ciInstanceKlass <name> <is_linked> <is_initialized> <length> tag # # # ...
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   696
  //
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   697
  // Load the klass 'name' and link or initialize it.  Verify that the
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   698
  // constant pool is the same length as 'length' and make sure the
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   699
  // constant pool tags are in the same state.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   700
  void process_ciInstanceKlass(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   701
    InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   702
    if (k == NULL) {
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   703
      return;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   704
    }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   705
    int is_linked = parse_int("is_linked");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   706
    int is_initialized = parse_int("is_initialized");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   707
    int length = parse_int("length");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   708
    if (is_initialized) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   709
      k->initialize(THREAD);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   710
      if (HAS_PENDING_EXCEPTION) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   711
        oop throwable = PENDING_EXCEPTION;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   712
        java_lang_Throwable::print(throwable, tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   713
        tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   714
        if (ReplayIgnoreInitErrors) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   715
          CLEAR_PENDING_EXCEPTION;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   716
          k->set_init_state(InstanceKlass::fully_initialized);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   717
        } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   718
          return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   719
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   720
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   721
    } else if (is_linked) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   722
      k->link_class(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   723
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   724
    ConstantPool* cp = k->constants();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   725
    if (length != cp->length()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   726
      report_error("constant pool length mismatch: wrong class files?");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   727
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   728
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   729
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   730
    int parsed_two_word = 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   731
    for (int i = 1; i < length; i++) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   732
      int tag = parse_int("tag");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   733
      if (had_error()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   734
        return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   735
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   736
      switch (cp->tag_at(i).value()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   737
        case JVM_CONSTANT_UnresolvedClass: {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   738
          if (tag == JVM_CONSTANT_Class) {
25325
e3af4e02b0d5 8026977: NPG: Remove ConstantPool::lock
coleenp
parents: 24476
diff changeset
   739
            tty->print_cr("Resolving klass %s at %d", cp->klass_name_at(i)->as_utf8(), i);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   740
            Klass* k = cp->klass_at(i, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   741
          }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   742
          break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   743
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   744
        case JVM_CONSTANT_Long:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   745
        case JVM_CONSTANT_Double:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   746
          parsed_two_word = i + 1;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   747
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   748
        case JVM_CONSTANT_ClassIndex:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   749
        case JVM_CONSTANT_StringIndex:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   750
        case JVM_CONSTANT_String:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   751
        case JVM_CONSTANT_UnresolvedClassInError:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   752
        case JVM_CONSTANT_Fieldref:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   753
        case JVM_CONSTANT_Methodref:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   754
        case JVM_CONSTANT_InterfaceMethodref:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   755
        case JVM_CONSTANT_NameAndType:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   756
        case JVM_CONSTANT_Utf8:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   757
        case JVM_CONSTANT_Integer:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   758
        case JVM_CONSTANT_Float:
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   759
        case JVM_CONSTANT_MethodHandle:
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   760
        case JVM_CONSTANT_MethodType:
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47765
diff changeset
   761
        case JVM_CONSTANT_Dynamic:
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   762
        case JVM_CONSTANT_InvokeDynamic:
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   763
          if (tag != cp->tag_at(i).value()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   764
            report_error("tag mismatch: wrong class files?");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   765
            return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   766
          }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   767
          break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   768
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   769
        case JVM_CONSTANT_Class:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   770
          if (tag == JVM_CONSTANT_Class) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   771
          } else if (tag == JVM_CONSTANT_UnresolvedClass) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   772
            tty->print_cr("Warning: entry was unresolved in the replay data");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   773
          } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   774
            report_error("Unexpected tag");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   775
            return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   776
          }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   777
          break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   778
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   779
        case 0:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   780
          if (parsed_two_word == i) continue;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   781
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   782
        default:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 29081
diff changeset
   783
          fatal("Unexpected tag: %d", cp->tag_at(i).value());
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   784
          break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   785
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   786
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   787
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   788
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   789
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   790
  // Initialize a class and fill in the value for a static field.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   791
  // This is useful when the compile was dependent on the value of
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   792
  // static fields but it's impossible to properly rerun the static
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   793
  // initiailizer.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   794
  void process_staticfield(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   795
    InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   796
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   797
    if (k == NULL || ReplaySuppressInitializers == 0 ||
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46560
diff changeset
   798
        (ReplaySuppressInitializers == 2 && k->class_loader() == NULL)) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   799
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   800
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   801
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   802
    assert(k->is_initialized(), "must be");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   803
46259
73749cb53dc0 8174199: ci replay doesn't reallocate static final fields of recorded klass
roland
parents: 40892
diff changeset
   804
    const char* field_name = parse_escaped_string();
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   805
    const char* field_signature = parse_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   806
    fieldDescriptor fd;
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   807
    Symbol* name = SymbolTable::new_symbol(field_name);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   808
    Symbol* sig = SymbolTable::new_symbol(field_signature);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   809
    if (!k->find_local_field(name, sig, &fd) ||
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   810
        !fd.is_static() ||
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   811
        fd.has_initial_value()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   812
      report_error(field_name);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   813
      return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   814
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   815
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   816
    oop java_mirror = k->java_mirror();
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   817
    if (field_signature[0] == JVM_SIGNATURE_ARRAY) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   818
      int length = parse_int("array length");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   819
      oop value = NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   820
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   821
      if (field_signature[1] == JVM_SIGNATURE_ARRAY) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   822
        // multi dimensional array
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   823
        ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   824
        if (kelem == NULL) {
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   825
          return;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
   826
        }
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   827
        int rank = 0;
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   828
        while (field_signature[rank] == JVM_SIGNATURE_ARRAY) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   829
          rank++;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   830
        }
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
   831
        jint* dims = NEW_RESOURCE_ARRAY(jint, rank);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   832
        dims[0] = length;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   833
        for (int i = 1; i < rank; i++) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   834
          dims[i] = 1; // These aren't relevant to the compiler
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   835
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   836
        value = kelem->multi_allocate(rank, dims, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   837
      } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   838
        if (strcmp(field_signature, "[B") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   839
          value = oopFactory::new_byteArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   840
        } else if (strcmp(field_signature, "[Z") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   841
          value = oopFactory::new_boolArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   842
        } else if (strcmp(field_signature, "[C") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   843
          value = oopFactory::new_charArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   844
        } else if (strcmp(field_signature, "[S") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   845
          value = oopFactory::new_shortArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   846
        } else if (strcmp(field_signature, "[F") == 0) {
51554
5b0d86499960 8209958: Clean up duplicate basic array type statics in Universe
coleenp
parents: 51467
diff changeset
   847
          value = oopFactory::new_floatArray(length, CHECK);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   848
        } else if (strcmp(field_signature, "[D") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   849
          value = oopFactory::new_doubleArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   850
        } else if (strcmp(field_signature, "[I") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   851
          value = oopFactory::new_intArray(length, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   852
        } else if (strcmp(field_signature, "[J") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   853
          value = oopFactory::new_longArray(length, CHECK);
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   854
        } else if (field_signature[0] == JVM_SIGNATURE_ARRAY &&
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   855
                   field_signature[1] == JVM_SIGNATURE_CLASS) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46259
diff changeset
   856
          Klass* kelem = resolve_klass(field_signature + 1, CHECK);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46259
diff changeset
   857
          value = oopFactory::new_objArray(kelem, length, CHECK);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   858
        } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   859
          report_error("unhandled array staticfield");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   860
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   861
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   862
      java_mirror->obj_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   863
    } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   864
      const char* string_value = parse_escaped_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   865
      if (strcmp(field_signature, "I") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   866
        int value = atoi(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   867
        java_mirror->int_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   868
      } else if (strcmp(field_signature, "B") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   869
        int value = atoi(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   870
        java_mirror->byte_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   871
      } else if (strcmp(field_signature, "C") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   872
        int value = atoi(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   873
        java_mirror->char_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   874
      } else if (strcmp(field_signature, "S") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   875
        int value = atoi(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   876
        java_mirror->short_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   877
      } else if (strcmp(field_signature, "Z") == 0) {
38656
22c78787d80c 8150016: small typo in ciReplay code
jcm
parents: 38218
diff changeset
   878
        int value = atoi(string_value);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   879
        java_mirror->bool_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   880
      } else if (strcmp(field_signature, "J") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   881
        jlong value;
15228
e92acc84ade3 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 14588
diff changeset
   882
        if (sscanf(string_value, JLONG_FORMAT, &value) != 1) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   883
          fprintf(stderr, "Error parsing long: %s\n", string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   884
          return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   885
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   886
        java_mirror->long_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   887
      } else if (strcmp(field_signature, "F") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   888
        float value = atof(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   889
        java_mirror->float_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   890
      } else if (strcmp(field_signature, "D") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   891
        double value = atof(string_value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   892
        java_mirror->double_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   893
      } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   894
        Handle value = java_lang_String::create_from_str(string_value, CHECK);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   895
        java_mirror->obj_field_put(fd.offset(), value());
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 55050
diff changeset
   896
      } else if (field_signature[0] == JVM_SIGNATURE_CLASS) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46259
diff changeset
   897
        Klass* k = resolve_klass(string_value, CHECK);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46259
diff changeset
   898
        oop value = InstanceKlass::cast(k)->allocate_instance(CHECK);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   899
        java_mirror->obj_field_put(fd.offset(), value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   900
      } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   901
        report_error("unhandled staticfield");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   902
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   903
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   904
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   905
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   906
#if INCLUDE_JVMTI
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   907
  void process_JvmtiExport(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   908
    const char* field = parse_string();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   909
    bool value = parse_int("JvmtiExport flag") != 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   910
    if (strcmp(field, "can_access_local_variables") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   911
      JvmtiExport::set_can_access_local_variables(value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   912
    } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   913
      JvmtiExport::set_can_hotswap_or_post_breakpoint(value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   914
    } else if (strcmp(field, "can_post_on_exceptions") == 0) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   915
      JvmtiExport::set_can_post_on_exceptions(value);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   916
    } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   917
      report_error("Unrecognized JvmtiExport directive");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   918
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   919
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   920
#endif // INCLUDE_JVMTI
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   921
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   922
  // Create and initialize a record for a ciMethod
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   923
  ciMethodRecord* new_ciMethod(Method* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   924
    ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   925
    rec->_klass_name =  method->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   926
    rec->_method_name = method->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   927
    rec->_signature = method->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   928
    _ci_method_records.append(rec);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   929
    return rec;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   930
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   931
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   932
  // Lookup data for a ciMethod
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   933
  ciMethodRecord* find_ciMethodRecord(Method* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   934
    const char* klass_name =  method->method_holder()->name()->as_utf8();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   935
    const char* method_name = method->name()->as_utf8();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   936
    const char* signature = method->signature()->as_utf8();
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   937
    for (int i = 0; i < _ci_method_records.length(); i++) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   938
      ciMethodRecord* rec = _ci_method_records.at(i);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   939
      if (strcmp(rec->_klass_name, klass_name) == 0 &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   940
          strcmp(rec->_method_name, method_name) == 0 &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   941
          strcmp(rec->_signature, signature) == 0) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   942
        return rec;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   943
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   944
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   945
    return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   946
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   947
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   948
  // Create and initialize a record for a ciMethodData
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   949
  ciMethodDataRecord* new_ciMethodData(Method* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   950
    ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   951
    rec->_klass_name =  method->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   952
    rec->_method_name = method->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   953
    rec->_signature = method->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   954
    _ci_method_data_records.append(rec);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   955
    return rec;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   956
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   957
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   958
  // Lookup data for a ciMethodData
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   959
  ciMethodDataRecord* find_ciMethodDataRecord(Method* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   960
    const char* klass_name =  method->method_holder()->name()->as_utf8();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   961
    const char* method_name = method->name()->as_utf8();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   962
    const char* signature = method->signature()->as_utf8();
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   963
    for (int i = 0; i < _ci_method_data_records.length(); i++) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   964
      ciMethodDataRecord* rec = _ci_method_data_records.at(i);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   965
      if (strcmp(rec->_klass_name, klass_name) == 0 &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   966
          strcmp(rec->_method_name, method_name) == 0 &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   967
          strcmp(rec->_signature, signature) == 0) {
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   968
        return rec;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   969
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   970
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   971
    return NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   972
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
   973
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   974
  // Create and initialize a record for a ciInlineRecord
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   975
  ciInlineRecord* new_ciInlineRecord(Method* method, int bci, int depth) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   976
    ciInlineRecord* rec = NEW_RESOURCE_OBJ(ciInlineRecord);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   977
    rec->_klass_name =  method->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   978
    rec->_method_name = method->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   979
    rec->_signature = method->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   980
    rec->_inline_bci = bci;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   981
    rec->_inline_depth = depth;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   982
    _ci_inline_records->append(rec);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   983
    return rec;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   984
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   985
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   986
  // Lookup inlining data for a ciMethod
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   987
  ciInlineRecord* find_ciInlineRecord(Method* method, int bci, int depth) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   988
    if (_ci_inline_records != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   989
      return find_ciInlineRecord(_ci_inline_records, method, bci, depth);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   990
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   991
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   992
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   993
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   994
  static ciInlineRecord* find_ciInlineRecord(GrowableArray<ciInlineRecord*>*  records,
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   995
                                      Method* method, int bci, int depth) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   996
    if (records != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   997
      const char* klass_name  = method->method_holder()->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   998
      const char* method_name = method->name()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
   999
      const char* signature   = method->signature()->as_utf8();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1000
      for (int i = 0; i < records->length(); i++) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1001
        ciInlineRecord* rec = records->at(i);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1002
        if ((rec->_inline_bci == bci) &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1003
            (rec->_inline_depth == depth) &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1004
            (strcmp(rec->_klass_name, klass_name) == 0) &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1005
            (strcmp(rec->_method_name, method_name) == 0) &&
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1006
            (strcmp(rec->_signature, signature) == 0)) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1007
          return rec;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1008
        }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1009
      }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1010
    }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1011
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1012
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1013
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1014
  const char* error_message() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1015
    return _error_message;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1016
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1017
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1018
  void reset() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1019
    _error_message = NULL;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1020
    _ci_method_records.clear();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1021
    _ci_method_data_records.clear();
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1022
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1023
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1024
  // Take an ascii string contain \u#### escapes and convert it to utf8
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1025
  // in place.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1026
  static void unescape_string(char* value) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1027
    char* from = value;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1028
    char* to = value;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1029
    while (*from != '\0') {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1030
      if (*from != '\\') {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1031
        *from++ = *to++;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1032
      } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1033
        switch (from[1]) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1034
          case 'u': {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1035
            from += 2;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1036
            jchar value=0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1037
            for (int i=0; i<4; i++) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1038
              char c = *from++;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1039
              switch (c) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1040
                case '0': case '1': case '2': case '3': case '4':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1041
                case '5': case '6': case '7': case '8': case '9':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1042
                  value = (value << 4) + c - '0';
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1043
                  break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1044
                case 'a': case 'b': case 'c':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1045
                case 'd': case 'e': case 'f':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1046
                  value = (value << 4) + 10 + c - 'a';
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1047
                  break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1048
                case 'A': case 'B': case 'C':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1049
                case 'D': case 'E': case 'F':
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1050
                  value = (value << 4) + 10 + c - 'A';
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1051
                  break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1052
                default:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1053
                  ShouldNotReachHere();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1054
              }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1055
            }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1056
            UNICODE::convert_to_utf8(&value, 1, to);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1057
            to++;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1058
            break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1059
          }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1060
          case 't': *to++ = '\t'; from += 2; break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1061
          case 'n': *to++ = '\n'; from += 2; break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1062
          case 'r': *to++ = '\r'; from += 2; break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1063
          case 'f': *to++ = '\f'; from += 2; break;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1064
          default:
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1065
            ShouldNotReachHere();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1066
        }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1067
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1068
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1069
    *from = *to;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1070
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1071
};
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1072
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1073
void ciReplay::replay(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1074
  int exit_code = replay_impl(THREAD);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1075
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1076
  Threads::destroy_vm();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1077
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1078
  vm_exit(exit_code);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1079
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1080
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1081
void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1082
  if (FLAG_IS_DEFAULT(InlineDataFile)) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1083
    tty->print_cr("ERROR: no inline replay data file specified (use -XX:InlineDataFile=inline_pid12345.txt).");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1084
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1085
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1086
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1087
  VM_ENTRY_MARK;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1088
  // Load and parse the replay data
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1089
  CompileReplay rp(InlineDataFile, THREAD);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1090
  if (!rp.can_replay()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1091
    tty->print_cr("ciReplay: !rp.can_replay()");
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1092
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1093
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1094
  void* data = rp.process_inline(method, method->get_Method(), entry_bci, comp_level, THREAD);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1095
  if (HAS_PENDING_EXCEPTION) {
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 33602
diff changeset
  1096
    Handle throwable(THREAD, PENDING_EXCEPTION);
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1097
    CLEAR_PENDING_EXCEPTION;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1098
    java_lang_Throwable::print_stack_trace(throwable, tty);
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1099
    tty->cr();
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1100
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1101
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1102
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1103
  if (rp.had_error()) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1104
    tty->print_cr("ciReplay: Failed on %s", rp.error_message());
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1105
    return NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1106
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1107
  return data;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1108
}
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1109
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1110
int ciReplay::replay_impl(TRAPS) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1111
  HandleMark hm;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1112
  ResourceMark rm;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1113
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1114
  if (ReplaySuppressInitializers > 2) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1115
    // ReplaySuppressInitializers > 2 means that we want to allow
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1116
    // normal VM bootstrap but once we get into the replay itself
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1117
    // don't allow any intializers to be run.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1118
    ReplaySuppressInitializers = 1;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1119
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1120
17121
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
  1121
  if (FLAG_IS_DEFAULT(ReplayDataFile)) {
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
  1122
    tty->print_cr("ERROR: no compiler replay data file specified (use -XX:ReplayDataFile=replay_pid12345.txt).");
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
  1123
    return 1;
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
  1124
  }
e40a97c700d9 8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents: 17000
diff changeset
  1125
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1126
  // Load and parse the replay data
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1127
  CompileReplay rp(ReplayDataFile, THREAD);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1128
  int exit_code = 0;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1129
  if (rp.can_replay()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1130
    rp.process(THREAD);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1131
  } else {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1132
    exit_code = 1;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1133
    return exit_code;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1134
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1135
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1136
  if (HAS_PENDING_EXCEPTION) {
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 33602
diff changeset
  1137
    Handle throwable(THREAD, PENDING_EXCEPTION);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1138
    CLEAR_PENDING_EXCEPTION;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1139
    java_lang_Throwable::print_stack_trace(throwable, tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1140
    tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1141
    exit_code = 2;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1142
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1143
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1144
  if (rp.had_error()) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1145
    tty->print_cr("Failed on %s", rp.error_message());
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1146
    exit_code = 1;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1147
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1148
  return exit_code;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1149
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1150
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1151
void ciReplay::initialize(ciMethodData* m) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1152
  if (replay_state == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1153
    return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1154
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1155
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1156
  ASSERT_IN_VM;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1157
  ResourceMark rm;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1158
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1159
  Method* method = m->get_MethodData()->method();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1160
  ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1161
  if (rec == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1162
    // This indicates some mismatch with the original environment and
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1163
    // the replay environment though it's not always enough to
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1164
    // interfere with reproducing a bug
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1165
    tty->print_cr("Warning: requesting ciMethodData record for method with no data: ");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1166
    method->print_name(tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1167
    tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1168
  } else {
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1169
    m->_state = rec->_state;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1170
    m->_current_mileage = rec->_current_mileage;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1171
    if (rec->_data_length != 0) {
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1172
      assert(m->_data_size + m->_extra_data_size == rec->_data_length * (int)sizeof(rec->_data[0]) ||
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1173
             m->_data_size == rec->_data_length * (int)sizeof(rec->_data[0]), "must agree");
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1174
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1175
      // Write the correct ciObjects back into the profile data
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1176
      ciEnv* env = ciEnv::current();
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1177
      for (int i = 0; i < rec->_classes_length; i++) {
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1178
        Klass *k = rec->_classes[i];
46531
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1179
        // In case this class pointer is is tagged, preserve the tag bits
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1180
        intptr_t status = 0;
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1181
        if (k != NULL) {
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1182
          status = ciTypeEntries::with_status(env->get_metadata(k)->as_klass(), rec->_data[rec->_classes_offsets[i]]);
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1183
        }
f78769631206 8181781: Replay compilation should ignore unresolved Klass with -XX:+ReplayIgnoreInitErrors
thartmann
parents: 46329
diff changeset
  1184
        rec->_data[rec->_classes_offsets[i]] = status;
24476
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1185
      }
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1186
      for (int i = 0; i < rec->_methods_length; i++) {
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1187
        Method *m = rec->_methods[i];
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1188
        *(ciMetadata**)(rec->_data + rec->_methods_offsets[i]) =
912595db2e75 8026694: New type profiling points break compilation replay
roland
parents: 24324
diff changeset
  1189
          env->get_metadata(m);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1190
      }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1191
      // Copy the updated profile data into place as intptr_ts
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1192
#ifdef _LP64
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1193
      Copy::conjoint_jlongs_atomic((jlong *)rec->_data, (jlong *)m->_data, rec->_data_length);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1194
#else
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1195
      Copy::conjoint_jints_atomic((jint *)rec->_data, (jint *)m->_data, rec->_data_length);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1196
#endif
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1197
    }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1198
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1199
    // copy in the original header
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1200
    Copy::conjoint_jbytes(rec->_orig_data, (char*)&m->_orig, rec->_orig_data_length);
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1201
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1202
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1203
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1204
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1205
bool ciReplay::should_not_inline(ciMethod* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1206
  if (replay_state == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1207
    return false;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1208
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1209
  VM_ENTRY_MARK;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1210
  // ciMethod without a record shouldn't be inlined.
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1211
  return replay_state->find_ciMethodRecord(method->get_Method()) == NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1212
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1213
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1214
bool ciReplay::should_inline(void* data, ciMethod* method, int bci, int inline_depth) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1215
  if (data != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1216
    GrowableArray<ciInlineRecord*>*  records = (GrowableArray<ciInlineRecord*>*)data;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1217
    VM_ENTRY_MARK;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1218
    // Inline record are ordered by bci and depth.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1219
    return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) != NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1220
  } else if (replay_state != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1221
    VM_ENTRY_MARK;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1222
    // Inline record are ordered by bci and depth.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1223
    return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) != NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1224
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1225
  return false;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1226
}
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1227
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1228
bool ciReplay::should_not_inline(void* data, ciMethod* method, int bci, int inline_depth) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1229
  if (data != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1230
    GrowableArray<ciInlineRecord*>*  records = (GrowableArray<ciInlineRecord*>*)data;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1231
    VM_ENTRY_MARK;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1232
    // Inline record are ordered by bci and depth.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1233
    return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) == NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1234
  } else if (replay_state != NULL) {
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1235
    VM_ENTRY_MARK;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1236
    // Inline record are ordered by bci and depth.
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1237
    return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) == NULL;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1238
  }
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1239
  return false;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1240
}
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1241
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1242
void ciReplay::initialize(ciMethod* m) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1243
  if (replay_state == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1244
    return;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1245
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1246
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1247
  ASSERT_IN_VM;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1248
  ResourceMark rm;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1249
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1250
  Method* method = m->get_Method();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1251
  ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1252
  if (rec == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1253
    // This indicates some mismatch with the original environment and
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1254
    // the replay environment though it's not always enough to
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1255
    // interfere with reproducing a bug
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1256
    tty->print_cr("Warning: requesting ciMethod record for method with no data: ");
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1257
    method->print_name(tty);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1258
    tty->cr();
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1259
  } else {
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15483
diff changeset
  1260
    EXCEPTION_CONTEXT;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1261
    // m->_instructions_size = rec->_instructions_size;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1262
    m->_instructions_size = -1;
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1263
    m->_interpreter_invocation_count = rec->_interpreter_invocation_count;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1264
    m->_interpreter_throwout_count = rec->_interpreter_throwout_count;
20695
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 18984
diff changeset
  1265
    MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR);
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 18984
diff changeset
  1266
    guarantee(mcs != NULL, "method counters allocation failed");
22243
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1267
    mcs->invocation_counter()->_counter = rec->_invocation_counter;
91944eab7b92 8028468: Add inlining information into ciReplay
kvn
parents: 20695
diff changeset
  1268
    mcs->backedge_counter()->_counter = rec->_backedge_counter;
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1269
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1270
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1271
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1272
bool ciReplay::is_loaded(Method* method) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1273
  if (replay_state == NULL) {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1274
    return true;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1275
  }
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1276
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1277
  ASSERT_IN_VM;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1278
  ResourceMark rm;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1279
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1280
  ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1281
  return rec != NULL;
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents:
diff changeset
  1282
}
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 14477
diff changeset
  1283
#endif // PRODUCT