src/hotspot/share/ci/ciSignature.cpp
author coleenp
Tue, 14 May 2019 11:29:18 -0400
changeset 54847 59ea39bb2809
parent 49449 ef5d5d343e2a
permissions -rw-r--r--
8223657: Remove unused THREAD argument from SymbolTable functions Summary: also made lookup and lookup_only functions private to SymbolTable. External callers use new_symbol or probe. Reviewed-by: dholmes, gziemski
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 49449
diff changeset
     2
 * Copyright (c) 1999, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
13929
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    26
#include "ci/ciMethodType.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "ci/ciSignature.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    28
#include "ci/ciUtilities.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/allocation.inline.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 33593
diff changeset
    30
#include "memory/resourceArea.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "runtime/signature.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// ciSignature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// This class represents the signature of a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// ciSignature::ciSignature
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 24424
diff changeset
    40
ciSignature::ciSignature(ciKlass* accessing_klass, const constantPoolHandle& cpool, ciSymbol* symbol) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  ASSERT_IN_VM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  EXCEPTION_CONTEXT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  _accessing_klass = accessing_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  _symbol = symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  ciEnv* env = CURRENT_ENV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  Arena* arena = env->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  _types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  int size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  int count = 0;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    52
  ResourceMark rm(THREAD);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    53
  Symbol* sh = symbol->get_symbol();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  SignatureStream ss(sh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  for (; ; ss.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    // Process one element of the signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    ciType* type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    if (!ss.is_object()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      type = ciType::make(ss.type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    } else {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 49449
diff changeset
    61
      Symbol* name = ss.as_symbol();
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 49449
diff changeset
    62
      ciSymbol* klass_name = env->get_symbol(name);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 49449
diff changeset
    63
      type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    _types->append(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    if (ss.at_return_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      // Done processing the return type; do not add it into the count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    size += type->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  _size = size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  _count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// ------------------------------------------------------------------
13929
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    78
// ciSignature::ciSignature
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    79
ciSignature::ciSignature(ciKlass* accessing_klass, ciSymbol* symbol, ciMethodType* method_type) :
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    80
  _symbol(symbol),
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    81
  _accessing_klass(accessing_klass),
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    82
  _size( method_type->ptype_slot_count()),
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    83
  _count(method_type->ptype_count())
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    84
{
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    85
  ASSERT_IN_VM;
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    86
  EXCEPTION_CONTEXT;
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    87
  Arena* arena = CURRENT_ENV->arena();
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    88
  _types = new (arena) GrowableArray<ciType*>(arena, _count + 1, 0, NULL);
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    89
  for (int i = 0; i < _count; i++) {
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    90
    _types->append(method_type->ptype_at(i));
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    91
  }
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    92
  _types->append(method_type->rtype());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    93
}
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    94
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 10734
diff changeset
    95
// ------------------------------------------------------------------
10734
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
    96
// ciSignature::return_type
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
// What is the return type of this signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
ciType* ciSignature::return_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  return _types->at(_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// ------------------------------------------------------------------
10734
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   104
// ciSignature::type_at
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// What is the type of the index'th element of this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// signature?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
ciType* ciSignature::type_at(int index) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  assert(index < _count, "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // The first _klasses element holds the return klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  return _types->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// ------------------------------------------------------------------
10734
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   115
// ciSignature::equals
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   116
//
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   117
// Compare this signature to another one.  Signatures with different
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   118
// accessing classes but with signature-types resolved to the same
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   119
// types are defined to be equal.
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   120
bool ciSignature::equals(ciSignature* that) {
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   121
  // Compare signature
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   122
  if (!this->as_symbol()->equals(that->as_symbol()))  return false;
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   123
  // Compare all types of the arguments
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   124
  for (int i = 0; i < _count; i++) {
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   125
    if (this->type_at(i) != that->type_at(i))         return false;
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   126
  }
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   127
  // Compare the return type
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   128
  if (this->return_type() != that->return_type())     return false;
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   129
  return true;
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   130
}
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   131
065435337883 7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents: 10008
diff changeset
   132
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// ciSignature::print_signature
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
void ciSignature::print_signature() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  _symbol->print_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// ciSignature::print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
void ciSignature::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  tty->print("<ciSignature symbol=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  print_signature();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
 tty->print(" accessing_klass=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  _accessing_klass->print();
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 13929
diff changeset
   145
  tty->print(" address=" INTPTR_FORMAT ">", p2i((address)this));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
}