author | redestad |
Wed, 20 Feb 2019 09:53:28 +0100 | |
changeset 53838 | c8c9bd65c198 |
parent 49449 | ef5d5d343e2a |
child 54847 | 59ea39bb2809 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
37248 | 2 |
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
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 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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 | 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 | 29 |
#include "memory/allocation.inline.hpp" |
37248 | 30 |
#include "memory/resourceArea.hpp" |
7397 | 31 |
#include "oops/oop.inline.hpp" |
32 |
#include "runtime/signature.hpp" |
|
1 | 33 |
|
34 |
// ciSignature |
|
35 |
// |
|
36 |
// This class represents the signature of a method. |
|
37 |
||
38 |
// ------------------------------------------------------------------ |
|
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 | 41 |
ASSERT_IN_VM; |
42 |
EXCEPTION_CONTEXT; |
|
43 |
_accessing_klass = accessing_klass; |
|
44 |
_symbol = symbol; |
|
45 |
||
46 |
ciEnv* env = CURRENT_ENV; |
|
47 |
Arena* arena = env->arena(); |
|
48 |
_types = new (arena) GrowableArray<ciType*>(arena, 8, 0, NULL); |
|
49 |
||
50 |
int size = 0; |
|
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 | 54 |
SignatureStream ss(sh); |
55 |
for (; ; ss.next()) { |
|
56 |
// Process one element of the signature |
|
57 |
ciType* type; |
|
58 |
if (!ss.is_object()) { |
|
59 |
type = ciType::make(ss.type()); |
|
60 |
} else { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
61 |
Symbol* name = ss.as_symbol(THREAD); |
1 | 62 |
if (HAS_PENDING_EXCEPTION) { |
63 |
type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass() |
|
64 |
: (ciType*)ciEnv::unloaded_ciinstance_klass(); |
|
65 |
env->record_out_of_memory_failure(); |
|
66 |
CLEAR_PENDING_EXCEPTION; |
|
67 |
} else { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
68 |
ciSymbol* klass_name = env->get_symbol(name); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
8921
diff
changeset
|
69 |
type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false); |
1 | 70 |
} |
71 |
} |
|
72 |
_types->append(type); |
|
73 |
if (ss.at_return_type()) { |
|
74 |
// Done processing the return type; do not add it into the count. |
|
75 |
break; |
|
76 |
} |
|
77 |
size += type->size(); |
|
78 |
count++; |
|
79 |
} |
|
80 |
_size = size; |
|
81 |
_count = count; |
|
82 |
} |
|
83 |
||
84 |
// ------------------------------------------------------------------ |
|
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
|
85 |
// 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
|
86 |
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
|
87 |
_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
|
88 |
_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
|
89 |
_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
|
90 |
_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
|
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 |
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
|
93 |
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
|
94 |
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
|
95 |
_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
|
96 |
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
|
97 |
_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
|
98 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
10734
diff
changeset
|
99 |
_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
|
100 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
10734
diff
changeset
|
101 |
|
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
10734
diff
changeset
|
102 |
// ------------------------------------------------------------------ |
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
|
103 |
// ciSignature::return_type |
1 | 104 |
// |
105 |
// What is the return type of this signature? |
|
106 |
ciType* ciSignature::return_type() const { |
|
107 |
return _types->at(_count); |
|
108 |
} |
|
109 |
||
110 |
// ------------------------------------------------------------------ |
|
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
|
111 |
// ciSignature::type_at |
1 | 112 |
// |
113 |
// What is the type of the index'th element of this |
|
114 |
// signature? |
|
115 |
ciType* ciSignature::type_at(int index) const { |
|
116 |
assert(index < _count, "out of bounds"); |
|
117 |
// The first _klasses element holds the return klass. |
|
118 |
return _types->at(index); |
|
119 |
} |
|
120 |
||
121 |
// ------------------------------------------------------------------ |
|
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
|
122 |
// 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
|
123 |
// |
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 |
// 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
|
125 |
// 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
|
126 |
// 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
|
127 |
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
|
128 |
// 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
|
129 |
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
|
130 |
// 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
|
131 |
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
|
132 |
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
|
133 |
} |
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10008
diff
changeset
|
134 |
// 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
|
135 |
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
|
136 |
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
|
137 |
} |
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10008
diff
changeset
|
138 |
|
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10008
diff
changeset
|
139 |
// ------------------------------------------------------------------ |
1 | 140 |
// ciSignature::print_signature |
141 |
void ciSignature::print_signature() { |
|
142 |
_symbol->print_symbol(); |
|
143 |
} |
|
144 |
||
145 |
// ------------------------------------------------------------------ |
|
146 |
// ciSignature::print |
|
147 |
void ciSignature::print() { |
|
148 |
tty->print("<ciSignature symbol="); |
|
149 |
print_signature(); |
|
150 |
tty->print(" accessing_klass="); |
|
151 |
_accessing_klass->print(); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13929
diff
changeset
|
152 |
tty->print(" address=" INTPTR_FORMAT ">", p2i((address)this)); |
1 | 153 |
} |