author | psandoz |
Tue, 10 Feb 2015 21:32:05 +0100 | |
changeset 28954 | 7dda6c26cc98 |
parent 28719 | 5a9aedf87213 |
child 28957 | 75ca61f0b7c7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
28719 | 2 |
* Copyright (c) 1999, 2015, 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:
5426
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5426
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:
5426
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24953
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "classfile/systemDictionary.hpp" |
28 |
#include "classfile/vmSymbols.hpp" |
|
8872
36680c58660e
7022998: JSR 292 recursive method handle calls inline themselves infinitely
twisti
parents:
8734
diff
changeset
|
29 |
#include "compiler/compileBroker.hpp" |
7397 | 30 |
#include "compiler/compileLog.hpp" |
31 |
#include "oops/objArrayKlass.hpp" |
|
32 |
#include "opto/addnode.hpp" |
|
33 |
#include "opto/callGenerator.hpp" |
|
23528 | 34 |
#include "opto/castnode.hpp" |
7397 | 35 |
#include "opto/cfgnode.hpp" |
23528 | 36 |
#include "opto/convertnode.hpp" |
37 |
#include "opto/countbitsnode.hpp" |
|
38 |
#include "opto/intrinsicnode.hpp" |
|
7397 | 39 |
#include "opto/idealKit.hpp" |
20289 | 40 |
#include "opto/mathexactnode.hpp" |
23528 | 41 |
#include "opto/movenode.hpp" |
7397 | 42 |
#include "opto/mulnode.hpp" |
23528 | 43 |
#include "opto/narrowptrnode.hpp" |
7397 | 44 |
#include "opto/parse.hpp" |
45 |
#include "opto/runtime.hpp" |
|
46 |
#include "opto/subnode.hpp" |
|
47 |
#include "prims/nativeLookup.hpp" |
|
48 |
#include "runtime/sharedRuntime.hpp" |
|
18025 | 49 |
#include "trace/traceMacros.hpp" |
1 | 50 |
|
51 |
class LibraryIntrinsic : public InlineCallGenerator { |
|
52 |
// Extend the set of intrinsics known to the runtime: |
|
53 |
public: |
|
54 |
private: |
|
55 |
bool _is_virtual; |
|
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
56 |
bool _does_virtual_dispatch; |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
57 |
int8_t _predicates_count; // Intrinsic is predicated by several conditions |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
58 |
int8_t _last_predicate; // Last generated predicate |
1 | 59 |
vmIntrinsics::ID _intrinsic_id; |
60 |
||
61 |
public: |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
62 |
LibraryIntrinsic(ciMethod* m, bool is_virtual, int predicates_count, bool does_virtual_dispatch, vmIntrinsics::ID id) |
1 | 63 |
: InlineCallGenerator(m), |
64 |
_is_virtual(is_virtual), |
|
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
65 |
_does_virtual_dispatch(does_virtual_dispatch), |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
66 |
_predicates_count((int8_t)predicates_count), |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
67 |
_last_predicate((int8_t)-1), |
1 | 68 |
_intrinsic_id(id) |
69 |
{ |
|
70 |
} |
|
71 |
virtual bool is_intrinsic() const { return true; } |
|
72 |
virtual bool is_virtual() const { return _is_virtual; } |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
73 |
virtual bool is_predicated() const { return _predicates_count > 0; } |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
74 |
virtual int predicates_count() const { return _predicates_count; } |
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
75 |
virtual bool does_virtual_dispatch() const { return _does_virtual_dispatch; } |
24946
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24945
diff
changeset
|
76 |
virtual JVMState* generate(JVMState* jvms); |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
77 |
virtual Node* generate_predicate(JVMState* jvms, int predicate); |
1 | 78 |
vmIntrinsics::ID intrinsic_id() const { return _intrinsic_id; } |
79 |
}; |
|
80 |
||
81 |
||
82 |
// Local helper class for LibraryIntrinsic: |
|
83 |
class LibraryCallKit : public GraphKit { |
|
84 |
private: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
85 |
LibraryIntrinsic* _intrinsic; // the library intrinsic being called |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
86 |
Node* _result; // the result node, if any |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
87 |
int _reexecute_sp; // the stack pointer when bytecode needs to be reexecuted |
1 | 88 |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
89 |
const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr = false); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
90 |
|
1 | 91 |
public: |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
92 |
LibraryCallKit(JVMState* jvms, LibraryIntrinsic* intrinsic) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
93 |
: GraphKit(jvms), |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
94 |
_intrinsic(intrinsic), |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
95 |
_result(NULL) |
1 | 96 |
{ |
14627
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
97 |
// Check if this is a root compile. In that case we don't have a caller. |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
98 |
if (!jvms->has_method()) { |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
99 |
_reexecute_sp = sp(); |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
100 |
} else { |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
101 |
// Find out how many arguments the interpreter needs when deoptimizing |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
102 |
// and save the stack pointer value so it can used by uncommon_trap. |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
103 |
// We find the argument count by looking at the declared signature. |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
104 |
bool ignored_will_link; |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
105 |
ciSignature* declared_signature = NULL; |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
106 |
ciMethod* ignored_callee = caller()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
107 |
const int nargs = declared_signature->arg_size_for_bc(caller()->java_code_at_bci(bci())); |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
108 |
_reexecute_sp = sp() + nargs; // "push" arguments back on stack |
e377574462e9
8004319: test/gc/7168848/HumongousAlloc.java fails after 7172640
twisti
parents:
14621
diff
changeset
|
109 |
} |
1 | 110 |
} |
111 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
112 |
virtual LibraryCallKit* is_LibraryCallKit() const { return (LibraryCallKit*)this; } |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
113 |
|
1 | 114 |
ciMethod* caller() const { return jvms()->method(); } |
115 |
int bci() const { return jvms()->bci(); } |
|
116 |
LibraryIntrinsic* intrinsic() const { return _intrinsic; } |
|
117 |
vmIntrinsics::ID intrinsic_id() const { return _intrinsic->intrinsic_id(); } |
|
118 |
ciMethod* callee() const { return _intrinsic->method(); } |
|
119 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
120 |
bool try_to_inline(int predicate); |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
121 |
Node* try_to_predicate(int predicate); |
1 | 122 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
123 |
void push_result() { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
124 |
// Push the result onto the stack. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
125 |
if (!stopped() && result() != NULL) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
126 |
BasicType bt = result()->bottom_type()->basic_type(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
127 |
push_node(bt, result()); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
128 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
129 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
130 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
131 |
private: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
132 |
void fatal_unexpected_iid(vmIntrinsics::ID iid) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
133 |
fatal(err_msg_res("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid))); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
134 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
135 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
136 |
void set_result(Node* n) { assert(_result == NULL, "only set once"); _result = n; } |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
137 |
void set_result(RegionNode* region, PhiNode* value); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
138 |
Node* result() { return _result; } |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
139 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
140 |
virtual int reexecute_sp() { return _reexecute_sp; } |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
141 |
|
1 | 142 |
// Helper functions to inline natives |
143 |
Node* generate_guard(Node* test, RegionNode* region, float true_prob); |
|
144 |
Node* generate_slow_guard(Node* test, RegionNode* region); |
|
145 |
Node* generate_fair_guard(Node* test, RegionNode* region); |
|
146 |
Node* generate_negative_guard(Node* index, RegionNode* region, |
|
147 |
// resulting CastII of index: |
|
148 |
Node* *pos_index = NULL); |
|
149 |
Node* generate_limit_guard(Node* offset, Node* subseq_length, |
|
150 |
Node* array_length, |
|
151 |
RegionNode* region); |
|
152 |
Node* generate_current_thread(Node* &tls_output); |
|
153 |
Node* load_mirror_from_klass(Node* klass); |
|
154 |
Node* load_klass_from_mirror_common(Node* mirror, bool never_see_null, |
|
155 |
RegionNode* region, int null_path, |
|
156 |
int offset); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
157 |
Node* load_klass_from_mirror(Node* mirror, bool never_see_null, |
1 | 158 |
RegionNode* region, int null_path) { |
159 |
int offset = java_lang_Class::klass_offset_in_bytes(); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
160 |
return load_klass_from_mirror_common(mirror, never_see_null, |
1 | 161 |
region, null_path, |
162 |
offset); |
|
163 |
} |
|
164 |
Node* load_array_klass_from_mirror(Node* mirror, bool never_see_null, |
|
165 |
RegionNode* region, int null_path) { |
|
166 |
int offset = java_lang_Class::array_klass_offset_in_bytes(); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
167 |
return load_klass_from_mirror_common(mirror, never_see_null, |
1 | 168 |
region, null_path, |
169 |
offset); |
|
170 |
} |
|
171 |
Node* generate_access_flags_guard(Node* kls, |
|
172 |
int modifier_mask, int modifier_bits, |
|
173 |
RegionNode* region); |
|
174 |
Node* generate_interface_guard(Node* kls, RegionNode* region); |
|
175 |
Node* generate_array_guard(Node* kls, RegionNode* region) { |
|
176 |
return generate_array_guard_common(kls, region, false, false); |
|
177 |
} |
|
178 |
Node* generate_non_array_guard(Node* kls, RegionNode* region) { |
|
179 |
return generate_array_guard_common(kls, region, false, true); |
|
180 |
} |
|
181 |
Node* generate_objArray_guard(Node* kls, RegionNode* region) { |
|
182 |
return generate_array_guard_common(kls, region, true, false); |
|
183 |
} |
|
184 |
Node* generate_non_objArray_guard(Node* kls, RegionNode* region) { |
|
185 |
return generate_array_guard_common(kls, region, true, true); |
|
186 |
} |
|
187 |
Node* generate_array_guard_common(Node* kls, RegionNode* region, |
|
188 |
bool obj_array, bool not_array); |
|
189 |
Node* generate_virtual_guard(Node* obj_klass, RegionNode* slow_region); |
|
190 |
CallJavaNode* generate_method_call(vmIntrinsics::ID method_id, |
|
191 |
bool is_virtual = false, bool is_static = false); |
|
192 |
CallJavaNode* generate_method_call_static(vmIntrinsics::ID method_id) { |
|
193 |
return generate_method_call(method_id, false, true); |
|
194 |
} |
|
195 |
CallJavaNode* generate_method_call_virtual(vmIntrinsics::ID method_id) { |
|
196 |
return generate_method_call(method_id, true, false); |
|
197 |
} |
|
14132 | 198 |
Node * load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, bool is_exact, bool is_static); |
1 | 199 |
|
12623 | 200 |
Node* make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2); |
201 |
Node* make_string_method_node(int opcode, Node* str1, Node* str2); |
|
1 | 202 |
bool inline_string_compareTo(); |
203 |
bool inline_string_indexOf(); |
|
204 |
Node* string_indexOf(Node* string_object, ciTypeArray* target_array, jint offset, jint cache_i, jint md2_i); |
|
2348 | 205 |
bool inline_string_equals(); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
206 |
Node* round_double_node(Node* n); |
1 | 207 |
bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName); |
208 |
bool inline_math_native(vmIntrinsics::ID id); |
|
209 |
bool inline_trig(vmIntrinsics::ID id); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
210 |
bool inline_math(vmIntrinsics::ID id); |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
211 |
template <typename OverflowOp> |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
212 |
bool inline_math_overflow(Node* arg1, Node* arg2); |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
213 |
void inline_math_mathExact(Node* math, Node* test); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
214 |
bool inline_math_addExactI(bool is_increment); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
215 |
bool inline_math_addExactL(bool is_increment); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
216 |
bool inline_math_multiplyExactI(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
217 |
bool inline_math_multiplyExactL(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
218 |
bool inline_math_negateExactI(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
219 |
bool inline_math_negateExactL(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
220 |
bool inline_math_subtractExactI(bool is_decrement); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
221 |
bool inline_math_subtractExactL(bool is_decrement); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
222 |
bool inline_exp(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
223 |
bool inline_pow(); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
224 |
Node* finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); |
1 | 225 |
bool inline_min_max(vmIntrinsics::ID id); |
226 |
Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); |
|
227 |
// This returns Type::AnyPtr, RawPtr, or OopPtr. |
|
228 |
int classify_unsafe_addr(Node* &base, Node* &offset); |
|
229 |
Node* make_unsafe_address(Node* base, Node* offset); |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
230 |
// Helper for inline_unsafe_access. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
231 |
// Generates the guards that check whether the result of |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
232 |
// Unsafe.getObject should be recorded in an SATB log buffer. |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
233 |
void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar); |
1 | 234 |
bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile); |
19337 | 235 |
static bool klass_needs_init_guard(Node* kls); |
1 | 236 |
bool inline_unsafe_allocate(); |
237 |
bool inline_unsafe_copyMemory(); |
|
238 |
bool inline_native_currentThread(); |
|
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
239 |
#ifdef TRACE_HAVE_INTRINSICS |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
240 |
bool inline_native_classID(); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
241 |
bool inline_native_threadID(); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
242 |
#endif |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
243 |
bool inline_native_time_funcs(address method, const char* funcName); |
1 | 244 |
bool inline_native_isInterrupted(); |
245 |
bool inline_native_Class_query(vmIntrinsics::ID id); |
|
246 |
bool inline_native_subtype_check(); |
|
247 |
||
248 |
bool inline_native_newArray(); |
|
249 |
bool inline_native_getLength(); |
|
250 |
bool inline_array_copyOf(bool is_copyOfRange); |
|
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
251 |
bool inline_array_equals(); |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
252 |
void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark); |
1 | 253 |
bool inline_native_clone(bool is_virtual); |
254 |
bool inline_native_Reflection_getCallerClass(); |
|
255 |
// Helper function for inlining native object hash method |
|
256 |
bool inline_native_hashcode(bool is_virtual, bool is_static); |
|
257 |
bool inline_native_getClass(); |
|
258 |
||
259 |
// Helper functions for inlining arraycopy |
|
260 |
bool inline_arraycopy(); |
|
261 |
AllocateArrayNode* tightly_coupled_allocation(Node* ptr, |
|
262 |
RegionNode* slow_region); |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
263 |
typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
264 |
bool inline_unsafe_load_store(BasicType type, LoadStoreKind kind); |
1 | 265 |
bool inline_unsafe_ordered_store(BasicType type); |
14832 | 266 |
bool inline_unsafe_fence(vmIntrinsics::ID id); |
1 | 267 |
bool inline_fp_conversions(vmIntrinsics::ID id); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
268 |
bool inline_number_methods(vmIntrinsics::ID id); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
269 |
bool inline_reference_get(); |
27450
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
270 |
bool inline_Class_cast(); |
14132 | 271 |
bool inline_aescrypt_Block(vmIntrinsics::ID id); |
272 |
bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); |
|
273 |
Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); |
|
274 |
Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); |
|
22505 | 275 |
Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object); |
24953
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
276 |
bool inline_sha_implCompress(vmIntrinsics::ID id); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
277 |
bool inline_digestBase_implCompressMB(int predicate); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
278 |
bool inline_sha_implCompressMB(Node* digestBaseObj, ciInstanceKlass* instklass_SHA, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
279 |
bool long_state, address stubAddr, const char *stubName, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
280 |
Node* src_start, Node* ofs, Node* limit); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
281 |
Node* get_state_from_sha_object(Node *sha_object); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
282 |
Node* get_state_from_sha5_object(Node *sha_object); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
283 |
Node* inline_digestBase_implCompressMB_predicate(int predicate); |
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
284 |
bool inline_encodeISOArray(); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
285 |
bool inline_updateCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
286 |
bool inline_updateBytesCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
287 |
bool inline_updateByteBufferCRC32(); |
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
288 |
bool inline_multiplyToLen(); |
1 | 289 |
}; |
290 |
||
291 |
||
292 |
//---------------------------make_vm_intrinsic---------------------------- |
|
293 |
CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { |
|
294 |
vmIntrinsics::ID id = m->intrinsic_id(); |
|
295 |
assert(id != vmIntrinsics::_none, "must be a VM intrinsic"); |
|
296 |
||
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
297 |
ccstr disable_intr = NULL; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
298 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
299 |
if ((DisableIntrinsic[0] != '\0' |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
300 |
&& strstr(DisableIntrinsic, vmIntrinsics::name_at(id)) != NULL) || |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
301 |
(method_has_option_value("DisableIntrinsic", disable_intr) |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
302 |
&& strstr(disable_intr, vmIntrinsics::name_at(id)) != NULL)) { |
1 | 303 |
// disabled by a user request on the command line: |
304 |
// example: -XX:DisableIntrinsic=_hashCode,_getClass |
|
305 |
return NULL; |
|
306 |
} |
|
307 |
||
308 |
if (!m->is_loaded()) { |
|
309 |
// do not attempt to inline unloaded methods |
|
310 |
return NULL; |
|
311 |
} |
|
312 |
||
313 |
// Only a few intrinsics implement a virtual dispatch. |
|
314 |
// They are expensive calls which are also frequently overridden. |
|
315 |
if (is_virtual) { |
|
316 |
switch (id) { |
|
317 |
case vmIntrinsics::_hashCode: |
|
318 |
case vmIntrinsics::_clone: |
|
319 |
// OK, Object.hashCode and Object.clone intrinsics come in both flavors |
|
320 |
break; |
|
321 |
default: |
|
322 |
return NULL; |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
// -XX:-InlineNatives disables nearly all intrinsics: |
|
327 |
if (!InlineNatives) { |
|
328 |
switch (id) { |
|
329 |
case vmIntrinsics::_indexOf: |
|
330 |
case vmIntrinsics::_compareTo: |
|
2348 | 331 |
case vmIntrinsics::_equals: |
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
332 |
case vmIntrinsics::_equalsC: |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
333 |
case vmIntrinsics::_getAndAddInt: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
334 |
case vmIntrinsics::_getAndAddLong: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
335 |
case vmIntrinsics::_getAndSetInt: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
336 |
case vmIntrinsics::_getAndSetLong: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
337 |
case vmIntrinsics::_getAndSetObject: |
14832 | 338 |
case vmIntrinsics::_loadFence: |
339 |
case vmIntrinsics::_storeFence: |
|
340 |
case vmIntrinsics::_fullFence: |
|
1 | 341 |
break; // InlineNatives does not control String.compareTo |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
342 |
case vmIntrinsics::_Reference_get: |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
343 |
break; // InlineNatives does not control Reference.get |
1 | 344 |
default: |
345 |
return NULL; |
|
346 |
} |
|
347 |
} |
|
348 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
349 |
int predicates = 0; |
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
350 |
bool does_virtual_dispatch = false; |
14132 | 351 |
|
1 | 352 |
switch (id) { |
353 |
case vmIntrinsics::_compareTo: |
|
354 |
if (!SpecialStringCompareTo) return NULL; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
355 |
if (!Matcher::match_rule_supported(Op_StrComp)) return NULL; |
1 | 356 |
break; |
357 |
case vmIntrinsics::_indexOf: |
|
358 |
if (!SpecialStringIndexOf) return NULL; |
|
359 |
break; |
|
2348 | 360 |
case vmIntrinsics::_equals: |
361 |
if (!SpecialStringEquals) return NULL; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
362 |
if (!Matcher::match_rule_supported(Op_StrEquals)) return NULL; |
2348 | 363 |
break; |
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
364 |
case vmIntrinsics::_equalsC: |
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
365 |
if (!SpecialArraysEquals) return NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
366 |
if (!Matcher::match_rule_supported(Op_AryEq)) return NULL; |
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
367 |
break; |
1 | 368 |
case vmIntrinsics::_arraycopy: |
369 |
if (!InlineArrayCopy) return NULL; |
|
370 |
break; |
|
371 |
case vmIntrinsics::_copyMemory: |
|
372 |
if (StubRoutines::unsafe_arraycopy() == NULL) return NULL; |
|
373 |
if (!InlineArrayCopy) return NULL; |
|
374 |
break; |
|
375 |
case vmIntrinsics::_hashCode: |
|
376 |
if (!InlineObjectHash) return NULL; |
|
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
377 |
does_virtual_dispatch = true; |
1 | 378 |
break; |
379 |
case vmIntrinsics::_clone: |
|
20296
bc70e1c29125
8014447: Object.hashCode intrinsic breaks inline caches
shade
parents:
20289
diff
changeset
|
380 |
does_virtual_dispatch = true; |
1 | 381 |
case vmIntrinsics::_copyOf: |
382 |
case vmIntrinsics::_copyOfRange: |
|
383 |
if (!InlineObjectCopy) return NULL; |
|
384 |
// These also use the arraycopy intrinsic mechanism: |
|
385 |
if (!InlineArrayCopy) return NULL; |
|
386 |
break; |
|
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
387 |
case vmIntrinsics::_encodeISOArray: |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
388 |
if (!SpecialEncodeISOArray) return NULL; |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
389 |
if (!Matcher::match_rule_supported(Op_EncodeISOArray)) return NULL; |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
390 |
break; |
1 | 391 |
case vmIntrinsics::_checkIndex: |
392 |
// We do not intrinsify this. The optimizer does fine with it. |
|
393 |
return NULL; |
|
394 |
||
395 |
case vmIntrinsics::_getCallerClass: |
|
396 |
if (!InlineReflectionGetCallerClass) return NULL; |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
397 |
if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL; |
1 | 398 |
break; |
399 |
||
2255
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
400 |
case vmIntrinsics::_bitCount_i: |
12113
71f302d5c8ee
7152957: VM crashes with assert(false) failed: bad AD file
never
parents:
12107
diff
changeset
|
401 |
if (!Matcher::match_rule_supported(Op_PopCountI)) return NULL; |
12107
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
402 |
break; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
403 |
|
2255
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
404 |
case vmIntrinsics::_bitCount_l: |
12113
71f302d5c8ee
7152957: VM crashes with assert(false) failed: bad AD file
never
parents:
12107
diff
changeset
|
405 |
if (!Matcher::match_rule_supported(Op_PopCountL)) return NULL; |
12107
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
406 |
break; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
407 |
|
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
408 |
case vmIntrinsics::_numberOfLeadingZeros_i: |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
409 |
if (!Matcher::match_rule_supported(Op_CountLeadingZerosI)) return NULL; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
410 |
break; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
411 |
|
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
412 |
case vmIntrinsics::_numberOfLeadingZeros_l: |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
413 |
if (!Matcher::match_rule_supported(Op_CountLeadingZerosL)) return NULL; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
414 |
break; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
415 |
|
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
416 |
case vmIntrinsics::_numberOfTrailingZeros_i: |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
417 |
if (!Matcher::match_rule_supported(Op_CountTrailingZerosI)) return NULL; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
418 |
break; |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
419 |
|
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
420 |
case vmIntrinsics::_numberOfTrailingZeros_l: |
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
421 |
if (!Matcher::match_rule_supported(Op_CountTrailingZerosL)) return NULL; |
2255
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
422 |
break; |
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
423 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
424 |
case vmIntrinsics::_reverseBytes_c: |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
425 |
if (!Matcher::match_rule_supported(Op_ReverseBytesUS)) return NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
426 |
break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
427 |
case vmIntrinsics::_reverseBytes_s: |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
428 |
if (!Matcher::match_rule_supported(Op_ReverseBytesS)) return NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
429 |
break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
430 |
case vmIntrinsics::_reverseBytes_i: |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
431 |
if (!Matcher::match_rule_supported(Op_ReverseBytesI)) return NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
432 |
break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
433 |
case vmIntrinsics::_reverseBytes_l: |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
434 |
if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
435 |
break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
436 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
437 |
case vmIntrinsics::_Reference_get: |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
438 |
// Use the intrinsic version of Reference.get() so that the value in |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
439 |
// the referent field can be registered by the G1 pre-barrier code. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
440 |
// Also add memory barrier to prevent commoning reads from this field |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
441 |
// across safepoint since GC can change it value. |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
442 |
break; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
443 |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
444 |
case vmIntrinsics::_compareAndSwapObject: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
445 |
#ifdef _LP64 |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
446 |
if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapP)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
447 |
#endif |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
448 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
449 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
450 |
case vmIntrinsics::_compareAndSwapLong: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
451 |
if (!Matcher::match_rule_supported(Op_CompareAndSwapL)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
452 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
453 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
454 |
case vmIntrinsics::_getAndAddInt: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
455 |
if (!Matcher::match_rule_supported(Op_GetAndAddI)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
456 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
457 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
458 |
case vmIntrinsics::_getAndAddLong: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
459 |
if (!Matcher::match_rule_supported(Op_GetAndAddL)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
460 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
461 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
462 |
case vmIntrinsics::_getAndSetInt: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
463 |
if (!Matcher::match_rule_supported(Op_GetAndSetI)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
464 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
465 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
466 |
case vmIntrinsics::_getAndSetLong: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
467 |
if (!Matcher::match_rule_supported(Op_GetAndSetL)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
468 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
469 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
470 |
case vmIntrinsics::_getAndSetObject: |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
471 |
#ifdef _LP64 |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
472 |
if (!UseCompressedOops && !Matcher::match_rule_supported(Op_GetAndSetP)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
473 |
if (UseCompressedOops && !Matcher::match_rule_supported(Op_GetAndSetN)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
474 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
475 |
#else |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
476 |
if (!Matcher::match_rule_supported(Op_GetAndSetP)) return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
477 |
break; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
478 |
#endif |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
479 |
|
14132 | 480 |
case vmIntrinsics::_aescrypt_encryptBlock: |
481 |
case vmIntrinsics::_aescrypt_decryptBlock: |
|
482 |
if (!UseAESIntrinsics) return NULL; |
|
483 |
break; |
|
484 |
||
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
485 |
case vmIntrinsics::_multiplyToLen: |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
486 |
if (!UseMultiplyToLenIntrinsic) return NULL; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
487 |
break; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
488 |
|
14132 | 489 |
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
490 |
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
|
491 |
if (!UseAESIntrinsics) return NULL; |
|
492 |
// these two require the predicated logic |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
493 |
predicates = 1; |
14132 | 494 |
break; |
495 |
||
24953
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
496 |
case vmIntrinsics::_sha_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
497 |
if (!UseSHA1Intrinsics) return NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
498 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
499 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
500 |
case vmIntrinsics::_sha2_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
501 |
if (!UseSHA256Intrinsics) return NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
502 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
503 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
504 |
case vmIntrinsics::_sha5_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
505 |
if (!UseSHA512Intrinsics) return NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
506 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
507 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
508 |
case vmIntrinsics::_digestBase_implCompressMB: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
509 |
if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) return NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
510 |
predicates = 3; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
511 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
512 |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
513 |
case vmIntrinsics::_updateCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
514 |
case vmIntrinsics::_updateBytesCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
515 |
case vmIntrinsics::_updateByteBufferCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
516 |
if (!UseCRC32Intrinsics) return NULL; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
517 |
break; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
518 |
|
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
519 |
case vmIntrinsics::_incrementExactI: |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
520 |
case vmIntrinsics::_addExactI: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
521 |
if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
522 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
523 |
case vmIntrinsics::_incrementExactL: |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
524 |
case vmIntrinsics::_addExactL: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
525 |
if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
526 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
527 |
case vmIntrinsics::_decrementExactI: |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
528 |
case vmIntrinsics::_subtractExactI: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
529 |
if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
530 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
531 |
case vmIntrinsics::_decrementExactL: |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
532 |
case vmIntrinsics::_subtractExactL: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
533 |
if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
534 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
535 |
case vmIntrinsics::_negateExactI: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
536 |
if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
537 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
538 |
case vmIntrinsics::_negateExactL: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
539 |
if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
540 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
541 |
case vmIntrinsics::_multiplyExactI: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
542 |
if (!Matcher::match_rule_supported(Op_OverflowMulI) || !UseMathExactIntrinsics) return NULL; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
543 |
break; |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
544 |
case vmIntrinsics::_multiplyExactL: |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
545 |
if (!Matcher::match_rule_supported(Op_OverflowMulL) || !UseMathExactIntrinsics) return NULL; |
20289 | 546 |
break; |
547 |
||
1 | 548 |
default: |
3273
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
3268
diff
changeset
|
549 |
assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility"); |
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
3268
diff
changeset
|
550 |
assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?"); |
1 | 551 |
break; |
552 |
} |
|
553 |
||
554 |
// -XX:-InlineClassNatives disables natives from the Class class. |
|
555 |
// The flag applies to all reflective calls, notably Array.newArray |
|
556 |
// (visible to Java programmers as Array.newInstance). |
|
557 |
if (m->holder()->name() == ciSymbol::java_lang_Class() || |
|
558 |
m->holder()->name() == ciSymbol::java_lang_reflect_Array()) { |
|
559 |
if (!InlineClassNatives) return NULL; |
|
560 |
} |
|
561 |
||
562 |
// -XX:-InlineThreadNatives disables natives from the Thread class. |
|
563 |
if (m->holder()->name() == ciSymbol::java_lang_Thread()) { |
|
564 |
if (!InlineThreadNatives) return NULL; |
|
565 |
} |
|
566 |
||
567 |
// -XX:-InlineMathNatives disables natives from the Math,Float and Double classes. |
|
568 |
if (m->holder()->name() == ciSymbol::java_lang_Math() || |
|
569 |
m->holder()->name() == ciSymbol::java_lang_Float() || |
|
570 |
m->holder()->name() == ciSymbol::java_lang_Double()) { |
|
571 |
if (!InlineMathNatives) return NULL; |
|
572 |
} |
|
573 |
||
574 |
// -XX:-InlineUnsafeOps disables natives from the Unsafe class. |
|
575 |
if (m->holder()->name() == ciSymbol::sun_misc_Unsafe()) { |
|
576 |
if (!InlineUnsafeOps) return NULL; |
|
577 |
} |
|
578 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
579 |
return new LibraryIntrinsic(m, is_virtual, predicates, does_virtual_dispatch, (vmIntrinsics::ID) id); |
1 | 580 |
} |
581 |
||
582 |
//----------------------register_library_intrinsics----------------------- |
|
583 |
// Initialize this file's data structures, for each Compile instance. |
|
584 |
void Compile::register_library_intrinsics() { |
|
585 |
// Nothing to do here. |
|
586 |
} |
|
587 |
||
24946
24b68ccf3fc4
8026796: Make replace_in_map() on parent maps generic
roland
parents:
24945
diff
changeset
|
588 |
JVMState* LibraryIntrinsic::generate(JVMState* jvms) { |
1 | 589 |
LibraryCallKit kit(jvms, this); |
590 |
Compile* C = kit.C; |
|
591 |
int nodes = C->unique(); |
|
592 |
#ifndef PRODUCT |
|
20073 | 593 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
1 | 594 |
char buf[1000]; |
595 |
const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); |
|
596 |
tty->print_cr("Intrinsic %s", str); |
|
597 |
} |
|
598 |
#endif |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
599 |
ciMethod* callee = kit.callee(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
600 |
const int bci = kit.bci(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
601 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
602 |
// Try to inline the intrinsic. |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
603 |
if (kit.try_to_inline(_last_predicate)) { |
20073 | 604 |
if (C->print_intrinsics() || C->print_inlining()) { |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
605 |
C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); |
1 | 606 |
} |
607 |
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); |
|
608 |
if (C->log()) { |
|
609 |
C->log()->elem("intrinsic id='%s'%s nodes='%d'", |
|
610 |
vmIntrinsics::name_at(intrinsic_id()), |
|
611 |
(is_virtual() ? " virtual='1'" : ""), |
|
612 |
C->unique() - nodes); |
|
613 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
614 |
// Push the result from the inlined method onto the stack. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
615 |
kit.push_result(); |
23846
490ace57944d
8007988: PrintInlining output is inconsistent with incremental inlining
roland
parents:
23528
diff
changeset
|
616 |
C->print_inlining_update(this); |
1 | 617 |
return kit.transfer_exceptions_into_jvms(); |
618 |
} |
|
619 |
||
12107
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
620 |
// The intrinsic bailed out |
20073 | 621 |
if (C->print_intrinsics() || C->print_inlining()) { |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
622 |
if (jvms->has_method()) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
623 |
// Not a root compile. |
12107
0d67c9f2abf2
6658428: C2 doesn't inline java method if corresponding intrinsic failed to inline.
never
parents:
11732
diff
changeset
|
624 |
const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)"; |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
625 |
C->print_inlining(callee, jvms->depth() - 1, bci, msg); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
626 |
} else { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
627 |
// Root compile |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
628 |
tty->print("Did not generate intrinsic %s%s at bci:%d in", |
3273
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
3268
diff
changeset
|
629 |
vmIntrinsics::name_at(intrinsic_id()), |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
630 |
(is_virtual() ? " (virtual)" : ""), bci); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
631 |
} |
1 | 632 |
} |
633 |
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); |
|
23846
490ace57944d
8007988: PrintInlining output is inconsistent with incremental inlining
roland
parents:
23528
diff
changeset
|
634 |
C->print_inlining_update(this); |
1 | 635 |
return NULL; |
636 |
} |
|
637 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
638 |
Node* LibraryIntrinsic::generate_predicate(JVMState* jvms, int predicate) { |
14132 | 639 |
LibraryCallKit kit(jvms, this); |
640 |
Compile* C = kit.C; |
|
641 |
int nodes = C->unique(); |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
642 |
_last_predicate = predicate; |
14132 | 643 |
#ifndef PRODUCT |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
644 |
assert(is_predicated() && predicate < predicates_count(), "sanity"); |
20073 | 645 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
14132 | 646 |
char buf[1000]; |
647 |
const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); |
|
648 |
tty->print_cr("Predicate for intrinsic %s", str); |
|
649 |
} |
|
650 |
#endif |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
651 |
ciMethod* callee = kit.callee(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
652 |
const int bci = kit.bci(); |
14132 | 653 |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
654 |
Node* slow_ctl = kit.try_to_predicate(predicate); |
14132 | 655 |
if (!kit.failing()) { |
20073 | 656 |
if (C->print_intrinsics() || C->print_inlining()) { |
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
657 |
C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual, predicate)" : "(intrinsic, predicate)"); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
658 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
659 |
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); |
14132 | 660 |
if (C->log()) { |
661 |
C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'", |
|
662 |
vmIntrinsics::name_at(intrinsic_id()), |
|
663 |
(is_virtual() ? " virtual='1'" : ""), |
|
664 |
C->unique() - nodes); |
|
665 |
} |
|
666 |
return slow_ctl; // Could be NULL if the check folds. |
|
667 |
} |
|
668 |
||
669 |
// The intrinsic bailed out |
|
20073 | 670 |
if (C->print_intrinsics() || C->print_inlining()) { |
14132 | 671 |
if (jvms->has_method()) { |
672 |
// Not a root compile. |
|
673 |
const char* msg = "failed to generate predicate for intrinsic"; |
|
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
674 |
C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg); |
14132 | 675 |
} else { |
676 |
// Root compile |
|
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
677 |
C->print_inlining_stream()->print("Did not generate predicate for intrinsic %s%s at bci:%d in", |
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
678 |
vmIntrinsics::name_at(intrinsic_id()), |
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
679 |
(is_virtual() ? " (virtual)" : ""), bci); |
14132 | 680 |
} |
681 |
} |
|
682 |
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); |
|
683 |
return NULL; |
|
684 |
} |
|
685 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
686 |
bool LibraryCallKit::try_to_inline(int predicate) { |
1 | 687 |
// Handle symbolic names for otherwise undistinguished boolean switches: |
688 |
const bool is_store = true; |
|
689 |
const bool is_native_ptr = true; |
|
690 |
const bool is_static = true; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
691 |
const bool is_volatile = true; |
1 | 692 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
693 |
if (!jvms()->has_method()) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
694 |
// Root JVMState has a null method. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
695 |
assert(map()->memory()->Opcode() == Op_Parm, ""); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
696 |
// Insert the memory aliasing node |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
697 |
set_all_memory(reset_memory()); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
698 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
699 |
assert(merged_memory(), ""); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
700 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
701 |
|
1 | 702 |
switch (intrinsic_id()) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
703 |
case vmIntrinsics::_hashCode: return inline_native_hashcode(intrinsic()->is_virtual(), !is_static); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
704 |
case vmIntrinsics::_identityHashCode: return inline_native_hashcode(/*!virtual*/ false, is_static); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
705 |
case vmIntrinsics::_getClass: return inline_native_getClass(); |
1 | 706 |
|
707 |
case vmIntrinsics::_dsin: |
|
708 |
case vmIntrinsics::_dcos: |
|
709 |
case vmIntrinsics::_dtan: |
|
710 |
case vmIntrinsics::_dabs: |
|
711 |
case vmIntrinsics::_datan2: |
|
712 |
case vmIntrinsics::_dsqrt: |
|
713 |
case vmIntrinsics::_dexp: |
|
714 |
case vmIntrinsics::_dlog: |
|
715 |
case vmIntrinsics::_dlog10: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
716 |
case vmIntrinsics::_dpow: return inline_math_native(intrinsic_id()); |
1 | 717 |
|
718 |
case vmIntrinsics::_min: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
719 |
case vmIntrinsics::_max: return inline_min_max(intrinsic_id()); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
720 |
|
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
721 |
case vmIntrinsics::_addExactI: return inline_math_addExactI(false /* add */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
722 |
case vmIntrinsics::_addExactL: return inline_math_addExactL(false /* add */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
723 |
case vmIntrinsics::_decrementExactI: return inline_math_subtractExactI(true /* decrement */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
724 |
case vmIntrinsics::_decrementExactL: return inline_math_subtractExactL(true /* decrement */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
725 |
case vmIntrinsics::_incrementExactI: return inline_math_addExactI(true /* increment */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
726 |
case vmIntrinsics::_incrementExactL: return inline_math_addExactL(true /* increment */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
727 |
case vmIntrinsics::_multiplyExactI: return inline_math_multiplyExactI(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
728 |
case vmIntrinsics::_multiplyExactL: return inline_math_multiplyExactL(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
729 |
case vmIntrinsics::_negateExactI: return inline_math_negateExactI(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
730 |
case vmIntrinsics::_negateExactL: return inline_math_negateExactL(); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
731 |
case vmIntrinsics::_subtractExactI: return inline_math_subtractExactI(false /* subtract */); |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
732 |
case vmIntrinsics::_subtractExactL: return inline_math_subtractExactL(false /* subtract */); |
20289 | 733 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
734 |
case vmIntrinsics::_arraycopy: return inline_arraycopy(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
735 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
736 |
case vmIntrinsics::_compareTo: return inline_string_compareTo(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
737 |
case vmIntrinsics::_indexOf: return inline_string_indexOf(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
738 |
case vmIntrinsics::_equals: return inline_string_equals(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
739 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
740 |
case vmIntrinsics::_getObject: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
741 |
case vmIntrinsics::_getBoolean: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
742 |
case vmIntrinsics::_getByte: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
743 |
case vmIntrinsics::_getShort: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
744 |
case vmIntrinsics::_getChar: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
745 |
case vmIntrinsics::_getInt: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
746 |
case vmIntrinsics::_getLong: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
747 |
case vmIntrinsics::_getFloat: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
748 |
case vmIntrinsics::_getDouble: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
749 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
750 |
case vmIntrinsics::_putObject: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
751 |
case vmIntrinsics::_putBoolean: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
752 |
case vmIntrinsics::_putByte: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
753 |
case vmIntrinsics::_putShort: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
754 |
case vmIntrinsics::_putChar: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
755 |
case vmIntrinsics::_putInt: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
756 |
case vmIntrinsics::_putLong: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
757 |
case vmIntrinsics::_putFloat: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
758 |
case vmIntrinsics::_putDouble: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
759 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
760 |
case vmIntrinsics::_getByte_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_BYTE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
761 |
case vmIntrinsics::_getShort_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_SHORT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
762 |
case vmIntrinsics::_getChar_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_CHAR, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
763 |
case vmIntrinsics::_getInt_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_INT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
764 |
case vmIntrinsics::_getLong_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_LONG, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
765 |
case vmIntrinsics::_getFloat_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_FLOAT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
766 |
case vmIntrinsics::_getDouble_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_DOUBLE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
767 |
case vmIntrinsics::_getAddress_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_ADDRESS, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
768 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
769 |
case vmIntrinsics::_putByte_raw: return inline_unsafe_access( is_native_ptr, is_store, T_BYTE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
770 |
case vmIntrinsics::_putShort_raw: return inline_unsafe_access( is_native_ptr, is_store, T_SHORT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
771 |
case vmIntrinsics::_putChar_raw: return inline_unsafe_access( is_native_ptr, is_store, T_CHAR, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
772 |
case vmIntrinsics::_putInt_raw: return inline_unsafe_access( is_native_ptr, is_store, T_INT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
773 |
case vmIntrinsics::_putLong_raw: return inline_unsafe_access( is_native_ptr, is_store, T_LONG, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
774 |
case vmIntrinsics::_putFloat_raw: return inline_unsafe_access( is_native_ptr, is_store, T_FLOAT, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
775 |
case vmIntrinsics::_putDouble_raw: return inline_unsafe_access( is_native_ptr, is_store, T_DOUBLE, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
776 |
case vmIntrinsics::_putAddress_raw: return inline_unsafe_access( is_native_ptr, is_store, T_ADDRESS, !is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
777 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
778 |
case vmIntrinsics::_getObjectVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
779 |
case vmIntrinsics::_getBooleanVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
780 |
case vmIntrinsics::_getByteVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
781 |
case vmIntrinsics::_getShortVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
782 |
case vmIntrinsics::_getCharVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
783 |
case vmIntrinsics::_getIntVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
784 |
case vmIntrinsics::_getLongVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
785 |
case vmIntrinsics::_getFloatVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
786 |
case vmIntrinsics::_getDoubleVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
787 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
788 |
case vmIntrinsics::_putObjectVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
789 |
case vmIntrinsics::_putBooleanVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
790 |
case vmIntrinsics::_putByteVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
791 |
case vmIntrinsics::_putShortVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
792 |
case vmIntrinsics::_putCharVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
793 |
case vmIntrinsics::_putIntVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
794 |
case vmIntrinsics::_putLongVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
795 |
case vmIntrinsics::_putFloatVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
796 |
case vmIntrinsics::_putDoubleVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, is_volatile); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
797 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
798 |
case vmIntrinsics::_compareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmpxchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
799 |
case vmIntrinsics::_compareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmpxchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
800 |
case vmIntrinsics::_compareAndSwapLong: return inline_unsafe_load_store(T_LONG, LS_cmpxchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
801 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
802 |
case vmIntrinsics::_putOrderedObject: return inline_unsafe_ordered_store(T_OBJECT); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
803 |
case vmIntrinsics::_putOrderedInt: return inline_unsafe_ordered_store(T_INT); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
804 |
case vmIntrinsics::_putOrderedLong: return inline_unsafe_ordered_store(T_LONG); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
805 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
806 |
case vmIntrinsics::_getAndAddInt: return inline_unsafe_load_store(T_INT, LS_xadd); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
807 |
case vmIntrinsics::_getAndAddLong: return inline_unsafe_load_store(T_LONG, LS_xadd); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
808 |
case vmIntrinsics::_getAndSetInt: return inline_unsafe_load_store(T_INT, LS_xchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
809 |
case vmIntrinsics::_getAndSetLong: return inline_unsafe_load_store(T_LONG, LS_xchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
810 |
case vmIntrinsics::_getAndSetObject: return inline_unsafe_load_store(T_OBJECT, LS_xchg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
811 |
|
14832 | 812 |
case vmIntrinsics::_loadFence: |
813 |
case vmIntrinsics::_storeFence: |
|
814 |
case vmIntrinsics::_fullFence: return inline_unsafe_fence(intrinsic_id()); |
|
815 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
816 |
case vmIntrinsics::_currentThread: return inline_native_currentThread(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
817 |
case vmIntrinsics::_isInterrupted: return inline_native_isInterrupted(); |
1 | 818 |
|
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
819 |
#ifdef TRACE_HAVE_INTRINSICS |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
820 |
case vmIntrinsics::_classID: return inline_native_classID(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
821 |
case vmIntrinsics::_threadID: return inline_native_threadID(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
822 |
case vmIntrinsics::_counterTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime"); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
823 |
#endif |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
824 |
case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
825 |
case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
826 |
case vmIntrinsics::_allocateInstance: return inline_unsafe_allocate(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
827 |
case vmIntrinsics::_copyMemory: return inline_unsafe_copyMemory(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
828 |
case vmIntrinsics::_newArray: return inline_native_newArray(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
829 |
case vmIntrinsics::_getLength: return inline_native_getLength(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
830 |
case vmIntrinsics::_copyOf: return inline_array_copyOf(false); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
831 |
case vmIntrinsics::_copyOfRange: return inline_array_copyOf(true); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
832 |
case vmIntrinsics::_equalsC: return inline_array_equals(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
833 |
case vmIntrinsics::_clone: return inline_native_clone(intrinsic()->is_virtual()); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
834 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
835 |
case vmIntrinsics::_isAssignableFrom: return inline_native_subtype_check(); |
1 | 836 |
|
837 |
case vmIntrinsics::_isInstance: |
|
838 |
case vmIntrinsics::_getModifiers: |
|
839 |
case vmIntrinsics::_isInterface: |
|
840 |
case vmIntrinsics::_isArray: |
|
841 |
case vmIntrinsics::_isPrimitive: |
|
842 |
case vmIntrinsics::_getSuperclass: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
843 |
case vmIntrinsics::_getClassAccessFlags: return inline_native_Class_query(intrinsic_id()); |
1 | 844 |
|
845 |
case vmIntrinsics::_floatToRawIntBits: |
|
846 |
case vmIntrinsics::_floatToIntBits: |
|
847 |
case vmIntrinsics::_intBitsToFloat: |
|
848 |
case vmIntrinsics::_doubleToRawLongBits: |
|
849 |
case vmIntrinsics::_doubleToLongBits: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
850 |
case vmIntrinsics::_longBitsToDouble: return inline_fp_conversions(intrinsic_id()); |
1 | 851 |
|
2862
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
852 |
case vmIntrinsics::_numberOfLeadingZeros_i: |
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
853 |
case vmIntrinsics::_numberOfLeadingZeros_l: |
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
854 |
case vmIntrinsics::_numberOfTrailingZeros_i: |
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
855 |
case vmIntrinsics::_numberOfTrailingZeros_l: |
2255
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
856 |
case vmIntrinsics::_bitCount_i: |
54abdf3e1055
6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents:
2131
diff
changeset
|
857 |
case vmIntrinsics::_bitCount_l: |
1 | 858 |
case vmIntrinsics::_reverseBytes_i: |
859 |
case vmIntrinsics::_reverseBytes_l: |
|
5352
cee8f7acb7bc
6946040: add intrinsic for short and char reverseBytes
never
parents:
4581
diff
changeset
|
860 |
case vmIntrinsics::_reverseBytes_s: |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
861 |
case vmIntrinsics::_reverseBytes_c: return inline_number_methods(intrinsic_id()); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
862 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
863 |
case vmIntrinsics::_getCallerClass: return inline_native_Reflection_getCallerClass(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
864 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
865 |
case vmIntrinsics::_Reference_get: return inline_reference_get(); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
866 |
|
27450
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
867 |
case vmIntrinsics::_Class_cast: return inline_Class_cast(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
868 |
|
14132 | 869 |
case vmIntrinsics::_aescrypt_encryptBlock: |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
870 |
case vmIntrinsics::_aescrypt_decryptBlock: return inline_aescrypt_Block(intrinsic_id()); |
14132 | 871 |
|
872 |
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
|
873 |
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
|
874 |
return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); |
|
875 |
||
24953
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
876 |
case vmIntrinsics::_sha_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
877 |
case vmIntrinsics::_sha2_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
878 |
case vmIntrinsics::_sha5_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
879 |
return inline_sha_implCompress(intrinsic_id()); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
880 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
881 |
case vmIntrinsics::_digestBase_implCompressMB: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
882 |
return inline_digestBase_implCompressMB(predicate); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
883 |
|
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
884 |
case vmIntrinsics::_multiplyToLen: |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
885 |
return inline_multiplyToLen(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
886 |
|
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
887 |
case vmIntrinsics::_encodeISOArray: |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
888 |
return inline_encodeISOArray(); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
889 |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
890 |
case vmIntrinsics::_updateCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
891 |
return inline_updateCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
892 |
case vmIntrinsics::_updateBytesCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
893 |
return inline_updateBytesCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
894 |
case vmIntrinsics::_updateByteBufferCRC32: |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
895 |
return inline_updateByteBufferCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
896 |
|
1 | 897 |
default: |
898 |
// If you get here, it may be that someone has added a new intrinsic |
|
899 |
// to the list in vmSymbols.hpp without implementing it here. |
|
900 |
#ifndef PRODUCT |
|
901 |
if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) { |
|
902 |
tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)", |
|
903 |
vmIntrinsics::name_at(intrinsic_id()), intrinsic_id()); |
|
904 |
} |
|
905 |
#endif |
|
906 |
return false; |
|
907 |
} |
|
908 |
} |
|
909 |
||
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
910 |
Node* LibraryCallKit::try_to_predicate(int predicate) { |
14132 | 911 |
if (!jvms()->has_method()) { |
912 |
// Root JVMState has a null method. |
|
913 |
assert(map()->memory()->Opcode() == Op_Parm, ""); |
|
914 |
// Insert the memory aliasing node |
|
915 |
set_all_memory(reset_memory()); |
|
916 |
} |
|
917 |
assert(merged_memory(), ""); |
|
918 |
||
919 |
switch (intrinsic_id()) { |
|
920 |
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
|
921 |
return inline_cipherBlockChaining_AESCrypt_predicate(false); |
|
922 |
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
|
923 |
return inline_cipherBlockChaining_AESCrypt_predicate(true); |
|
24953
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
924 |
case vmIntrinsics::_digestBase_implCompressMB: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
925 |
return inline_digestBase_implCompressMB_predicate(predicate); |
14132 | 926 |
|
927 |
default: |
|
928 |
// If you get here, it may be that someone has added a new intrinsic |
|
929 |
// to the list in vmSymbols.hpp without implementing it here. |
|
930 |
#ifndef PRODUCT |
|
931 |
if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) { |
|
932 |
tty->print_cr("*** Warning: Unimplemented predicate for intrinsic %s(%d)", |
|
933 |
vmIntrinsics::name_at(intrinsic_id()), intrinsic_id()); |
|
934 |
} |
|
935 |
#endif |
|
936 |
Node* slow_ctl = control(); |
|
937 |
set_control(top()); // No fast path instrinsic |
|
938 |
return slow_ctl; |
|
939 |
} |
|
940 |
} |
|
941 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
942 |
//------------------------------set_result------------------------------- |
1 | 943 |
// Helper function for finishing intrinsics. |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
944 |
void LibraryCallKit::set_result(RegionNode* region, PhiNode* value) { |
1 | 945 |
record_for_igvn(region); |
946 |
set_control(_gvn.transform(region)); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
947 |
set_result( _gvn.transform(value)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
948 |
assert(value->type()->basic_type() == result()->bottom_type()->basic_type(), "sanity"); |
1 | 949 |
} |
950 |
||
951 |
//------------------------------generate_guard--------------------------- |
|
952 |
// Helper function for generating guarded fast-slow graph structures. |
|
953 |
// The given 'test', if true, guards a slow path. If the test fails |
|
954 |
// then a fast path can be taken. (We generally hope it fails.) |
|
955 |
// In all cases, GraphKit::control() is updated to the fast path. |
|
956 |
// The returned value represents the control for the slow path. |
|
957 |
// The return value is never 'top'; it is either a valid control |
|
958 |
// or NULL if it is obvious that the slow path can never be taken. |
|
959 |
// Also, if region and the slow control are not NULL, the slow edge |
|
960 |
// is appended to the region. |
|
961 |
Node* LibraryCallKit::generate_guard(Node* test, RegionNode* region, float true_prob) { |
|
962 |
if (stopped()) { |
|
963 |
// Already short circuited. |
|
964 |
return NULL; |
|
965 |
} |
|
966 |
||
967 |
// Build an if node and its projections. |
|
968 |
// If test is true we take the slow path, which we assume is uncommon. |
|
969 |
if (_gvn.type(test) == TypeInt::ZERO) { |
|
970 |
// The slow branch is never taken. No need to build this guard. |
|
971 |
return NULL; |
|
972 |
} |
|
973 |
||
974 |
IfNode* iff = create_and_map_if(control(), test, true_prob, COUNT_UNKNOWN); |
|
975 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
976 |
Node* if_slow = _gvn.transform(new IfTrueNode(iff)); |
1 | 977 |
if (if_slow == top()) { |
978 |
// The slow branch is never taken. No need to build this guard. |
|
979 |
return NULL; |
|
980 |
} |
|
981 |
||
982 |
if (region != NULL) |
|
983 |
region->add_req(if_slow); |
|
984 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
985 |
Node* if_fast = _gvn.transform(new IfFalseNode(iff)); |
1 | 986 |
set_control(if_fast); |
987 |
||
988 |
return if_slow; |
|
989 |
} |
|
990 |
||
991 |
inline Node* LibraryCallKit::generate_slow_guard(Node* test, RegionNode* region) { |
|
992 |
return generate_guard(test, region, PROB_UNLIKELY_MAG(3)); |
|
993 |
} |
|
994 |
inline Node* LibraryCallKit::generate_fair_guard(Node* test, RegionNode* region) { |
|
995 |
return generate_guard(test, region, PROB_FAIR); |
|
996 |
} |
|
997 |
||
998 |
inline Node* LibraryCallKit::generate_negative_guard(Node* index, RegionNode* region, |
|
999 |
Node* *pos_index) { |
|
1000 |
if (stopped()) |
|
1001 |
return NULL; // already stopped |
|
1002 |
if (_gvn.type(index)->higher_equal(TypeInt::POS)) // [0,maxint] |
|
1003 |
return NULL; // index is already adequately typed |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1004 |
Node* cmp_lt = _gvn.transform(new CmpINode(index, intcon(0))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1005 |
Node* bol_lt = _gvn.transform(new BoolNode(cmp_lt, BoolTest::lt)); |
1 | 1006 |
Node* is_neg = generate_guard(bol_lt, region, PROB_MIN); |
1007 |
if (is_neg != NULL && pos_index != NULL) { |
|
1008 |
// Emulate effect of Parse::adjust_map_after_if. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1009 |
Node* ccast = new CastIINode(index, TypeInt::POS); |
1 | 1010 |
ccast->set_req(0, control()); |
1011 |
(*pos_index) = _gvn.transform(ccast); |
|
1012 |
} |
|
1013 |
return is_neg; |
|
1014 |
} |
|
1015 |
||
1016 |
// Make sure that 'position' is a valid limit index, in [0..length]. |
|
1017 |
// There are two equivalent plans for checking this: |
|
1018 |
// A. (offset + copyLength) unsigned<= arrayLength |
|
1019 |
// B. offset <= (arrayLength - copyLength) |
|
1020 |
// We require that all of the values above, except for the sum and |
|
1021 |
// difference, are already known to be non-negative. |
|
1022 |
// Plan A is robust in the face of overflow, if offset and copyLength |
|
1023 |
// are both hugely positive. |
|
1024 |
// |
|
1025 |
// Plan B is less direct and intuitive, but it does not overflow at |
|
1026 |
// all, since the difference of two non-negatives is always |
|
1027 |
// representable. Whenever Java methods must perform the equivalent |
|
1028 |
// check they generally use Plan B instead of Plan A. |
|
1029 |
// For the moment we use Plan A. |
|
1030 |
inline Node* LibraryCallKit::generate_limit_guard(Node* offset, |
|
1031 |
Node* subseq_length, |
|
1032 |
Node* array_length, |
|
1033 |
RegionNode* region) { |
|
1034 |
if (stopped()) |
|
1035 |
return NULL; // already stopped |
|
1036 |
bool zero_offset = _gvn.type(offset) == TypeInt::ZERO; |
|
11446 | 1037 |
if (zero_offset && subseq_length->eqv_uncast(array_length)) |
1 | 1038 |
return NULL; // common case of whole-array copy |
1039 |
Node* last = subseq_length; |
|
1040 |
if (!zero_offset) // last += offset |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1041 |
last = _gvn.transform(new AddINode(last, offset)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1042 |
Node* cmp_lt = _gvn.transform(new CmpUNode(array_length, last)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1043 |
Node* bol_lt = _gvn.transform(new BoolNode(cmp_lt, BoolTest::lt)); |
1 | 1044 |
Node* is_over = generate_guard(bol_lt, region, PROB_MIN); |
1045 |
return is_over; |
|
1046 |
} |
|
1047 |
||
1048 |
||
1049 |
//--------------------------generate_current_thread-------------------- |
|
1050 |
Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { |
|
1051 |
ciKlass* thread_klass = env()->Thread_klass(); |
|
1052 |
const Type* thread_type = TypeOopPtr::make_from_klass(thread_klass)->cast_to_ptr_type(TypePtr::NotNull); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1053 |
Node* thread = _gvn.transform(new ThreadLocalNode()); |
1 | 1054 |
Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::threadObj_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
1055 |
Node* threadObj = make_load(NULL, p, thread_type, T_OBJECT, MemNode::unordered); |
1 | 1056 |
tls_output = thread; |
1057 |
return threadObj; |
|
1058 |
} |
|
1059 |
||
1060 |
||
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1061 |
//------------------------------make_string_method_node------------------------ |
12623 | 1062 |
// Helper method for String intrinsic functions. This version is called |
1063 |
// with str1 and str2 pointing to String object nodes. |
|
1064 |
// |
|
1065 |
Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1, Node* str2) { |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1066 |
Node* no_ctrl = NULL; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1067 |
|
12623 | 1068 |
// Get start addr of string |
1069 |
Node* str1_value = load_String_value(no_ctrl, str1); |
|
1070 |
Node* str1_offset = load_String_offset(no_ctrl, str1); |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1071 |
Node* str1_start = array_element_address(str1_value, str1_offset, T_CHAR); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1072 |
|
12623 | 1073 |
// Get length of string 1 |
1074 |
Node* str1_len = load_String_length(no_ctrl, str1); |
|
1075 |
||
1076 |
Node* str2_value = load_String_value(no_ctrl, str2); |
|
1077 |
Node* str2_offset = load_String_offset(no_ctrl, str2); |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1078 |
Node* str2_start = array_element_address(str2_value, str2_offset, T_CHAR); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1079 |
|
12623 | 1080 |
Node* str2_len = NULL; |
1081 |
Node* result = NULL; |
|
1082 |
||
1083 |
switch (opcode) { |
|
1084 |
case Op_StrIndexOf: |
|
1085 |
// Get length of string 2 |
|
1086 |
str2_len = load_String_length(no_ctrl, str2); |
|
1087 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1088 |
result = new StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1089 |
str1_start, str1_len, str2_start, str2_len); |
12623 | 1090 |
break; |
1091 |
case Op_StrComp: |
|
1092 |
// Get length of string 2 |
|
1093 |
str2_len = load_String_length(no_ctrl, str2); |
|
1094 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1095 |
result = new StrCompNode(control(), memory(TypeAryPtr::CHARS), |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1096 |
str1_start, str1_len, str2_start, str2_len); |
12623 | 1097 |
break; |
1098 |
case Op_StrEquals: |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1099 |
result = new StrEqualsNode(control(), memory(TypeAryPtr::CHARS), |
12623 | 1100 |
str1_start, str2_start, str1_len); |
1101 |
break; |
|
1102 |
default: |
|
1103 |
ShouldNotReachHere(); |
|
1104 |
return NULL; |
|
1105 |
} |
|
1106 |
||
1107 |
// All these intrinsics have checks. |
|
1108 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
1109 |
||
1110 |
return _gvn.transform(result); |
|
1111 |
} |
|
1112 |
||
1113 |
// Helper method for String intrinsic functions. This version is called |
|
1114 |
// with str1 and str2 pointing to char[] nodes, with cnt1 and cnt2 pointing |
|
1115 |
// to Int nodes containing the lenghts of str1 and str2. |
|
1116 |
// |
|
1117 |
Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2) { |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1118 |
Node* result = NULL; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1119 |
switch (opcode) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1120 |
case Op_StrIndexOf: |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1121 |
result = new StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1122 |
str1_start, cnt1, str2_start, cnt2); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1123 |
break; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1124 |
case Op_StrComp: |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1125 |
result = new StrCompNode(control(), memory(TypeAryPtr::CHARS), |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1126 |
str1_start, cnt1, str2_start, cnt2); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1127 |
break; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1128 |
case Op_StrEquals: |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1129 |
result = new StrEqualsNode(control(), memory(TypeAryPtr::CHARS), |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1130 |
str1_start, str2_start, cnt1); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1131 |
break; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1132 |
default: |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1133 |
ShouldNotReachHere(); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1134 |
return NULL; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1135 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1136 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1137 |
// All these intrinsics have checks. |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1138 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1139 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1140 |
return _gvn.transform(result); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1141 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1142 |
|
1 | 1143 |
//------------------------------inline_string_compareTo------------------------ |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1144 |
// public int java.lang.String.compareTo(String anotherString); |
1 | 1145 |
bool LibraryCallKit::inline_string_compareTo() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1146 |
Node* receiver = null_check(argument(0)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1147 |
Node* arg = null_check(argument(1)); |
1 | 1148 |
if (stopped()) { |
1149 |
return true; |
|
1150 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1151 |
set_result(make_string_method_node(Op_StrComp, receiver, arg)); |
1 | 1152 |
return true; |
1153 |
} |
|
1154 |
||
2348 | 1155 |
//------------------------------inline_string_equals------------------------ |
1156 |
bool LibraryCallKit::inline_string_equals() { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1157 |
Node* receiver = null_check_receiver(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1158 |
// NOTE: Do not null check argument for String.equals() because spec |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1159 |
// allows to specify NULL as argument. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1160 |
Node* argument = this->argument(1); |
2348 | 1161 |
if (stopped()) { |
1162 |
return true; |
|
1163 |
} |
|
1164 |
||
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1165 |
// paths (plus control) merge |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1166 |
RegionNode* region = new RegionNode(5); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1167 |
Node* phi = new PhiNode(region, TypeInt::BOOL); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1168 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1169 |
// does source == target string? |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1170 |
Node* cmp = _gvn.transform(new CmpPNode(receiver, argument)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1171 |
Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1172 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1173 |
Node* if_eq = generate_slow_guard(bol, NULL); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1174 |
if (if_eq != NULL) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1175 |
// receiver == argument |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1176 |
phi->init_req(2, intcon(1)); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1177 |
region->init_req(2, if_eq); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1178 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1179 |
|
2348 | 1180 |
// get String klass for instanceOf |
1181 |
ciInstanceKlass* klass = env()->String_klass(); |
|
1182 |
||
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1183 |
if (!stopped()) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1184 |
Node* inst = gen_instanceof(argument, makecon(TypeKlassPtr::make(klass))); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1185 |
Node* cmp = _gvn.transform(new CmpINode(inst, intcon(1))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1186 |
Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1187 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1188 |
Node* inst_false = generate_guard(bol, NULL, PROB_MIN); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1189 |
//instanceOf == true, fallthrough |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1190 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1191 |
if (inst_false != NULL) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1192 |
phi->init_req(3, intcon(0)); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1193 |
region->init_req(3, inst_false); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1194 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1195 |
} |
2348 | 1196 |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1197 |
if (!stopped()) { |
12623 | 1198 |
const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(klass); |
1199 |
||
5409
95cd788badb7
6951190: assert(!klass_is_exact(),"only non-exact klass") while building JDK
never
parents:
5352
diff
changeset
|
1200 |
// Properly cast the argument to String |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1201 |
argument = _gvn.transform(new CheckCastPPNode(control(), argument, string_type)); |
9438
287ac3395f02
7041100: The load in String.equals intrinsic executed before null check
kvn
parents:
9333
diff
changeset
|
1202 |
// This path is taken only when argument's type is String:NotNull. |
287ac3395f02
7041100: The load in String.equals intrinsic executed before null check
kvn
parents:
9333
diff
changeset
|
1203 |
argument = cast_not_null(argument, false); |
5409
95cd788badb7
6951190: assert(!klass_is_exact(),"only non-exact klass") while building JDK
never
parents:
5352
diff
changeset
|
1204 |
|
12623 | 1205 |
Node* no_ctrl = NULL; |
1206 |
||
1207 |
// Get start addr of receiver |
|
1208 |
Node* receiver_val = load_String_value(no_ctrl, receiver); |
|
1209 |
Node* receiver_offset = load_String_offset(no_ctrl, receiver); |
|
1210 |
Node* receiver_start = array_element_address(receiver_val, receiver_offset, T_CHAR); |
|
1211 |
||
1212 |
// Get length of receiver |
|
1213 |
Node* receiver_cnt = load_String_length(no_ctrl, receiver); |
|
1214 |
||
1215 |
// Get start addr of argument |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1216 |
Node* argument_val = load_String_value(no_ctrl, argument); |
12623 | 1217 |
Node* argument_offset = load_String_offset(no_ctrl, argument); |
1218 |
Node* argument_start = array_element_address(argument_val, argument_offset, T_CHAR); |
|
1219 |
||
1220 |
// Get length of argument |
|
1221 |
Node* argument_cnt = load_String_length(no_ctrl, argument); |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1222 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1223 |
// Check for receiver count != argument count |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1224 |
Node* cmp = _gvn.transform(new CmpINode(receiver_cnt, argument_cnt)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1225 |
Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1226 |
Node* if_ne = generate_slow_guard(bol, NULL); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1227 |
if (if_ne != NULL) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1228 |
phi->init_req(4, intcon(0)); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1229 |
region->init_req(4, if_ne); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1230 |
} |
12623 | 1231 |
|
1232 |
// Check for count == 0 is done by assembler code for StrEquals. |
|
1233 |
||
1234 |
if (!stopped()) { |
|
1235 |
Node* equals = make_string_method_node(Op_StrEquals, receiver_start, receiver_cnt, argument_start, argument_cnt); |
|
1236 |
phi->init_req(1, equals); |
|
1237 |
region->init_req(1, control()); |
|
1238 |
} |
|
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1239 |
} |
2348 | 1240 |
|
1241 |
// post merge |
|
1242 |
set_control(_gvn.transform(region)); |
|
1243 |
record_for_igvn(region); |
|
1244 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1245 |
set_result(_gvn.transform(phi)); |
2348 | 1246 |
return true; |
1247 |
} |
|
1248 |
||
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
1249 |
//------------------------------inline_array_equals---------------------------- |
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
1250 |
bool LibraryCallKit::inline_array_equals() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1251 |
Node* arg1 = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1252 |
Node* arg2 = argument(1); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1253 |
set_result(_gvn.transform(new AryEqNode(control(), memory(TypeAryPtr::CHARS), arg1, arg2))); |
595
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
1254 |
return true; |
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
1255 |
} |
a2be4c89de81
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
590
diff
changeset
|
1256 |
|
1 | 1257 |
// Java version of String.indexOf(constant string) |
1258 |
// class StringDecl { |
|
1259 |
// StringDecl(char[] ca) { |
|
1260 |
// offset = 0; |
|
1261 |
// count = ca.length; |
|
1262 |
// value = ca; |
|
1263 |
// } |
|
1264 |
// int offset; |
|
1265 |
// int count; |
|
1266 |
// char[] value; |
|
1267 |
// } |
|
1268 |
// |
|
1269 |
// static int string_indexOf_J(StringDecl string_object, char[] target_object, |
|
1270 |
// int targetOffset, int cache_i, int md2) { |
|
1271 |
// int cache = cache_i; |
|
1272 |
// int sourceOffset = string_object.offset; |
|
1273 |
// int sourceCount = string_object.count; |
|
1274 |
// int targetCount = target_object.length; |
|
1275 |
// |
|
1276 |
// int targetCountLess1 = targetCount - 1; |
|
1277 |
// int sourceEnd = sourceOffset + sourceCount - targetCountLess1; |
|
1278 |
// |
|
1279 |
// char[] source = string_object.value; |
|
1280 |
// char[] target = target_object; |
|
1281 |
// int lastChar = target[targetCountLess1]; |
|
1282 |
// |
|
1283 |
// outer_loop: |
|
1284 |
// for (int i = sourceOffset; i < sourceEnd; ) { |
|
1285 |
// int src = source[i + targetCountLess1]; |
|
1286 |
// if (src == lastChar) { |
|
1287 |
// // With random strings and a 4-character alphabet, |
|
1288 |
// // reverse matching at this point sets up 0.8% fewer |
|
1289 |
// // frames, but (paradoxically) makes 0.3% more probes. |
|
1290 |
// // Since those probes are nearer the lastChar probe, |
|
1291 |
// // there is may be a net D$ win with reverse matching. |
|
1292 |
// // But, reversing loop inhibits unroll of inner loop |
|
1293 |
// // for unknown reason. So, does running outer loop from |
|
1294 |
// // (sourceOffset - targetCountLess1) to (sourceOffset + sourceCount) |
|
1295 |
// for (int j = 0; j < targetCountLess1; j++) { |
|
1296 |
// if (target[targetOffset + j] != source[i+j]) { |
|
1297 |
// if ((cache & (1 << source[i+j])) == 0) { |
|
1298 |
// if (md2 < j+1) { |
|
1299 |
// i += j+1; |
|
1300 |
// continue outer_loop; |
|
1301 |
// } |
|
1302 |
// } |
|
1303 |
// i += md2; |
|
1304 |
// continue outer_loop; |
|
1305 |
// } |
|
1306 |
// } |
|
1307 |
// return i - sourceOffset; |
|
1308 |
// } |
|
1309 |
// if ((cache & (1 << src)) == 0) { |
|
1310 |
// i += targetCountLess1; |
|
1311 |
// } // using "i += targetCount;" and an "else i++;" causes a jump to jump. |
|
1312 |
// i++; |
|
1313 |
// } |
|
1314 |
// return -1; |
|
1315 |
// } |
|
1316 |
||
1317 |
//------------------------------string_indexOf------------------------ |
|
1318 |
Node* LibraryCallKit::string_indexOf(Node* string_object, ciTypeArray* target_array, jint targetOffset_i, |
|
1319 |
jint cache_i, jint md2_i) { |
|
1320 |
||
1321 |
Node* no_ctrl = NULL; |
|
1322 |
float likely = PROB_LIKELY(0.9); |
|
1323 |
float unlikely = PROB_UNLIKELY(0.9); |
|
1324 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1325 |
const int nargs = 0; // no arguments to push back for uncommon trap in predicate |
8732
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
8498
diff
changeset
|
1326 |
|
12623 | 1327 |
Node* source = load_String_value(no_ctrl, string_object); |
1328 |
Node* sourceOffset = load_String_offset(no_ctrl, string_object); |
|
1329 |
Node* sourceCount = load_String_length(no_ctrl, string_object); |
|
1 | 1330 |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
1331 |
Node* target = _gvn.transform( makecon(TypeOopPtr::make_from_constant(target_array, true))); |
1 | 1332 |
jint target_length = target_array->length(); |
1333 |
const TypeAry* target_array_type = TypeAry::make(TypeInt::CHAR, TypeInt::make(0, target_length, Type::WidenMin)); |
|
1334 |
const TypeAryPtr* target_type = TypeAryPtr::make(TypePtr::BotPTR, target_array_type, target_array->klass(), true, Type::OffsetBot); |
|
1335 |
||
19770
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19719
diff
changeset
|
1336 |
// String.value field is known to be @Stable. |
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19719
diff
changeset
|
1337 |
if (UseImplicitStableValues) { |
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19719
diff
changeset
|
1338 |
target = cast_array_to_stable(target, target_type); |
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19719
diff
changeset
|
1339 |
} |
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19719
diff
changeset
|
1340 |
|
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
1341 |
IdealKit kit(this, false, true); |
1 | 1342 |
#define __ kit. |
1343 |
Node* zero = __ ConI(0); |
|
1344 |
Node* one = __ ConI(1); |
|
1345 |
Node* cache = __ ConI(cache_i); |
|
1346 |
Node* md2 = __ ConI(md2_i); |
|
1347 |
Node* lastChar = __ ConI(target_array->char_at(target_length - 1)); |
|
1348 |
Node* targetCountLess1 = __ ConI(target_length - 1); |
|
1349 |
Node* targetOffset = __ ConI(targetOffset_i); |
|
1350 |
Node* sourceEnd = __ SubI(__ AddI(sourceOffset, sourceCount), targetCountLess1); |
|
1351 |
||
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
1352 |
IdealVariable rtn(kit), i(kit), j(kit); __ declarations_done(); |
1 | 1353 |
Node* outer_loop = __ make_label(2 /* goto */); |
1354 |
Node* return_ = __ make_label(1); |
|
1355 |
||
1356 |
__ set(rtn,__ ConI(-1)); |
|
8732
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
8498
diff
changeset
|
1357 |
__ loop(this, nargs, i, sourceOffset, BoolTest::lt, sourceEnd); { |
1 | 1358 |
Node* i2 = __ AddI(__ value(i), targetCountLess1); |
1359 |
// pin to prohibit loading of "next iteration" value which may SEGV (rare) |
|
1360 |
Node* src = load_array_element(__ ctrl(), source, i2, TypeAryPtr::CHARS); |
|
1361 |
__ if_then(src, BoolTest::eq, lastChar, unlikely); { |
|
8732
16fc1c68714b
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
8498
diff
changeset
|
1362 |
__ loop(this, nargs, j, zero, BoolTest::lt, targetCountLess1); { |
1 | 1363 |
Node* tpj = __ AddI(targetOffset, __ value(j)); |
1364 |
Node* targ = load_array_element(no_ctrl, target, tpj, target_type); |
|
1365 |
Node* ipj = __ AddI(__ value(i), __ value(j)); |
|
1366 |
Node* src2 = load_array_element(no_ctrl, source, ipj, TypeAryPtr::CHARS); |
|
1367 |
__ if_then(targ, BoolTest::ne, src2); { |
|
1368 |
__ if_then(__ AndI(cache, __ LShiftI(one, src2)), BoolTest::eq, zero); { |
|
1369 |
__ if_then(md2, BoolTest::lt, __ AddI(__ value(j), one)); { |
|
1370 |
__ increment(i, __ AddI(__ value(j), one)); |
|
1371 |
__ goto_(outer_loop); |
|
1372 |
} __ end_if(); __ dead(j); |
|
1373 |
}__ end_if(); __ dead(j); |
|
1374 |
__ increment(i, md2); |
|
1375 |
__ goto_(outer_loop); |
|
1376 |
}__ end_if(); |
|
1377 |
__ increment(j, one); |
|
1378 |
}__ end_loop(); __ dead(j); |
|
1379 |
__ set(rtn, __ SubI(__ value(i), sourceOffset)); __ dead(i); |
|
1380 |
__ goto_(return_); |
|
1381 |
}__ end_if(); |
|
1382 |
__ if_then(__ AndI(cache, __ LShiftI(one, src)), BoolTest::eq, zero, likely); { |
|
1383 |
__ increment(i, targetCountLess1); |
|
1384 |
}__ end_if(); |
|
1385 |
__ increment(i, one); |
|
1386 |
__ bind(outer_loop); |
|
1387 |
}__ end_loop(); __ dead(i); |
|
1388 |
__ bind(return_); |
|
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
1389 |
|
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
1390 |
// Final sync IdealKit and GraphKit. |
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
1391 |
final_sync(kit); |
1 | 1392 |
Node* result = __ value(rtn); |
1393 |
#undef __ |
|
1394 |
C->set_has_loops(true); |
|
1395 |
return result; |
|
1396 |
} |
|
1397 |
||
1398 |
//------------------------------inline_string_indexOf------------------------ |
|
1399 |
bool LibraryCallKit::inline_string_indexOf() { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1400 |
Node* receiver = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1401 |
Node* arg = argument(1); |
2348 | 1402 |
|
1403 |
Node* result; |
|
8494
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1404 |
if (Matcher::has_match_rule(Op_StrIndexOf) && |
2348 | 1405 |
UseSSE42Intrinsics) { |
1406 |
// Generate SSE4.2 version of indexOf |
|
1407 |
// We currently only have match rules that use SSE4.2 |
|
1408 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1409 |
receiver = null_check(receiver); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1410 |
arg = null_check(arg); |
2348 | 1411 |
if (stopped()) { |
1412 |
return true; |
|
1413 |
} |
|
1414 |
||
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1415 |
// Make the merge point |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1416 |
RegionNode* result_rgn = new RegionNode(4); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1417 |
Node* result_phi = new PhiNode(result_rgn, TypeInt::INT); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1418 |
Node* no_ctrl = NULL; |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1419 |
|
12623 | 1420 |
// Get start addr of source string |
1421 |
Node* source = load_String_value(no_ctrl, receiver); |
|
1422 |
Node* source_offset = load_String_offset(no_ctrl, receiver); |
|
1423 |
Node* source_start = array_element_address(source, source_offset, T_CHAR); |
|
1424 |
||
1425 |
// Get length of source string |
|
1426 |
Node* source_cnt = load_String_length(no_ctrl, receiver); |
|
1427 |
||
1428 |
// Get start addr of substring |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1429 |
Node* substr = load_String_value(no_ctrl, arg); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1430 |
Node* substr_offset = load_String_offset(no_ctrl, arg); |
12623 | 1431 |
Node* substr_start = array_element_address(substr, substr_offset, T_CHAR); |
1432 |
||
1433 |
// Get length of source string |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1434 |
Node* substr_cnt = load_String_length(no_ctrl, arg); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1435 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1436 |
// Check for substr count > string count |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1437 |
Node* cmp = _gvn.transform(new CmpINode(substr_cnt, source_cnt)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1438 |
Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::gt)); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1439 |
Node* if_gt = generate_slow_guard(bol, NULL); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1440 |
if (if_gt != NULL) { |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1441 |
result_phi->init_req(2, intcon(-1)); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1442 |
result_rgn->init_req(2, if_gt); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1443 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1444 |
|
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1445 |
if (!stopped()) { |
8494
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1446 |
// Check for substr count == 0 |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1447 |
cmp = _gvn.transform(new CmpINode(substr_cnt, intcon(0))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1448 |
bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); |
8494
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1449 |
Node* if_zero = generate_slow_guard(bol, NULL); |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1450 |
if (if_zero != NULL) { |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1451 |
result_phi->init_req(3, intcon(0)); |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1452 |
result_rgn->init_req(3, if_zero); |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1453 |
} |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1454 |
} |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1455 |
|
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1456 |
if (!stopped()) { |
12623 | 1457 |
result = make_string_method_node(Op_StrIndexOf, source_start, source_cnt, substr_start, substr_cnt); |
3905
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1458 |
result_phi->init_req(1, result); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1459 |
result_rgn->init_req(1, control()); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1460 |
} |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1461 |
set_control(_gvn.transform(result_rgn)); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1462 |
record_for_igvn(result_rgn); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1463 |
result = _gvn.transform(result_phi); |
7d725029ac85
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
3805
diff
changeset
|
1464 |
|
8494
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1465 |
} else { // Use LibraryCallKit::string_indexOf |
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1466 |
// don't intrinsify if argument isn't a constant string. |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1467 |
if (!arg->is_Con()) { |
2348 | 1468 |
return false; |
1469 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1470 |
const TypeOopPtr* str_type = _gvn.type(arg)->isa_oopptr(); |
2348 | 1471 |
if (str_type == NULL) { |
1472 |
return false; |
|
1473 |
} |
|
1474 |
ciInstanceKlass* klass = env()->String_klass(); |
|
1475 |
ciObject* str_const = str_type->const_oop(); |
|
1476 |
if (str_const == NULL || str_const->klass() != klass) { |
|
1477 |
return false; |
|
1478 |
} |
|
1479 |
ciInstance* str = str_const->as_instance(); |
|
1480 |
assert(str != NULL, "must be instance"); |
|
1481 |
||
12623 | 1482 |
ciObject* v = str->field_value_by_offset(java_lang_String::value_offset_in_bytes()).as_object(); |
2348 | 1483 |
ciTypeArray* pat = v->as_type_array(); // pattern (argument) character array |
1484 |
||
12623 | 1485 |
int o; |
1486 |
int c; |
|
1487 |
if (java_lang_String::has_offset_field()) { |
|
1488 |
o = str->field_value_by_offset(java_lang_String::offset_offset_in_bytes()).as_int(); |
|
1489 |
c = str->field_value_by_offset(java_lang_String::count_offset_in_bytes()).as_int(); |
|
1490 |
} else { |
|
1491 |
o = 0; |
|
1492 |
c = pat->length(); |
|
1493 |
} |
|
1494 |
||
2348 | 1495 |
// constant strings have no offset and count == length which |
1496 |
// simplifies the resulting code somewhat so lets optimize for that. |
|
1497 |
if (o != 0 || c != pat->length()) { |
|
1498 |
return false; |
|
1499 |
} |
|
1500 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1501 |
receiver = null_check(receiver, T_OBJECT); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1502 |
// NOTE: No null check on the argument is needed since it's a constant String oop. |
2348 | 1503 |
if (stopped()) { |
8494
4258c78226d9
6942326: x86 code in string_indexof() could read beyond reserved heap space
kvn
parents:
7397
diff
changeset
|
1504 |
return true; |
2348 | 1505 |
} |
1506 |
||
1507 |
// The null string as a pattern always returns 0 (match at beginning of string) |
|
1508 |
if (c == 0) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1509 |
set_result(intcon(0)); |
2348 | 1510 |
return true; |
1511 |
} |
|
1512 |
||
1513 |
// Generate default indexOf |
|
1514 |
jchar lastChar = pat->char_at(o + (c - 1)); |
|
1515 |
int cache = 0; |
|
1516 |
int i; |
|
1517 |
for (i = 0; i < c - 1; i++) { |
|
1518 |
assert(i < pat->length(), "out of range"); |
|
1519 |
cache |= (1 << (pat->char_at(o + i) & (sizeof(cache) * BitsPerByte - 1))); |
|
1520 |
} |
|
1521 |
||
1522 |
int md2 = c; |
|
1523 |
for (i = 0; i < c - 1; i++) { |
|
1524 |
assert(i < pat->length(), "out of range"); |
|
1525 |
if (pat->char_at(o + i) == lastChar) { |
|
1526 |
md2 = (c - 1) - i; |
|
1527 |
} |
|
1528 |
} |
|
1529 |
||
1530 |
result = string_indexOf(receiver, pat, o, cache, md2); |
|
1 | 1531 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1532 |
set_result(result); |
1 | 1533 |
return true; |
1534 |
} |
|
1535 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1536 |
//--------------------------round_double_node-------------------------------- |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1537 |
// Round a double node if necessary. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1538 |
Node* LibraryCallKit::round_double_node(Node* n) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1539 |
if (Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1) |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1540 |
n = _gvn.transform(new RoundDoubleNode(0, n)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1541 |
return n; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1542 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1543 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1544 |
//------------------------------inline_math----------------------------------- |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1545 |
// public static double Math.abs(double) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1546 |
// public static double Math.sqrt(double) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1547 |
// public static double Math.log(double) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1548 |
// public static double Math.log10(double) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1549 |
bool LibraryCallKit::inline_math(vmIntrinsics::ID id) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1550 |
Node* arg = round_double_node(argument(0)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1551 |
Node* n; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1552 |
switch (id) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1553 |
case vmIntrinsics::_dabs: n = new AbsDNode( arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1554 |
case vmIntrinsics::_dsqrt: n = new SqrtDNode(C, control(), arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1555 |
case vmIntrinsics::_dlog: n = new LogDNode(C, control(), arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1556 |
case vmIntrinsics::_dlog10: n = new Log10DNode(C, control(), arg); break; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1557 |
default: fatal_unexpected_iid(id); break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1558 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1559 |
set_result(_gvn.transform(n)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1560 |
return true; |
1 | 1561 |
} |
1562 |
||
1563 |
//------------------------------inline_trig---------------------------------- |
|
1564 |
// Inline sin/cos/tan instructions, if possible. If rounding is required, do |
|
1565 |
// argument reduction which will turn into a fast/slow diamond. |
|
1566 |
bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1567 |
Node* arg = round_double_node(argument(0)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1568 |
Node* n = NULL; |
1 | 1569 |
|
1570 |
switch (id) { |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1571 |
case vmIntrinsics::_dsin: n = new SinDNode(C, control(), arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1572 |
case vmIntrinsics::_dcos: n = new CosDNode(C, control(), arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1573 |
case vmIntrinsics::_dtan: n = new TanDNode(C, control(), arg); break; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1574 |
default: fatal_unexpected_iid(id); break; |
1 | 1575 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1576 |
n = _gvn.transform(n); |
1 | 1577 |
|
1578 |
// Rounding required? Check for argument reduction! |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1579 |
if (Matcher::strict_fp_requires_explicit_rounding) { |
1 | 1580 |
static const double pi_4 = 0.7853981633974483; |
1581 |
static const double neg_pi_4 = -0.7853981633974483; |
|
1582 |
// pi/2 in 80-bit extended precision |
|
1583 |
// static const unsigned char pi_2_bits_x[] = {0x35,0xc2,0x68,0x21,0xa2,0xda,0x0f,0xc9,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00}; |
|
1584 |
// -pi/2 in 80-bit extended precision |
|
1585 |
// static const unsigned char neg_pi_2_bits_x[] = {0x35,0xc2,0x68,0x21,0xa2,0xda,0x0f,0xc9,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x00}; |
|
1586 |
// Cutoff value for using this argument reduction technique |
|
1587 |
//static const double pi_2_minus_epsilon = 1.564660403643354; |
|
1588 |
//static const double neg_pi_2_plus_epsilon = -1.564660403643354; |
|
1589 |
||
1590 |
// Pseudocode for sin: |
|
1591 |
// if (x <= Math.PI / 4.0) { |
|
1592 |
// if (x >= -Math.PI / 4.0) return fsin(x); |
|
1593 |
// if (x >= -Math.PI / 2.0) return -fcos(x + Math.PI / 2.0); |
|
1594 |
// } else { |
|
1595 |
// if (x <= Math.PI / 2.0) return fcos(x - Math.PI / 2.0); |
|
1596 |
// } |
|
1597 |
// return StrictMath.sin(x); |
|
1598 |
||
1599 |
// Pseudocode for cos: |
|
1600 |
// if (x <= Math.PI / 4.0) { |
|
1601 |
// if (x >= -Math.PI / 4.0) return fcos(x); |
|
1602 |
// if (x >= -Math.PI / 2.0) return fsin(x + Math.PI / 2.0); |
|
1603 |
// } else { |
|
1604 |
// if (x <= Math.PI / 2.0) return -fsin(x - Math.PI / 2.0); |
|
1605 |
// } |
|
1606 |
// return StrictMath.cos(x); |
|
1607 |
||
1608 |
// Actually, sticking in an 80-bit Intel value into C2 will be tough; it |
|
1609 |
// requires a special machine instruction to load it. Instead we'll try |
|
1610 |
// the 'easy' case. If we really need the extra range +/- PI/2 we'll |
|
1611 |
// probably do the math inside the SIN encoding. |
|
1612 |
||
1613 |
// Make the merge point |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1614 |
RegionNode* r = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1615 |
Node* phi = new PhiNode(r, Type::DOUBLE); |
1 | 1616 |
|
1617 |
// Flatten arg so we need only 1 test |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1618 |
Node *abs = _gvn.transform(new AbsDNode(arg)); |
1 | 1619 |
// Node for PI/4 constant |
1620 |
Node *pi4 = makecon(TypeD::make(pi_4)); |
|
1621 |
// Check PI/4 : abs(arg) |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1622 |
Node *cmp = _gvn.transform(new CmpDNode(pi4,abs)); |
1 | 1623 |
// Check: If PI/4 < abs(arg) then go slow |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1624 |
Node *bol = _gvn.transform(new BoolNode( cmp, BoolTest::lt )); |
1 | 1625 |
// Branch either way |
1626 |
IfNode *iff = create_and_xform_if(control(),bol, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
|
1627 |
set_control(opt_iff(r,iff)); |
|
1628 |
||
1629 |
// Set fast path result |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1630 |
phi->init_req(2, n); |
1 | 1631 |
|
1632 |
// Slow path - non-blocking leaf call |
|
1633 |
Node* call = NULL; |
|
1634 |
switch (id) { |
|
1635 |
case vmIntrinsics::_dsin: |
|
1636 |
call = make_runtime_call(RC_LEAF, OptoRuntime::Math_D_D_Type(), |
|
1637 |
CAST_FROM_FN_PTR(address, SharedRuntime::dsin), |
|
1638 |
"Sin", NULL, arg, top()); |
|
1639 |
break; |
|
1640 |
case vmIntrinsics::_dcos: |
|
1641 |
call = make_runtime_call(RC_LEAF, OptoRuntime::Math_D_D_Type(), |
|
1642 |
CAST_FROM_FN_PTR(address, SharedRuntime::dcos), |
|
1643 |
"Cos", NULL, arg, top()); |
|
1644 |
break; |
|
1645 |
case vmIntrinsics::_dtan: |
|
1646 |
call = make_runtime_call(RC_LEAF, OptoRuntime::Math_D_D_Type(), |
|
1647 |
CAST_FROM_FN_PTR(address, SharedRuntime::dtan), |
|
1648 |
"Tan", NULL, arg, top()); |
|
1649 |
break; |
|
1650 |
} |
|
1651 |
assert(control()->in(0) == call, ""); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1652 |
Node* slow_result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1653 |
r->init_req(1, control()); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1654 |
phi->init_req(1, slow_result); |
1 | 1655 |
|
1656 |
// Post-merge |
|
1657 |
set_control(_gvn.transform(r)); |
|
1658 |
record_for_igvn(r); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1659 |
n = _gvn.transform(phi); |
1 | 1660 |
|
1661 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
1662 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1663 |
set_result(n); |
1 | 1664 |
return true; |
1665 |
} |
|
1666 |
||
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1667 |
Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { |
13203 | 1668 |
//------------------- |
1669 |
//result=(result.isNaN())? funcAddr():result; |
|
1670 |
// Check: If isNaN() by checking result!=result? then either trap |
|
1671 |
// or go to runtime |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1672 |
Node* cmpisnan = _gvn.transform(new CmpDNode(result, result)); |
13203 | 1673 |
// Build the boolean node |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1674 |
Node* bolisnum = _gvn.transform(new BoolNode(cmpisnan, BoolTest::eq)); |
13203 | 1675 |
|
1676 |
if (!too_many_traps(Deoptimization::Reason_intrinsic)) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1677 |
{ BuildCutout unless(this, bolisnum, PROB_STATIC_FREQUENT); |
13203 | 1678 |
// The pow or exp intrinsic returned a NaN, which requires a call |
1679 |
// to the runtime. Recompile with the runtime call. |
|
1680 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
|
1681 |
Deoptimization::Action_make_not_entrant); |
|
1682 |
} |
|
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1683 |
return result; |
13203 | 1684 |
} else { |
1685 |
// If this inlining ever returned NaN in the past, we compile a call |
|
1686 |
// to the runtime to properly handle corner cases |
|
1687 |
||
1688 |
IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1689 |
Node* if_slow = _gvn.transform(new IfFalseNode(iff)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1690 |
Node* if_fast = _gvn.transform(new IfTrueNode(iff)); |
13203 | 1691 |
|
1692 |
if (!if_slow->is_top()) { |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1693 |
RegionNode* result_region = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1694 |
PhiNode* result_val = new PhiNode(result_region, Type::DOUBLE); |
13203 | 1695 |
|
1696 |
result_region->init_req(1, if_fast); |
|
1697 |
result_val->init_req(1, result); |
|
1698 |
||
1699 |
set_control(if_slow); |
|
1700 |
||
1701 |
const TypePtr* no_memory_effects = NULL; |
|
1702 |
Node* rt = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, |
|
1703 |
no_memory_effects, |
|
1704 |
x, top(), y, y ? top() : NULL); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1705 |
Node* value = _gvn.transform(new ProjNode(rt, TypeFunc::Parms+0)); |
13203 | 1706 |
#ifdef ASSERT |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1707 |
Node* value_top = _gvn.transform(new ProjNode(rt, TypeFunc::Parms+1)); |
13203 | 1708 |
assert(value_top == top(), "second value must be top"); |
1709 |
#endif |
|
1710 |
||
1711 |
result_region->init_req(2, control()); |
|
1712 |
result_val->init_req(2, value); |
|
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1713 |
set_control(_gvn.transform(result_region)); |
24344
9cd6465ec36c
8042052: assert(t != NULL) failed: must set before get
anoll
parents:
24314
diff
changeset
|
1714 |
return _gvn.transform(result_val); |
13203 | 1715 |
} else { |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1716 |
return result; |
13203 | 1717 |
} |
1718 |
} |
|
1719 |
} |
|
1720 |
||
1 | 1721 |
//------------------------------inline_exp------------------------------------- |
1722 |
// Inline exp instructions, if possible. The Intel hardware only misses |
|
1723 |
// really odd corner cases (+/- Infinity). Just uncommon-trap them. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1724 |
bool LibraryCallKit::inline_exp() { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1725 |
Node* arg = round_double_node(argument(0)); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1726 |
Node* n = _gvn.transform(new ExpDNode(C, control(), arg)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1727 |
|
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1728 |
n = finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1729 |
set_result(n); |
1 | 1730 |
|
1731 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
1732 |
return true; |
|
1733 |
} |
|
1734 |
||
1735 |
//------------------------------inline_pow------------------------------------- |
|
1736 |
// Inline power instructions, if possible. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1737 |
bool LibraryCallKit::inline_pow() { |
1 | 1738 |
// Pseudocode for pow |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1739 |
// if (y == 2) { |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1740 |
// return x * x; |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1741 |
// } else { |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1742 |
// if (x <= 0.0) { |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1743 |
// long longy = (long)y; |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1744 |
// if ((double)longy == y) { // if y is long |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1745 |
// if (y + 1 == y) longy = 0; // huge number: even |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1746 |
// result = ((1&longy) == 0)?-DPow(abs(x), y):DPow(abs(x), y); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1747 |
// } else { |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1748 |
// result = NaN; |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1749 |
// } |
1 | 1750 |
// } else { |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1751 |
// result = DPow(x,y); |
1 | 1752 |
// } |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1753 |
// if (result != result)? { |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1754 |
// result = uncommon_trap() or runtime_call(); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1755 |
// } |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1756 |
// return result; |
1 | 1757 |
// } |
1758 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1759 |
Node* x = round_double_node(argument(0)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1760 |
Node* y = round_double_node(argument(2)); |
1 | 1761 |
|
13203 | 1762 |
Node* result = NULL; |
1763 |
||
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1764 |
Node* const_two_node = makecon(TypeD::make(2.0)); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1765 |
Node* cmp_node = _gvn.transform(new CmpDNode(y, const_two_node)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1766 |
Node* bool_node = _gvn.transform(new BoolNode(cmp_node, BoolTest::eq)); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1767 |
IfNode* if_node = create_and_xform_if(control(), bool_node, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1768 |
Node* if_true = _gvn.transform(new IfTrueNode(if_node)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1769 |
Node* if_false = _gvn.transform(new IfFalseNode(if_node)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1770 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1771 |
RegionNode* region_node = new RegionNode(3); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1772 |
region_node->init_req(1, if_true); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1773 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1774 |
Node* phi_node = new PhiNode(region_node, Type::DOUBLE); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1775 |
// special case for x^y where y == 2, we can convert it to x * x |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1776 |
phi_node->init_req(1, _gvn.transform(new MulDNode(x, x))); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1777 |
|
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1778 |
// set control to if_false since we will now process the false branch |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1779 |
set_control(if_false); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1780 |
|
13203 | 1781 |
if (!too_many_traps(Deoptimization::Reason_intrinsic)) { |
1782 |
// Short form: skip the fancy tests and just check for NaN result. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1783 |
result = _gvn.transform(new PowDNode(C, control(), x, y)); |
1 | 1784 |
} else { |
13203 | 1785 |
// If this inlining ever returned NaN in the past, include all |
1786 |
// checks + call to the runtime. |
|
1 | 1787 |
|
1788 |
// Set the merge point for If node with condition of (x <= 0.0) |
|
1789 |
// There are four possible paths to region node and phi node |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1790 |
RegionNode *r = new RegionNode(4); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1791 |
Node *phi = new PhiNode(r, Type::DOUBLE); |
1 | 1792 |
|
1793 |
// Build the first if node: if (x <= 0.0) |
|
1794 |
// Node for 0 constant |
|
1795 |
Node *zeronode = makecon(TypeD::ZERO); |
|
1796 |
// Check x:0 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1797 |
Node *cmp = _gvn.transform(new CmpDNode(x, zeronode)); |
1 | 1798 |
// Check: If (x<=0) then go complex path |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1799 |
Node *bol1 = _gvn.transform(new BoolNode( cmp, BoolTest::le )); |
1 | 1800 |
// Branch either way |
1801 |
IfNode *if1 = create_and_xform_if(control(),bol1, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); |
|
1802 |
// Fast path taken; set region slot 3 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1803 |
Node *fast_taken = _gvn.transform(new IfFalseNode(if1)); |
1 | 1804 |
r->init_req(3,fast_taken); // Capture fast-control |
1805 |
||
1806 |
// Fast path not-taken, i.e. slow path |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1807 |
Node *complex_path = _gvn.transform(new IfTrueNode(if1)); |
1 | 1808 |
|
1809 |
// Set fast path result |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1810 |
Node *fast_result = _gvn.transform(new PowDNode(C, control(), x, y)); |
1 | 1811 |
phi->init_req(3, fast_result); |
1812 |
||
1813 |
// Complex path |
|
13203 | 1814 |
// Build the second if node (if y is long) |
1815 |
// Node for (long)y |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1816 |
Node *longy = _gvn.transform(new ConvD2LNode(y)); |
13203 | 1817 |
// Node for (double)((long) y) |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1818 |
Node *doublelongy= _gvn.transform(new ConvL2DNode(longy)); |
13203 | 1819 |
// Check (double)((long) y) : y |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1820 |
Node *cmplongy= _gvn.transform(new CmpDNode(doublelongy, y)); |
13203 | 1821 |
// Check if (y isn't long) then go to slow path |
1822 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1823 |
Node *bol2 = _gvn.transform(new BoolNode( cmplongy, BoolTest::ne )); |
2131 | 1824 |
// Branch either way |
1 | 1825 |
IfNode *if2 = create_and_xform_if(complex_path,bol2, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1826 |
Node* ylong_path = _gvn.transform(new IfFalseNode(if2)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1827 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1828 |
Node *slow_path = _gvn.transform(new IfTrueNode(if2)); |
13203 | 1829 |
|
1830 |
// Calculate DPow(abs(x), y)*(1 & (long)y) |
|
1 | 1831 |
// Node for constant 1 |
13203 | 1832 |
Node *conone = longcon(1); |
1833 |
// 1& (long)y |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1834 |
Node *signnode= _gvn.transform(new AndLNode(conone, longy)); |
13203 | 1835 |
|
1836 |
// A huge number is always even. Detect a huge number by checking |
|
1837 |
// if y + 1 == y and set integer to be tested for parity to 0. |
|
1838 |
// Required for corner case: |
|
1839 |
// (long)9.223372036854776E18 = max_jlong |
|
1840 |
// (double)(long)9.223372036854776E18 = 9.223372036854776E18 |
|
1841 |
// max_jlong is odd but 9.223372036854776E18 is even |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1842 |
Node* yplus1 = _gvn.transform(new AddDNode(y, makecon(TypeD::make(1)))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1843 |
Node *cmpyplus1= _gvn.transform(new CmpDNode(yplus1, y)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1844 |
Node *bolyplus1 = _gvn.transform(new BoolNode( cmpyplus1, BoolTest::eq )); |
13203 | 1845 |
Node* correctedsign = NULL; |
1846 |
if (ConditionalMoveLimit != 0) { |
|
25930 | 1847 |
correctedsign = _gvn.transform(CMoveNode::make(NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG)); |
13203 | 1848 |
} else { |
1849 |
IfNode *ifyplus1 = create_and_xform_if(ylong_path,bolyplus1, PROB_FAIR, COUNT_UNKNOWN); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1850 |
RegionNode *r = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1851 |
Node *phi = new PhiNode(r, TypeLong::LONG); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1852 |
r->init_req(1, _gvn.transform(new IfFalseNode(ifyplus1))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1853 |
r->init_req(2, _gvn.transform(new IfTrueNode(ifyplus1))); |
13203 | 1854 |
phi->init_req(1, signnode); |
1855 |
phi->init_req(2, longcon(0)); |
|
1856 |
correctedsign = _gvn.transform(phi); |
|
1857 |
ylong_path = _gvn.transform(r); |
|
1858 |
record_for_igvn(r); |
|
1859 |
} |
|
1860 |
||
1 | 1861 |
// zero node |
13203 | 1862 |
Node *conzero = longcon(0); |
1863 |
// Check (1&(long)y)==0? |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1864 |
Node *cmpeq1 = _gvn.transform(new CmpLNode(correctedsign, conzero)); |
13203 | 1865 |
// Check if (1&(long)y)!=0?, if so the result is negative |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1866 |
Node *bol3 = _gvn.transform(new BoolNode( cmpeq1, BoolTest::ne )); |
1 | 1867 |
// abs(x) |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1868 |
Node *absx=_gvn.transform(new AbsDNode(x)); |
1 | 1869 |
// abs(x)^y |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1870 |
Node *absxpowy = _gvn.transform(new PowDNode(C, control(), absx, y)); |
1 | 1871 |
// -abs(x)^y |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1872 |
Node *negabsxpowy = _gvn.transform(new NegDNode (absxpowy)); |
13203 | 1873 |
// (1&(long)y)==1?-DPow(abs(x), y):DPow(abs(x), y) |
1874 |
Node *signresult = NULL; |
|
1875 |
if (ConditionalMoveLimit != 0) { |
|
25930 | 1876 |
signresult = _gvn.transform(CMoveNode::make(NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE)); |
13203 | 1877 |
} else { |
1878 |
IfNode *ifyeven = create_and_xform_if(ylong_path,bol3, PROB_FAIR, COUNT_UNKNOWN); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1879 |
RegionNode *r = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1880 |
Node *phi = new PhiNode(r, Type::DOUBLE); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1881 |
r->init_req(1, _gvn.transform(new IfFalseNode(ifyeven))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1882 |
r->init_req(2, _gvn.transform(new IfTrueNode(ifyeven))); |
13203 | 1883 |
phi->init_req(1, absxpowy); |
1884 |
phi->init_req(2, negabsxpowy); |
|
1885 |
signresult = _gvn.transform(phi); |
|
1886 |
ylong_path = _gvn.transform(r); |
|
1887 |
record_for_igvn(r); |
|
1888 |
} |
|
1 | 1889 |
// Set complex path fast result |
13203 | 1890 |
r->init_req(2, ylong_path); |
1 | 1891 |
phi->init_req(2, signresult); |
1892 |
||
1893 |
static const jlong nan_bits = CONST64(0x7ff8000000000000); |
|
1894 |
Node *slow_result = makecon(TypeD::make(*(double*)&nan_bits)); // return NaN |
|
1895 |
r->init_req(1,slow_path); |
|
1896 |
phi->init_req(1,slow_result); |
|
1897 |
||
1898 |
// Post merge |
|
1899 |
set_control(_gvn.transform(r)); |
|
1900 |
record_for_igvn(r); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1901 |
result = _gvn.transform(phi); |
1 | 1902 |
} |
1903 |
||
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1904 |
result = finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1905 |
|
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1906 |
// control from finish_pow_exp is now input to the region node |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1907 |
region_node->set_req(2, control()); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1908 |
// the result from finish_pow_exp is now input to the phi node |
24344
9cd6465ec36c
8042052: assert(t != NULL) failed: must set before get
anoll
parents:
24314
diff
changeset
|
1909 |
phi_node->init_req(2, result); |
24314
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1910 |
set_control(_gvn.transform(region_node)); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1911 |
record_for_igvn(region_node); |
b66e3734cb3f
8029302: Performance regression in Math.pow intrinsic
adlertz
parents:
23846
diff
changeset
|
1912 |
set_result(_gvn.transform(phi_node)); |
1 | 1913 |
|
1914 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
1915 |
return true; |
|
1916 |
} |
|
1917 |
||
1918 |
//------------------------------runtime_math----------------------------- |
|
1919 |
bool LibraryCallKit::runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName) { |
|
1920 |
assert(call_type == OptoRuntime::Math_DD_D_Type() || call_type == OptoRuntime::Math_D_D_Type(), |
|
1921 |
"must be (DD)D or (D)D type"); |
|
1922 |
||
1923 |
// Inputs |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1924 |
Node* a = round_double_node(argument(0)); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1925 |
Node* b = (call_type == OptoRuntime::Math_DD_D_Type()) ? round_double_node(argument(2)) : NULL; |
1 | 1926 |
|
1927 |
const TypePtr* no_memory_effects = NULL; |
|
1928 |
Node* trig = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, |
|
1929 |
no_memory_effects, |
|
1930 |
a, top(), b, b ? top() : NULL); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1931 |
Node* value = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+0)); |
1 | 1932 |
#ifdef ASSERT |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1933 |
Node* value_top = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+1)); |
1 | 1934 |
assert(value_top == top(), "second value must be top"); |
1935 |
#endif |
|
1936 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1937 |
set_result(value); |
1 | 1938 |
return true; |
1939 |
} |
|
1940 |
||
1941 |
//------------------------------inline_math_native----------------------------- |
|
1942 |
bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1943 |
#define FN_PTR(f) CAST_FROM_FN_PTR(address, f) |
1 | 1944 |
switch (id) { |
1945 |
// These intrinsics are not properly supported on all hardware |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1946 |
case vmIntrinsics::_dcos: return Matcher::has_match_rule(Op_CosD) ? inline_trig(id) : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1947 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dcos), "COS"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1948 |
case vmIntrinsics::_dsin: return Matcher::has_match_rule(Op_SinD) ? inline_trig(id) : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1949 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dsin), "SIN"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1950 |
case vmIntrinsics::_dtan: return Matcher::has_match_rule(Op_TanD) ? inline_trig(id) : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1951 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan), "TAN"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1952 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1953 |
case vmIntrinsics::_dlog: return Matcher::has_match_rule(Op_LogD) ? inline_math(id) : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1954 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog), "LOG"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1955 |
case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1956 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); |
1 | 1957 |
|
1958 |
// These intrinsics are supported on all hardware |
|
22879
177361c49b26
8035394: PPC64: Make usage of intrinsic dsqrt depend on processor recognition.
goetz
parents:
22872
diff
changeset
|
1959 |
case vmIntrinsics::_dsqrt: return Matcher::match_rule_supported(Op_SqrtD) ? inline_math(id) : false; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1960 |
case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_math(id) : false; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1961 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1962 |
case vmIntrinsics::_dexp: return Matcher::has_match_rule(Op_ExpD) ? inline_exp() : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1963 |
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp), "EXP"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1964 |
case vmIntrinsics::_dpow: return Matcher::has_match_rule(Op_PowD) ? inline_pow() : |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1965 |
runtime_math(OptoRuntime::Math_DD_D_Type(), FN_PTR(SharedRuntime::dpow), "POW"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1966 |
#undef FN_PTR |
1 | 1967 |
|
1968 |
// These intrinsics are not yet correctly implemented |
|
1969 |
case vmIntrinsics::_datan2: |
|
1970 |
return false; |
|
1971 |
||
1972 |
default: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1973 |
fatal_unexpected_iid(id); |
1 | 1974 |
return false; |
1975 |
} |
|
1976 |
} |
|
1977 |
||
1978 |
static bool is_simple_name(Node* n) { |
|
1979 |
return (n->req() == 1 // constant |
|
1980 |
|| (n->is_Type() && n->as_Type()->type()->singleton()) |
|
1981 |
|| n->is_Proj() // parameter or return value |
|
1982 |
|| n->is_Phi() // local of some sort |
|
1983 |
); |
|
1984 |
} |
|
1985 |
||
1986 |
//----------------------------inline_min_max----------------------------------- |
|
1987 |
bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
1988 |
set_result(generate_min_max(id, argument(0), argument(1))); |
1 | 1989 |
return true; |
1990 |
} |
|
1991 |
||
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
1992 |
void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1993 |
Node* bol = _gvn.transform( new BoolNode(test, BoolTest::overflow) ); |
20289 | 1994 |
IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1995 |
Node* fast_path = _gvn.transform( new IfFalseNode(check)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
1996 |
Node* slow_path = _gvn.transform( new IfTrueNode(check) ); |
20289 | 1997 |
|
1998 |
{ |
|
1999 |
PreserveJVMState pjvms(this); |
|
2000 |
PreserveReexecuteState preexecs(this); |
|
2001 |
jvms()->set_should_reexecute(true); |
|
2002 |
||
2003 |
set_control(slow_path); |
|
2004 |
set_i_o(i_o()); |
|
2005 |
||
2006 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
|
2007 |
Deoptimization::Action_none); |
|
2008 |
} |
|
2009 |
||
2010 |
set_control(fast_path); |
|
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2011 |
set_result(math); |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2012 |
} |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2013 |
|
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2014 |
template <typename OverflowOp> |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2015 |
bool LibraryCallKit::inline_math_overflow(Node* arg1, Node* arg2) { |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2016 |
typedef typename OverflowOp::MathOp MathOp; |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2017 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2018 |
MathOp* mathOp = new MathOp(arg1, arg2); |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2019 |
Node* operation = _gvn.transform( mathOp ); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2020 |
Node* ofcheck = _gvn.transform( new OverflowOp(arg1, arg2) ); |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2021 |
inline_math_mathExact(operation, ofcheck); |
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2022 |
return true; |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2023 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2024 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2025 |
bool LibraryCallKit::inline_math_addExactI(bool is_increment) { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2026 |
return inline_math_overflow<OverflowAddINode>(argument(0), is_increment ? intcon(1) : argument(1)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2027 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2028 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2029 |
bool LibraryCallKit::inline_math_addExactL(bool is_increment) { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2030 |
return inline_math_overflow<OverflowAddLNode>(argument(0), is_increment ? longcon(1) : argument(2)); |
20289 | 2031 |
} |
2032 |
||
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2033 |
bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2034 |
return inline_math_overflow<OverflowSubINode>(argument(0), is_decrement ? intcon(1) : argument(1)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2035 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2036 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2037 |
bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2038 |
return inline_math_overflow<OverflowSubLNode>(argument(0), is_decrement ? longcon(1) : argument(2)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2039 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2040 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2041 |
bool LibraryCallKit::inline_math_negateExactI() { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2042 |
return inline_math_overflow<OverflowSubINode>(intcon(0), argument(0)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2043 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2044 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2045 |
bool LibraryCallKit::inline_math_negateExactL() { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2046 |
return inline_math_overflow<OverflowSubLNode>(longcon(0), argument(0)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2047 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2048 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2049 |
bool LibraryCallKit::inline_math_multiplyExactI() { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2050 |
return inline_math_overflow<OverflowMulINode>(argument(0), argument(1)); |
21105
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2051 |
} |
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2052 |
|
47618ee96ed5
8026844: Various Math functions needs intrinsification
rbackman
parents:
21099
diff
changeset
|
2053 |
bool LibraryCallKit::inline_math_multiplyExactL() { |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
22879
diff
changeset
|
2054 |
return inline_math_overflow<OverflowMulLNode>(argument(0), argument(2)); |
20289 | 2055 |
} |
2056 |
||
1 | 2057 |
Node* |
2058 |
LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { |
|
2059 |
// These are the candidate return value: |
|
2060 |
Node* xvalue = x0; |
|
2061 |
Node* yvalue = y0; |
|
2062 |
||
2063 |
if (xvalue == yvalue) { |
|
2064 |
return xvalue; |
|
2065 |
} |
|
2066 |
||
2067 |
bool want_max = (id == vmIntrinsics::_max); |
|
2068 |
||
2069 |
const TypeInt* txvalue = _gvn.type(xvalue)->isa_int(); |
|
2070 |
const TypeInt* tyvalue = _gvn.type(yvalue)->isa_int(); |
|
2071 |
if (txvalue == NULL || tyvalue == NULL) return top(); |
|
2072 |
// This is not really necessary, but it is consistent with a |
|
2073 |
// hypothetical MaxINode::Value method: |
|
2074 |
int widen = MAX2(txvalue->_widen, tyvalue->_widen); |
|
2075 |
||
2076 |
// %%% This folding logic should (ideally) be in a different place. |
|
2077 |
// Some should be inside IfNode, and there to be a more reliable |
|
2078 |
// transformation of ?: style patterns into cmoves. We also want |
|
2079 |
// more powerful optimizations around cmove and min/max. |
|
2080 |
||
2081 |
// Try to find a dominating comparison of these guys. |
|
2082 |
// It can simplify the index computation for Arrays.copyOf |
|
2083 |
// and similar uses of System.arraycopy. |
|
2084 |
// First, compute the normalized version of CmpI(x, y). |
|
2085 |
int cmp_op = Op_CmpI; |
|
2086 |
Node* xkey = xvalue; |
|
2087 |
Node* ykey = yvalue; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2088 |
Node* ideal_cmpxy = _gvn.transform(new CmpINode(xkey, ykey)); |
1 | 2089 |
if (ideal_cmpxy->is_Cmp()) { |
2090 |
// E.g., if we have CmpI(length - offset, count), |
|
2091 |
// it might idealize to CmpI(length, count + offset) |
|
2092 |
cmp_op = ideal_cmpxy->Opcode(); |
|
2093 |
xkey = ideal_cmpxy->in(1); |
|
2094 |
ykey = ideal_cmpxy->in(2); |
|
2095 |
} |
|
2096 |
||
2097 |
// Start by locating any relevant comparisons. |
|
2098 |
Node* start_from = (xkey->outcnt() < ykey->outcnt()) ? xkey : ykey; |
|
2099 |
Node* cmpxy = NULL; |
|
2100 |
Node* cmpyx = NULL; |
|
2101 |
for (DUIterator_Fast kmax, k = start_from->fast_outs(kmax); k < kmax; k++) { |
|
2102 |
Node* cmp = start_from->fast_out(k); |
|
2103 |
if (cmp->outcnt() > 0 && // must have prior uses |
|
2104 |
cmp->in(0) == NULL && // must be context-independent |
|
2105 |
cmp->Opcode() == cmp_op) { // right kind of compare |
|
2106 |
if (cmp->in(1) == xkey && cmp->in(2) == ykey) cmpxy = cmp; |
|
2107 |
if (cmp->in(1) == ykey && cmp->in(2) == xkey) cmpyx = cmp; |
|
2108 |
} |
|
2109 |
} |
|
2110 |
||
2111 |
const int NCMPS = 2; |
|
2112 |
Node* cmps[NCMPS] = { cmpxy, cmpyx }; |
|
2113 |
int cmpn; |
|
2114 |
for (cmpn = 0; cmpn < NCMPS; cmpn++) { |
|
2115 |
if (cmps[cmpn] != NULL) break; // find a result |
|
2116 |
} |
|
2117 |
if (cmpn < NCMPS) { |
|
2118 |
// Look for a dominating test that tells us the min and max. |
|
2119 |
int depth = 0; // Limit search depth for speed |
|
2120 |
Node* dom = control(); |
|
2121 |
for (; dom != NULL; dom = IfNode::up_one_dom(dom, true)) { |
|
2122 |
if (++depth >= 100) break; |
|
2123 |
Node* ifproj = dom; |
|
2124 |
if (!ifproj->is_Proj()) continue; |
|
2125 |
Node* iff = ifproj->in(0); |
|
2126 |
if (!iff->is_If()) continue; |
|
2127 |
Node* bol = iff->in(1); |
|
2128 |
if (!bol->is_Bool()) continue; |
|
2129 |
Node* cmp = bol->in(1); |
|
2130 |
if (cmp == NULL) continue; |
|
2131 |
for (cmpn = 0; cmpn < NCMPS; cmpn++) |
|
2132 |
if (cmps[cmpn] == cmp) break; |
|
2133 |
if (cmpn == NCMPS) continue; |
|
2134 |
BoolTest::mask btest = bol->as_Bool()->_test._test; |
|
2135 |
if (ifproj->is_IfFalse()) btest = BoolTest(btest).negate(); |
|
2136 |
if (cmp->in(1) == ykey) btest = BoolTest(btest).commute(); |
|
2137 |
// At this point, we know that 'x btest y' is true. |
|
2138 |
switch (btest) { |
|
2139 |
case BoolTest::eq: |
|
2140 |
// They are proven equal, so we can collapse the min/max. |
|
2141 |
// Either value is the answer. Choose the simpler. |
|
2142 |
if (is_simple_name(yvalue) && !is_simple_name(xvalue)) |
|
2143 |
return yvalue; |
|
2144 |
return xvalue; |
|
2145 |
case BoolTest::lt: // x < y |
|
2146 |
case BoolTest::le: // x <= y |
|
2147 |
return (want_max ? yvalue : xvalue); |
|
2148 |
case BoolTest::gt: // x > y |
|
2149 |
case BoolTest::ge: // x >= y |
|
2150 |
return (want_max ? xvalue : yvalue); |
|
2151 |
} |
|
2152 |
} |
|
2153 |
} |
|
2154 |
||
2155 |
// We failed to find a dominating test. |
|
2156 |
// Let's pick a test that might GVN with prior tests. |
|
2157 |
Node* best_bol = NULL; |
|
2158 |
BoolTest::mask best_btest = BoolTest::illegal; |
|
2159 |
for (cmpn = 0; cmpn < NCMPS; cmpn++) { |
|
2160 |
Node* cmp = cmps[cmpn]; |
|
2161 |
if (cmp == NULL) continue; |
|
2162 |
for (DUIterator_Fast jmax, j = cmp->fast_outs(jmax); j < jmax; j++) { |
|
2163 |
Node* bol = cmp->fast_out(j); |
|
2164 |
if (!bol->is_Bool()) continue; |
|
2165 |
BoolTest::mask btest = bol->as_Bool()->_test._test; |
|
2166 |
if (btest == BoolTest::eq || btest == BoolTest::ne) continue; |
|
2167 |
if (cmp->in(1) == ykey) btest = BoolTest(btest).commute(); |
|
2168 |
if (bol->outcnt() > (best_bol == NULL ? 0 : best_bol->outcnt())) { |
|
2169 |
best_bol = bol->as_Bool(); |
|
2170 |
best_btest = btest; |
|
2171 |
} |
|
2172 |
} |
|
2173 |
} |
|
2174 |
||
2175 |
Node* answer_if_true = NULL; |
|
2176 |
Node* answer_if_false = NULL; |
|
2177 |
switch (best_btest) { |
|
2178 |
default: |
|
2179 |
if (cmpxy == NULL) |
|
2180 |
cmpxy = ideal_cmpxy; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2181 |
best_bol = _gvn.transform(new BoolNode(cmpxy, BoolTest::lt)); |
1 | 2182 |
// and fall through: |
2183 |
case BoolTest::lt: // x < y |
|
2184 |
case BoolTest::le: // x <= y |
|
2185 |
answer_if_true = (want_max ? yvalue : xvalue); |
|
2186 |
answer_if_false = (want_max ? xvalue : yvalue); |
|
2187 |
break; |
|
2188 |
case BoolTest::gt: // x > y |
|
2189 |
case BoolTest::ge: // x >= y |
|
2190 |
answer_if_true = (want_max ? xvalue : yvalue); |
|
2191 |
answer_if_false = (want_max ? yvalue : xvalue); |
|
2192 |
break; |
|
2193 |
} |
|
2194 |
||
2195 |
jint hi, lo; |
|
2196 |
if (want_max) { |
|
2197 |
// We can sharpen the minimum. |
|
2198 |
hi = MAX2(txvalue->_hi, tyvalue->_hi); |
|
2199 |
lo = MAX2(txvalue->_lo, tyvalue->_lo); |
|
2200 |
} else { |
|
2201 |
// We can sharpen the maximum. |
|
2202 |
hi = MIN2(txvalue->_hi, tyvalue->_hi); |
|
2203 |
lo = MIN2(txvalue->_lo, tyvalue->_lo); |
|
2204 |
} |
|
2205 |
||
2206 |
// Use a flow-free graph structure, to avoid creating excess control edges |
|
2207 |
// which could hinder other optimizations. |
|
2208 |
// Since Math.min/max is often used with arraycopy, we want |
|
2209 |
// tightly_coupled_allocation to be able to see beyond min/max expressions. |
|
25930 | 2210 |
Node* cmov = CMoveNode::make(NULL, best_bol, |
1 | 2211 |
answer_if_false, answer_if_true, |
2212 |
TypeInt::make(lo, hi, widen)); |
|
2213 |
||
2214 |
return _gvn.transform(cmov); |
|
2215 |
||
2216 |
/* |
|
2217 |
// This is not as desirable as it may seem, since Min and Max |
|
2218 |
// nodes do not have a full set of optimizations. |
|
2219 |
// And they would interfere, anyway, with 'if' optimizations |
|
2220 |
// and with CMoveI canonical forms. |
|
2221 |
switch (id) { |
|
2222 |
case vmIntrinsics::_min: |
|
2223 |
result_val = _gvn.transform(new (C, 3) MinINode(x,y)); break; |
|
2224 |
case vmIntrinsics::_max: |
|
2225 |
result_val = _gvn.transform(new (C, 3) MaxINode(x,y)); break; |
|
2226 |
default: |
|
2227 |
ShouldNotReachHere(); |
|
2228 |
} |
|
2229 |
*/ |
|
2230 |
} |
|
2231 |
||
2232 |
inline int |
|
2233 |
LibraryCallKit::classify_unsafe_addr(Node* &base, Node* &offset) { |
|
2234 |
const TypePtr* base_type = TypePtr::NULL_PTR; |
|
2235 |
if (base != NULL) base_type = _gvn.type(base)->isa_ptr(); |
|
2236 |
if (base_type == NULL) { |
|
2237 |
// Unknown type. |
|
2238 |
return Type::AnyPtr; |
|
2239 |
} else if (base_type == TypePtr::NULL_PTR) { |
|
2240 |
// Since this is a NULL+long form, we have to switch to a rawptr. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2241 |
base = _gvn.transform(new CastX2PNode(offset)); |
1 | 2242 |
offset = MakeConX(0); |
2243 |
return Type::RawPtr; |
|
2244 |
} else if (base_type->base() == Type::RawPtr) { |
|
2245 |
return Type::RawPtr; |
|
2246 |
} else if (base_type->isa_oopptr()) { |
|
2247 |
// Base is never null => always a heap address. |
|
2248 |
if (base_type->ptr() == TypePtr::NotNull) { |
|
2249 |
return Type::OopPtr; |
|
2250 |
} |
|
2251 |
// Offset is small => always a heap address. |
|
2252 |
const TypeX* offset_type = _gvn.type(offset)->isa_intptr_t(); |
|
2253 |
if (offset_type != NULL && |
|
2254 |
base_type->offset() == 0 && // (should always be?) |
|
2255 |
offset_type->_lo >= 0 && |
|
2256 |
!MacroAssembler::needs_explicit_null_check(offset_type->_hi)) { |
|
2257 |
return Type::OopPtr; |
|
2258 |
} |
|
2259 |
// Otherwise, it might either be oop+off or NULL+addr. |
|
2260 |
return Type::AnyPtr; |
|
2261 |
} else { |
|
2262 |
// No information: |
|
2263 |
return Type::AnyPtr; |
|
2264 |
} |
|
2265 |
} |
|
2266 |
||
2267 |
inline Node* LibraryCallKit::make_unsafe_address(Node* base, Node* offset) { |
|
2268 |
int kind = classify_unsafe_addr(base, offset); |
|
2269 |
if (kind == Type::RawPtr) { |
|
2270 |
return basic_plus_adr(top(), base, offset); |
|
2271 |
} else { |
|
2272 |
return basic_plus_adr(base, offset); |
|
2273 |
} |
|
2274 |
} |
|
2275 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2276 |
//--------------------------inline_number_methods----------------------------- |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2277 |
// inline int Integer.numberOfLeadingZeros(int) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2278 |
// inline int Long.numberOfLeadingZeros(long) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2279 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2280 |
// inline int Integer.numberOfTrailingZeros(int) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2281 |
// inline int Long.numberOfTrailingZeros(long) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2282 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2283 |
// inline int Integer.bitCount(int) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2284 |
// inline int Long.bitCount(long) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2285 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2286 |
// inline char Character.reverseBytes(char) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2287 |
// inline short Short.reverseBytes(short) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2288 |
// inline int Integer.reverseBytes(int) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2289 |
// inline long Long.reverseBytes(long) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2290 |
bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2291 |
Node* arg = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2292 |
Node* n; |
2862
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
2293 |
switch (id) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2294 |
case vmIntrinsics::_numberOfLeadingZeros_i: n = new CountLeadingZerosINode( arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2295 |
case vmIntrinsics::_numberOfLeadingZeros_l: n = new CountLeadingZerosLNode( arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2296 |
case vmIntrinsics::_numberOfTrailingZeros_i: n = new CountTrailingZerosINode(arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2297 |
case vmIntrinsics::_numberOfTrailingZeros_l: n = new CountTrailingZerosLNode(arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2298 |
case vmIntrinsics::_bitCount_i: n = new PopCountINode( arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2299 |
case vmIntrinsics::_bitCount_l: n = new PopCountLNode( arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2300 |
case vmIntrinsics::_reverseBytes_c: n = new ReverseBytesUSNode(0, arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2301 |
case vmIntrinsics::_reverseBytes_s: n = new ReverseBytesSNode( 0, arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2302 |
case vmIntrinsics::_reverseBytes_i: n = new ReverseBytesINode( 0, arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2303 |
case vmIntrinsics::_reverseBytes_l: n = new ReverseBytesLNode( 0, arg); break; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2304 |
default: fatal_unexpected_iid(id); break; |
2862
fad636edf18f
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents:
2574
diff
changeset
|
2305 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2306 |
set_result(_gvn.transform(n)); |
1 | 2307 |
return true; |
2308 |
} |
|
2309 |
||
2310 |
//----------------------------inline_unsafe_access---------------------------- |
|
2311 |
||
2312 |
const static BasicType T_ADDRESS_HOLDER = T_LONG; |
|
2313 |
||
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2314 |
// Helper that guards and inserts a pre-barrier. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2315 |
void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset, |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2316 |
Node* pre_val, bool need_mem_bar) { |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2317 |
// We could be accessing the referent field of a reference object. If so, when G1 |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2318 |
// is enabled, we need to log the value in the referent field in an SATB buffer. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2319 |
// This routine performs some compile time filters and generates suitable |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2320 |
// runtime filters that guard the pre-barrier code. |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2321 |
// Also add memory barrier for non volatile load from the referent field |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2322 |
// to prevent commoning of loads across safepoint. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2323 |
if (!UseG1GC && !need_mem_bar) |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2324 |
return; |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2325 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2326 |
// Some compile time checks. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2327 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2328 |
// If offset is a constant, is it java_lang_ref_Reference::_reference_offset? |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2329 |
const TypeX* otype = offset->find_intptr_t_type(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2330 |
if (otype != NULL && otype->is_con() && |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2331 |
otype->get_con() != java_lang_ref_Reference::referent_offset) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2332 |
// Constant offset but not the reference_offset so just return |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2333 |
return; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2334 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2335 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2336 |
// We only need to generate the runtime guards for instances. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2337 |
const TypeOopPtr* btype = base_oop->bottom_type()->isa_oopptr(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2338 |
if (btype != NULL) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2339 |
if (btype->isa_aryptr()) { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2340 |
// Array type so nothing to do |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2341 |
return; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2342 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2343 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2344 |
const TypeInstPtr* itype = btype->isa_instptr(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2345 |
if (itype != NULL) { |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2346 |
// Can the klass of base_oop be statically determined to be |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2347 |
// _not_ a sub-class of Reference and _not_ Object? |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2348 |
ciKlass* klass = itype->klass(); |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2349 |
if ( klass->is_loaded() && |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2350 |
!klass->is_subtype_of(env()->Reference_klass()) && |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2351 |
!env()->Object_klass()->is_subtype_of(klass)) { |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2352 |
return; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2353 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2354 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2355 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2356 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2357 |
// The compile time filters did not reject base_oop/offset so |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2358 |
// we need to generate the following runtime filters |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2359 |
// |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2360 |
// if (offset == java_lang_ref_Reference::_reference_offset) { |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2361 |
// if (instance_of(base, java.lang.ref.Reference)) { |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2362 |
// pre_barrier(_, pre_val, ...); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2363 |
// } |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2364 |
// } |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2365 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2366 |
float likely = PROB_LIKELY( 0.999); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2367 |
float unlikely = PROB_UNLIKELY(0.999); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2368 |
|
9182 | 2369 |
IdealKit ideal(this); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2370 |
#define __ ideal. |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2371 |
|
9181
d32bbcce6b1f
7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure
johnc
parents:
9179
diff
changeset
|
2372 |
Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2373 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2374 |
__ if_then(offset, BoolTest::eq, referent_off, unlikely); { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2375 |
// Update graphKit memory and control from IdealKit. |
9182 | 2376 |
sync_kit(ideal); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2377 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2378 |
Node* ref_klass_con = makecon(TypeKlassPtr::make(env()->Reference_klass())); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2379 |
Node* is_instof = gen_instanceof(base_oop, ref_klass_con); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2380 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2381 |
// Update IdealKit memory and control from graphKit. |
9182 | 2382 |
__ sync_kit(this); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2383 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2384 |
Node* one = __ ConI(1); |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2385 |
// is_instof == 0 if base_oop == NULL |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2386 |
__ if_then(is_instof, BoolTest::eq, one, unlikely); { |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2387 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2388 |
// Update graphKit from IdeakKit. |
9182 | 2389 |
sync_kit(ideal); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2390 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2391 |
// Use the pre-barrier to record the value in the referent field |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2392 |
pre_barrier(false /* do_load */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2393 |
__ ctrl(), |
9185
7b717a00a48e
7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents:
9182
diff
changeset
|
2394 |
NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2395 |
pre_val /* pre_val */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2396 |
T_OBJECT); |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2397 |
if (need_mem_bar) { |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2398 |
// Add memory barrier to prevent commoning reads from this field |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2399 |
// across safepoint since GC can change its value. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2400 |
insert_mem_bar(Op_MemBarCPUOrder); |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2401 |
} |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2402 |
// Update IdealKit from graphKit. |
9182 | 2403 |
__ sync_kit(this); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2404 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2405 |
} __ end_if(); // _ref_type != ref_none |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2406 |
} __ end_if(); // offset == referent_offset |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2407 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2408 |
// Final sync IdealKit and GraphKit. |
9182 | 2409 |
final_sync(ideal); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2410 |
#undef __ |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2411 |
} |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2412 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2413 |
|
1 | 2414 |
// Interpret Unsafe.fieldOffset cookies correctly: |
2415 |
extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset); |
|
2416 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2417 |
const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2418 |
// Attempt to infer a sharper value type from the offset and base type. |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2419 |
ciKlass* sharpened_klass = NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2420 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2421 |
// See if it is an instance field, with an object type. |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2422 |
if (alias_type->field() != NULL) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2423 |
assert(!is_native_ptr, "native pointer op cannot use a java address"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2424 |
if (alias_type->field()->type()->is_klass()) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2425 |
sharpened_klass = alias_type->field()->type()->as_klass(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2426 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2427 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2428 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2429 |
// See if it is a narrow oop array. |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2430 |
if (adr_type->isa_aryptr()) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2431 |
if (adr_type->offset() >= objArrayOopDesc::base_offset_in_bytes()) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2432 |
const TypeOopPtr *elem_type = adr_type->is_aryptr()->elem()->isa_oopptr(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2433 |
if (elem_type != NULL) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2434 |
sharpened_klass = elem_type->klass(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2435 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2436 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2437 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2438 |
|
13968
8c9029c01470
8000263: JSR 292: signature types may appear to be unloaded
twisti
parents:
13895
diff
changeset
|
2439 |
// The sharpened class might be unloaded if there is no class loader |
8c9029c01470
8000263: JSR 292: signature types may appear to be unloaded
twisti
parents:
13895
diff
changeset
|
2440 |
// contraint in place. |
8c9029c01470
8000263: JSR 292: signature types may appear to be unloaded
twisti
parents:
13895
diff
changeset
|
2441 |
if (sharpened_klass != NULL && sharpened_klass->is_loaded()) { |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2442 |
const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2443 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2444 |
#ifndef PRODUCT |
20073 | 2445 |
if (C->print_intrinsics() || C->print_inlining()) { |
13968
8c9029c01470
8000263: JSR 292: signature types may appear to be unloaded
twisti
parents:
13895
diff
changeset
|
2446 |
tty->print(" from base type: "); adr_type->dump(); |
8c9029c01470
8000263: JSR 292: signature types may appear to be unloaded
twisti
parents:
13895
diff
changeset
|
2447 |
tty->print(" sharpened value: "); tjp->dump(); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2448 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2449 |
#endif |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2450 |
// Sharpen the value type. |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2451 |
return tjp; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2452 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2453 |
return NULL; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2454 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2455 |
|
1 | 2456 |
bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile) { |
2457 |
if (callee()->is_static()) return false; // caller must have the capability! |
|
2458 |
||
2459 |
#ifndef PRODUCT |
|
2460 |
{ |
|
2461 |
ResourceMark rm; |
|
2462 |
// Check the signatures. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2463 |
ciSignature* sig = callee()->signature(); |
1 | 2464 |
#ifdef ASSERT |
2465 |
if (!is_store) { |
|
2466 |
// Object getObject(Object base, int/long offset), etc. |
|
2467 |
BasicType rtype = sig->return_type()->basic_type(); |
|
2468 |
if (rtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::getAddress_name()) |
|
2469 |
rtype = T_ADDRESS; // it is really a C void* |
|
2470 |
assert(rtype == type, "getter must return the expected value"); |
|
2471 |
if (!is_native_ptr) { |
|
2472 |
assert(sig->count() == 2, "oop getter has 2 arguments"); |
|
2473 |
assert(sig->type_at(0)->basic_type() == T_OBJECT, "getter base is object"); |
|
2474 |
assert(sig->type_at(1)->basic_type() == T_LONG, "getter offset is correct"); |
|
2475 |
} else { |
|
2476 |
assert(sig->count() == 1, "native getter has 1 argument"); |
|
2477 |
assert(sig->type_at(0)->basic_type() == T_LONG, "getter base is long"); |
|
2478 |
} |
|
2479 |
} else { |
|
2480 |
// void putObject(Object base, int/long offset, Object x), etc. |
|
2481 |
assert(sig->return_type()->basic_type() == T_VOID, "putter must not return a value"); |
|
2482 |
if (!is_native_ptr) { |
|
2483 |
assert(sig->count() == 3, "oop putter has 3 arguments"); |
|
2484 |
assert(sig->type_at(0)->basic_type() == T_OBJECT, "putter base is object"); |
|
2485 |
assert(sig->type_at(1)->basic_type() == T_LONG, "putter offset is correct"); |
|
2486 |
} else { |
|
2487 |
assert(sig->count() == 2, "native putter has 2 arguments"); |
|
2488 |
assert(sig->type_at(0)->basic_type() == T_LONG, "putter base is long"); |
|
2489 |
} |
|
2490 |
BasicType vtype = sig->type_at(sig->count()-1)->basic_type(); |
|
2491 |
if (vtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::putAddress_name()) |
|
2492 |
vtype = T_ADDRESS; // it is really a C void* |
|
2493 |
assert(vtype == type, "putter must accept the expected value"); |
|
2494 |
} |
|
2495 |
#endif // ASSERT |
|
2496 |
} |
|
2497 |
#endif //PRODUCT |
|
2498 |
||
2499 |
C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
|
2500 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2501 |
Node* receiver = argument(0); // type: oop |
1 | 2502 |
|
28954
7dda6c26cc98
8068977: Remove unused sun.misc.Unsafe prefetch intrinsic support
psandoz
parents:
28719
diff
changeset
|
2503 |
// Build address expression. |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2504 |
Node* adr; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2505 |
Node* heap_base_oop = top(); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2506 |
Node* offset = top(); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2507 |
Node* val; |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2508 |
|
1 | 2509 |
if (!is_native_ptr) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2510 |
// The base is either a Java object or a value produced by Unsafe.staticFieldBase |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2511 |
Node* base = argument(1); // type: oop |
1 | 2512 |
// The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2513 |
offset = argument(2); // type: long |
1 | 2514 |
// We currently rely on the cookies produced by Unsafe.xxxFieldOffset |
2515 |
// to be plain byte offsets, which are also the same as those accepted |
|
2516 |
// by oopDesc::field_base. |
|
2517 |
assert(Unsafe_field_offset_to_byte_offset(11) == 11, |
|
2518 |
"fieldOffset must be byte-scaled"); |
|
2519 |
// 32-bit machines ignore the high half! |
|
2520 |
offset = ConvL2X(offset); |
|
2521 |
adr = make_unsafe_address(base, offset); |
|
2522 |
heap_base_oop = base; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2523 |
val = is_store ? argument(4) : NULL; |
1 | 2524 |
} else { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2525 |
Node* ptr = argument(1); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2526 |
ptr = ConvL2X(ptr); // adjust Java long to machine word |
1 | 2527 |
adr = make_unsafe_address(NULL, ptr); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2528 |
val = is_store ? argument(3) : NULL; |
1 | 2529 |
} |
2530 |
||
2531 |
const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
|
2532 |
||
2533 |
// First guess at the value type. |
|
2534 |
const Type *value_type = Type::get_const_basic_type(type); |
|
2535 |
||
2536 |
// Try to categorize the address. If it comes up as TypeJavaPtr::BOTTOM, |
|
2537 |
// there was not enough information to nail it down. |
|
2538 |
Compile::AliasType* alias_type = C->alias_type(adr_type); |
|
2539 |
assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
|
2540 |
||
2541 |
// We will need memory barriers unless we can determine a unique |
|
2542 |
// alias category for this reference. (Note: If for some reason |
|
2543 |
// the barriers get omitted and the unsafe reference begins to "pollute" |
|
2544 |
// the alias analysis of the rest of the graph, either Compile::can_alias |
|
2545 |
// or Compile::must_alias will throw a diagnostic assert.) |
|
2546 |
bool need_mem_bar = (alias_type->adr_type() == TypeOopPtr::BOTTOM); |
|
2547 |
||
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2548 |
// If we are reading the value of the referent field of a Reference |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2549 |
// object (either by using Unsafe directly or through reflection) |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2550 |
// then, if G1 is enabled, we need to record the referent in an |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2551 |
// SATB log buffer using the pre-barrier mechanism. |
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2552 |
// Also we need to add memory barrier to prevent commoning reads |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2553 |
// from this field across safepoint since GC can change its value. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
2554 |
bool need_read_barrier = !is_native_ptr && !is_store && |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2555 |
offset != top() && heap_base_oop != top(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2556 |
|
1 | 2557 |
if (!is_store && type == T_OBJECT) { |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2558 |
const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type, is_native_ptr); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2559 |
if (tjp != NULL) { |
1 | 2560 |
value_type = tjp; |
2561 |
} |
|
2562 |
} |
|
2563 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2564 |
receiver = null_check(receiver); |
1 | 2565 |
if (stopped()) { |
2566 |
return true; |
|
2567 |
} |
|
2568 |
// Heap pointers get a null-check from the interpreter, |
|
2569 |
// as a courtesy. However, this is not guaranteed by Unsafe, |
|
2570 |
// and it is not possible to fully distinguish unintended nulls |
|
2571 |
// from intended ones in this API. |
|
2572 |
||
2573 |
if (is_volatile) { |
|
2574 |
// We need to emit leading and trailing CPU membars (see below) in |
|
2575 |
// addition to memory membars when is_volatile. This is a little |
|
2576 |
// too strong, but avoids the need to insert per-alias-type |
|
2577 |
// volatile membars (for stores; compare Parse::do_put_xxx), which |
|
2131 | 2578 |
// we cannot do effectively here because we probably only have a |
1 | 2579 |
// rough approximation of type. |
2580 |
need_mem_bar = true; |
|
2581 |
// For Stores, place a memory ordering barrier now. |
|
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2582 |
if (is_store) { |
1 | 2583 |
insert_mem_bar(Op_MemBarRelease); |
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2584 |
} else { |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2585 |
if (support_IRIW_for_not_multiple_copy_atomic_cpu) { |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2586 |
insert_mem_bar(Op_MemBarVolatile); |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2587 |
} |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2588 |
} |
1 | 2589 |
} |
2590 |
||
2591 |
// Memory barrier to prevent normal and 'unsafe' accesses from |
|
2592 |
// bypassing each other. Happens after null checks, so the |
|
2593 |
// exception paths do not take memory state from the memory barrier, |
|
2594 |
// so there's no problems making a strong assert about mixing users |
|
2595 |
// of safe & unsafe memory. Otherwise fails in a CTW of rt.jar |
|
2596 |
// around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. |
|
2597 |
if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
|
2598 |
||
2599 |
if (!is_store) { |
|
26171
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
2600 |
MemNode::MemOrd mo = is_volatile ? MemNode::acquire : MemNode::unordered; |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
2601 |
Node* p = make_load(control(), adr, value_type, type, adr_type, mo, is_volatile); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2602 |
// load value |
1 | 2603 |
switch (type) { |
2604 |
case T_BOOLEAN: |
|
2605 |
case T_CHAR: |
|
2606 |
case T_BYTE: |
|
2607 |
case T_SHORT: |
|
2608 |
case T_INT: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2609 |
case T_LONG: |
1 | 2610 |
case T_FLOAT: |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2611 |
case T_DOUBLE: |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2612 |
break; |
1 | 2613 |
case T_OBJECT: |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2614 |
if (need_read_barrier) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2615 |
insert_pre_barrier(heap_base_oop, offset, p, !(is_volatile || need_mem_bar)); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
2616 |
} |
1 | 2617 |
break; |
2618 |
case T_ADDRESS: |
|
2619 |
// Cast to an int type. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2620 |
p = _gvn.transform(new CastP2XNode(NULL, p)); |
23495
f222fac90da2
6653795: C2 intrinsic for Unsafe.getAddress performs pointer sign extension on 32-bit systems
poonam
parents:
23181
diff
changeset
|
2621 |
p = ConvX2UL(p); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2622 |
break; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2623 |
default: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2624 |
fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); |
1 | 2625 |
break; |
2626 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2627 |
// The load node has the control of the preceding MemBarCPUOrder. All |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2628 |
// following nodes will have the control of the MemBarCPUOrder inserted at |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2629 |
// the end of this method. So, pushing the load onto the stack at a later |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2630 |
// point is fine. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2631 |
set_result(p); |
1 | 2632 |
} else { |
2633 |
// place effect of store into memory |
|
2634 |
switch (type) { |
|
2635 |
case T_DOUBLE: |
|
2636 |
val = dstore_rounding(val); |
|
2637 |
break; |
|
2638 |
case T_ADDRESS: |
|
2639 |
// Repackage the long as a pointer. |
|
2640 |
val = ConvL2X(val); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2641 |
val = _gvn.transform(new CastX2PNode(val)); |
1 | 2642 |
break; |
2643 |
} |
|
2644 |
||
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2645 |
MemNode::MemOrd mo = is_volatile ? MemNode::release : MemNode::unordered; |
1 | 2646 |
if (type != T_OBJECT ) { |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2647 |
(void) store_to_memory(control(), adr, val, type, adr_type, mo, is_volatile); |
1 | 2648 |
} else { |
2649 |
// Possibly an oop being stored to Java heap or native memory |
|
2650 |
if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(heap_base_oop))) { |
|
2651 |
// oop to Java heap. |
|
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2652 |
(void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type, mo); |
1 | 2653 |
} else { |
2654 |
// We can't tell at compile time if we are storing in the Java heap or outside |
|
2655 |
// of it. So we need to emit code to conditionally do the proper type of |
|
2656 |
// store. |
|
2657 |
||
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
2658 |
IdealKit ideal(this); |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2659 |
#define __ ideal. |
1 | 2660 |
// QQQ who knows what probability is here?? |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2661 |
__ if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); { |
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2662 |
// Sync IdealKit and graphKit. |
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
2663 |
sync_kit(ideal); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2664 |
Node* st = store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type, mo); |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2665 |
// Update IdealKit memory. |
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
2666 |
__ sync_kit(this); |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2667 |
} __ else_(); { |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2668 |
__ store(__ ctrl(), adr, val, type, alias_type->index(), mo, is_volatile); |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2669 |
} __ end_if(); |
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2670 |
// Final sync IdealKit and GraphKit. |
9100
860ba6f8b53f
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
8872
diff
changeset
|
2671 |
final_sync(ideal); |
3268
f034e0c86895
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
3189
diff
changeset
|
2672 |
#undef __ |
1 | 2673 |
} |
2674 |
} |
|
2675 |
} |
|
2676 |
||
2677 |
if (is_volatile) { |
|
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2678 |
if (!is_store) { |
1 | 2679 |
insert_mem_bar(Op_MemBarAcquire); |
22868
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2680 |
} else { |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2681 |
if (!support_IRIW_for_not_multiple_copy_atomic_cpu) { |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2682 |
insert_mem_bar(Op_MemBarVolatile); |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2683 |
} |
7f6eb436873b
8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents:
22855
diff
changeset
|
2684 |
} |
1 | 2685 |
} |
2686 |
||
2687 |
if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
|
2688 |
||
2689 |
return true; |
|
2690 |
} |
|
2691 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2692 |
//----------------------------inline_unsafe_load_store---------------------------- |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2693 |
// This method serves a couple of different customers (depending on LoadStoreKind): |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2694 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2695 |
// LS_cmpxchg: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2696 |
// public final native boolean compareAndSwapObject(Object o, long offset, Object expected, Object x); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2697 |
// public final native boolean compareAndSwapInt( Object o, long offset, int expected, int x); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2698 |
// public final native boolean compareAndSwapLong( Object o, long offset, long expected, long x); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2699 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2700 |
// LS_xadd: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2701 |
// public int getAndAddInt( Object o, long offset, int delta) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2702 |
// public long getAndAddLong(Object o, long offset, long delta) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2703 |
// |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2704 |
// LS_xchg: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2705 |
// int getAndSet(Object o, long offset, int newValue) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2706 |
// long getAndSet(Object o, long offset, long newValue) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2707 |
// Object getAndSet(Object o, long offset, Object newValue) |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2708 |
// |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2709 |
bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind) { |
1 | 2710 |
// This basic scheme here is the same as inline_unsafe_access, but |
2711 |
// differs in enough details that combining them would make the code |
|
2712 |
// overly confusing. (This is a true fact! I originally combined |
|
2713 |
// them, but even I was confused by it!) As much code/comments as |
|
2714 |
// possible are retained from inline_unsafe_access though to make |
|
2131 | 2715 |
// the correspondences clearer. - dl |
1 | 2716 |
|
2717 |
if (callee()->is_static()) return false; // caller must have the capability! |
|
2718 |
||
2719 |
#ifndef PRODUCT |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2720 |
BasicType rtype; |
1 | 2721 |
{ |
2722 |
ResourceMark rm; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2723 |
// Check the signatures. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2724 |
ciSignature* sig = callee()->signature(); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2725 |
rtype = sig->return_type()->basic_type(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2726 |
if (kind == LS_xadd || kind == LS_xchg) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2727 |
// Check the signatures. |
1 | 2728 |
#ifdef ASSERT |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2729 |
assert(rtype == type, "get and set must return the expected type"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2730 |
assert(sig->count() == 3, "get and set has 3 arguments"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2731 |
assert(sig->type_at(0)->basic_type() == T_OBJECT, "get and set base is object"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2732 |
assert(sig->type_at(1)->basic_type() == T_LONG, "get and set offset is long"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2733 |
assert(sig->type_at(2)->basic_type() == type, "get and set must take expected type as new value/delta"); |
1 | 2734 |
#endif // ASSERT |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2735 |
} else if (kind == LS_cmpxchg) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2736 |
// Check the signatures. |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2737 |
#ifdef ASSERT |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2738 |
assert(rtype == T_BOOLEAN, "CAS must return boolean"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2739 |
assert(sig->count() == 4, "CAS has 4 arguments"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2740 |
assert(sig->type_at(0)->basic_type() == T_OBJECT, "CAS base is object"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2741 |
assert(sig->type_at(1)->basic_type() == T_LONG, "CAS offset is long"); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2742 |
#endif // ASSERT |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2743 |
} else { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2744 |
ShouldNotReachHere(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2745 |
} |
1 | 2746 |
} |
2747 |
#endif //PRODUCT |
|
2748 |
||
2749 |
C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
|
2750 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2751 |
// Get arguments: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2752 |
Node* receiver = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2753 |
Node* base = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2754 |
Node* offset = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2755 |
Node* oldval = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2756 |
Node* newval = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2757 |
if (kind == LS_cmpxchg) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2758 |
const bool two_slot_type = type2size[type] == 2; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2759 |
receiver = argument(0); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2760 |
base = argument(1); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2761 |
offset = argument(2); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2762 |
oldval = argument(4); // type: oop, int, or long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2763 |
newval = argument(two_slot_type ? 6 : 5); // type: oop, int, or long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2764 |
} else if (kind == LS_xadd || kind == LS_xchg){ |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2765 |
receiver = argument(0); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2766 |
base = argument(1); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2767 |
offset = argument(2); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2768 |
oldval = NULL; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2769 |
newval = argument(4); // type: oop, int, or long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2770 |
} |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2771 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2772 |
// Null check receiver. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2773 |
receiver = null_check(receiver); |
1 | 2774 |
if (stopped()) { |
2775 |
return true; |
|
2776 |
} |
|
2777 |
||
2778 |
// Build field offset expression. |
|
2779 |
// We currently rely on the cookies produced by Unsafe.xxxFieldOffset |
|
2780 |
// to be plain byte offsets, which are also the same as those accepted |
|
2781 |
// by oopDesc::field_base. |
|
2782 |
assert(Unsafe_field_offset_to_byte_offset(11) == 11, "fieldOffset must be byte-scaled"); |
|
2783 |
// 32-bit machines ignore the high half of long offsets |
|
2784 |
offset = ConvL2X(offset); |
|
2785 |
Node* adr = make_unsafe_address(base, offset); |
|
2786 |
const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
|
2787 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2788 |
// For CAS, unlike inline_unsafe_access, there seems no point in |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2789 |
// trying to refine types. Just use the coarse types here. |
1 | 2790 |
const Type *value_type = Type::get_const_basic_type(type); |
2791 |
Compile::AliasType* alias_type = C->alias_type(adr_type); |
|
2792 |
assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2793 |
|
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2794 |
if (kind == LS_xchg && type == T_OBJECT) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2795 |
const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2796 |
if (tjp != NULL) { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2797 |
value_type = tjp; |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2798 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2799 |
} |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2800 |
|
1 | 2801 |
int alias_idx = C->get_alias_index(adr_type); |
2802 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2803 |
// Memory-model-wise, a LoadStore acts like a little synchronized |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2804 |
// block, so needs barriers on each side. These don't translate |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2805 |
// into actual barriers on most machines, but we still need rest of |
1 | 2806 |
// compiler to respect ordering. |
2807 |
||
2808 |
insert_mem_bar(Op_MemBarRelease); |
|
2809 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
2810 |
||
2811 |
// 4984716: MemBars must be inserted before this |
|
2812 |
// memory node in order to avoid a false |
|
2813 |
// dependency which will confuse the scheduler. |
|
2814 |
Node *mem = memory(alias_idx); |
|
2815 |
||
2816 |
// For now, we handle only those cases that actually exist: ints, |
|
2817 |
// longs, and Object. Adding others should be straightforward. |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2818 |
Node* load_store; |
1 | 2819 |
switch(type) { |
2820 |
case T_INT: |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2821 |
if (kind == LS_xadd) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2822 |
load_store = _gvn.transform(new GetAndAddINode(control(), mem, adr, newval, adr_type)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2823 |
} else if (kind == LS_xchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2824 |
load_store = _gvn.transform(new GetAndSetINode(control(), mem, adr, newval, adr_type)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2825 |
} else if (kind == LS_cmpxchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2826 |
load_store = _gvn.transform(new CompareAndSwapINode(control(), mem, adr, newval, oldval)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2827 |
} else { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2828 |
ShouldNotReachHere(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2829 |
} |
1 | 2830 |
break; |
2831 |
case T_LONG: |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2832 |
if (kind == LS_xadd) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2833 |
load_store = _gvn.transform(new GetAndAddLNode(control(), mem, adr, newval, adr_type)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2834 |
} else if (kind == LS_xchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2835 |
load_store = _gvn.transform(new GetAndSetLNode(control(), mem, adr, newval, adr_type)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2836 |
} else if (kind == LS_cmpxchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2837 |
load_store = _gvn.transform(new CompareAndSwapLNode(control(), mem, adr, newval, oldval)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2838 |
} else { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2839 |
ShouldNotReachHere(); |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2840 |
} |
1 | 2841 |
break; |
2842 |
case T_OBJECT: |
|
11724
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2843 |
// Transformation of a value which could be NULL pointer (CastPP #NULL) |
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2844 |
// could be delayed during Parse (for example, in adjust_map_after_if()). |
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2845 |
// Execute transformation here to avoid barrier generation in such case. |
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2846 |
if (_gvn.type(newval) == TypePtr::NULL_PTR) |
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2847 |
newval = _gvn.makecon(TypePtr::NULL_PTR); |
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2848 |
|
1500e51fdcbf
7143491: G1 C2 CTW: assert(p2x->outcnt() == 2) failed: expects 2 users: Xor and URShift nodes
kvn
parents:
11446
diff
changeset
|
2849 |
// Reference stores need a store barrier. |
19719
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2850 |
if (kind == LS_xchg) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2851 |
// If pre-barrier must execute before the oop store, old value will require do_load here. |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2852 |
if (!can_move_pre_barrier()) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2853 |
pre_barrier(true /* do_load*/, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2854 |
control(), base, adr, alias_idx, newval, value_type->make_oopptr(), |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2855 |
NULL /* pre_val*/, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2856 |
T_OBJECT); |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2857 |
} // Else move pre_barrier to use load_store value, see below. |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2858 |
} else if (kind == LS_cmpxchg) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2859 |
// Same as for newval above: |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2860 |
if (_gvn.type(oldval) == TypePtr::NULL_PTR) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2861 |
oldval = _gvn.makecon(TypePtr::NULL_PTR); |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2862 |
} |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2863 |
// The only known value which might get overwritten is oldval. |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2864 |
pre_barrier(false /* do_load */, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2865 |
control(), NULL, NULL, max_juint, NULL, NULL, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2866 |
oldval /* pre_val */, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2867 |
T_OBJECT); |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2868 |
} else { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2869 |
ShouldNotReachHere(); |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2870 |
} |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2871 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
207
diff
changeset
|
2872 |
#ifdef _LP64 |
589 | 2873 |
if (adr->bottom_type()->is_ptr_to_narrowoop()) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2874 |
Node *newval_enc = _gvn.transform(new EncodePNode(newval, newval->bottom_type()->make_narrowoop())); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2875 |
if (kind == LS_xchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2876 |
load_store = _gvn.transform(new GetAndSetNNode(control(), mem, adr, |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2877 |
newval_enc, adr_type, value_type->make_narrowoop())); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2878 |
} else { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2879 |
assert(kind == LS_cmpxchg, "wrong LoadStore operation"); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2880 |
Node *oldval_enc = _gvn.transform(new EncodePNode(oldval, oldval->bottom_type()->make_narrowoop())); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2881 |
load_store = _gvn.transform(new CompareAndSwapNNode(control(), mem, adr, |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2882 |
newval_enc, oldval_enc)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2883 |
} |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
207
diff
changeset
|
2884 |
} else |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
207
diff
changeset
|
2885 |
#endif |
767
64fb1fd7186d
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
600
diff
changeset
|
2886 |
{ |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2887 |
if (kind == LS_xchg) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2888 |
load_store = _gvn.transform(new GetAndSetPNode(control(), mem, adr, newval, adr_type, value_type->is_oopptr())); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2889 |
} else { |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2890 |
assert(kind == LS_cmpxchg, "wrong LoadStore operation"); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2891 |
load_store = _gvn.transform(new CompareAndSwapPNode(control(), mem, adr, newval, oldval)); |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2892 |
} |
767
64fb1fd7186d
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
600
diff
changeset
|
2893 |
} |
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2894 |
post_barrier(control(), load_store, base, adr, alias_idx, newval, T_OBJECT, true); |
1 | 2895 |
break; |
2896 |
default: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2897 |
fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); |
1 | 2898 |
break; |
2899 |
} |
|
2900 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2901 |
// SCMemProjNodes represent the memory state of a LoadStore. Their |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2902 |
// main role is to prevent LoadStore nodes from being optimized away |
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2903 |
// when their results aren't used. |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2904 |
Node* proj = _gvn.transform(new SCMemProjNode(load_store)); |
1 | 2905 |
set_memory(proj, alias_idx); |
2906 |
||
19719
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2907 |
if (type == T_OBJECT && kind == LS_xchg) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2908 |
#ifdef _LP64 |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2909 |
if (adr->bottom_type()->is_ptr_to_narrowoop()) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
2910 |
load_store = _gvn.transform(new DecodeNNode(load_store, load_store->get_ptr_type())); |
19719
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2911 |
} |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2912 |
#endif |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2913 |
if (can_move_pre_barrier()) { |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2914 |
// Don't need to load pre_val. The old value is returned by load_store. |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2915 |
// The pre_barrier can execute after the xchg as long as no safepoint |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2916 |
// gets inserted between them. |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2917 |
pre_barrier(false /* do_load */, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2918 |
control(), NULL, NULL, max_juint, NULL, NULL, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2919 |
load_store /* pre_val */, |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2920 |
T_OBJECT); |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2921 |
} |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2922 |
} |
e856f36c853b
8023597: Optimize G1 barriers code for unsafe load_store
kvn
parents:
19337
diff
changeset
|
2923 |
|
1 | 2924 |
// Add the trailing membar surrounding the access |
2925 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
2926 |
insert_mem_bar(Op_MemBarAcquire); |
|
2927 |
||
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
2928 |
assert(type2size[load_store->bottom_type()->basic_type()] == type2size[rtype], "result type should match"); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2929 |
set_result(load_store); |
1 | 2930 |
return true; |
2931 |
} |
|
2932 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2933 |
//----------------------------inline_unsafe_ordered_store---------------------- |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2934 |
// public native void sun.misc.Unsafe.putOrderedObject(Object o, long offset, Object x); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2935 |
// public native void sun.misc.Unsafe.putOrderedInt(Object o, long offset, int x); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2936 |
// public native void sun.misc.Unsafe.putOrderedLong(Object o, long offset, long x); |
1 | 2937 |
bool LibraryCallKit::inline_unsafe_ordered_store(BasicType type) { |
2938 |
// This is another variant of inline_unsafe_access, differing in |
|
2939 |
// that it always issues store-store ("release") barrier and ensures |
|
2940 |
// store-atomicity (which only matters for "long"). |
|
2941 |
||
2942 |
if (callee()->is_static()) return false; // caller must have the capability! |
|
2943 |
||
2944 |
#ifndef PRODUCT |
|
2945 |
{ |
|
2946 |
ResourceMark rm; |
|
2947 |
// Check the signatures. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2948 |
ciSignature* sig = callee()->signature(); |
1 | 2949 |
#ifdef ASSERT |
2950 |
BasicType rtype = sig->return_type()->basic_type(); |
|
2951 |
assert(rtype == T_VOID, "must return void"); |
|
2952 |
assert(sig->count() == 3, "has 3 arguments"); |
|
2953 |
assert(sig->type_at(0)->basic_type() == T_OBJECT, "base is object"); |
|
2954 |
assert(sig->type_at(1)->basic_type() == T_LONG, "offset is long"); |
|
2955 |
#endif // ASSERT |
|
2956 |
} |
|
2957 |
#endif //PRODUCT |
|
2958 |
||
2959 |
C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
|
2960 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2961 |
// Get arguments: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2962 |
Node* receiver = argument(0); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2963 |
Node* base = argument(1); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2964 |
Node* offset = argument(2); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2965 |
Node* val = argument(4); // type: oop, int, or long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2966 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2967 |
// Null check receiver. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2968 |
receiver = null_check(receiver); |
1 | 2969 |
if (stopped()) { |
2970 |
return true; |
|
2971 |
} |
|
2972 |
||
2973 |
// Build field offset expression. |
|
2974 |
assert(Unsafe_field_offset_to_byte_offset(11) == 11, "fieldOffset must be byte-scaled"); |
|
2975 |
// 32-bit machines ignore the high half of long offsets |
|
2976 |
offset = ConvL2X(offset); |
|
2977 |
Node* adr = make_unsafe_address(base, offset); |
|
2978 |
const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
|
2979 |
const Type *value_type = Type::get_const_basic_type(type); |
|
2980 |
Compile::AliasType* alias_type = C->alias_type(adr_type); |
|
2981 |
||
2982 |
insert_mem_bar(Op_MemBarRelease); |
|
2983 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
2984 |
// Ensure that the store is atomic for longs: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
2985 |
const bool require_atomic_access = true; |
1 | 2986 |
Node* store; |
2987 |
if (type == T_OBJECT) // reference stores need a store barrier. |
|
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2988 |
store = store_oop_to_unknown(control(), base, adr, adr_type, val, type, MemNode::release); |
1 | 2989 |
else { |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
2990 |
store = store_to_memory(control(), adr, val, type, adr_type, MemNode::release, require_atomic_access); |
1 | 2991 |
} |
2992 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
2993 |
return true; |
|
2994 |
} |
|
2995 |
||
14832 | 2996 |
bool LibraryCallKit::inline_unsafe_fence(vmIntrinsics::ID id) { |
2997 |
// Regardless of form, don't allow previous ld/st to move down, |
|
2998 |
// then issue acquire, release, or volatile mem_bar. |
|
2999 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
3000 |
switch(id) { |
|
3001 |
case vmIntrinsics::_loadFence: |
|
22855
d637fd28a6c3
8028515: PPPC64 (part 113.2): opto: Introduce LoadFence/StoreFence.
goetz
parents:
22845
diff
changeset
|
3002 |
insert_mem_bar(Op_LoadFence); |
14832 | 3003 |
return true; |
3004 |
case vmIntrinsics::_storeFence: |
|
22855
d637fd28a6c3
8028515: PPPC64 (part 113.2): opto: Introduce LoadFence/StoreFence.
goetz
parents:
22845
diff
changeset
|
3005 |
insert_mem_bar(Op_StoreFence); |
14832 | 3006 |
return true; |
3007 |
case vmIntrinsics::_fullFence: |
|
3008 |
insert_mem_bar(Op_MemBarVolatile); |
|
3009 |
return true; |
|
3010 |
default: |
|
3011 |
fatal_unexpected_iid(id); |
|
3012 |
return false; |
|
3013 |
} |
|
3014 |
} |
|
3015 |
||
19337 | 3016 |
bool LibraryCallKit::klass_needs_init_guard(Node* kls) { |
3017 |
if (!kls->is_Con()) { |
|
3018 |
return true; |
|
3019 |
} |
|
3020 |
const TypeKlassPtr* klsptr = kls->bottom_type()->isa_klassptr(); |
|
3021 |
if (klsptr == NULL) { |
|
3022 |
return true; |
|
3023 |
} |
|
3024 |
ciInstanceKlass* ik = klsptr->klass()->as_instance_klass(); |
|
3025 |
// don't need a guard for a klass that is already initialized |
|
3026 |
return !ik->is_initialized(); |
|
3027 |
} |
|
3028 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3029 |
//----------------------------inline_unsafe_allocate--------------------------- |
19337 | 3030 |
// public native Object sun.misc.Unsafe.allocateInstance(Class<?> cls); |
1 | 3031 |
bool LibraryCallKit::inline_unsafe_allocate() { |
3032 |
if (callee()->is_static()) return false; // caller must have the capability! |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3033 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3034 |
null_check_receiver(); // null-check, then ignore |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3035 |
Node* cls = null_check(argument(1)); |
1 | 3036 |
if (stopped()) return true; |
3037 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3038 |
Node* kls = load_klass_from_mirror(cls, false, NULL, 0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3039 |
kls = null_check(kls); |
1 | 3040 |
if (stopped()) return true; // argument was like int.class |
3041 |
||
19337 | 3042 |
Node* test = NULL; |
3043 |
if (LibraryCallKit::klass_needs_init_guard(kls)) { |
|
3044 |
// Note: The argument might still be an illegal value like |
|
3045 |
// Serializable.class or Object[].class. The runtime will handle it. |
|
3046 |
// But we must make an explicit check for initialization. |
|
3047 |
Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); |
|
3048 |
// Use T_BOOLEAN for InstanceKlass::_init_state so the compiler |
|
3049 |
// can generate code to load it as unsigned byte. |
|
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3050 |
Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); |
19337 | 3051 |
Node* bits = intcon(InstanceKlass::fully_initialized); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3052 |
test = _gvn.transform(new SubINode(inst, bits)); |
19337 | 3053 |
// The 'test' is non-zero if we need to take a slow path. |
3054 |
} |
|
1 | 3055 |
|
3056 |
Node* obj = new_instance(kls, test); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3057 |
set_result(obj); |
1 | 3058 |
return true; |
3059 |
} |
|
3060 |
||
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3061 |
#ifdef TRACE_HAVE_INTRINSICS |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3062 |
/* |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3063 |
* oop -> myklass |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3064 |
* myklass->trace_id |= USED |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3065 |
* return myklass->trace_id & ~0x3 |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3066 |
*/ |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3067 |
bool LibraryCallKit::inline_native_classID() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3068 |
null_check_receiver(); // null-check, then ignore |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3069 |
Node* cls = null_check(argument(1), T_OBJECT); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3070 |
Node* kls = load_klass_from_mirror(cls, false, NULL, 0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3071 |
kls = null_check(kls, T_OBJECT); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3072 |
ByteSize offset = TRACE_ID_OFFSET; |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3073 |
Node* insp = basic_plus_adr(kls, in_bytes(offset)); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3074 |
Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3075 |
Node* bits = longcon(~0x03l); // ignore bit 0 & 1 |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3076 |
Node* andl = _gvn.transform(new AndLNode(tvalue, bits)); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3077 |
Node* clsused = longcon(0x01l); // set the class bit |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3078 |
Node* orl = _gvn.transform(new OrLNode(tvalue, clsused)); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3079 |
|
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3080 |
const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3081 |
store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3082 |
set_result(andl); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3083 |
return true; |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3084 |
} |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3085 |
|
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3086 |
bool LibraryCallKit::inline_native_threadID() { |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3087 |
Node* tls_ptr = NULL; |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3088 |
Node* cur_thr = generate_current_thread(tls_ptr); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3089 |
Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3090 |
Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3091 |
p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::thread_id_offset())); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3092 |
|
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3093 |
Node* threadid = NULL; |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3094 |
size_t thread_id_size = OSThread::thread_id_size(); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3095 |
if (thread_id_size == (size_t) BytesPerLong) { |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3096 |
threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG, MemNode::unordered)); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3097 |
} else if (thread_id_size == (size_t) BytesPerInt) { |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3098 |
threadid = make_load(control(), p, TypeInt::INT, T_INT, MemNode::unordered); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3099 |
} else { |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3100 |
ShouldNotReachHere(); |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3101 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3102 |
set_result(threadid); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3103 |
return true; |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3104 |
} |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3105 |
#endif |
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3106 |
|
1 | 3107 |
//------------------------inline_native_time_funcs-------------- |
3108 |
// inline code for System.currentTimeMillis() and System.nanoTime() |
|
3109 |
// these have the same type and signature |
|
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
12113
diff
changeset
|
3110 |
bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* funcName) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3111 |
const TypeFunc* tf = OptoRuntime::void_long_Type(); |
1 | 3112 |
const TypePtr* no_memory_effects = NULL; |
3113 |
Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3114 |
Node* value = _gvn.transform(new ProjNode(time, TypeFunc::Parms+0)); |
1 | 3115 |
#ifdef ASSERT |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3116 |
Node* value_top = _gvn.transform(new ProjNode(time, TypeFunc::Parms+1)); |
1 | 3117 |
assert(value_top == top(), "second value must be top"); |
3118 |
#endif |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3119 |
set_result(value); |
1 | 3120 |
return true; |
3121 |
} |
|
3122 |
||
3123 |
//------------------------inline_native_currentThread------------------ |
|
3124 |
bool LibraryCallKit::inline_native_currentThread() { |
|
3125 |
Node* junk = NULL; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3126 |
set_result(generate_current_thread(junk)); |
1 | 3127 |
return true; |
3128 |
} |
|
3129 |
||
3130 |
//------------------------inline_native_isInterrupted------------------ |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3131 |
// private native boolean java.lang.Thread.isInterrupted(boolean ClearInterrupted); |
1 | 3132 |
bool LibraryCallKit::inline_native_isInterrupted() { |
3133 |
// Add a fast path to t.isInterrupted(clear_int): |
|
23181
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3134 |
// (t == Thread.current() && |
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3135 |
// (!TLS._osthread._interrupted || WINDOWS_ONLY(false) NOT_WINDOWS(!clear_int))) |
1 | 3136 |
// ? TLS._osthread._interrupted : /*slow path:*/ t.isInterrupted(clear_int) |
3137 |
// So, in the common case that the interrupt bit is false, |
|
3138 |
// we avoid making a call into the VM. Even if the interrupt bit |
|
3139 |
// is true, if the clear_int argument is false, we avoid the VM call. |
|
3140 |
// However, if the receiver is not currentThread, we must call the VM, |
|
3141 |
// because there must be some locking done around the operation. |
|
3142 |
||
3143 |
// We only go to the fast case code if we pass two guards. |
|
3144 |
// Paths which do not pass are accumulated in the slow_region. |
|
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3145 |
|
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3146 |
enum { |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3147 |
no_int_result_path = 1, // t == Thread.current() && !TLS._osthread._interrupted |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3148 |
no_clear_result_path = 2, // t == Thread.current() && TLS._osthread._interrupted && !clear_int |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3149 |
slow_result_path = 3, // slow path: t.isInterrupted(clear_int) |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3150 |
PATH_LIMIT |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3151 |
}; |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3152 |
|
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3153 |
// Ensure that it's not possible to move the load of TLS._osthread._interrupted flag |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3154 |
// out of the function. |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3155 |
insert_mem_bar(Op_MemBarCPUOrder); |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3156 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3157 |
RegionNode* result_rgn = new RegionNode(PATH_LIMIT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3158 |
PhiNode* result_val = new PhiNode(result_rgn, TypeInt::BOOL); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3159 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3160 |
RegionNode* slow_region = new RegionNode(1); |
1 | 3161 |
record_for_igvn(slow_region); |
3162 |
||
3163 |
// (a) Receiving thread must be the current thread. |
|
3164 |
Node* rec_thr = argument(0); |
|
3165 |
Node* tls_ptr = NULL; |
|
3166 |
Node* cur_thr = generate_current_thread(tls_ptr); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3167 |
Node* cmp_thr = _gvn.transform(new CmpPNode(cur_thr, rec_thr)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3168 |
Node* bol_thr = _gvn.transform(new BoolNode(cmp_thr, BoolTest::ne)); |
1 | 3169 |
|
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3170 |
generate_slow_guard(bol_thr, slow_region); |
1 | 3171 |
|
3172 |
// (b) Interrupt bit on TLS must be false. |
|
3173 |
Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); |
|
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3174 |
Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
1 | 3175 |
p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset())); |
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3176 |
|
2874
cb263b90c794
6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
2862
diff
changeset
|
3177 |
// Set the control input on the field _interrupted read to prevent it floating up. |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3178 |
Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT, MemNode::unordered); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3179 |
Node* cmp_bit = _gvn.transform(new CmpINode(int_bit, intcon(0))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3180 |
Node* bol_bit = _gvn.transform(new BoolNode(cmp_bit, BoolTest::ne)); |
1 | 3181 |
|
3182 |
IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); |
|
3183 |
||
3184 |
// First fast path: if (!TLS._interrupted) return false; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3185 |
Node* false_bit = _gvn.transform(new IfFalseNode(iff_bit)); |
1 | 3186 |
result_rgn->init_req(no_int_result_path, false_bit); |
3187 |
result_val->init_req(no_int_result_path, intcon(0)); |
|
3188 |
||
3189 |
// drop through to next case |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3190 |
set_control( _gvn.transform(new IfTrueNode(iff_bit))); |
1 | 3191 |
|
23181
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3192 |
#ifndef TARGET_OS_FAMILY_windows |
1 | 3193 |
// (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path. |
3194 |
Node* clr_arg = argument(1); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3195 |
Node* cmp_arg = _gvn.transform(new CmpINode(clr_arg, intcon(0))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3196 |
Node* bol_arg = _gvn.transform(new BoolNode(cmp_arg, BoolTest::ne)); |
1 | 3197 |
IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN); |
3198 |
||
3199 |
// Second fast path: ... else if (!clear_int) return true; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3200 |
Node* false_arg = _gvn.transform(new IfFalseNode(iff_arg)); |
1 | 3201 |
result_rgn->init_req(no_clear_result_path, false_arg); |
3202 |
result_val->init_req(no_clear_result_path, intcon(1)); |
|
3203 |
||
3204 |
// drop through to next case |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3205 |
set_control( _gvn.transform(new IfTrueNode(iff_arg))); |
23181
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3206 |
#else |
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3207 |
// To return true on Windows you must read the _interrupted field |
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3208 |
// and check the the event state i.e. take the slow path. |
5e692cee40be
8036102: part of the fix for 6498581 lost in mismerge
dsamersoff
parents:
23179
diff
changeset
|
3209 |
#endif // TARGET_OS_FAMILY_windows |
1 | 3210 |
|
3211 |
// (d) Otherwise, go to the slow path. |
|
3212 |
slow_region->add_req(control()); |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
3213 |
set_control( _gvn.transform(slow_region)); |
1 | 3214 |
|
3215 |
if (stopped()) { |
|
3216 |
// There is no slow path. |
|
3217 |
result_rgn->init_req(slow_result_path, top()); |
|
3218 |
result_val->init_req(slow_result_path, top()); |
|
3219 |
} else { |
|
3220 |
// non-virtual because it is a private non-static |
|
3221 |
CallJavaNode* slow_call = generate_method_call(vmIntrinsics::_isInterrupted); |
|
3222 |
||
3223 |
Node* slow_val = set_results_for_java_call(slow_call); |
|
3224 |
// this->control() comes from set_results_for_java_call |
|
3225 |
||
3226 |
Node* fast_io = slow_call->in(TypeFunc::I_O); |
|
3227 |
Node* fast_mem = slow_call->in(TypeFunc::Memory); |
|
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3228 |
|
1 | 3229 |
// These two phis are pre-filled with copies of of the fast IO and Memory |
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3230 |
PhiNode* result_mem = PhiNode::make(result_rgn, fast_mem, Type::MEMORY, TypePtr::BOTTOM); |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3231 |
PhiNode* result_io = PhiNode::make(result_rgn, fast_io, Type::ABIO); |
1 | 3232 |
|
3233 |
result_rgn->init_req(slow_result_path, control()); |
|
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3234 |
result_io ->init_req(slow_result_path, i_o()); |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3235 |
result_mem->init_req(slow_result_path, reset_memory()); |
1 | 3236 |
result_val->init_req(slow_result_path, slow_val); |
3237 |
||
14829
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3238 |
set_all_memory(_gvn.transform(result_mem)); |
03af9abeb93b
8003135: HotSpot inlines and hoists the Thread.currentThread().isInterrupted() out of the loop
vlivanov
parents:
14627
diff
changeset
|
3239 |
set_i_o( _gvn.transform(result_io)); |
1 | 3240 |
} |
3241 |
||
3242 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3243 |
set_result(result_rgn, result_val); |
1 | 3244 |
return true; |
3245 |
} |
|
3246 |
||
3247 |
//---------------------------load_mirror_from_klass---------------------------- |
|
3248 |
// Given a klass oop, load its java mirror (a java.lang.Class oop). |
|
3249 |
Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { |
|
11430
718fc06da49a
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
10566
diff
changeset
|
3250 |
Node* p = basic_plus_adr(klass, in_bytes(Klass::java_mirror_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3251 |
return make_load(NULL, p, TypeInstPtr::MIRROR, T_OBJECT, MemNode::unordered); |
1 | 3252 |
} |
3253 |
||
3254 |
//-----------------------load_klass_from_mirror_common------------------------- |
|
3255 |
// Given a java mirror (a java.lang.Class oop), load its corresponding klass oop. |
|
3256 |
// Test the klass oop for null (signifying a primitive Class like Integer.TYPE), |
|
3257 |
// and branch to the given path on the region. |
|
3258 |
// If never_see_null, take an uncommon trap on null, so we can optimistically |
|
3259 |
// compile for the non-null case. |
|
3260 |
// If the region is NULL, force never_see_null = true. |
|
3261 |
Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror, |
|
3262 |
bool never_see_null, |
|
3263 |
RegionNode* region, |
|
3264 |
int null_path, |
|
3265 |
int offset) { |
|
3266 |
if (region == NULL) never_see_null = true; |
|
3267 |
Node* p = basic_plus_adr(mirror, offset); |
|
3268 |
const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL; |
|
27637
cf68c0af6882
8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents:
27455
diff
changeset
|
3269 |
Node* kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type)); |
1 | 3270 |
Node* null_ctl = top(); |
3271 |
kls = null_check_oop(kls, &null_ctl, never_see_null); |
|
3272 |
if (region != NULL) { |
|
3273 |
// Set region->in(null_path) if the mirror is a primitive (e.g, int.class). |
|
3274 |
region->init_req(null_path, null_ctl); |
|
3275 |
} else { |
|
3276 |
assert(null_ctl == top(), "no loose ends"); |
|
3277 |
} |
|
3278 |
return kls; |
|
3279 |
} |
|
3280 |
||
3281 |
//--------------------(inline_native_Class_query helpers)--------------------- |
|
3282 |
// Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER. |
|
3283 |
// Fall through if (mods & mask) == bits, take the guard otherwise. |
|
3284 |
Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { |
|
3285 |
// Branch around if the given klass has the given modifier bit set. |
|
3286 |
// Like generate_guard, adds a new path onto the region. |
|
11430
718fc06da49a
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
10566
diff
changeset
|
3287 |
Node* modp = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3288 |
Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT, MemNode::unordered); |
1 | 3289 |
Node* mask = intcon(modifier_mask); |
3290 |
Node* bits = intcon(modifier_bits); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3291 |
Node* mbit = _gvn.transform(new AndINode(mods, mask)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3292 |
Node* cmp = _gvn.transform(new CmpINode(mbit, bits)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3293 |
Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); |
1 | 3294 |
return generate_fair_guard(bol, region); |
3295 |
} |
|
3296 |
Node* LibraryCallKit::generate_interface_guard(Node* kls, RegionNode* region) { |
|
3297 |
return generate_access_flags_guard(kls, JVM_ACC_INTERFACE, 0, region); |
|
3298 |
} |
|
3299 |
||
3300 |
//-------------------------inline_native_Class_query------------------- |
|
3301 |
bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { |
|
3302 |
const Type* return_type = TypeInt::BOOL; |
|
3303 |
Node* prim_return_value = top(); // what happens if it's a primitive class? |
|
3304 |
bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
|
3305 |
bool expect_prim = false; // most of these guys expect to work on refs |
|
3306 |
||
3307 |
enum { _normal_path = 1, _prim_path = 2, PATH_LIMIT }; |
|
3308 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3309 |
Node* mirror = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3310 |
Node* obj = top(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3311 |
|
1 | 3312 |
switch (id) { |
3313 |
case vmIntrinsics::_isInstance: |
|
3314 |
// nothing is an instance of a primitive type |
|
3315 |
prim_return_value = intcon(0); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3316 |
obj = argument(1); |
1 | 3317 |
break; |
3318 |
case vmIntrinsics::_getModifiers: |
|
3319 |
prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
|
3320 |
assert(is_power_of_2((int)JVM_ACC_WRITTEN_FLAGS+1), "change next line"); |
|
3321 |
return_type = TypeInt::make(0, JVM_ACC_WRITTEN_FLAGS, Type::WidenMin); |
|
3322 |
break; |
|
3323 |
case vmIntrinsics::_isInterface: |
|
3324 |
prim_return_value = intcon(0); |
|
3325 |
break; |
|
3326 |
case vmIntrinsics::_isArray: |
|
3327 |
prim_return_value = intcon(0); |
|
3328 |
expect_prim = true; // cf. ObjectStreamClass.getClassSignature |
|
3329 |
break; |
|
3330 |
case vmIntrinsics::_isPrimitive: |
|
3331 |
prim_return_value = intcon(1); |
|
3332 |
expect_prim = true; // obviously |
|
3333 |
break; |
|
3334 |
case vmIntrinsics::_getSuperclass: |
|
3335 |
prim_return_value = null(); |
|
3336 |
return_type = TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR); |
|
3337 |
break; |
|
3338 |
case vmIntrinsics::_getClassAccessFlags: |
|
3339 |
prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
|
3340 |
return_type = TypeInt::INT; // not bool! 6297094 |
|
3341 |
break; |
|
3342 |
default: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3343 |
fatal_unexpected_iid(id); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3344 |
break; |
1 | 3345 |
} |
3346 |
||
3347 |
const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr(); |
|
3348 |
if (mirror_con == NULL) return false; // cannot happen? |
|
3349 |
||
3350 |
#ifndef PRODUCT |
|
20073 | 3351 |
if (C->print_intrinsics() || C->print_inlining()) { |
1 | 3352 |
ciType* k = mirror_con->java_mirror_type(); |
3353 |
if (k) { |
|
3354 |
tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id())); |
|
3355 |
k->print_name(); |
|
3356 |
tty->cr(); |
|
3357 |
} |
|
3358 |
} |
|
3359 |
#endif |
|
3360 |
||
3361 |
// Null-check the mirror, and the mirror's klass ptr (in case it is a primitive). |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3362 |
RegionNode* region = new RegionNode(PATH_LIMIT); |
1 | 3363 |
record_for_igvn(region); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3364 |
PhiNode* phi = new PhiNode(region, return_type); |
1 | 3365 |
|
3366 |
// The mirror will never be null of Reflection.getClassAccessFlags, however |
|
3367 |
// it may be null for Class.isInstance or Class.getModifiers. Throw a NPE |
|
3368 |
// if it is. See bug 4774291. |
|
3369 |
||
3370 |
// For Reflection.getClassAccessFlags(), the null check occurs in |
|
3371 |
// the wrong place; see inline_unsafe_access(), above, for a similar |
|
3372 |
// situation. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3373 |
mirror = null_check(mirror); |
1 | 3374 |
// If mirror or obj is dead, only null-path is taken. |
3375 |
if (stopped()) return true; |
|
3376 |
||
3377 |
if (expect_prim) never_see_null = false; // expect nulls (meaning prims) |
|
3378 |
||
3379 |
// Now load the mirror's klass metaobject, and null-check it. |
|
3380 |
// Side-effects region with the control path if the klass is null. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3381 |
Node* kls = load_klass_from_mirror(mirror, never_see_null, region, _prim_path); |
1 | 3382 |
// If kls is null, we have a primitive mirror. |
3383 |
phi->init_req(_prim_path, prim_return_value); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3384 |
if (stopped()) { set_result(region, phi); return true; } |
21099 | 3385 |
bool safe_for_replace = (region->in(_prim_path) == top()); |
1 | 3386 |
|
3387 |
Node* p; // handy temp |
|
3388 |
Node* null_ctl; |
|
3389 |
||
3390 |
// Now that we have the non-null klass, we can perform the real query. |
|
3391 |
// For constant classes, the query will constant-fold in LoadNode::Value. |
|
3392 |
Node* query_value = top(); |
|
3393 |
switch (id) { |
|
3394 |
case vmIntrinsics::_isInstance: |
|
3395 |
// nothing is an instance of a primitive type |
|
21099 | 3396 |
query_value = gen_instanceof(obj, kls, safe_for_replace); |
1 | 3397 |
break; |
3398 |
||
3399 |
case vmIntrinsics::_getModifiers: |
|
11430
718fc06da49a
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
10566
diff
changeset
|
3400 |
p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3401 |
query_value = make_load(NULL, p, TypeInt::INT, T_INT, MemNode::unordered); |
1 | 3402 |
break; |
3403 |
||
3404 |
case vmIntrinsics::_isInterface: |
|
3405 |
// (To verify this code sequence, check the asserts in JVM_IsInterface.) |
|
3406 |
if (generate_interface_guard(kls, region) != NULL) |
|
3407 |
// A guard was added. If the guard is taken, it was an interface. |
|
3408 |
phi->add_req(intcon(1)); |
|
3409 |
// If we fall through, it's a plain class. |
|
3410 |
query_value = intcon(0); |
|
3411 |
break; |
|
3412 |
||
3413 |
case vmIntrinsics::_isArray: |
|
3414 |
// (To verify this code sequence, check the asserts in JVM_IsArrayClass.) |
|
3415 |
if (generate_array_guard(kls, region) != NULL) |
|
3416 |
// A guard was added. If the guard is taken, it was an array. |
|
3417 |
phi->add_req(intcon(1)); |
|
3418 |
// If we fall through, it's a plain class. |
|
3419 |
query_value = intcon(0); |
|
3420 |
break; |
|
3421 |
||
3422 |
case vmIntrinsics::_isPrimitive: |
|
3423 |
query_value = intcon(0); // "normal" path produces false |
|
3424 |
break; |
|
3425 |
||
3426 |
case vmIntrinsics::_getSuperclass: |
|
3427 |
// The rules here are somewhat unfortunate, but we can still do better |
|
3428 |
// with random logic than with a JNI call. |
|
3429 |
// Interfaces store null or Object as _super, but must report null. |
|
3430 |
// Arrays store an intermediate super as _super, but must report Object. |
|
3431 |
// Other types can report the actual _super. |
|
3432 |
// (To verify this code sequence, check the asserts in JVM_IsInterface.) |
|
3433 |
if (generate_interface_guard(kls, region) != NULL) |
|
3434 |
// A guard was added. If the guard is taken, it was an interface. |
|
3435 |
phi->add_req(null()); |
|
3436 |
if (generate_array_guard(kls, region) != NULL) |
|
3437 |
// A guard was added. If the guard is taken, it was an array. |
|
3438 |
phi->add_req(makecon(TypeInstPtr::make(env()->Object_klass()->java_mirror()))); |
|
3439 |
// If we fall through, it's a plain class. Get its _super. |
|
11430
718fc06da49a
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
10566
diff
changeset
|
3440 |
p = basic_plus_adr(kls, in_bytes(Klass::super_offset())); |
27637
cf68c0af6882
8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents:
27455
diff
changeset
|
3441 |
kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL)); |
1 | 3442 |
null_ctl = top(); |
3443 |
kls = null_check_oop(kls, &null_ctl); |
|
3444 |
if (null_ctl != top()) { |
|
3445 |
// If the guard is taken, Object.superClass is null (both klass and mirror). |
|
3446 |
region->add_req(null_ctl); |
|
3447 |
phi ->add_req(null()); |
|
3448 |
} |
|
3449 |
if (!stopped()) { |
|
3450 |
query_value = load_mirror_from_klass(kls); |
|
3451 |
} |
|
3452 |
break; |
|
3453 |
||
3454 |
case vmIntrinsics::_getClassAccessFlags: |
|
11430
718fc06da49a
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
10566
diff
changeset
|
3455 |
p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3456 |
query_value = make_load(NULL, p, TypeInt::INT, T_INT, MemNode::unordered); |
1 | 3457 |
break; |
3458 |
||
3459 |
default: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3460 |
fatal_unexpected_iid(id); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3461 |
break; |
1 | 3462 |
} |
3463 |
||
3464 |
// Fall-through is the normal case of a query to a real class. |
|
3465 |
phi->init_req(1, query_value); |
|
3466 |
region->init_req(1, control()); |
|
3467 |
||
3468 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3469 |
set_result(region, phi); |
1 | 3470 |
return true; |
3471 |
} |
|
3472 |
||
27450
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3473 |
//-------------------------inline_Class_cast------------------- |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3474 |
bool LibraryCallKit::inline_Class_cast() { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3475 |
Node* mirror = argument(0); // Class |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3476 |
Node* obj = argument(1); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3477 |
const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3478 |
if (mirror_con == NULL) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3479 |
return false; // dead path (mirror->is_top()). |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3480 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3481 |
if (obj == NULL || obj->is_top()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3482 |
return false; // dead path |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3483 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3484 |
const TypeOopPtr* tp = _gvn.type(obj)->isa_oopptr(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3485 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3486 |
// First, see if Class.cast() can be folded statically. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3487 |
// java_mirror_type() returns non-null for compile-time Class constants. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3488 |
ciType* tm = mirror_con->java_mirror_type(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3489 |
if (tm != NULL && tm->is_klass() && |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3490 |
tp != NULL && tp->klass() != NULL) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3491 |
if (!tp->klass()->is_loaded()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3492 |
// Don't use intrinsic when class is not loaded. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3493 |
return false; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3494 |
} else { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3495 |
int static_res = C->static_subtype_check(tm->as_klass(), tp->klass()); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3496 |
if (static_res == Compile::SSC_always_true) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3497 |
// isInstance() is true - fold the code. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3498 |
set_result(obj); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3499 |
return true; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3500 |
} else if (static_res == Compile::SSC_always_false) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3501 |
// Don't use intrinsic, have to throw ClassCastException. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3502 |
// If the reference is null, the non-intrinsic bytecode will |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3503 |
// be optimized appropriately. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3504 |
return false; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3505 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3506 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3507 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3508 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3509 |
// Bailout intrinsic and do normal inlining if exception path is frequent. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3510 |
if (too_many_traps(Deoptimization::Reason_intrinsic)) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3511 |
return false; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3512 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3513 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3514 |
// Generate dynamic checks. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3515 |
// Class.cast() is java implementation of _checkcast bytecode. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3516 |
// Do checkcast (Parse::do_checkcast()) optimizations here. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3517 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3518 |
mirror = null_check(mirror); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3519 |
// If mirror is dead, only null-path is taken. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3520 |
if (stopped()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3521 |
return true; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3522 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3523 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3524 |
// Not-subtype or the mirror's klass ptr is NULL (in case it is a primitive). |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3525 |
enum { _bad_type_path = 1, _prim_path = 2, PATH_LIMIT }; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3526 |
RegionNode* region = new RegionNode(PATH_LIMIT); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3527 |
record_for_igvn(region); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3528 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3529 |
// Now load the mirror's klass metaobject, and null-check it. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3530 |
// If kls is null, we have a primitive mirror and |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3531 |
// nothing is an instance of a primitive type. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3532 |
Node* kls = load_klass_from_mirror(mirror, false, region, _prim_path); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3533 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3534 |
Node* res = top(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3535 |
if (!stopped()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3536 |
Node* bad_type_ctrl = top(); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3537 |
// Do checkcast optimizations. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3538 |
res = gen_checkcast(obj, kls, &bad_type_ctrl); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3539 |
region->init_req(_bad_type_path, bad_type_ctrl); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3540 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3541 |
if (region->in(_prim_path) != top() || |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3542 |
region->in(_bad_type_path) != top()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3543 |
// Let Interpreter throw ClassCastException. |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3544 |
PreserveJVMState pjvms(this); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3545 |
set_control(_gvn.transform(region)); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3546 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3547 |
Deoptimization::Action_maybe_recompile); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3548 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3549 |
if (!stopped()) { |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3550 |
set_result(res); |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3551 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3552 |
return true; |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3553 |
} |
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3554 |
|
603dbcf4f547
8054492: Casting can result in redundant null checks in generated code
kvn
parents:
26584
diff
changeset
|
3555 |
|
1 | 3556 |
//--------------------------inline_native_subtype_check------------------------ |
3557 |
// This intrinsic takes the JNI calls out of the heart of |
|
3558 |
// UnsafeFieldAccessorImpl.set, which improves Field.set, readObject, etc. |
|
3559 |
bool LibraryCallKit::inline_native_subtype_check() { |
|
3560 |
// Pull both arguments off the stack. |
|
3561 |
Node* args[2]; // two java.lang.Class mirrors: superc, subc |
|
3562 |
args[0] = argument(0); |
|
3563 |
args[1] = argument(1); |
|
3564 |
Node* klasses[2]; // corresponding Klasses: superk, subk |
|
3565 |
klasses[0] = klasses[1] = top(); |
|
3566 |
||
3567 |
enum { |
|
3568 |
// A full decision tree on {superc is prim, subc is prim}: |
|
3569 |
_prim_0_path = 1, // {P,N} => false |
|
3570 |
// {P,P} & superc!=subc => false |
|
3571 |
_prim_same_path, // {P,P} & superc==subc => true |
|
3572 |
_prim_1_path, // {N,P} => false |
|
3573 |
_ref_subtype_path, // {N,N} & subtype check wins => true |
|
3574 |
_both_ref_path, // {N,N} & subtype check loses => false |
|
3575 |
PATH_LIMIT |
|
3576 |
}; |
|
3577 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3578 |
RegionNode* region = new RegionNode(PATH_LIMIT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3579 |
Node* phi = new PhiNode(region, TypeInt::BOOL); |
1 | 3580 |
record_for_igvn(region); |
3581 |
||
3582 |
const TypePtr* adr_type = TypeRawPtr::BOTTOM; // memory type of loads |
|
3583 |
const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL; |
|
3584 |
int class_klass_offset = java_lang_Class::klass_offset_in_bytes(); |
|
3585 |
||
3586 |
// First null-check both mirrors and load each mirror's klass metaobject. |
|
3587 |
int which_arg; |
|
3588 |
for (which_arg = 0; which_arg <= 1; which_arg++) { |
|
3589 |
Node* arg = args[which_arg]; |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3590 |
arg = null_check(arg); |
1 | 3591 |
if (stopped()) break; |
14828
bb9dffedf46c
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
14627
diff
changeset
|
3592 |
args[which_arg] = arg; |
1 | 3593 |
|
3594 |
Node* p = basic_plus_adr(arg, class_klass_offset); |
|
27637
cf68c0af6882
8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents:
27455
diff
changeset
|
3595 |
Node* kls = LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, adr_type, kls_type); |
1 | 3596 |
klasses[which_arg] = _gvn.transform(kls); |
3597 |
} |
|
3598 |
||
3599 |
// Having loaded both klasses, test each for null. |
|
3600 |
bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
|
3601 |
for (which_arg = 0; which_arg <= 1; which_arg++) { |
|
3602 |
Node* kls = klasses[which_arg]; |
|
3603 |
Node* null_ctl = top(); |
|
3604 |
kls = null_check_oop(kls, &null_ctl, never_see_null); |
|
3605 |
int prim_path = (which_arg == 0 ? _prim_0_path : _prim_1_path); |
|
3606 |
region->init_req(prim_path, null_ctl); |
|
3607 |
if (stopped()) break; |
|
3608 |
klasses[which_arg] = kls; |
|
3609 |
} |
|
3610 |
||
3611 |
if (!stopped()) { |
|
3612 |
// now we have two reference types, in klasses[0..1] |
|
3613 |
Node* subk = klasses[1]; // the argument to isAssignableFrom |
|
3614 |
Node* superk = klasses[0]; // the receiver |
|
3615 |
region->set_req(_both_ref_path, gen_subtype_check(subk, superk)); |
|
3616 |
// now we have a successful reference subtype check |
|
3617 |
region->set_req(_ref_subtype_path, control()); |
|
3618 |
} |
|
3619 |
||
3620 |
// If both operands are primitive (both klasses null), then |
|
3621 |
// we must return true when they are identical primitives. |
|
3622 |
// It is convenient to test this after the first null klass check. |
|
3623 |
set_control(region->in(_prim_0_path)); // go back to first null check |
|
3624 |
if (!stopped()) { |
|
3625 |
// Since superc is primitive, make a guard for the superc==subc case. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3626 |
Node* cmp_eq = _gvn.transform(new CmpPNode(args[0], args[1])); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3627 |
Node* bol_eq = _gvn.transform(new BoolNode(cmp_eq, BoolTest::eq)); |
1 | 3628 |
generate_guard(bol_eq, region, PROB_FAIR); |
3629 |
if (region->req() == PATH_LIMIT+1) { |
|
3630 |
// A guard was added. If the added guard is taken, superc==subc. |
|
3631 |
region->swap_edges(PATH_LIMIT, _prim_same_path); |
|
3632 |
region->del_req(PATH_LIMIT); |
|
3633 |
} |
|
3634 |
region->set_req(_prim_0_path, control()); // Not equal after all. |
|
3635 |
} |
|
3636 |
||
3637 |
// these are the only paths that produce 'true': |
|
3638 |
phi->set_req(_prim_same_path, intcon(1)); |
|
3639 |
phi->set_req(_ref_subtype_path, intcon(1)); |
|
3640 |
||
3641 |
// pull together the cases: |
|
3642 |
assert(region->req() == PATH_LIMIT, "sane region"); |
|
3643 |
for (uint i = 1; i < region->req(); i++) { |
|
3644 |
Node* ctl = region->in(i); |
|
3645 |
if (ctl == NULL || ctl == top()) { |
|
3646 |
region->set_req(i, top()); |
|
3647 |
phi ->set_req(i, top()); |
|
3648 |
} else if (phi->in(i) == NULL) { |
|
3649 |
phi->set_req(i, intcon(0)); // all other paths produce 'false' |
|
3650 |
} |
|
3651 |
} |
|
3652 |
||
3653 |
set_control(_gvn.transform(region)); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3654 |
set_result(_gvn.transform(phi)); |
1 | 3655 |
return true; |
3656 |
} |
|
3657 |
||
3658 |
//---------------------generate_array_guard_common------------------------ |
|
3659 |
Node* LibraryCallKit::generate_array_guard_common(Node* kls, RegionNode* region, |
|
3660 |
bool obj_array, bool not_array) { |
|
3661 |
// If obj_array/non_array==false/false: |
|
3662 |
// Branch around if the given klass is in fact an array (either obj or prim). |
|
3663 |
// If obj_array/non_array==false/true: |
|
3664 |
// Branch around if the given klass is not an array klass of any kind. |
|
3665 |
// If obj_array/non_array==true/true: |
|
3666 |
// Branch around if the kls is not an oop array (kls is int[], String, etc.) |
|
3667 |
// If obj_array/non_array==true/false: |
|
3668 |
// Branch around if the kls is an oop array (Object[] or subtype) |
|
3669 |
// |
|
3670 |
// Like generate_guard, adds a new path onto the region. |
|
3671 |
jint layout_con = 0; |
|
3672 |
Node* layout_val = get_layout_helper(kls, layout_con); |
|
3673 |
if (layout_val == NULL) { |
|
3674 |
bool query = (obj_array |
|
3675 |
? Klass::layout_helper_is_objArray(layout_con) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
3676 |
: Klass::layout_helper_is_array(layout_con)); |
1 | 3677 |
if (query == not_array) { |
3678 |
return NULL; // never a branch |
|
3679 |
} else { // always a branch |
|
3680 |
Node* always_branch = control(); |
|
3681 |
if (region != NULL) |
|
3682 |
region->add_req(always_branch); |
|
3683 |
set_control(top()); |
|
3684 |
return always_branch; |
|
3685 |
} |
|
3686 |
} |
|
3687 |
// Now test the correct condition. |
|
3688 |
jint nval = (obj_array |
|
3689 |
? ((jint)Klass::_lh_array_tag_type_value |
|
3690 |
<< Klass::_lh_array_tag_shift) |
|
3691 |
: Klass::_lh_neutral_value); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3692 |
Node* cmp = _gvn.transform(new CmpINode(layout_val, intcon(nval))); |
1 | 3693 |
BoolTest::mask btest = BoolTest::lt; // correct for testing is_[obj]array |
3694 |
// invert the test if we are looking for a non-array |
|
3695 |
if (not_array) btest = BoolTest(btest).negate(); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3696 |
Node* bol = _gvn.transform(new BoolNode(cmp, btest)); |
1 | 3697 |
return generate_fair_guard(bol, region); |
3698 |
} |
|
3699 |
||
3700 |
||
3701 |
//-----------------------inline_native_newArray-------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3702 |
// private static native Object java.lang.reflect.newArray(Class<?> componentType, int length); |
1 | 3703 |
bool LibraryCallKit::inline_native_newArray() { |
3704 |
Node* mirror = argument(0); |
|
3705 |
Node* count_val = argument(1); |
|
3706 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3707 |
mirror = null_check(mirror); |
589 | 3708 |
// If mirror or obj is dead, only null-path is taken. |
3709 |
if (stopped()) return true; |
|
1 | 3710 |
|
3711 |
enum { _normal_path = 1, _slow_path = 2, PATH_LIMIT }; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3712 |
RegionNode* result_reg = new RegionNode(PATH_LIMIT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3713 |
PhiNode* result_val = new PhiNode(result_reg, TypeInstPtr::NOTNULL); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3714 |
PhiNode* result_io = new PhiNode(result_reg, Type::ABIO); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3715 |
PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); |
1 | 3716 |
|
3717 |
bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
|
3718 |
Node* klass_node = load_array_klass_from_mirror(mirror, never_see_null, |
|
3719 |
result_reg, _slow_path); |
|
3720 |
Node* normal_ctl = control(); |
|
3721 |
Node* no_array_ctl = result_reg->in(_slow_path); |
|
3722 |
||
3723 |
// Generate code for the slow case. We make a call to newArray(). |
|
3724 |
set_control(no_array_ctl); |
|
3725 |
if (!stopped()) { |
|
3726 |
// Either the input type is void.class, or else the |
|
3727 |
// array klass has not yet been cached. Either the |
|
3728 |
// ensuing call will throw an exception, or else it |
|
3729 |
// will cache the array klass for next time. |
|
3730 |
PreserveJVMState pjvms(this); |
|
3731 |
CallJavaNode* slow_call = generate_method_call_static(vmIntrinsics::_newArray); |
|
3732 |
Node* slow_result = set_results_for_java_call(slow_call); |
|
3733 |
// this->control() comes from set_results_for_java_call |
|
3734 |
result_reg->set_req(_slow_path, control()); |
|
3735 |
result_val->set_req(_slow_path, slow_result); |
|
3736 |
result_io ->set_req(_slow_path, i_o()); |
|
3737 |
result_mem->set_req(_slow_path, reset_memory()); |
|
3738 |
} |
|
3739 |
||
3740 |
set_control(normal_ctl); |
|
3741 |
if (!stopped()) { |
|
3742 |
// Normal case: The array type has been cached in the java.lang.Class. |
|
3743 |
// The following call works fine even if the array type is polymorphic. |
|
3744 |
// It could be a dynamic mix of int[], boolean[], Object[], etc. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3745 |
Node* obj = new_array(klass_node, count_val, 0); // no arguments to push |
1 | 3746 |
result_reg->init_req(_normal_path, control()); |
3747 |
result_val->init_req(_normal_path, obj); |
|
3748 |
result_io ->init_req(_normal_path, i_o()); |
|
3749 |
result_mem->init_req(_normal_path, reset_memory()); |
|
3750 |
} |
|
3751 |
||
3752 |
// Return the combined state. |
|
3753 |
set_i_o( _gvn.transform(result_io) ); |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
3754 |
set_all_memory( _gvn.transform(result_mem)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3755 |
|
1 | 3756 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3757 |
set_result(result_reg, result_val); |
1 | 3758 |
return true; |
3759 |
} |
|
3760 |
||
3761 |
//----------------------inline_native_getLength-------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3762 |
// public static native int java.lang.reflect.Array.getLength(Object array); |
1 | 3763 |
bool LibraryCallKit::inline_native_getLength() { |
3764 |
if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; |
|
3765 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3766 |
Node* array = null_check(argument(0)); |
1 | 3767 |
// If array is dead, only null-path is taken. |
3768 |
if (stopped()) return true; |
|
3769 |
||
3770 |
// Deoptimize if it is a non-array. |
|
3771 |
Node* non_array = generate_non_array_guard(load_object_klass(array), NULL); |
|
3772 |
||
3773 |
if (non_array != NULL) { |
|
3774 |
PreserveJVMState pjvms(this); |
|
3775 |
set_control(non_array); |
|
3776 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
|
3777 |
Deoptimization::Action_maybe_recompile); |
|
3778 |
} |
|
3779 |
||
3780 |
// If control is dead, only non-array-path is taken. |
|
3781 |
if (stopped()) return true; |
|
3782 |
||
3783 |
// The works fine even if the array type is polymorphic. |
|
3784 |
// It could be a dynamic mix of int[], boolean[], Object[], etc. |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3785 |
Node* result = load_array_length(array); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3786 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3787 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3788 |
set_result(result); |
1 | 3789 |
return true; |
3790 |
} |
|
3791 |
||
3792 |
//------------------------inline_array_copyOf---------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3793 |
// public static <T,U> T[] java.util.Arrays.copyOf( U[] original, int newLength, Class<? extends T[]> newType); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3794 |
// public static <T,U> T[] java.util.Arrays.copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType); |
1 | 3795 |
bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { |
3796 |
if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; |
|
3797 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3798 |
// Get the arguments. |
1 | 3799 |
Node* original = argument(0); |
3800 |
Node* start = is_copyOfRange? argument(1): intcon(0); |
|
3801 |
Node* end = is_copyOfRange? argument(2): argument(1); |
|
3802 |
Node* array_type_mirror = is_copyOfRange? argument(3): argument(2); |
|
3803 |
||
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3804 |
Node* newcopy; |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3805 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3806 |
// Set the original stack and the reexecute bit for the interpreter to reexecute |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3807 |
// the bytecode that invokes Arrays.copyOf if deoptimization happens. |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3808 |
{ PreserveReexecuteState preexecs(this); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3809 |
jvms()->set_should_reexecute(true); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3810 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3811 |
array_type_mirror = null_check(array_type_mirror); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3812 |
original = null_check(original); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3813 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3814 |
// Check if a null path was taken unconditionally. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3815 |
if (stopped()) return true; |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3816 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3817 |
Node* orig_length = load_array_length(original); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3818 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3819 |
Node* klass_node = load_klass_from_mirror(array_type_mirror, false, NULL, 0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3820 |
klass_node = null_check(klass_node); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3821 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3822 |
RegionNode* bailout = new RegionNode(1); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3823 |
record_for_igvn(bailout); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3824 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3825 |
// Despite the generic type of Arrays.copyOf, the mirror might be int, int[], etc. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3826 |
// Bail out if that is so. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3827 |
Node* not_objArray = generate_non_objArray_guard(klass_node, bailout); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3828 |
if (not_objArray != NULL) { |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3829 |
// Improve the klass node's type from the new optimistic assumption: |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3830 |
ciKlass* ak = ciArrayKlass::make(env()->Object_klass()); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3831 |
const Type* akls = TypeKlassPtr::make(TypePtr::NotNull, ak, 0/*offset*/); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3832 |
Node* cast = new CastPPNode(klass_node, akls); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3833 |
cast->init_req(0, control()); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3834 |
klass_node = _gvn.transform(cast); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3835 |
} |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3836 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3837 |
// Bail out if either start or end is negative. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3838 |
generate_negative_guard(start, bailout, &start); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3839 |
generate_negative_guard(end, bailout, &end); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3840 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3841 |
Node* length = end; |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3842 |
if (_gvn.type(start) != TypeInt::ZERO) { |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3843 |
length = _gvn.transform(new SubINode(end, start)); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3844 |
} |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3845 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3846 |
// Bail out if length is negative. |
13105
68f3bf10f08e
7174363: Arrays.copyOfRange leads to VM crash with -Xcomp -server if executed by testing framework
roland
parents:
12957
diff
changeset
|
3847 |
// Without this the new_array would throw |
68f3bf10f08e
7174363: Arrays.copyOfRange leads to VM crash with -Xcomp -server if executed by testing framework
roland
parents:
12957
diff
changeset
|
3848 |
// NegativeArraySizeException but IllegalArgumentException is what |
68f3bf10f08e
7174363: Arrays.copyOfRange leads to VM crash with -Xcomp -server if executed by testing framework
roland
parents:
12957
diff
changeset
|
3849 |
// should be thrown |
68f3bf10f08e
7174363: Arrays.copyOfRange leads to VM crash with -Xcomp -server if executed by testing framework
roland
parents:
12957
diff
changeset
|
3850 |
generate_negative_guard(length, bailout, &length); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3851 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3852 |
if (bailout->req() > 1) { |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3853 |
PreserveJVMState pjvms(this); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3854 |
set_control(_gvn.transform(bailout)); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3855 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3856 |
Deoptimization::Action_maybe_recompile); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3857 |
} |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3858 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3859 |
if (!stopped()) { |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3860 |
// How many elements will we copy from the original? |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3861 |
// The answer is MinI(orig_length - start, length). |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3862 |
Node* orig_tail = _gvn.transform(new SubINode(orig_length, start)); |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3863 |
Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3864 |
|
26435
b446202ac824
8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
26434
diff
changeset
|
3865 |
newcopy = new_array(klass_node, length, 0); // no arguments to push |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3866 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3867 |
// Generate a direct call to the right arraycopy function(s). |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3868 |
// We know the copy is disjoint but we might not know if the |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3869 |
// oop stores need checking. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3870 |
// Extreme case: Arrays.copyOf((Integer[])x, 10, String[].class). |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
3871 |
// This will fail a store-check if x contains any non-nulls. |
26166 | 3872 |
|
3873 |
Node* alloc = tightly_coupled_allocation(newcopy, NULL); |
|
3874 |
||
26435
b446202ac824
8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
26434
diff
changeset
|
3875 |
ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, alloc != NULL, |
b446202ac824
8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
26434
diff
changeset
|
3876 |
load_object_klass(original), klass_node); |
26166 | 3877 |
if (!is_copyOfRange) { |
3878 |
ac->set_copyof(); |
|
3879 |
} else { |
|
3880 |
ac->set_copyofrange(); |
|
3881 |
} |
|
3882 |
Node* n = _gvn.transform(ac); |
|
3883 |
assert(n == ac, "cannot disappear"); |
|
3884 |
ac->connect_outputs(this); |
|
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
3885 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3886 |
} // original reexecute is set back here |
1 | 3887 |
|
3888 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3889 |
if (!stopped()) { |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3890 |
set_result(newcopy); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3891 |
} |
1 | 3892 |
return true; |
3893 |
} |
|
3894 |
||
3895 |
||
3896 |
//----------------------generate_virtual_guard--------------------------- |
|
3897 |
// Helper for hashCode and clone. Peeks inside the vtable to avoid a call. |
|
3898 |
Node* LibraryCallKit::generate_virtual_guard(Node* obj_klass, |
|
3899 |
RegionNode* slow_region) { |
|
3900 |
ciMethod* method = callee(); |
|
3901 |
int vtable_index = method->vtable_index(); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19770
diff
changeset
|
3902 |
assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19770
diff
changeset
|
3903 |
err_msg_res("bad index %d", vtable_index)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
3904 |
// Get the Method* out of the appropriate vtable entry. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
3905 |
int entry_offset = (InstanceKlass::vtable_start_offset() + |
1 | 3906 |
vtable_index*vtableEntry::size()) * wordSize + |
3907 |
vtableEntry::method_offset_in_bytes(); |
|
3908 |
Node* entry_addr = basic_plus_adr(obj_klass, entry_offset); |
|
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
3909 |
Node* target_call = make_load(NULL, entry_addr, TypePtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
1 | 3910 |
|
3911 |
// Compare the target method with the expected method (e.g., Object.hashCode). |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
3912 |
const TypePtr* native_call_addr = TypeMetadataPtr::make(method); |
1 | 3913 |
|
3914 |
Node* native_call = makecon(native_call_addr); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3915 |
Node* chk_native = _gvn.transform(new CmpPNode(target_call, native_call)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3916 |
Node* test_native = _gvn.transform(new BoolNode(chk_native, BoolTest::ne)); |
1 | 3917 |
|
3918 |
return generate_slow_guard(test_native, slow_region); |
|
3919 |
} |
|
3920 |
||
3921 |
//-----------------------generate_method_call---------------------------- |
|
3922 |
// Use generate_method_call to make a slow-call to the real |
|
3923 |
// method if the fast path fails. An alternative would be to |
|
3924 |
// use a stub like OptoRuntime::slow_arraycopy_Java. |
|
3925 |
// This only works for expanding the current library call, |
|
3926 |
// not another intrinsic. (E.g., don't use this for making an |
|
3927 |
// arraycopy call inside of the copyOf intrinsic.) |
|
3928 |
CallJavaNode* |
|
3929 |
LibraryCallKit::generate_method_call(vmIntrinsics::ID method_id, bool is_virtual, bool is_static) { |
|
3930 |
// When compiling the intrinsic method itself, do not use this technique. |
|
3931 |
guarantee(callee() != C->method(), "cannot make slow-call to self"); |
|
3932 |
||
3933 |
ciMethod* method = callee(); |
|
3934 |
// ensure the JVMS we have will be correct for this call |
|
3935 |
guarantee(method_id == method->intrinsic_id(), "must match"); |
|
3936 |
||
3937 |
const TypeFunc* tf = TypeFunc::make(method); |
|
3938 |
CallJavaNode* slow_call; |
|
3939 |
if (is_static) { |
|
3940 |
assert(!is_virtual, ""); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3941 |
slow_call = new CallStaticJavaNode(C, tf, |
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13886
diff
changeset
|
3942 |
SharedRuntime::get_resolve_static_call_stub(), |
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13886
diff
changeset
|
3943 |
method, bci()); |
1 | 3944 |
} else if (is_virtual) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3945 |
null_check_receiver(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
3946 |
int vtable_index = Method::invalid_vtable_index; |
1 | 3947 |
if (UseInlineCaches) { |
3948 |
// Suppress the vtable call |
|
3949 |
} else { |
|
3950 |
// hashCode and clone are not a miranda methods, |
|
3951 |
// so the vtable index is fixed. |
|
3952 |
// No need to use the linkResolver to get it. |
|
3953 |
vtable_index = method->vtable_index(); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19770
diff
changeset
|
3954 |
assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19770
diff
changeset
|
3955 |
err_msg_res("bad index %d", vtable_index)); |
1 | 3956 |
} |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3957 |
slow_call = new CallDynamicJavaNode(tf, |
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13886
diff
changeset
|
3958 |
SharedRuntime::get_resolve_virtual_call_stub(), |
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13886
diff
changeset
|
3959 |
method, vtable_index, bci()); |
1 | 3960 |
} else { // neither virtual nor static: opt_virtual |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3961 |
null_check_receiver(); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3962 |
slow_call = new CallStaticJavaNode(C, tf, |
1 | 3963 |
SharedRuntime::get_resolve_opt_virtual_call_stub(), |
3964 |
method, bci()); |
|
3965 |
slow_call->set_optimized_virtual(true); |
|
3966 |
} |
|
3967 |
set_arguments_for_java_call(slow_call); |
|
3968 |
set_edges_for_java_call(slow_call); |
|
3969 |
return slow_call; |
|
3970 |
} |
|
3971 |
||
3972 |
||
24916
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
3973 |
/** |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
3974 |
* Build special case code for calls to hashCode on an object. This call may |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
3975 |
* be virtual (invokevirtual) or bound (invokespecial). For each case we generate |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
3976 |
* slightly different code. |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
3977 |
*/ |
1 | 3978 |
bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { |
3979 |
assert(is_static == callee()->is_static(), "correct intrinsic selection"); |
|
3980 |
assert(!(is_virtual && is_static), "either virtual, special, or static"); |
|
3981 |
||
3982 |
enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT }; |
|
3983 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3984 |
RegionNode* result_reg = new RegionNode(PATH_LIMIT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3985 |
PhiNode* result_val = new PhiNode(result_reg, TypeInt::INT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3986 |
PhiNode* result_io = new PhiNode(result_reg, Type::ABIO); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
3987 |
PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); |
1 | 3988 |
Node* obj = NULL; |
3989 |
if (!is_static) { |
|
3990 |
// Check for hashing null object |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
3991 |
obj = null_check_receiver(); |
1 | 3992 |
if (stopped()) return true; // unconditionally null |
3993 |
result_reg->init_req(_null_path, top()); |
|
3994 |
result_val->init_req(_null_path, top()); |
|
3995 |
} else { |
|
3996 |
// Do a null check, and return zero if null. |
|
3997 |
// System.identityHashCode(null) == 0 |
|
3998 |
obj = argument(0); |
|
3999 |
Node* null_ctl = top(); |
|
4000 |
obj = null_check_oop(obj, &null_ctl); |
|
4001 |
result_reg->init_req(_null_path, null_ctl); |
|
4002 |
result_val->init_req(_null_path, _gvn.intcon(0)); |
|
4003 |
} |
|
4004 |
||
4005 |
// Unconditionally null? Then return right away. |
|
4006 |
if (stopped()) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4007 |
set_control( result_reg->in(_null_path)); |
1 | 4008 |
if (!stopped()) |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4009 |
set_result(result_val->in(_null_path)); |
1 | 4010 |
return true; |
4011 |
} |
|
4012 |
||
4013 |
// We only go to the fast case code if we pass a number of guards. The |
|
4014 |
// paths which do not pass are accumulated in the slow_region. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4015 |
RegionNode* slow_region = new RegionNode(1); |
1 | 4016 |
record_for_igvn(slow_region); |
4017 |
||
4018 |
// If this is a virtual call, we generate a funny guard. We pull out |
|
4019 |
// the vtable entry corresponding to hashCode() from the target object. |
|
4020 |
// If the target method which we are calling happens to be the native |
|
4021 |
// Object hashCode() method, we pass the guard. We do not need this |
|
4022 |
// guard for non-virtual calls -- the caller is known to be the native |
|
4023 |
// Object hashCode(). |
|
4024 |
if (is_virtual) { |
|
24916
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4025 |
// After null check, get the object's klass. |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4026 |
Node* obj_klass = load_object_klass(obj); |
1 | 4027 |
generate_virtual_guard(obj_klass, slow_region); |
4028 |
} |
|
4029 |
||
4030 |
// Get the header out of the object, use LoadMarkNode when available |
|
4031 |
Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); |
|
24916
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4032 |
// The control of the load must be NULL. Otherwise, the load can move before |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4033 |
// the null check after castPP removal. |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4034 |
Node* no_ctrl = NULL; |
bcf892f54aba
8011646: SEGV in compiled code with loop predication
anoll
parents:
24456
diff
changeset
|
4035 |
Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); |
1 | 4036 |
|
4037 |
// Test the header to see if it is unlocked. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4038 |
Node *lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4039 |
Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4040 |
Node *unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4041 |
Node *chk_unlocked = _gvn.transform(new CmpXNode( lmasked_header, unlocked_val)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4042 |
Node *test_unlocked = _gvn.transform(new BoolNode( chk_unlocked, BoolTest::ne)); |
1 | 4043 |
|
4044 |
generate_slow_guard(test_unlocked, slow_region); |
|
4045 |
||
4046 |
// Get the hash value and check to see that it has been properly assigned. |
|
4047 |
// We depend on hash_mask being at most 32 bits and avoid the use of |
|
4048 |
// hash_mask_in_place because it could be larger than 32 bits in a 64-bit |
|
4049 |
// vm: see markOop.hpp. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4050 |
Node *hash_mask = _gvn.intcon(markOopDesc::hash_mask); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4051 |
Node *hash_shift = _gvn.intcon(markOopDesc::hash_shift); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4052 |
Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift)); |
1 | 4053 |
// This hack lets the hash bits live anywhere in the mark object now, as long |
2131 | 4054 |
// as the shift drops the relevant bits into the low 32 bits. Note that |
1 | 4055 |
// Java spec says that HashCode is an int so there's no point in capturing |
4056 |
// an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build). |
|
4057 |
hshifted_header = ConvX2I(hshifted_header); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4058 |
Node *hash_val = _gvn.transform(new AndINode(hshifted_header, hash_mask)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4059 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4060 |
Node *no_hash_val = _gvn.intcon(markOopDesc::no_hash); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4061 |
Node *chk_assigned = _gvn.transform(new CmpINode( hash_val, no_hash_val)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4062 |
Node *test_assigned = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq)); |
1 | 4063 |
|
4064 |
generate_slow_guard(test_assigned, slow_region); |
|
4065 |
||
4066 |
Node* init_mem = reset_memory(); |
|
4067 |
// fill in the rest of the null path: |
|
4068 |
result_io ->init_req(_null_path, i_o()); |
|
4069 |
result_mem->init_req(_null_path, init_mem); |
|
4070 |
||
4071 |
result_val->init_req(_fast_path, hash_val); |
|
4072 |
result_reg->init_req(_fast_path, control()); |
|
4073 |
result_io ->init_req(_fast_path, i_o()); |
|
4074 |
result_mem->init_req(_fast_path, init_mem); |
|
4075 |
||
4076 |
// Generate code for the slow case. We make a call to hashCode(). |
|
4077 |
set_control(_gvn.transform(slow_region)); |
|
4078 |
if (!stopped()) { |
|
4079 |
// No need for PreserveJVMState, because we're using up the present state. |
|
4080 |
set_all_memory(init_mem); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4081 |
vmIntrinsics::ID hashCode_id = is_static ? vmIntrinsics::_identityHashCode : vmIntrinsics::_hashCode; |
1 | 4082 |
CallJavaNode* slow_call = generate_method_call(hashCode_id, is_virtual, is_static); |
4083 |
Node* slow_result = set_results_for_java_call(slow_call); |
|
4084 |
// this->control() comes from set_results_for_java_call |
|
4085 |
result_reg->init_req(_slow_path, control()); |
|
4086 |
result_val->init_req(_slow_path, slow_result); |
|
4087 |
result_io ->set_req(_slow_path, i_o()); |
|
4088 |
result_mem ->set_req(_slow_path, reset_memory()); |
|
4089 |
} |
|
4090 |
||
4091 |
// Return the combined state. |
|
4092 |
set_i_o( _gvn.transform(result_io) ); |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
4093 |
set_all_memory( _gvn.transform(result_mem)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4094 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4095 |
set_result(result_reg, result_val); |
1 | 4096 |
return true; |
4097 |
} |
|
4098 |
||
4099 |
//---------------------------inline_native_getClass---------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4100 |
// public final native Class<?> java.lang.Object.getClass(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4101 |
// |
2131 | 4102 |
// Build special case code for calls to getClass on an object. |
1 | 4103 |
bool LibraryCallKit::inline_native_getClass() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4104 |
Node* obj = null_check_receiver(); |
1 | 4105 |
if (stopped()) return true; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4106 |
set_result(load_mirror_from_klass(load_object_klass(obj))); |
1 | 4107 |
return true; |
4108 |
} |
|
4109 |
||
4110 |
//-----------------inline_native_Reflection_getCallerClass--------------------- |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4111 |
// public static native Class<?> sun.reflect.Reflection.getCallerClass(); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4112 |
// |
1 | 4113 |
// In the presence of deep enough inlining, getCallerClass() becomes a no-op. |
4114 |
// |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4115 |
// NOTE: This code must perform the same logic as JVM_GetCallerClass |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4116 |
// in that it must skip particular security frames and checks for |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4117 |
// caller sensitive methods. |
1 | 4118 |
bool LibraryCallKit::inline_native_Reflection_getCallerClass() { |
4119 |
#ifndef PRODUCT |
|
20073 | 4120 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
1 | 4121 |
tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass"); |
4122 |
} |
|
4123 |
#endif |
|
4124 |
||
4125 |
if (!jvms()->has_method()) { |
|
4126 |
#ifndef PRODUCT |
|
20073 | 4127 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
1 | 4128 |
tty->print_cr(" Bailing out because intrinsic was inlined at top level"); |
4129 |
} |
|
4130 |
#endif |
|
4131 |
return false; |
|
4132 |
} |
|
4133 |
||
4134 |
// Walk back up the JVM state to find the caller at the required |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4135 |
// depth. |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4136 |
JVMState* caller_jvms = jvms(); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4137 |
|
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4138 |
// Cf. JVM_GetCallerClass |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4139 |
// NOTE: Start the loop at depth 1 because the current JVM state does |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4140 |
// not include the Reflection.getCallerClass() frame. |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4141 |
for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) { |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4142 |
ciMethod* m = caller_jvms->method(); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4143 |
switch (n) { |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4144 |
case 0: |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4145 |
fatal("current JVM state does not include the Reflection.getCallerClass frame"); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4146 |
break; |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4147 |
case 1: |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4148 |
// Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass). |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4149 |
if (!m->caller_sensitive()) { |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4150 |
#ifndef PRODUCT |
20073 | 4151 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4152 |
tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4153 |
} |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4154 |
#endif |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4155 |
return false; // bail-out; let JVM_GetCallerClass do the work |
1 | 4156 |
} |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4157 |
break; |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4158 |
default: |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4159 |
if (!m->is_ignored_by_security_stack_walk()) { |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4160 |
// We have reached the desired frame; return the holder class. |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4161 |
// Acquire method holder as java.lang.Class and push as constant. |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4162 |
ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4163 |
ciInstance* caller_mirror = caller_klass->java_mirror(); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4164 |
set_result(makecon(TypeInstPtr::make(caller_mirror))); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4165 |
|
1 | 4166 |
#ifndef PRODUCT |
20073 | 4167 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4168 |
tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth()); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4169 |
tty->print_cr(" JVM state at this point:"); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4170 |
for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4171 |
ciMethod* m = jvms()->of_depth(i)->method(); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4172 |
tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4173 |
} |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4174 |
} |
1 | 4175 |
#endif |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4176 |
return true; |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4177 |
} |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4178 |
break; |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4179 |
} |
1 | 4180 |
} |
4181 |
||
4182 |
#ifndef PRODUCT |
|
20073 | 4183 |
if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4184 |
tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth()); |
1 | 4185 |
tty->print_cr(" JVM state at this point:"); |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4186 |
for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4187 |
ciMethod* m = jvms()->of_depth(i)->method(); |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4188 |
tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); |
1 | 4189 |
} |
4190 |
} |
|
4191 |
#endif |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4192 |
|
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15752
diff
changeset
|
4193 |
return false; // bail-out; let JVM_GetCallerClass do the work |
1 | 4194 |
} |
4195 |
||
4196 |
bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4197 |
Node* arg = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4198 |
Node* result; |
1 | 4199 |
|
4200 |
switch (id) { |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4201 |
case vmIntrinsics::_floatToRawIntBits: result = new MoveF2INode(arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4202 |
case vmIntrinsics::_intBitsToFloat: result = new MoveI2FNode(arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4203 |
case vmIntrinsics::_doubleToRawLongBits: result = new MoveD2LNode(arg); break; |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4204 |
case vmIntrinsics::_longBitsToDouble: result = new MoveL2DNode(arg); break; |
1 | 4205 |
|
4206 |
case vmIntrinsics::_doubleToLongBits: { |
|
4207 |
// two paths (plus control) merge in a wood |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4208 |
RegionNode *r = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4209 |
Node *phi = new PhiNode(r, TypeLong::LONG); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4210 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4211 |
Node *cmpisnan = _gvn.transform(new CmpDNode(arg, arg)); |
1 | 4212 |
// Build the boolean node |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4213 |
Node *bolisnan = _gvn.transform(new BoolNode(cmpisnan, BoolTest::ne)); |
1 | 4214 |
|
4215 |
// Branch either way. |
|
4216 |
// NaN case is less traveled, which makes all the difference. |
|
4217 |
IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
|
4218 |
Node *opt_isnan = _gvn.transform(ifisnan); |
|
4219 |
assert( opt_isnan->is_If(), "Expect an IfNode"); |
|
4220 |
IfNode *opt_ifisnan = (IfNode*)opt_isnan; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4221 |
Node *iftrue = _gvn.transform(new IfTrueNode(opt_ifisnan)); |
1 | 4222 |
|
4223 |
set_control(iftrue); |
|
4224 |
||
4225 |
static const jlong nan_bits = CONST64(0x7ff8000000000000); |
|
4226 |
Node *slow_result = longcon(nan_bits); // return NaN |
|
4227 |
phi->init_req(1, _gvn.transform( slow_result )); |
|
4228 |
r->init_req(1, iftrue); |
|
4229 |
||
4230 |
// Else fall through |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4231 |
Node *iffalse = _gvn.transform(new IfFalseNode(opt_ifisnan)); |
1 | 4232 |
set_control(iffalse); |
4233 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4234 |
phi->init_req(2, _gvn.transform(new MoveD2LNode(arg))); |
1 | 4235 |
r->init_req(2, iffalse); |
4236 |
||
4237 |
// Post merge |
|
4238 |
set_control(_gvn.transform(r)); |
|
4239 |
record_for_igvn(r); |
|
4240 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4241 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4242 |
result = phi; |
1 | 4243 |
assert(result->bottom_type()->isa_long(), "must be"); |
4244 |
break; |
|
4245 |
} |
|
4246 |
||
4247 |
case vmIntrinsics::_floatToIntBits: { |
|
4248 |
// two paths (plus control) merge in a wood |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4249 |
RegionNode *r = new RegionNode(3); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4250 |
Node *phi = new PhiNode(r, TypeInt::INT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4251 |
|
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4252 |
Node *cmpisnan = _gvn.transform(new CmpFNode(arg, arg)); |
1 | 4253 |
// Build the boolean node |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4254 |
Node *bolisnan = _gvn.transform(new BoolNode(cmpisnan, BoolTest::ne)); |
1 | 4255 |
|
4256 |
// Branch either way. |
|
4257 |
// NaN case is less traveled, which makes all the difference. |
|
4258 |
IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
|
4259 |
Node *opt_isnan = _gvn.transform(ifisnan); |
|
4260 |
assert( opt_isnan->is_If(), "Expect an IfNode"); |
|
4261 |
IfNode *opt_ifisnan = (IfNode*)opt_isnan; |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4262 |
Node *iftrue = _gvn.transform(new IfTrueNode(opt_ifisnan)); |
1 | 4263 |
|
4264 |
set_control(iftrue); |
|
4265 |
||
4266 |
static const jint nan_bits = 0x7fc00000; |
|
4267 |
Node *slow_result = makecon(TypeInt::make(nan_bits)); // return NaN |
|
4268 |
phi->init_req(1, _gvn.transform( slow_result )); |
|
4269 |
r->init_req(1, iftrue); |
|
4270 |
||
4271 |
// Else fall through |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4272 |
Node *iffalse = _gvn.transform(new IfFalseNode(opt_ifisnan)); |
1 | 4273 |
set_control(iffalse); |
4274 |
||
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4275 |
phi->init_req(2, _gvn.transform(new MoveF2INode(arg))); |
1 | 4276 |
r->init_req(2, iffalse); |
4277 |
||
4278 |
// Post merge |
|
4279 |
set_control(_gvn.transform(r)); |
|
4280 |
record_for_igvn(r); |
|
4281 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4282 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4283 |
result = phi; |
1 | 4284 |
assert(result->bottom_type()->isa_int(), "must be"); |
4285 |
break; |
|
4286 |
} |
|
4287 |
||
4288 |
default: |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4289 |
fatal_unexpected_iid(id); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4290 |
break; |
1 | 4291 |
} |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4292 |
set_result(_gvn.transform(result)); |
1 | 4293 |
return true; |
4294 |
} |
|
4295 |
||
4296 |
#ifdef _LP64 |
|
4297 |
#define XTOP ,top() /*additional argument*/ |
|
4298 |
#else //_LP64 |
|
4299 |
#define XTOP /*no additional argument*/ |
|
4300 |
#endif //_LP64 |
|
4301 |
||
4302 |
//----------------------inline_unsafe_copyMemory------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4303 |
// public native void sun.misc.Unsafe.copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes); |
1 | 4304 |
bool LibraryCallKit::inline_unsafe_copyMemory() { |
4305 |
if (callee()->is_static()) return false; // caller must have the capability! |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4306 |
null_check_receiver(); // null-check receiver |
1 | 4307 |
if (stopped()) return true; |
4308 |
||
4309 |
C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
|
4310 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4311 |
Node* src_ptr = argument(1); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4312 |
Node* src_off = ConvL2X(argument(2)); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4313 |
Node* dst_ptr = argument(4); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4314 |
Node* dst_off = ConvL2X(argument(5)); // type: long |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4315 |
Node* size = ConvL2X(argument(7)); // type: long |
1 | 4316 |
|
4317 |
assert(Unsafe_field_offset_to_byte_offset(11) == 11, |
|
4318 |
"fieldOffset must be byte-scaled"); |
|
4319 |
||
4320 |
Node* src = make_unsafe_address(src_ptr, src_off); |
|
4321 |
Node* dst = make_unsafe_address(dst_ptr, dst_off); |
|
4322 |
||
4323 |
// Conservatively insert a memory barrier on all memory slices. |
|
4324 |
// Do not let writes of the copy source or destination float below the copy. |
|
4325 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
4326 |
||
4327 |
// Call it. Note that the length argument is not scaled. |
|
4328 |
make_runtime_call(RC_LEAF|RC_NO_FP, |
|
4329 |
OptoRuntime::fast_arraycopy_Type(), |
|
4330 |
StubRoutines::unsafe_arraycopy(), |
|
4331 |
"unsafe_arraycopy", |
|
4332 |
TypeRawPtr::BOTTOM, |
|
4333 |
src, dst, size XTOP); |
|
4334 |
||
4335 |
// Do not let reads of the copy destination float above the copy. |
|
4336 |
insert_mem_bar(Op_MemBarCPUOrder); |
|
4337 |
||
4338 |
return true; |
|
4339 |
} |
|
4340 |
||
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4341 |
//------------------------clone_coping----------------------------------- |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4342 |
// Helper function for inline_native_clone. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4343 |
void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark) { |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4344 |
assert(obj_size != NULL, ""); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4345 |
Node* raw_obj = alloc_obj->in(1); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4346 |
assert(alloc_obj->is_CheckCastPP() && raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), ""); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4347 |
|
11431
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4348 |
AllocateNode* alloc = NULL; |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4349 |
if (ReduceBulkZeroing) { |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4350 |
// We will be completely responsible for initializing this object - |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4351 |
// mark Initialize node as complete. |
11431
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4352 |
alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn); |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4353 |
// The object was just allocated - there should be no any stores! |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4354 |
guarantee(alloc != NULL && alloc->maybe_set_complete(&_gvn), ""); |
11431
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4355 |
// Mark as complete_with_arraycopy so that on AllocateNode |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4356 |
// expansion, we know this AllocateNode is initialized by an array |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4357 |
// copy and a StoreStore barrier exists after the array copy. |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4358 |
alloc->initialization()->set_complete_with_arraycopy(); |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4359 |
} |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4360 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4361 |
// Copy the fastest available way. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4362 |
// TODO: generate fields copies for small objects instead. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4363 |
Node* src = obj; |
3805
3cddd4882151
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
3797
diff
changeset
|
4364 |
Node* dest = alloc_obj; |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4365 |
Node* size = _gvn.transform(obj_size); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4366 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4367 |
// Exclude the header but include array length to copy by 8 bytes words. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4368 |
// Can't use base_offset_in_bytes(bt) since basic type is unknown. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4369 |
int base_off = is_array ? arrayOopDesc::length_offset_in_bytes() : |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4370 |
instanceOopDesc::base_offset_in_bytes(); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4371 |
// base_off: |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4372 |
// 8 - 32-bit VM |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
4373 |
// 12 - 64-bit VM, compressed klass |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13486
diff
changeset
|
4374 |
// 16 - 64-bit VM, normal klass |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4375 |
if (base_off % BytesPerLong != 0) { |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19719
diff
changeset
|
4376 |
assert(UseCompressedClassPointers, ""); |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4377 |
if (is_array) { |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4378 |
// Exclude length to copy by 8 bytes words. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4379 |
base_off += sizeof(int); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4380 |
} else { |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4381 |
// Include klass to copy by 8 bytes words. |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4382 |
base_off = instanceOopDesc::klass_offset_in_bytes(); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4383 |
} |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4384 |
assert(base_off % BytesPerLong == 0, "expect 8 bytes alignment"); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4385 |
} |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4386 |
src = basic_plus_adr(src, base_off); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4387 |
dest = basic_plus_adr(dest, base_off); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4388 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4389 |
// Compute the length also, if needed: |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4390 |
Node* countx = size; |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4391 |
countx = _gvn.transform(new SubXNode(countx, MakeConX(base_off))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4392 |
countx = _gvn.transform(new URShiftXNode(countx, intcon(LogBytesPerLong) )); |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4393 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4394 |
const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; |
26166 | 4395 |
|
4396 |
ArrayCopyNode* ac = ArrayCopyNode::make(this, false, src, NULL, dest, NULL, countx, false); |
|
4397 |
ac->set_clonebasic(); |
|
4398 |
Node* n = _gvn.transform(ac); |
|
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4399 |
if (n == ac) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4400 |
set_predefined_output_for_runtime_call(ac, ac->in(TypeFunc::Memory), raw_adr_type); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4401 |
} else { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4402 |
set_all_memory(n); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4403 |
} |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4404 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4405 |
// If necessary, emit some card marks afterwards. (Non-arrays only.) |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4406 |
if (card_mark) { |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4407 |
assert(!is_array, ""); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4408 |
// Put in store barrier for any and all oops we are sticking |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4409 |
// into this object. (We could avoid this if we could prove |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4410 |
// that the object type contains no oop fields at all.) |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4411 |
Node* no_particular_value = NULL; |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4412 |
Node* no_particular_field = NULL; |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4413 |
int raw_adr_idx = Compile::AliasIdxRaw; |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4414 |
post_barrier(control(), |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4415 |
memory(raw_adr_type), |
3805
3cddd4882151
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
3797
diff
changeset
|
4416 |
alloc_obj, |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4417 |
no_particular_field, |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4418 |
raw_adr_idx, |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4419 |
no_particular_value, |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4420 |
T_OBJECT, |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4421 |
false); |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4422 |
} |
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4423 |
|
3805
3cddd4882151
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
3797
diff
changeset
|
4424 |
// Do not let reads from the cloned object float above the arraycopy. |
11431
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4425 |
if (alloc != NULL) { |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4426 |
// Do not let stores that initialize this object be reordered with |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4427 |
// a subsequent store that would make this object accessible by |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4428 |
// other threads. |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4429 |
// Record what AllocateNode this StoreStore protects so that |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4430 |
// escape analysis can go from the MemBarStoreStoreNode to the |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4431 |
// AllocateNode and eliminate the MemBarStoreStoreNode if possible |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4432 |
// based on the escape status of the AllocateNode. |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4433 |
insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out(AllocateNode::RawAddress)); |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4434 |
} else { |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4435 |
insert_mem_bar(Op_MemBarCPUOrder); |
5ca3a19e559a
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
11430
diff
changeset
|
4436 |
} |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4437 |
} |
1 | 4438 |
|
4439 |
//------------------------inline_native_clone---------------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4440 |
// protected native Object java.lang.Object.clone(); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4441 |
// |
1 | 4442 |
// Here are the simple edge cases: |
4443 |
// null receiver => normal trap |
|
4444 |
// virtual and clone was overridden => slow path to out-of-line clone |
|
4445 |
// not cloneable or finalizer => slow path to out-of-line Object.clone |
|
4446 |
// |
|
4447 |
// The general case has two steps, allocation and copying. |
|
4448 |
// Allocation has two cases, and uses GraphKit::new_instance or new_array. |
|
4449 |
// |
|
4450 |
// Copying also has two cases, oop arrays and everything else. |
|
4451 |
// Oop arrays use arrayof_oop_arraycopy (same as System.arraycopy). |
|
4452 |
// Everything else uses the tight inline loop supplied by CopyArrayNode. |
|
4453 |
// |
|
4454 |
// These steps fold up nicely if and when the cloned object's klass |
|
4455 |
// can be sharply typed as an object array, a type array, or an instance. |
|
4456 |
// |
|
4457 |
bool LibraryCallKit::inline_native_clone(bool is_virtual) { |
|
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4458 |
PhiNode* result_val; |
1 | 4459 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4460 |
// Set the reexecute bit for the interpreter to reexecute |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4461 |
// the bytecode that invokes Object.clone if deoptimization happens. |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4462 |
{ PreserveReexecuteState preexecs(this); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4463 |
jvms()->set_should_reexecute(true); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4464 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4465 |
Node* obj = null_check_receiver(); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4466 |
if (stopped()) return true; |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4467 |
|
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4468 |
const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4469 |
|
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4470 |
// If we are going to clone an instance, we need its exact type to |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4471 |
// know the number and types of fields to convert the clone to |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4472 |
// loads/stores. Maybe a speculative type can help us. |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4473 |
if (!obj_type->klass_is_exact() && |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4474 |
obj_type->speculative_type() != NULL && |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4475 |
obj_type->speculative_type()->is_instance_klass()) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4476 |
ciInstanceKlass* spec_ik = obj_type->speculative_type()->as_instance_klass(); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4477 |
if (spec_ik->nof_nonstatic_fields() <= ArrayCopyLoadStoreMaxElem && |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4478 |
!spec_ik->has_injected_fields()) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4479 |
ciKlass* k = obj_type->klass(); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4480 |
if (!k->is_instance_klass() || |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4481 |
k->as_instance_klass()->is_interface() || |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4482 |
k->as_instance_klass()->has_subklass()) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4483 |
obj = maybe_cast_profiled_obj(obj, obj_type->speculative_type(), false); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4484 |
} |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4485 |
} |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4486 |
} |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4487 |
|
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4488 |
Node* obj_klass = load_object_klass(obj); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4489 |
const TypeKlassPtr* tklass = _gvn.type(obj_klass)->isa_klassptr(); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4490 |
const TypeOopPtr* toop = ((tklass != NULL) |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4491 |
? tklass->as_instance_type() |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4492 |
: TypeInstPtr::NOTNULL); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4493 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4494 |
// Conservatively insert a memory barrier on all memory slices. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4495 |
// Do not let writes into the original float below the clone. |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4496 |
insert_mem_bar(Op_MemBarCPUOrder); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4497 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4498 |
// paths into result_reg: |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4499 |
enum { |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4500 |
_slow_path = 1, // out-of-line call to clone method (virtual or not) |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4501 |
_objArray_path, // plain array allocation, plus arrayof_oop_arraycopy |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4502 |
_array_path, // plain array allocation, plus arrayof_long_arraycopy |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4503 |
_instance_path, // plain instance allocation, plus arrayof_long_arraycopy |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4504 |
PATH_LIMIT |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4505 |
}; |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4506 |
RegionNode* result_reg = new RegionNode(PATH_LIMIT); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4507 |
result_val = new PhiNode(result_reg, TypeInstPtr::NOTNULL); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4508 |
PhiNode* result_i_o = new PhiNode(result_reg, Type::ABIO); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4509 |
PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4510 |
record_for_igvn(result_reg); |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4511 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4512 |
const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; |
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4513 |
int raw_adr_idx = Compile::AliasIdxRaw; |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4514 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4515 |
Node* array_ctl = generate_array_guard(obj_klass, (RegionNode*)NULL); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4516 |
if (array_ctl != NULL) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4517 |
// It's an array. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4518 |
PreserveJVMState pjvms(this); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4519 |
set_control(array_ctl); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4520 |
Node* obj_length = load_array_length(obj); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4521 |
Node* obj_size = NULL; |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4522 |
Node* alloc_obj = new_array(obj_klass, obj_length, 0, &obj_size); // no arguments to push |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4523 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4524 |
if (!use_ReduceInitialCardMarks()) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4525 |
// If it is an oop array, it requires very special treatment, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4526 |
// because card marking is required on each card of the array. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4527 |
Node* is_obja = generate_objArray_guard(obj_klass, (RegionNode*)NULL); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4528 |
if (is_obja != NULL) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4529 |
PreserveJVMState pjvms2(this); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4530 |
set_control(is_obja); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4531 |
// Generate a direct call to the right arraycopy function(s). |
26166 | 4532 |
Node* alloc = tightly_coupled_allocation(alloc_obj, NULL); |
4533 |
ArrayCopyNode* ac = ArrayCopyNode::make(this, true, obj, intcon(0), alloc_obj, intcon(0), obj_length, alloc != NULL); |
|
4534 |
ac->set_cloneoop(); |
|
4535 |
Node* n = _gvn.transform(ac); |
|
4536 |
assert(n == ac, "cannot disappear"); |
|
4537 |
ac->connect_outputs(this); |
|
4538 |
||
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4539 |
result_reg->init_req(_objArray_path, control()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4540 |
result_val->init_req(_objArray_path, alloc_obj); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4541 |
result_i_o ->set_req(_objArray_path, i_o()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4542 |
result_mem ->set_req(_objArray_path, reset_memory()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4543 |
} |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4544 |
} |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4545 |
// Otherwise, there are no card marks to worry about. |
4030
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4546 |
// (We can dispense with card marks if we know the allocation |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4547 |
// comes out of eden (TLAB)... In fact, ReduceInitialCardMarks |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4548 |
// causes the non-eden paths to take compensating steps to |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4549 |
// simulate a fresh allocation, so that no further |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4550 |
// card marks are required in compiled code to initialize |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
3905
diff
changeset
|
4551 |
// the object.) |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4552 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4553 |
if (!stopped()) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4554 |
copy_to_clone(obj, alloc_obj, obj_size, true, false); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4555 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4556 |
// Present the results of the copy. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4557 |
result_reg->init_req(_array_path, control()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4558 |
result_val->init_req(_array_path, alloc_obj); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4559 |
result_i_o ->set_req(_array_path, i_o()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4560 |
result_mem ->set_req(_array_path, reset_memory()); |
1 | 4561 |
} |
4562 |
} |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4563 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4564 |
// We only go to the instance fast case code if we pass a number of guards. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4565 |
// The paths which do not pass are accumulated in the slow_region. |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4566 |
RegionNode* slow_region = new RegionNode(1); |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4567 |
record_for_igvn(slow_region); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4568 |
if (!stopped()) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4569 |
// It's an instance (we did array above). Make the slow-path tests. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4570 |
// If this is a virtual call, we generate a funny guard. We grab |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4571 |
// the vtable entry corresponding to clone() from the target object. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4572 |
// If the target method which we are calling happens to be the |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4573 |
// Object clone() method, we pass the guard. We do not need this |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4574 |
// guard for non-virtual calls; the caller is known to be the native |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4575 |
// Object clone(). |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4576 |
if (is_virtual) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4577 |
generate_virtual_guard(obj_klass, slow_region); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4578 |
} |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4579 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4580 |
// The object must be cloneable and must not have a finalizer. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4581 |
// Both of these conditions may be checked in a single test. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4582 |
// We could optimize the cloneable test further, but we don't care. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4583 |
generate_access_flags_guard(obj_klass, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4584 |
// Test both conditions: |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4585 |
JVM_ACC_IS_CLONEABLE | JVM_ACC_HAS_FINALIZER, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4586 |
// Must be cloneable but not finalizer: |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4587 |
JVM_ACC_IS_CLONEABLE, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4588 |
slow_region); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4589 |
} |
3186
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4590 |
|
11ba3d09bd0e
6840775: Multiple JVM crashes seen with 1.6.0_10 through 1.6.0_14
kvn
parents:
3180
diff
changeset
|
4591 |
if (!stopped()) { |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4592 |
// It's an instance, and it passed the slow-path tests. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4593 |
PreserveJVMState pjvms(this); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4594 |
Node* obj_size = NULL; |
24945
6df48e563632
8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
24923
diff
changeset
|
4595 |
// Need to deoptimize on exception from allocation since Object.clone intrinsic |
6df48e563632
8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
24923
diff
changeset
|
4596 |
// is reexecuted if deoptimization occurs and there could be problems when merging |
6df48e563632
8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
24923
diff
changeset
|
4597 |
// exception state between multiple Object.clone versions (reexecute=true vs reexecute=false). |
6df48e563632
8033626: assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place
vlivanov
parents:
24923
diff
changeset
|
4598 |
Node* alloc_obj = new_instance(obj_klass, NULL, &obj_size, /*deoptimize_on_exception=*/true); |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4599 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4600 |
copy_to_clone(obj, alloc_obj, obj_size, false, !use_ReduceInitialCardMarks()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4601 |
|
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4602 |
// Present the results of the slow call. |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4603 |
result_reg->init_req(_instance_path, control()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4604 |
result_val->init_req(_instance_path, alloc_obj); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4605 |
result_i_o ->set_req(_instance_path, i_o()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4606 |
result_mem ->set_req(_instance_path, reset_memory()); |
1 | 4607 |
} |
4608 |
||
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4609 |
// Generate code for the slow case. We make a call to clone(). |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4610 |
set_control(_gvn.transform(slow_region)); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4611 |
if (!stopped()) { |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4612 |
PreserveJVMState pjvms(this); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4613 |
CallJavaNode* slow_call = generate_method_call(vmIntrinsics::_clone, is_virtual); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4614 |
Node* slow_result = set_results_for_java_call(slow_call); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4615 |
// this->control() comes from set_results_for_java_call |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4616 |
result_reg->init_req(_slow_path, control()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4617 |
result_val->init_req(_slow_path, slow_result); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4618 |
result_i_o ->set_req(_slow_path, i_o()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4619 |
result_mem ->set_req(_slow_path, reset_memory()); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
3596
diff
changeset
|
4620 |
} |
3602
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4621 |
|
99f3c60b73a9
6868269: CompileTheWorld assertion failure introduced by the reexecute bit implementation
cfang
parents:
3600
diff
changeset
|
4622 |
// Return the combined state. |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
4623 |
set_control( _gvn.transform(result_reg)); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
4624 |
set_i_o( _gvn.transform(result_i_o)); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
4625 |
set_all_memory( _gvn.transform(result_mem)); |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4626 |
} // original reexecute is set back here |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4627 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4628 |
set_result(_gvn.transform(result_val)); |
1 | 4629 |
return true; |
4630 |
} |
|
4631 |
||
4632 |
//------------------------------inline_arraycopy----------------------- |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4633 |
// public static native void java.lang.System.arraycopy(Object src, int srcPos, |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4634 |
// Object dest, int destPos, |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4635 |
// int length); |
1 | 4636 |
bool LibraryCallKit::inline_arraycopy() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4637 |
// Get the arguments. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4638 |
Node* src = argument(0); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4639 |
Node* src_offset = argument(1); // type: int |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4640 |
Node* dest = argument(2); // type: oop |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4641 |
Node* dest_offset = argument(3); // type: int |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4642 |
Node* length = argument(4); // type: int |
1 | 4643 |
|
26166 | 4644 |
// The following tests must be performed |
1 | 4645 |
// (1) src and dest are arrays. |
26166 | 4646 |
// (2) src and dest arrays must have elements of the same BasicType |
4647 |
// (3) src and dest must not be null. |
|
4648 |
// (4) src_offset must not be negative. |
|
4649 |
// (5) dest_offset must not be negative. |
|
4650 |
// (6) length must not be negative. |
|
4651 |
// (7) src_offset + length must not exceed length of src. |
|
4652 |
// (8) dest_offset + length must not exceed length of dest. |
|
4653 |
// (9) each element of an oop array must be assignable |
|
4654 |
||
4655 |
// (3) src and dest must not be null. |
|
4656 |
// always do this here because we need the JVM state for uncommon traps |
|
4657 |
src = null_check(src, T_ARRAY); |
|
4658 |
dest = null_check(dest, T_ARRAY); |
|
4659 |
||
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4660 |
// Check for allocation before we add nodes that would confuse |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4661 |
// tightly_coupled_allocation() |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4662 |
AllocateArrayNode* alloc = tightly_coupled_allocation(dest, NULL); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4663 |
|
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4664 |
SafePointNode* sfpt = NULL; |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4665 |
if (alloc != NULL) { |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4666 |
// The JVM state for uncommon traps between the allocation and |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4667 |
// arraycopy is set to the state before the allocation: if the |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4668 |
// initialization is performed by the array copy, we don't want to |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4669 |
// go back to the interpreter with an unitialized array. |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4670 |
JVMState* old_jvms = alloc->jvms(); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4671 |
JVMState* jvms = old_jvms->clone_shallow(C); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4672 |
uint size = alloc->req(); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4673 |
sfpt = new SafePointNode(size, jvms); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4674 |
jvms->set_map(sfpt); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4675 |
for (uint i = 0; i < size; i++) { |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4676 |
sfpt->init_req(i, alloc->in(i)); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4677 |
} |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4678 |
// re-push array length for deoptimization |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4679 |
sfpt->ins_req(jvms->stkoff() + jvms->sp(), alloc->in(AllocateNode::ALength)); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4680 |
jvms->set_sp(jvms->sp()+1); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4681 |
jvms->set_monoff(jvms->monoff()+1); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4682 |
jvms->set_scloff(jvms->scloff()+1); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4683 |
jvms->set_endoff(jvms->endoff()+1); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4684 |
jvms->set_should_reexecute(true); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4685 |
|
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4686 |
sfpt->set_i_o(map()->i_o()); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4687 |
sfpt->set_memory(map()->memory()); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4688 |
} |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4689 |
|
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4690 |
bool validated = false; |
26166 | 4691 |
|
4692 |
const Type* src_type = _gvn.type(src); |
|
4693 |
const Type* dest_type = _gvn.type(dest); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
4694 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
1 | 4695 |
const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
21099 | 4696 |
|
4697 |
// Do we have the type of src? |
|
4698 |
bool has_src = (top_src != NULL && top_src->klass() != NULL); |
|
4699 |
// Do we have the type of dest? |
|
4700 |
bool has_dest = (top_dest != NULL && top_dest->klass() != NULL); |
|
4701 |
// Is the type for src from speculation? |
|
4702 |
bool src_spec = false; |
|
4703 |
// Is the type for dest from speculation? |
|
4704 |
bool dest_spec = false; |
|
4705 |
||
4706 |
if (!has_src || !has_dest) { |
|
4707 |
// We don't have sufficient type information, let's see if |
|
4708 |
// speculative types can help. We need to have types for both src |
|
4709 |
// and dest so that it pays off. |
|
4710 |
||
4711 |
// Do we already have or could we have type information for src |
|
4712 |
bool could_have_src = has_src; |
|
4713 |
// Do we already have or could we have type information for dest |
|
4714 |
bool could_have_dest = has_dest; |
|
4715 |
||
4716 |
ciKlass* src_k = NULL; |
|
4717 |
if (!has_src) { |
|
23525
e3eb08ead679
8031755: Type speculation should be used to optimize explicit null checks
roland
parents:
23495
diff
changeset
|
4718 |
src_k = src_type->speculative_type_not_null(); |
21099 | 4719 |
if (src_k != NULL && src_k->is_array_klass()) { |
4720 |
could_have_src = true; |
|
4721 |
} |
|
4722 |
} |
|
4723 |
||
4724 |
ciKlass* dest_k = NULL; |
|
4725 |
if (!has_dest) { |
|
23525
e3eb08ead679
8031755: Type speculation should be used to optimize explicit null checks
roland
parents:
23495
diff
changeset
|
4726 |
dest_k = dest_type->speculative_type_not_null(); |
21099 | 4727 |
if (dest_k != NULL && dest_k->is_array_klass()) { |
4728 |
could_have_dest = true; |
|
4729 |
} |
|
4730 |
} |
|
4731 |
||
4732 |
if (could_have_src && could_have_dest) { |
|
4733 |
// This is going to pay off so emit the required guards |
|
4734 |
if (!has_src) { |
|
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4735 |
src = maybe_cast_profiled_obj(src, src_k, true, sfpt); |
21099 | 4736 |
src_type = _gvn.type(src); |
4737 |
top_src = src_type->isa_aryptr(); |
|
4738 |
has_src = (top_src != NULL && top_src->klass() != NULL); |
|
4739 |
src_spec = true; |
|
4740 |
} |
|
4741 |
if (!has_dest) { |
|
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4742 |
dest = maybe_cast_profiled_obj(dest, dest_k, true); |
21099 | 4743 |
dest_type = _gvn.type(dest); |
4744 |
top_dest = dest_type->isa_aryptr(); |
|
4745 |
has_dest = (top_dest != NULL && top_dest->klass() != NULL); |
|
4746 |
dest_spec = true; |
|
4747 |
} |
|
4748 |
} |
|
4749 |
} |
|
4750 |
||
26166 | 4751 |
if (has_src && has_dest) { |
4752 |
BasicType src_elem = top_src->klass()->as_array_klass()->element_type()->basic_type(); |
|
4753 |
BasicType dest_elem = top_dest->klass()->as_array_klass()->element_type()->basic_type(); |
|
4754 |
if (src_elem == T_ARRAY) src_elem = T_OBJECT; |
|
4755 |
if (dest_elem == T_ARRAY) dest_elem = T_OBJECT; |
|
4756 |
||
4757 |
if (src_elem == dest_elem && src_elem == T_OBJECT) { |
|
4758 |
// If both arrays are object arrays then having the exact types |
|
4759 |
// for both will remove the need for a subtype check at runtime |
|
4760 |
// before the call and may make it possible to pick a faster copy |
|
4761 |
// routine (without a subtype check on every element) |
|
4762 |
// Do we have the exact type of src? |
|
4763 |
bool could_have_src = src_spec; |
|
4764 |
// Do we have the exact type of dest? |
|
4765 |
bool could_have_dest = dest_spec; |
|
4766 |
ciKlass* src_k = top_src->klass(); |
|
4767 |
ciKlass* dest_k = top_dest->klass(); |
|
4768 |
if (!src_spec) { |
|
4769 |
src_k = src_type->speculative_type_not_null(); |
|
4770 |
if (src_k != NULL && src_k->is_array_klass()) { |
|
21099 | 4771 |
could_have_src = true; |
26166 | 4772 |
} |
21099 | 4773 |
} |
26166 | 4774 |
if (!dest_spec) { |
4775 |
dest_k = dest_type->speculative_type_not_null(); |
|
4776 |
if (dest_k != NULL && dest_k->is_array_klass()) { |
|
4777 |
could_have_dest = true; |
|
4778 |
} |
|
21099 | 4779 |
} |
26166 | 4780 |
if (could_have_src && could_have_dest) { |
4781 |
// If we can have both exact types, emit the missing guards |
|
4782 |
if (could_have_src && !src_spec) { |
|
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4783 |
src = maybe_cast_profiled_obj(src, src_k, true, sfpt); |
26166 | 4784 |
} |
4785 |
if (could_have_dest && !dest_spec) { |
|
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4786 |
dest = maybe_cast_profiled_obj(dest, dest_k, true); |
26166 | 4787 |
} |
21099 | 4788 |
} |
4789 |
} |
|
4790 |
} |
|
4791 |
||
26166 | 4792 |
if (!too_many_traps(Deoptimization::Reason_intrinsic) && !src->is_top() && !dest->is_top()) { |
4793 |
// validate arguments: enables transformation the ArrayCopyNode |
|
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4794 |
validated = true; |
26166 | 4795 |
|
4796 |
RegionNode* slow_region = new RegionNode(1); |
|
1 | 4797 |
record_for_igvn(slow_region); |
26166 | 4798 |
|
4799 |
// (1) src and dest are arrays. |
|
4800 |
generate_non_array_guard(load_object_klass(src), slow_region); |
|
4801 |
generate_non_array_guard(load_object_klass(dest), slow_region); |
|
4802 |
||
4803 |
// (2) src and dest arrays must have elements of the same BasicType |
|
4804 |
// done at macro expansion or at Ideal transformation time |
|
4805 |
||
4806 |
// (4) src_offset must not be negative. |
|
4807 |
generate_negative_guard(src_offset, slow_region); |
|
4808 |
||
4809 |
// (5) dest_offset must not be negative. |
|
4810 |
generate_negative_guard(dest_offset, slow_region); |
|
4811 |
||
4812 |
// (7) src_offset + length must not exceed length of src. |
|
4813 |
generate_limit_guard(src_offset, length, |
|
4814 |
load_array_length(src), |
|
4815 |
slow_region); |
|
4816 |
||
4817 |
// (8) dest_offset + length must not exceed length of dest. |
|
4818 |
generate_limit_guard(dest_offset, length, |
|
4819 |
load_array_length(dest), |
|
4820 |
slow_region); |
|
4821 |
||
4822 |
// (9) each element of an oop array must be assignable |
|
1 | 4823 |
Node* src_klass = load_object_klass(src); |
4824 |
Node* dest_klass = load_object_klass(dest); |
|
4825 |
Node* not_subtype_ctrl = gen_subtype_check(src_klass, dest_klass); |
|
26166 | 4826 |
|
1 | 4827 |
if (not_subtype_ctrl != top()) { |
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4828 |
if (sfpt != NULL) { |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4829 |
GraphKit kit(sfpt->jvms()); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4830 |
PreserveJVMState pjvms(&kit); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4831 |
kit.set_control(not_subtype_ctrl); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4832 |
kit.uncommon_trap(Deoptimization::Reason_intrinsic, |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4833 |
Deoptimization::Action_make_not_entrant); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4834 |
assert(kit.stopped(), "Should be stopped"); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4835 |
} else { |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4836 |
PreserveJVMState pjvms(this); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4837 |
set_control(not_subtype_ctrl); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4838 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4839 |
Deoptimization::Action_make_not_entrant); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4840 |
assert(stopped(), "Should be stopped"); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4841 |
} |
1 | 4842 |
} |
27921
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4843 |
if (sfpt != NULL) { |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4844 |
GraphKit kit(sfpt->jvms()); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4845 |
kit.set_control(_gvn.transform(slow_region)); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4846 |
kit.uncommon_trap(Deoptimization::Reason_intrinsic, |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4847 |
Deoptimization::Action_make_not_entrant); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4848 |
assert(kit.stopped(), "Should be stopped"); |
4b932655e504
8064703: crash running specjvm98's javac following 8060252
roland
parents:
27637
diff
changeset
|
4849 |
} else { |
26166 | 4850 |
PreserveJVMState pjvms(this); |
4851 |
set_control(_gvn.transform(slow_region)); |
|
4852 |
uncommon_trap(Deoptimization::Reason_intrinsic, |
|
4853 |
Deoptimization::Action_make_not_entrant); |
|
4854 |
assert(stopped(), "Should be stopped"); |
|
1 | 4855 |
} |
4856 |
} |
|
4857 |
||
26166 | 4858 |
if (stopped()) { |
4859 |
return true; |
|
1 | 4860 |
} |
4861 |
||
26180
2fbed11af70e
8055153: nsk/stress/jck60/jck60014 crashes on sparc
roland
parents:
26171
diff
changeset
|
4862 |
ArrayCopyNode* ac = ArrayCopyNode::make(this, true, src, src_offset, dest, dest_offset, length, alloc != NULL, |
2fbed11af70e
8055153: nsk/stress/jck60/jck60014 crashes on sparc
roland
parents:
26171
diff
changeset
|
4863 |
// Create LoadRange and LoadKlass nodes for use during macro expansion here |
2fbed11af70e
8055153: nsk/stress/jck60/jck60014 crashes on sparc
roland
parents:
26171
diff
changeset
|
4864 |
// so the compiler has a chance to eliminate them: during macro expansion, |
2fbed11af70e
8055153: nsk/stress/jck60/jck60014 crashes on sparc
roland
parents:
26171
diff
changeset
|
4865 |
// we have to set their control (CastPP nodes are eliminated). |
26435
b446202ac824
8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
26434
diff
changeset
|
4866 |
load_object_klass(src), load_object_klass(dest), |
b446202ac824
8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
26434
diff
changeset
|
4867 |
load_array_length(src), load_array_length(dest)); |
26166 | 4868 |
|
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4869 |
ac->set_arraycopy(validated); |
1 | 4870 |
|
26166 | 4871 |
Node* n = _gvn.transform(ac); |
28396
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4872 |
if (n == ac) { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4873 |
ac->connect_outputs(this); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4874 |
} else { |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4875 |
assert(validated, "shouldn't transform if all arguments not validated"); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4876 |
set_all_memory(n); |
7fe4347e6792
6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents:
27921
diff
changeset
|
4877 |
} |
26166 | 4878 |
|
4879 |
return true; |
|
1 | 4880 |
} |
4881 |
||
4882 |
||
4883 |
// Helper function which determines if an arraycopy immediately follows |
|
4884 |
// an allocation, with no intervening tests or other escapes for the object. |
|
4885 |
AllocateArrayNode* |
|
4886 |
LibraryCallKit::tightly_coupled_allocation(Node* ptr, |
|
4887 |
RegionNode* slow_region) { |
|
4888 |
if (stopped()) return NULL; // no fast path |
|
4889 |
if (C->AliasLevel() == 0) return NULL; // no MergeMems around |
|
4890 |
||
4891 |
AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(ptr, &_gvn); |
|
4892 |
if (alloc == NULL) return NULL; |
|
4893 |
||
4894 |
Node* rawmem = memory(Compile::AliasIdxRaw); |
|
4895 |
// Is the allocation's memory state untouched? |
|
4896 |
if (!(rawmem->is_Proj() && rawmem->in(0)->is_Initialize())) { |
|
4897 |
// Bail out if there have been raw-memory effects since the allocation. |
|
4898 |
// (Example: There might have been a call or safepoint.) |
|
4899 |
return NULL; |
|
4900 |
} |
|
4901 |
rawmem = rawmem->in(0)->as_Initialize()->memory(Compile::AliasIdxRaw); |
|
4902 |
if (!(rawmem->is_Proj() && rawmem->in(0) == alloc)) { |
|
4903 |
return NULL; |
|
4904 |
} |
|
4905 |
||
4906 |
// There must be no unexpected observers of this allocation. |
|
4907 |
for (DUIterator_Fast imax, i = ptr->fast_outs(imax); i < imax; i++) { |
|
4908 |
Node* obs = ptr->fast_out(i); |
|
4909 |
if (obs != this->map()) { |
|
4910 |
return NULL; |
|
4911 |
} |
|
4912 |
} |
|
4913 |
||
4914 |
// This arraycopy must unconditionally follow the allocation of the ptr. |
|
4915 |
Node* alloc_ctl = ptr->in(0); |
|
4916 |
assert(just_allocated_object(alloc_ctl) == ptr, "most recent allo"); |
|
4917 |
||
4918 |
Node* ctl = control(); |
|
4919 |
while (ctl != alloc_ctl) { |
|
4920 |
// There may be guards which feed into the slow_region. |
|
4921 |
// Any other control flow means that we might not get a chance |
|
4922 |
// to finish initializing the allocated object. |
|
4923 |
if ((ctl->is_IfFalse() || ctl->is_IfTrue()) && ctl->in(0)->is_If()) { |
|
4924 |
IfNode* iff = ctl->in(0)->as_If(); |
|
4925 |
Node* not_ctl = iff->proj_out(1 - ctl->as_Proj()->_con); |
|
4926 |
assert(not_ctl != NULL && not_ctl != ctl, "found alternate"); |
|
4927 |
if (slow_region != NULL && slow_region->find_edge(not_ctl) >= 1) { |
|
4928 |
ctl = iff->in(0); // This test feeds the known slow_region. |
|
4929 |
continue; |
|
4930 |
} |
|
4931 |
// One more try: Various low-level checks bottom out in |
|
4932 |
// uncommon traps. If the debug-info of the trap omits |
|
4933 |
// any reference to the allocation, as we've already |
|
4934 |
// observed, then there can be no objection to the trap. |
|
4935 |
bool found_trap = false; |
|
4936 |
for (DUIterator_Fast jmax, j = not_ctl->fast_outs(jmax); j < jmax; j++) { |
|
4937 |
Node* obs = not_ctl->fast_out(j); |
|
4938 |
if (obs->in(0) == not_ctl && obs->is_Call() && |
|
6418 | 4939 |
(obs->as_Call()->entry_point() == SharedRuntime::uncommon_trap_blob()->entry_point())) { |
1 | 4940 |
found_trap = true; break; |
4941 |
} |
|
4942 |
} |
|
4943 |
if (found_trap) { |
|
4944 |
ctl = iff->in(0); // This test feeds a harmless uncommon trap. |
|
4945 |
continue; |
|
4946 |
} |
|
4947 |
} |
|
4948 |
return NULL; |
|
4949 |
} |
|
4950 |
||
4951 |
// If we get this far, we have an allocation which immediately |
|
4952 |
// precedes the arraycopy, and we can take over zeroing the new object. |
|
4953 |
// The arraycopy will finish the initialization, and provide |
|
4954 |
// a new control state to which we will anchor the destination pointer. |
|
4955 |
||
4956 |
return alloc; |
|
4957 |
} |
|
4958 |
||
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4959 |
//-------------inline_encodeISOArray----------------------------------- |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4960 |
// encode char[] to byte[] in ISO_8859_1 |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4961 |
bool LibraryCallKit::inline_encodeISOArray() { |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4962 |
assert(callee()->signature()->size() == 5, "encodeISOArray has 5 parameters"); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4963 |
// no receiver since it is static method |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4964 |
Node *src = argument(0); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4965 |
Node *src_offset = argument(1); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4966 |
Node *dst = argument(2); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4967 |
Node *dst_offset = argument(3); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4968 |
Node *length = argument(4); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4969 |
|
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4970 |
const Type* src_type = src->Value(&_gvn); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4971 |
const Type* dst_type = dst->Value(&_gvn); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4972 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4973 |
const TypeAryPtr* top_dest = dst_type->isa_aryptr(); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4974 |
if (top_src == NULL || top_src->klass() == NULL || |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4975 |
top_dest == NULL || top_dest->klass() == NULL) { |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4976 |
// failed array check |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4977 |
return false; |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4978 |
} |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4979 |
|
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4980 |
// Figure out the size and type of the elements we will be copying. |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4981 |
BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4982 |
BasicType dst_elem = dst_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4983 |
if (src_elem != T_CHAR || dst_elem != T_BYTE) { |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4984 |
return false; |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4985 |
} |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4986 |
Node* src_start = array_element_address(src, src_offset, src_elem); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4987 |
Node* dst_start = array_element_address(dst, dst_offset, dst_elem); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4988 |
// 'src_start' points to src array + scaled offset |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4989 |
// 'dst_start' points to dst array + scaled offset |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4990 |
|
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4991 |
const TypeAryPtr* mtype = TypeAryPtr::BYTES; |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4992 |
Node* enc = new EncodeISOArrayNode(control(), memory(mtype), src_start, dst_start, length); |
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4993 |
enc = _gvn.transform(enc); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
4994 |
Node* res_mem = _gvn.transform(new SCMemProjNode(enc)); |
15242
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4995 |
set_memory(res_mem, mtype); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4996 |
set_result(enc); |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4997 |
return true; |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4998 |
} |
695bb216be99
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
15208
diff
changeset
|
4999 |
|
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5000 |
//-------------inline_multiplyToLen----------------------------------- |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5001 |
bool LibraryCallKit::inline_multiplyToLen() { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5002 |
assert(UseMultiplyToLenIntrinsic, "not implementated on this platform"); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5003 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5004 |
address stubAddr = StubRoutines::multiplyToLen(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5005 |
if (stubAddr == NULL) { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5006 |
return false; // Intrinsic's stub is not implemented on this platform |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5007 |
} |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5008 |
const char* stubName = "multiplyToLen"; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5009 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5010 |
assert(callee()->signature()->size() == 5, "multiplyToLen has 5 parameters"); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5011 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5012 |
Node* x = argument(1); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5013 |
Node* xlen = argument(2); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5014 |
Node* y = argument(3); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5015 |
Node* ylen = argument(4); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5016 |
Node* z = argument(5); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5017 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5018 |
const Type* x_type = x->Value(&_gvn); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5019 |
const Type* y_type = y->Value(&_gvn); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5020 |
const TypeAryPtr* top_x = x_type->isa_aryptr(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5021 |
const TypeAryPtr* top_y = y_type->isa_aryptr(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5022 |
if (top_x == NULL || top_x->klass() == NULL || |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5023 |
top_y == NULL || top_y->klass() == NULL) { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5024 |
// failed array check |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5025 |
return false; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5026 |
} |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5027 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5028 |
BasicType x_elem = x_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5029 |
BasicType y_elem = y_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5030 |
if (x_elem != T_INT || y_elem != T_INT) { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5031 |
return false; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5032 |
} |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5033 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5034 |
// Set the original stack and the reexecute bit for the interpreter to reexecute |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5035 |
// the bytecode that invokes BigInteger.multiplyToLen() if deoptimization happens |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5036 |
// on the return from z array allocation in runtime. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5037 |
{ PreserveReexecuteState preexecs(this); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5038 |
jvms()->set_should_reexecute(true); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5039 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5040 |
Node* x_start = array_element_address(x, intcon(0), x_elem); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5041 |
Node* y_start = array_element_address(y, intcon(0), y_elem); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5042 |
// 'x_start' points to x array + scaled xlen |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5043 |
// 'y_start' points to y array + scaled ylen |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5044 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5045 |
// Allocate the result array |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5046 |
Node* zlen = _gvn.transform(new AddINode(xlen, ylen)); |
26584
43335aea982b
8057758: Tests run TypeProfileLevel=222 crash with guarantee(0) failed: must find derived/base pair
roland
parents:
26442
diff
changeset
|
5047 |
ciKlass* klass = ciTypeArrayKlass::make(T_INT); |
43335aea982b
8057758: Tests run TypeProfileLevel=222 crash with guarantee(0) failed: must find derived/base pair
roland
parents:
26442
diff
changeset
|
5048 |
Node* klass_node = makecon(TypeKlassPtr::make(klass)); |
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5049 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5050 |
IdealKit ideal(this); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5051 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5052 |
#define __ ideal. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5053 |
Node* one = __ ConI(1); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5054 |
Node* zero = __ ConI(0); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5055 |
IdealVariable need_alloc(ideal), z_alloc(ideal); __ declarations_done(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5056 |
__ set(need_alloc, zero); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5057 |
__ set(z_alloc, z); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5058 |
__ if_then(z, BoolTest::eq, null()); { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5059 |
__ increment (need_alloc, one); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5060 |
} __ else_(); { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5061 |
// Update graphKit memory and control from IdealKit. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5062 |
sync_kit(ideal); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5063 |
Node* zlen_arg = load_array_length(z); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5064 |
// Update IdealKit memory and control from graphKit. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5065 |
__ sync_kit(this); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5066 |
__ if_then(zlen_arg, BoolTest::lt, zlen); { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5067 |
__ increment (need_alloc, one); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5068 |
} __ end_if(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5069 |
} __ end_if(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5070 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5071 |
__ if_then(__ value(need_alloc), BoolTest::ne, zero); { |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5072 |
// Update graphKit memory and control from IdealKit. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5073 |
sync_kit(ideal); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5074 |
Node * narr = new_array(klass_node, zlen, 1); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5075 |
// Update IdealKit memory and control from graphKit. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5076 |
__ sync_kit(this); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5077 |
__ set(z_alloc, narr); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5078 |
} __ end_if(); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5079 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5080 |
sync_kit(ideal); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5081 |
z = __ value(z_alloc); |
26584
43335aea982b
8057758: Tests run TypeProfileLevel=222 crash with guarantee(0) failed: must find derived/base pair
roland
parents:
26442
diff
changeset
|
5082 |
// Can't use TypeAryPtr::INTS which uses Bottom offset. |
43335aea982b
8057758: Tests run TypeProfileLevel=222 crash with guarantee(0) failed: must find derived/base pair
roland
parents:
26442
diff
changeset
|
5083 |
_gvn.set_type(z, TypeOopPtr::make_from_klass(klass)); |
26434
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5084 |
// Final sync IdealKit and GraphKit. |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5085 |
final_sync(ideal); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5086 |
#undef __ |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5087 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5088 |
Node* z_start = array_element_address(z, intcon(0), T_INT); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5089 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5090 |
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5091 |
OptoRuntime::multiplyToLen_Type(), |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5092 |
stubAddr, stubName, TypePtr::BOTTOM, |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5093 |
x_start, xlen, y_start, ylen, z_start, zlen); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5094 |
} // original reexecute is set back here |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5095 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5096 |
C->set_has_split_ifs(true); // Has chance for split-if optimization |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5097 |
set_result(z); |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5098 |
return true; |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5099 |
} |
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5100 |
|
09ad55e5f486
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents:
26180
diff
changeset
|
5101 |
|
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5102 |
/** |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5103 |
* Calculate CRC32 for byte. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5104 |
* int java.util.zip.CRC32.update(int crc, int b) |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5105 |
*/ |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5106 |
bool LibraryCallKit::inline_updateCRC32() { |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5107 |
assert(UseCRC32Intrinsics, "need AVX and LCMUL instructions support"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5108 |
assert(callee()->signature()->size() == 2, "update has 2 parameters"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5109 |
// no receiver since it is static method |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5110 |
Node* crc = argument(0); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5111 |
Node* b = argument(1); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5112 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5113 |
/* |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5114 |
* int c = ~ crc; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5115 |
* b = timesXtoThe32[(b ^ c) & 0xFF]; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5116 |
* b = b ^ (c >>> 8); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5117 |
* crc = ~b; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5118 |
*/ |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5119 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5120 |
Node* M1 = intcon(-1); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5121 |
crc = _gvn.transform(new XorINode(crc, M1)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5122 |
Node* result = _gvn.transform(new XorINode(crc, b)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5123 |
result = _gvn.transform(new AndINode(result, intcon(0xFF))); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5124 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5125 |
Node* base = makecon(TypeRawPtr::make(StubRoutines::crc_table_addr())); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5126 |
Node* offset = _gvn.transform(new LShiftINode(result, intcon(0x2))); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5127 |
Node* adr = basic_plus_adr(top(), base, ConvI2X(offset)); |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
5128 |
result = make_load(control(), adr, TypeInt::INT, T_INT, MemNode::unordered); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5129 |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5130 |
crc = _gvn.transform(new URShiftINode(crc, intcon(8))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5131 |
result = _gvn.transform(new XorINode(crc, result)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5132 |
result = _gvn.transform(new XorINode(result, M1)); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5133 |
set_result(result); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5134 |
return true; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5135 |
} |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5136 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5137 |
/** |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5138 |
* Calculate CRC32 for byte[] array. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5139 |
* int java.util.zip.CRC32.updateBytes(int crc, byte[] buf, int off, int len) |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5140 |
*/ |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5141 |
bool LibraryCallKit::inline_updateBytesCRC32() { |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5142 |
assert(UseCRC32Intrinsics, "need AVX and LCMUL instructions support"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5143 |
assert(callee()->signature()->size() == 4, "updateBytes has 4 parameters"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5144 |
// no receiver since it is static method |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5145 |
Node* crc = argument(0); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5146 |
Node* src = argument(1); // type: oop |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5147 |
Node* offset = argument(2); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5148 |
Node* length = argument(3); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5149 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5150 |
const Type* src_type = src->Value(&_gvn); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5151 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5152 |
if (top_src == NULL || top_src->klass() == NULL) { |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5153 |
// failed array check |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5154 |
return false; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5155 |
} |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5156 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5157 |
// Figure out the size and type of the elements we will be copying. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5158 |
BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5159 |
if (src_elem != T_BYTE) { |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5160 |
return false; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5161 |
} |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5162 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5163 |
// 'src_start' points to src array + scaled offset |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5164 |
Node* src_start = array_element_address(src, offset, src_elem); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5165 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5166 |
// We assume that range check is done by caller. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5167 |
// TODO: generate range check (offset+length < src.length) in debug VM. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5168 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5169 |
// Call the stub. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5170 |
address stubAddr = StubRoutines::updateBytesCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5171 |
const char *stubName = "updateBytesCRC32"; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5172 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5173 |
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::updateBytesCRC32_Type(), |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5174 |
stubAddr, stubName, TypePtr::BOTTOM, |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5175 |
crc, src_start, length); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5176 |
Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5177 |
set_result(result); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5178 |
return true; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5179 |
} |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5180 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5181 |
/** |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5182 |
* Calculate CRC32 for ByteBuffer. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5183 |
* int java.util.zip.CRC32.updateByteBuffer(int crc, long buf, int off, int len) |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5184 |
*/ |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5185 |
bool LibraryCallKit::inline_updateByteBufferCRC32() { |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5186 |
assert(UseCRC32Intrinsics, "need AVX and LCMUL instructions support"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5187 |
assert(callee()->signature()->size() == 5, "updateByteBuffer has 4 parameters and one is long"); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5188 |
// no receiver since it is static method |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5189 |
Node* crc = argument(0); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5190 |
Node* src = argument(1); // type: long |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5191 |
Node* offset = argument(3); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5192 |
Node* length = argument(4); // type: int |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5193 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5194 |
src = ConvL2X(src); // adjust Java long to machine word |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5195 |
Node* base = _gvn.transform(new CastX2PNode(src)); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5196 |
offset = ConvI2X(offset); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5197 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5198 |
// 'src_start' points to src array + scaled offset |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5199 |
Node* src_start = basic_plus_adr(top(), base, offset); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5200 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5201 |
// Call the stub. |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5202 |
address stubAddr = StubRoutines::updateBytesCRC32(); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5203 |
const char *stubName = "updateBytesCRC32"; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5204 |
|
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5205 |
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::updateBytesCRC32_Type(), |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5206 |
stubAddr, stubName, TypePtr::BOTTOM, |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5207 |
crc, src_start, length); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5208 |
Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5209 |
set_result(result); |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5210 |
return true; |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5211 |
} |
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
18025
diff
changeset
|
5212 |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5213 |
//----------------------------inline_reference_get---------------------------- |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5214 |
// public T java.lang.ref.Reference.get(); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5215 |
bool LibraryCallKit::inline_reference_get() { |
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5216 |
const int referent_offset = java_lang_ref_Reference::referent_offset; |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5217 |
guarantee(referent_offset > 0, "should have already been set"); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5218 |
|
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5219 |
// Get the argument: |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5220 |
Node* reference_obj = null_check_receiver(); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5221 |
if (stopped()) return true; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5222 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5223 |
Node* adr = basic_plus_adr(reference_obj, reference_obj, referent_offset); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5224 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5225 |
ciInstanceKlass* klass = env()->Object_klass(); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5226 |
const TypeOopPtr* object_type = TypeOopPtr::make_from_klass(klass); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5227 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5228 |
Node* no_ctrl = NULL; |
22845
d8812d0ff387
8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents:
21207
diff
changeset
|
5229 |
Node* result = make_load(no_ctrl, adr, object_type, T_OBJECT, MemNode::unordered); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5230 |
|
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5231 |
// Use the pre-barrier to record the value in the referent field |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5232 |
pre_barrier(false /* do_load */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5233 |
control(), |
9185
7b717a00a48e
7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents:
9182
diff
changeset
|
5234 |
NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5235 |
result /* pre_val */, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5236 |
T_OBJECT); |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5237 |
|
13486
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
5238 |
// Add memory barrier to prevent commoning reads from this field |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
5239 |
// across safepoint since GC can change its value. |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
5240 |
insert_mem_bar(Op_MemBarCPUOrder); |
4f0635e148c1
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
13391
diff
changeset
|
5241 |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5242 |
set_result(result); |
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5243 |
return true; |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8734
diff
changeset
|
5244 |
} |
14132 | 5245 |
|
5246 |
||
5247 |
Node * LibraryCallKit::load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, |
|
5248 |
bool is_exact=true, bool is_static=false) { |
|
5249 |
||
5250 |
const TypeInstPtr* tinst = _gvn.type(fromObj)->isa_instptr(); |
|
5251 |
assert(tinst != NULL, "obj is null"); |
|
5252 |
assert(tinst->klass()->is_loaded(), "obj is not loaded"); |
|
5253 |
assert(!is_exact || tinst->klass_is_exact(), "klass not exact"); |
|
5254 |
||
5255 |
ciField* field = tinst->klass()->as_instance_klass()->get_field_by_name(ciSymbol::make(fieldName), |
|
5256 |
ciSymbol::make(fieldTypeString), |
|
5257 |
is_static); |
|
5258 |
if (field == NULL) return (Node *) NULL; |
|
5259 |
assert (field != NULL, "undefined field"); |
|
5260 |
||
5261 |
// Next code copied from Parse::do_get_xxx(): |
|
5262 |
||
5263 |
// Compute address and memory type. |
|
5264 |
int offset = field->offset_in_bytes(); |
|
5265 |
bool is_vol = field->is_volatile(); |
|
5266 |
ciType* field_klass = field->type(); |
|
5267 |
assert(field_klass->is_loaded(), "should be loaded"); |
|
5268 |
const TypePtr* adr_type = C->alias_type(field)->adr_type(); |
|
5269 |
Node *adr = basic_plus_adr(fromObj, fromObj, offset); |
|
5270 |
BasicType bt = field->layout_type(); |
|
5271 |
||
5272 |
// Build the resultant type of the load |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5273 |
const Type *type; |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5274 |
if (bt == T_OBJECT) { |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5275 |
type = TypeOopPtr::make_from_klass(field_klass->as_klass()); |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5276 |
} else { |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5277 |
type = Type::get_const_basic_type(bt); |
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5278 |
} |
14132 | 5279 |
|
26171
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5280 |
if (support_IRIW_for_not_multiple_copy_atomic_cpu && is_vol) { |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5281 |
insert_mem_bar(Op_MemBarVolatile); // StoreLoad barrier |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5282 |
} |
14132 | 5283 |
// Build the load. |
26171
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5284 |
MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered; |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5285 |
Node* loadedField = make_load(NULL, adr, type, bt, adr_type, mo, is_vol); |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5286 |
// If reference is volatile, prevent following memory ops from |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5287 |
// floating up past the volatile read. Also prevents commoning |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5288 |
// another volatile read. |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5289 |
if (is_vol) { |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5290 |
// Memory barrier includes bogus read of value to force load BEFORE membar |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5291 |
insert_mem_bar(Op_MemBarAcquire, loadedField); |
ddd28cb3f2b9
8054927: Missing MemNode::acquire ordering in some volatile Load nodes
kvn
parents:
26166
diff
changeset
|
5292 |
} |
14132 | 5293 |
return loadedField; |
5294 |
} |
|
5295 |
||
5296 |
||
5297 |
//------------------------------inline_aescrypt_Block----------------------- |
|
5298 |
bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) { |
|
5299 |
address stubAddr; |
|
5300 |
const char *stubName; |
|
5301 |
assert(UseAES, "need AES instruction support"); |
|
5302 |
||
5303 |
switch(id) { |
|
5304 |
case vmIntrinsics::_aescrypt_encryptBlock: |
|
5305 |
stubAddr = StubRoutines::aescrypt_encryptBlock(); |
|
5306 |
stubName = "aescrypt_encryptBlock"; |
|
5307 |
break; |
|
5308 |
case vmIntrinsics::_aescrypt_decryptBlock: |
|
5309 |
stubAddr = StubRoutines::aescrypt_decryptBlock(); |
|
5310 |
stubName = "aescrypt_decryptBlock"; |
|
5311 |
break; |
|
5312 |
} |
|
5313 |
if (stubAddr == NULL) return false; |
|
5314 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5315 |
Node* aescrypt_object = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5316 |
Node* src = argument(1); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5317 |
Node* src_offset = argument(2); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5318 |
Node* dest = argument(3); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5319 |
Node* dest_offset = argument(4); |
14132 | 5320 |
|
5321 |
// (1) src and dest are arrays. |
|
5322 |
const Type* src_type = src->Value(&_gvn); |
|
5323 |
const Type* dest_type = dest->Value(&_gvn); |
|
5324 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
|
5325 |
const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
|
5326 |
assert (top_src != NULL && top_src->klass() != NULL && top_dest != NULL && top_dest->klass() != NULL, "args are strange"); |
|
5327 |
||
5328 |
// for the quick and dirty code we will skip all the checks. |
|
5329 |
// we are just trying to get the call to be generated. |
|
5330 |
Node* src_start = src; |
|
5331 |
Node* dest_start = dest; |
|
5332 |
if (src_offset != NULL || dest_offset != NULL) { |
|
5333 |
assert(src_offset != NULL && dest_offset != NULL, ""); |
|
5334 |
src_start = array_element_address(src, src_offset, T_BYTE); |
|
5335 |
dest_start = array_element_address(dest, dest_offset, T_BYTE); |
|
5336 |
} |
|
5337 |
||
5338 |
// now need to get the start of its expanded key array |
|
5339 |
// this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java |
|
5340 |
Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object); |
|
5341 |
if (k_start == NULL) return false; |
|
5342 |
||
22505 | 5343 |
if (Matcher::pass_original_key_for_aes()) { |
5344 |
// on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to |
|
5345 |
// compatibility issues between Java key expansion and SPARC crypto instructions |
|
5346 |
Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object); |
|
5347 |
if (original_k_start == NULL) return false; |
|
5348 |
||
5349 |
// Call the stub. |
|
5350 |
make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), |
|
5351 |
stubAddr, stubName, TypePtr::BOTTOM, |
|
5352 |
src_start, dest_start, k_start, original_k_start); |
|
5353 |
} else { |
|
5354 |
// Call the stub. |
|
5355 |
make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), |
|
5356 |
stubAddr, stubName, TypePtr::BOTTOM, |
|
5357 |
src_start, dest_start, k_start); |
|
5358 |
} |
|
14132 | 5359 |
|
5360 |
return true; |
|
5361 |
} |
|
5362 |
||
5363 |
//------------------------------inline_cipherBlockChaining_AESCrypt----------------------- |
|
5364 |
bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) { |
|
5365 |
address stubAddr; |
|
5366 |
const char *stubName; |
|
5367 |
||
5368 |
assert(UseAES, "need AES instruction support"); |
|
5369 |
||
5370 |
switch(id) { |
|
5371 |
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
|
5372 |
stubAddr = StubRoutines::cipherBlockChaining_encryptAESCrypt(); |
|
5373 |
stubName = "cipherBlockChaining_encryptAESCrypt"; |
|
5374 |
break; |
|
5375 |
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
|
5376 |
stubAddr = StubRoutines::cipherBlockChaining_decryptAESCrypt(); |
|
5377 |
stubName = "cipherBlockChaining_decryptAESCrypt"; |
|
5378 |
break; |
|
5379 |
} |
|
5380 |
if (stubAddr == NULL) return false; |
|
5381 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5382 |
Node* cipherBlockChaining_object = argument(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5383 |
Node* src = argument(1); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5384 |
Node* src_offset = argument(2); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5385 |
Node* len = argument(3); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5386 |
Node* dest = argument(4); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5387 |
Node* dest_offset = argument(5); |
14132 | 5388 |
|
5389 |
// (1) src and dest are arrays. |
|
5390 |
const Type* src_type = src->Value(&_gvn); |
|
5391 |
const Type* dest_type = dest->Value(&_gvn); |
|
5392 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
|
5393 |
const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
|
5394 |
assert (top_src != NULL && top_src->klass() != NULL |
|
5395 |
&& top_dest != NULL && top_dest->klass() != NULL, "args are strange"); |
|
5396 |
||
5397 |
// checks are the responsibility of the caller |
|
5398 |
Node* src_start = src; |
|
5399 |
Node* dest_start = dest; |
|
5400 |
if (src_offset != NULL || dest_offset != NULL) { |
|
5401 |
assert(src_offset != NULL && dest_offset != NULL, ""); |
|
5402 |
src_start = array_element_address(src, src_offset, T_BYTE); |
|
5403 |
dest_start = array_element_address(dest, dest_offset, T_BYTE); |
|
5404 |
} |
|
5405 |
||
5406 |
// if we are in this set of code, we "know" the embeddedCipher is an AESCrypt object |
|
5407 |
// (because of the predicated logic executed earlier). |
|
5408 |
// so we cast it here safely. |
|
5409 |
// this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java |
|
5410 |
||
5411 |
Node* embeddedCipherObj = load_field_from_object(cipherBlockChaining_object, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); |
|
5412 |
if (embeddedCipherObj == NULL) return false; |
|
5413 |
||
5414 |
// cast it to what we know it will be at runtime |
|
5415 |
const TypeInstPtr* tinst = _gvn.type(cipherBlockChaining_object)->isa_instptr(); |
|
5416 |
assert(tinst != NULL, "CBC obj is null"); |
|
5417 |
assert(tinst->klass()->is_loaded(), "CBC obj is not loaded"); |
|
5418 |
ciKlass* klass_AESCrypt = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make("com/sun/crypto/provider/AESCrypt")); |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5419 |
assert(klass_AESCrypt->is_loaded(), "predicate checks that this class is loaded"); |
14132 | 5420 |
|
5421 |
ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); |
|
5422 |
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt); |
|
5423 |
const TypeOopPtr* xtype = aklass->as_instance_type(); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5424 |
Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype); |
14132 | 5425 |
aescrypt_object = _gvn.transform(aescrypt_object); |
5426 |
||
5427 |
// we need to get the start of the aescrypt_object's expanded key array |
|
5428 |
Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object); |
|
5429 |
if (k_start == NULL) return false; |
|
5430 |
||
5431 |
// similarly, get the start address of the r vector |
|
5432 |
Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false); |
|
5433 |
if (objRvec == NULL) return false; |
|
5434 |
Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE); |
|
5435 |
||
22505 | 5436 |
Node* cbcCrypt; |
5437 |
if (Matcher::pass_original_key_for_aes()) { |
|
5438 |
// on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to |
|
5439 |
// compatibility issues between Java key expansion and SPARC crypto instructions |
|
5440 |
Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object); |
|
5441 |
if (original_k_start == NULL) return false; |
|
5442 |
||
5443 |
// Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start |
|
5444 |
cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP, |
|
5445 |
OptoRuntime::cipherBlockChaining_aescrypt_Type(), |
|
5446 |
stubAddr, stubName, TypePtr::BOTTOM, |
|
5447 |
src_start, dest_start, k_start, r_start, len, original_k_start); |
|
5448 |
} else { |
|
5449 |
// Call the stub, passing src_start, dest_start, k_start, r_start and src_len |
|
5450 |
cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP, |
|
5451 |
OptoRuntime::cipherBlockChaining_aescrypt_Type(), |
|
5452 |
stubAddr, stubName, TypePtr::BOTTOM, |
|
5453 |
src_start, dest_start, k_start, r_start, len); |
|
5454 |
} |
|
5455 |
||
5456 |
// return cipher length (int) |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5457 |
Node* retvalue = _gvn.transform(new ProjNode(cbcCrypt, TypeFunc::Parms)); |
22505 | 5458 |
set_result(retvalue); |
14132 | 5459 |
return true; |
5460 |
} |
|
5461 |
||
5462 |
//------------------------------get_key_start_from_aescrypt_object----------------------- |
|
5463 |
Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) { |
|
5464 |
Node* objAESCryptKey = load_field_from_object(aescrypt_object, "K", "[I", /*is_exact*/ false); |
|
5465 |
assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt"); |
|
5466 |
if (objAESCryptKey == NULL) return (Node *) NULL; |
|
5467 |
||
5468 |
// now have the array, need to get the start address of the K array |
|
5469 |
Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT); |
|
5470 |
return k_start; |
|
5471 |
} |
|
5472 |
||
22505 | 5473 |
//------------------------------get_original_key_start_from_aescrypt_object----------------------- |
5474 |
Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) { |
|
5475 |
Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false); |
|
5476 |
assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt"); |
|
5477 |
if (objAESCryptKey == NULL) return (Node *) NULL; |
|
5478 |
||
5479 |
// now have the array, need to get the start address of the lastKey array |
|
5480 |
Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE); |
|
5481 |
return original_k_start; |
|
5482 |
} |
|
5483 |
||
14132 | 5484 |
//----------------------------inline_cipherBlockChaining_AESCrypt_predicate---------------------------- |
5485 |
// Return node representing slow path of predicate check. |
|
5486 |
// the pseudo code we want to emulate with this predicate is: |
|
5487 |
// for encryption: |
|
5488 |
// if (embeddedCipherObj instanceof AESCrypt) do_intrinsic, else do_javapath |
|
5489 |
// for decryption: |
|
5490 |
// if ((embeddedCipherObj instanceof AESCrypt) && (cipher!=plain)) do_intrinsic, else do_javapath |
|
5491 |
// note cipher==plain is more conservative than the original java code but that's OK |
|
5492 |
// |
|
5493 |
Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting) { |
|
24948
bc074f400757
8035605: Expand functionality of PredictedIntrinsicGenerator
kvn
parents:
24946
diff
changeset
|
5494 |
// The receiver was checked for NULL already. |
14132 | 5495 |
Node* objCBC = argument(0); |
5496 |
||
5497 |
// Load embeddedCipher field of CipherBlockChaining object. |
|
5498 |
Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); |
|
5499 |
||
5500 |
// get AESCrypt klass for instanceOf check |
|
5501 |
// AESCrypt might not be loaded yet if some other SymmetricCipher got us to this compile point |
|
5502 |
// will have same classloader as CipherBlockChaining object |
|
5503 |
const TypeInstPtr* tinst = _gvn.type(objCBC)->isa_instptr(); |
|
5504 |
assert(tinst != NULL, "CBCobj is null"); |
|
5505 |
assert(tinst->klass()->is_loaded(), "CBCobj is not loaded"); |
|
5506 |
||
5507 |
// we want to do an instanceof comparison against the AESCrypt class |
|
5508 |
ciKlass* klass_AESCrypt = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make("com/sun/crypto/provider/AESCrypt")); |
|
5509 |
if (!klass_AESCrypt->is_loaded()) { |
|
5510 |
// if AESCrypt is not even loaded, we never take the intrinsic fast path |
|
5511 |
Node* ctrl = control(); |
|
5512 |
set_control(top()); // no regular fast path |
|
5513 |
return ctrl; |
|
5514 |
} |
|
5515 |
ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); |
|
5516 |
||
5517 |
Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt))); |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5518 |
Node* cmp_instof = _gvn.transform(new CmpINode(instof, intcon(1))); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5519 |
Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne)); |
14132 | 5520 |
|
5521 |
Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); |
|
5522 |
||
5523 |
// for encryption, we are done |
|
5524 |
if (!decrypting) |
|
5525 |
return instof_false; // even if it is NULL |
|
5526 |
||
5527 |
// for decryption, we need to add a further check to avoid |
|
5528 |
// taking the intrinsic path when cipher and plain are the same |
|
5529 |
// see the original java code for why. |
|
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5530 |
RegionNode* region = new RegionNode(3); |
14132 | 5531 |
region->init_req(1, instof_false); |
5532 |
Node* src = argument(1); |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
14132
diff
changeset
|
5533 |
Node* dest = argument(4); |
24923
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5534 |
Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest)); |
9631f7d691dc
8034812: remove IDX_INIT macro hack in Node class
thartmann
parents:
24916
diff
changeset
|
5535 |
Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq)); |
14132 | 5536 |
Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN); |
5537 |
region->init_req(2, src_dest_conjoint); |
|
5538 |
||
5539 |
record_for_igvn(region); |
|
5540 |
return _gvn.transform(region); |
|
5541 |
} |
|
24953
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5542 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5543 |
//------------------------------inline_sha_implCompress----------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5544 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5545 |
// Calculate SHA (i.e., SHA-1) for single-block byte[] array. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5546 |
// void com.sun.security.provider.SHA.implCompress(byte[] buf, int ofs) |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5547 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5548 |
// Calculate SHA2 (i.e., SHA-244 or SHA-256) for single-block byte[] array. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5549 |
// void com.sun.security.provider.SHA2.implCompress(byte[] buf, int ofs) |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5550 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5551 |
// Calculate SHA5 (i.e., SHA-384 or SHA-512) for single-block byte[] array. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5552 |
// void com.sun.security.provider.SHA5.implCompress(byte[] buf, int ofs) |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5553 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5554 |
bool LibraryCallKit::inline_sha_implCompress(vmIntrinsics::ID id) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5555 |
assert(callee()->signature()->size() == 2, "sha_implCompress has 2 parameters"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5556 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5557 |
Node* sha_obj = argument(0); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5558 |
Node* src = argument(1); // type oop |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5559 |
Node* ofs = argument(2); // type int |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5560 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5561 |
const Type* src_type = src->Value(&_gvn); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5562 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5563 |
if (top_src == NULL || top_src->klass() == NULL) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5564 |
// failed array check |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5565 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5566 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5567 |
// Figure out the size and type of the elements we will be copying. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5568 |
BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5569 |
if (src_elem != T_BYTE) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5570 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5571 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5572 |
// 'src_start' points to src array + offset |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5573 |
Node* src_start = array_element_address(src, ofs, src_elem); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5574 |
Node* state = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5575 |
address stubAddr; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5576 |
const char *stubName; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5577 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5578 |
switch(id) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5579 |
case vmIntrinsics::_sha_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5580 |
assert(UseSHA1Intrinsics, "need SHA1 instruction support"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5581 |
state = get_state_from_sha_object(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5582 |
stubAddr = StubRoutines::sha1_implCompress(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5583 |
stubName = "sha1_implCompress"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5584 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5585 |
case vmIntrinsics::_sha2_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5586 |
assert(UseSHA256Intrinsics, "need SHA256 instruction support"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5587 |
state = get_state_from_sha_object(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5588 |
stubAddr = StubRoutines::sha256_implCompress(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5589 |
stubName = "sha256_implCompress"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5590 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5591 |
case vmIntrinsics::_sha5_implCompress: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5592 |
assert(UseSHA512Intrinsics, "need SHA512 instruction support"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5593 |
state = get_state_from_sha5_object(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5594 |
stubAddr = StubRoutines::sha512_implCompress(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5595 |
stubName = "sha512_implCompress"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5596 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5597 |
default: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5598 |
fatal_unexpected_iid(id); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5599 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5600 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5601 |
if (state == NULL) return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5602 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5603 |
// Call the stub. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5604 |
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::sha_implCompress_Type(), |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5605 |
stubAddr, stubName, TypePtr::BOTTOM, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5606 |
src_start, state); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5607 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5608 |
return true; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5609 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5610 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5611 |
//------------------------------inline_digestBase_implCompressMB----------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5612 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5613 |
// Calculate SHA/SHA2/SHA5 for multi-block byte[] array. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5614 |
// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit) |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5615 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5616 |
bool LibraryCallKit::inline_digestBase_implCompressMB(int predicate) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5617 |
assert(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5618 |
"need SHA1/SHA256/SHA512 instruction support"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5619 |
assert((uint)predicate < 3, "sanity"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5620 |
assert(callee()->signature()->size() == 3, "digestBase_implCompressMB has 3 parameters"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5621 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5622 |
Node* digestBase_obj = argument(0); // The receiver was checked for NULL already. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5623 |
Node* src = argument(1); // byte[] array |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5624 |
Node* ofs = argument(2); // type int |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5625 |
Node* limit = argument(3); // type int |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5626 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5627 |
const Type* src_type = src->Value(&_gvn); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5628 |
const TypeAryPtr* top_src = src_type->isa_aryptr(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5629 |
if (top_src == NULL || top_src->klass() == NULL) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5630 |
// failed array check |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5631 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5632 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5633 |
// Figure out the size and type of the elements we will be copying. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5634 |
BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5635 |
if (src_elem != T_BYTE) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5636 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5637 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5638 |
// 'src_start' points to src array + offset |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5639 |
Node* src_start = array_element_address(src, ofs, src_elem); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5640 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5641 |
const char* klass_SHA_name = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5642 |
const char* stub_name = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5643 |
address stub_addr = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5644 |
bool long_state = false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5645 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5646 |
switch (predicate) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5647 |
case 0: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5648 |
if (UseSHA1Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5649 |
klass_SHA_name = "sun/security/provider/SHA"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5650 |
stub_name = "sha1_implCompressMB"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5651 |
stub_addr = StubRoutines::sha1_implCompressMB(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5652 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5653 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5654 |
case 1: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5655 |
if (UseSHA256Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5656 |
klass_SHA_name = "sun/security/provider/SHA2"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5657 |
stub_name = "sha256_implCompressMB"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5658 |
stub_addr = StubRoutines::sha256_implCompressMB(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5659 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5660 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5661 |
case 2: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5662 |
if (UseSHA512Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5663 |
klass_SHA_name = "sun/security/provider/SHA5"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5664 |
stub_name = "sha512_implCompressMB"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5665 |
stub_addr = StubRoutines::sha512_implCompressMB(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5666 |
long_state = true; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5667 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5668 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5669 |
default: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5670 |
fatal(err_msg_res("unknown SHA intrinsic predicate: %d", predicate)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5671 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5672 |
if (klass_SHA_name != NULL) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5673 |
// get DigestBase klass to lookup for SHA klass |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5674 |
const TypeInstPtr* tinst = _gvn.type(digestBase_obj)->isa_instptr(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5675 |
assert(tinst != NULL, "digestBase_obj is not instance???"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5676 |
assert(tinst->klass()->is_loaded(), "DigestBase is not loaded"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5677 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5678 |
ciKlass* klass_SHA = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make(klass_SHA_name)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5679 |
assert(klass_SHA->is_loaded(), "predicate checks that this class is loaded"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5680 |
ciInstanceKlass* instklass_SHA = klass_SHA->as_instance_klass(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5681 |
return inline_sha_implCompressMB(digestBase_obj, instklass_SHA, long_state, stub_addr, stub_name, src_start, ofs, limit); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5682 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5683 |
return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5684 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5685 |
//------------------------------inline_sha_implCompressMB----------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5686 |
bool LibraryCallKit::inline_sha_implCompressMB(Node* digestBase_obj, ciInstanceKlass* instklass_SHA, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5687 |
bool long_state, address stubAddr, const char *stubName, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5688 |
Node* src_start, Node* ofs, Node* limit) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5689 |
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_SHA); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5690 |
const TypeOopPtr* xtype = aklass->as_instance_type(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5691 |
Node* sha_obj = new CheckCastPPNode(control(), digestBase_obj, xtype); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5692 |
sha_obj = _gvn.transform(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5693 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5694 |
Node* state; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5695 |
if (long_state) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5696 |
state = get_state_from_sha5_object(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5697 |
} else { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5698 |
state = get_state_from_sha_object(sha_obj); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5699 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5700 |
if (state == NULL) return false; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5701 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5702 |
// Call the stub. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5703 |
Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5704 |
OptoRuntime::digestBase_implCompressMB_Type(), |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5705 |
stubAddr, stubName, TypePtr::BOTTOM, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5706 |
src_start, state, ofs, limit); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5707 |
// return ofs (int) |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5708 |
Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5709 |
set_result(result); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5710 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5711 |
return true; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5712 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5713 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5714 |
//------------------------------get_state_from_sha_object----------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5715 |
Node * LibraryCallKit::get_state_from_sha_object(Node *sha_object) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5716 |
Node* sha_state = load_field_from_object(sha_object, "state", "[I", /*is_exact*/ false); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5717 |
assert (sha_state != NULL, "wrong version of sun.security.provider.SHA/SHA2"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5718 |
if (sha_state == NULL) return (Node *) NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5719 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5720 |
// now have the array, need to get the start address of the state array |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5721 |
Node* state = array_element_address(sha_state, intcon(0), T_INT); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5722 |
return state; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5723 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5724 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5725 |
//------------------------------get_state_from_sha5_object----------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5726 |
Node * LibraryCallKit::get_state_from_sha5_object(Node *sha_object) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5727 |
Node* sha_state = load_field_from_object(sha_object, "state", "[J", /*is_exact*/ false); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5728 |
assert (sha_state != NULL, "wrong version of sun.security.provider.SHA5"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5729 |
if (sha_state == NULL) return (Node *) NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5730 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5731 |
// now have the array, need to get the start address of the state array |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5732 |
Node* state = array_element_address(sha_state, intcon(0), T_LONG); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5733 |
return state; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5734 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5735 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5736 |
//----------------------------inline_digestBase_implCompressMB_predicate---------------------------- |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5737 |
// Return node representing slow path of predicate check. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5738 |
// the pseudo code we want to emulate with this predicate is: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5739 |
// if (digestBaseObj instanceof SHA/SHA2/SHA5) do_intrinsic, else do_javapath |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5740 |
// |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5741 |
Node* LibraryCallKit::inline_digestBase_implCompressMB_predicate(int predicate) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5742 |
assert(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics, |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5743 |
"need SHA1/SHA256/SHA512 instruction support"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5744 |
assert((uint)predicate < 3, "sanity"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5745 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5746 |
// The receiver was checked for NULL already. |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5747 |
Node* digestBaseObj = argument(0); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5748 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5749 |
// get DigestBase klass for instanceOf check |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5750 |
const TypeInstPtr* tinst = _gvn.type(digestBaseObj)->isa_instptr(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5751 |
assert(tinst != NULL, "digestBaseObj is null"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5752 |
assert(tinst->klass()->is_loaded(), "DigestBase is not loaded"); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5753 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5754 |
const char* klass_SHA_name = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5755 |
switch (predicate) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5756 |
case 0: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5757 |
if (UseSHA1Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5758 |
// we want to do an instanceof comparison against the SHA class |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5759 |
klass_SHA_name = "sun/security/provider/SHA"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5760 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5761 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5762 |
case 1: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5763 |
if (UseSHA256Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5764 |
// we want to do an instanceof comparison against the SHA2 class |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5765 |
klass_SHA_name = "sun/security/provider/SHA2"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5766 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5767 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5768 |
case 2: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5769 |
if (UseSHA512Intrinsics) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5770 |
// we want to do an instanceof comparison against the SHA5 class |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5771 |
klass_SHA_name = "sun/security/provider/SHA5"; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5772 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5773 |
break; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5774 |
default: |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5775 |
fatal(err_msg_res("unknown SHA intrinsic predicate: %d", predicate)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5776 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5777 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5778 |
ciKlass* klass_SHA = NULL; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5779 |
if (klass_SHA_name != NULL) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5780 |
klass_SHA = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make(klass_SHA_name)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5781 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5782 |
if ((klass_SHA == NULL) || !klass_SHA->is_loaded()) { |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5783 |
// if none of SHA/SHA2/SHA5 is loaded, we never take the intrinsic fast path |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5784 |
Node* ctrl = control(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5785 |
set_control(top()); // no intrinsic path |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5786 |
return ctrl; |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5787 |
} |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5788 |
ciInstanceKlass* instklass_SHA = klass_SHA->as_instance_klass(); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5789 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5790 |
Node* instofSHA = gen_instanceof(digestBaseObj, makecon(TypeKlassPtr::make(instklass_SHA))); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5791 |
Node* cmp_instof = _gvn.transform(new CmpINode(instofSHA, intcon(1))); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5792 |
Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne)); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5793 |
Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5794 |
|
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5795 |
return instof_false; // even if it is NULL |
9680119572be
8035968: Leverage CPU Instructions to Improve SHA Performance on SPARC
kvn
parents:
24948
diff
changeset
|
5796 |
} |