src/hotspot/share/prims/methodComparator.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 53745 a535ba736cab
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53745
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7114
diff changeset
    25
#include "precompiled.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49593
diff changeset
    26
#include "logging/log.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 49340
diff changeset
    27
#include "memory/resourceArea.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 47216
diff changeset
    28
#include "oops/constantPool.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7114
diff changeset
    29
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
    30
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7114
diff changeset
    31
#include "prims/methodComparator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7114
diff changeset
    32
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7114
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
BytecodeStream *MethodComparator::_s_old;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
BytecodeStream *MethodComparator::_s_new;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
    37
ConstantPool* MethodComparator::_old_cp;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
    38
ConstantPool* MethodComparator::_new_cp;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
    40
bool MethodComparator::methods_EMCP(Method* old_method, Method* new_method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  if (old_method->code_size() != new_method->code_size())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  if (check_stack_and_locals_size(old_method, new_method) != 0) {
38259
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    44
    if (log_is_enabled(Debug, redefine, class, methodcomparator)) {
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    45
      ResourceMark rm;
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    46
      log_debug(redefine, class, methodcomparator)
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    47
        ("Methods %s non-comparable with diagnosis %d",
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    48
         old_method->name()->as_C_string(), check_stack_and_locals_size(old_method, new_method));
b495d1cfe673 8153535: Convert TraceRedefineClasses to Unified Logging
rehn
parents: 36092
diff changeset
    49
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  _old_cp = old_method->constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _new_cp = new_method->constants();
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53745
diff changeset
    55
  Thread* THREAD = Thread::current();
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53745
diff changeset
    56
  BytecodeStream s_old(methodHandle(THREAD, old_method));
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 53745
diff changeset
    57
  BytecodeStream s_new(methodHandle(THREAD, new_method));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  _s_old = &s_old;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  _s_new = &s_new;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  Bytecodes::Code c_old, c_new;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  while ((c_old = s_old.next()) >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    if ((c_new = s_new.next()) < 0 || c_old != c_new)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    if (! args_same(c_old, c_new))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // BytecodeStream returns the correct standard Java bytecodes for various "fast"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // bytecode versions, so we don't have to bother about them here..
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  switch (c_old) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  case Bytecodes::_new            : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  case Bytecodes::_anewarray      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  case Bytecodes::_multianewarray : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  case Bytecodes::_checkcast      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  case Bytecodes::_instanceof     : {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
    81
    u2 cpi_old = _s_old->get_index_u2();
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
    82
    u2 cpi_new = _s_new->get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    if (c_old == Bytecodes::_multianewarray &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  case Bytecodes::_getstatic       : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  case Bytecodes::_putstatic       : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  case Bytecodes::_getfield        : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  case Bytecodes::_putfield        : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  case Bytecodes::_invokevirtual   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  case Bytecodes::_invokespecial   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  case Bytecodes::_invokestatic    : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  case Bytecodes::_invokeinterface : {
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
    99
    int cpci_old = _s_old->get_index_u2_cpcache();
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   100
    int cpci_new = _s_new->get_index_u2_cpcache();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    // Check if the names of classes, field/method names and signatures at these indexes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    // are the same. Indices which are really into constantpool cache (rather than constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    // pool itself) are accepted by the constantpool query routines below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   110
  case Bytecodes::_invokedynamic: {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   111
    int cpci_old = _s_old->get_index_u4();
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   112
    int cpci_new = _s_new->get_index_u4();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   113
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   114
    // Check if the names of classes, field/method names and signatures at these indexes
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   115
    // are the same. Indices which are really into constantpool cache (rather than constant
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   116
    // pool itself) are accepted by the constantpool query routines below.
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   117
    if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) ||
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   118
        (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new)))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   119
      return false;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   120
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   121
    // Translate object indexes to constant pool cache indexes.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   122
    cpci_old = _old_cp->invokedynamic_cp_cache_index(cpci_old);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   123
    cpci_new = _new_cp->invokedynamic_cp_cache_index(cpci_new);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   124
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   125
    int cpi_old = _old_cp->cache()->entry_at(cpci_old)->constant_pool_index();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   126
    int cpi_new = _new_cp->cache()->entry_at(cpci_new)->constant_pool_index();
53745
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   127
    int bsm_old = _old_cp->bootstrap_method_ref_index_at(cpi_old);
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   128
    int bsm_new = _new_cp->bootstrap_method_ref_index_at(cpi_new);
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   129
    if (!pool_constants_same(bsm_old, bsm_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   130
      return false;
53745
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   131
    int cnt_old = _old_cp->bootstrap_argument_count_at(cpi_old);
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   132
    int cnt_new = _new_cp->bootstrap_argument_count_at(cpi_new);
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   133
    if (cnt_old != cnt_new)
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   134
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   135
    for (int arg_i = 0; arg_i < cnt_old; arg_i++) {
53745
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   136
      int idx_old = _old_cp->bootstrap_argument_index_at(cpi_old, arg_i);
a535ba736cab 8218004: Clean up terminology for shared methods within the JVM for indy and condy support
lfoltan
parents: 49982
diff changeset
   137
      int idx_new = _new_cp->bootstrap_argument_index_at(cpi_new, arg_i);
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   138
      if (!pool_constants_same(idx_old, idx_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   139
        return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   140
    }
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   141
    break;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   142
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  case Bytecodes::_ldc   : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  case Bytecodes::_ldc_w : {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   146
    Bytecode_loadconstant ldc_old(_s_old->method(), _s_old->bci());
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   147
    Bytecode_loadconstant ldc_new(_s_new->method(), _s_new->bci());
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   148
    int cpi_old = ldc_old.pool_index();
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   149
    int cpi_new = ldc_new.pool_index();
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   150
    if (!pool_constants_same(cpi_old, cpi_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   151
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  case Bytecodes::_ldc2_w : {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   156
    u2 cpi_old = _s_old->get_index_u2();
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   157
    u2 cpi_new = _s_new->get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    constantTag tag_old = _old_cp->tag_at(cpi_old);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    constantTag tag_new = _new_cp->tag_at(cpi_new);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    if (tag_old.value() != tag_new.value())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    if (tag_old.is_long()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      if (_old_cp->long_at(cpi_old) != _new_cp->long_at(cpi_new))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    } else {
5697
0cf7190475ee 6957080: MethodComparator needs stress testing
jrose
parents: 5696
diff changeset
   166
      // Use jlong_cast to compare the bits rather than numerical values.
0cf7190475ee 6957080: MethodComparator needs stress testing
jrose
parents: 5696
diff changeset
   167
      // This makes a difference for NaN constants.
0cf7190475ee 6957080: MethodComparator needs stress testing
jrose
parents: 5696
diff changeset
   168
      if (jlong_cast(_old_cp->double_at(cpi_old)) != jlong_cast(_new_cp->double_at(cpi_new)))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  case Bytecodes::_bipush :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    if (_s_old->bcp()[1] != _s_new->bcp()[1])
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  case Bytecodes::_sipush    :
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   180
    if (_s_old->get_index_u2() != _s_new->get_index_u2())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  case Bytecodes::_aload  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  case Bytecodes::_astore : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  case Bytecodes::_dload  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  case Bytecodes::_dstore : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  case Bytecodes::_fload  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  case Bytecodes::_fstore : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  case Bytecodes::_iload  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  case Bytecodes::_istore : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  case Bytecodes::_lload  : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  case Bytecodes::_lstore : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  case Bytecodes::_ret    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    if (_s_old->is_wide() != _s_new->is_wide())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    if (_s_old->get_index() != _s_new->get_index())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  case Bytecodes::_goto      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  case Bytecodes::_if_acmpeq : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  case Bytecodes::_if_acmpne : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  case Bytecodes::_if_icmpeq : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  case Bytecodes::_if_icmpne : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  case Bytecodes::_if_icmplt : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  case Bytecodes::_if_icmpge : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  case Bytecodes::_if_icmpgt : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  case Bytecodes::_if_icmple : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  case Bytecodes::_ifeq      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  case Bytecodes::_ifne      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  case Bytecodes::_iflt      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  case Bytecodes::_ifge      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  case Bytecodes::_ifgt      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  case Bytecodes::_ifle      : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  case Bytecodes::_ifnonnull : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  case Bytecodes::_ifnull    : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  case Bytecodes::_jsr       : {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   219
    int old_ofs = _s_old->bytecode().get_offset_s2(c_old);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   220
    int new_ofs = _s_new->bytecode().get_offset_s2(c_new);
36092
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   221
    if (old_ofs != new_ofs)
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   222
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  case Bytecodes::_iinc :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    if (_s_old->is_wide() != _s_new->is_wide())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    if (! _s_old->is_wide()) {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   230
      // We could use get_index_u1 and get_constant_u1, but it's simpler to grab both bytes at once:
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   231
      if (Bytes::get_Java_u2(_s_old->bcp() + 1) != Bytes::get_Java_u2(_s_new->bcp() + 1))
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    } else {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 3261
diff changeset
   234
      // We could use get_index_u2 and get_constant_u2, but it's simpler to grab all four bytes at once:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  case Bytecodes::_goto_w : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  case Bytecodes::_jsr_w  : {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   242
    int old_ofs = _s_old->bytecode().get_offset_s4(c_old);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   243
    int new_ofs = _s_new->bytecode().get_offset_s4(c_new);
36092
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   244
    if (old_ofs != new_ofs)
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   245
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  case Bytecodes::_lookupswitch : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  case Bytecodes::_tableswitch  : {
36092
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   251
    int len_old = _s_old->instruction_size();
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   252
    int len_new = _s_new->instruction_size();
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   253
    if (len_old != len_new)
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   254
      return false;
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   255
    if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0)
b1bf903783b8 8149096: Remove unused code in methodComparator
stuefe
parents: 28741
diff changeset
   256
      return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 38259
diff changeset
   259
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 38259
diff changeset
   260
  default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 38259
diff changeset
   261
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   267
bool MethodComparator::pool_constants_same(int cpi_old, int cpi_new) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   268
  constantTag tag_old = _old_cp->tag_at(cpi_old);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   269
  constantTag tag_new = _new_cp->tag_at(cpi_new);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   270
  if (tag_old.is_int() || tag_old.is_float()) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   271
    if (tag_old.value() != tag_new.value())
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   272
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   273
    if (tag_old.is_int()) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   274
      if (_old_cp->int_at(cpi_old) != _new_cp->int_at(cpi_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   275
        return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   276
    } else {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   277
      // Use jint_cast to compare the bits rather than numerical values.
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   278
      // This makes a difference for NaN constants.
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   279
      if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new)))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   280
        return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   281
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   282
  } else if (tag_old.is_string() && tag_new.is_string()) {
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   283
    if (strcmp(_old_cp->string_at_noresolve(cpi_old),
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   284
               _new_cp->string_at_noresolve(cpi_new)) != 0)
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   285
      return false;
28741
1f10b1bd612d 8008678: JSR 292: constant pool reconstitution must support pseudo strings
sspitsyn
parents: 13728
diff changeset
   286
    if (_old_cp->is_pseudo_string_at(cpi_old) || _new_cp->is_pseudo_string_at(cpi_new))
1f10b1bd612d 8008678: JSR 292: constant pool reconstitution must support pseudo strings
sspitsyn
parents: 13728
diff changeset
   287
      return (_old_cp->is_pseudo_string_at(cpi_old) == _new_cp->is_pseudo_string_at(cpi_new));
7114
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   288
  } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   289
    // tag_old should be klass - 4881222
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   290
    if (! (tag_new.is_unresolved_klass() || tag_new.is_klass()))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   291
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   292
    if (_old_cp->klass_at_noresolve(cpi_old) !=
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   293
        _new_cp->klass_at_noresolve(cpi_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   294
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   295
  } else if (tag_old.is_method_type() && tag_new.is_method_type()) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   296
    int mti_old = _old_cp->method_type_index_at(cpi_old);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   297
    int mti_new = _new_cp->method_type_index_at(cpi_new);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   298
    if ((_old_cp->symbol_at(mti_old) != _new_cp->symbol_at(mti_new)))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   299
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   300
  } else if (tag_old.is_method_handle() && tag_new.is_method_handle()) {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   301
    if (_old_cp->method_handle_ref_kind_at(cpi_old) !=
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   302
        _new_cp->method_handle_ref_kind_at(cpi_new))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   303
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   304
    int mhi_old = _old_cp->method_handle_index_at(cpi_old);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   305
    int mhi_new = _new_cp->method_handle_index_at(cpi_new);
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   306
    if ((_old_cp->uncached_klass_ref_at_noresolve(mhi_old) != _new_cp->uncached_klass_ref_at_noresolve(mhi_new)) ||
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   307
        (_old_cp->uncached_name_ref_at(mhi_old) != _new_cp->uncached_name_ref_at(mhi_new)) ||
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   308
        (_old_cp->uncached_signature_ref_at(mhi_old) != _new_cp->uncached_signature_ref_at(mhi_new)))
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   309
      return false;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   310
  } else {
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   311
    return false;  // unknown tag
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   312
  }
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   313
  return true;
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   314
}
65d21c4c6337 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 5882
diff changeset
   315
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8076
diff changeset
   317
int MethodComparator::check_stack_and_locals_size(Method* old_method, Method* new_method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  if (old_method->max_stack() != new_method->max_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  } else if (old_method->max_locals() != new_method->max_locals()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    return 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    return 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  } else return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}