Mercurial > hg > graal-compiler
comparison src/share/vm/opto/library_call.cpp @ 7206:d2f8c38e543d
Merge
author | roland |
---|---|
date | Fri, 07 Dec 2012 01:09:03 -0800 |
parents | dd38cfd12c3a |
children | 18712b1caf7a ad5dd04754ee eb409f2f146e |
comparison
equal
deleted
inserted
replaced
7191:816b7e5bf2ed | 7206:d2f8c38e543d |
---|---|
65 | 65 |
66 | 66 |
67 // Local helper class for LibraryIntrinsic: | 67 // Local helper class for LibraryIntrinsic: |
68 class LibraryCallKit : public GraphKit { | 68 class LibraryCallKit : public GraphKit { |
69 private: | 69 private: |
70 LibraryIntrinsic* _intrinsic; // the library intrinsic being called | 70 LibraryIntrinsic* _intrinsic; // the library intrinsic being called |
71 Node* _result; // the result node, if any | |
72 int _reexecute_sp; // the stack pointer when bytecode needs to be reexecuted | |
71 | 73 |
72 const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr = false); | 74 const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr = false); |
73 | 75 |
74 public: | 76 public: |
75 LibraryCallKit(JVMState* caller, LibraryIntrinsic* intrinsic) | 77 LibraryCallKit(JVMState* jvms, LibraryIntrinsic* intrinsic) |
76 : GraphKit(caller), | 78 : GraphKit(jvms), |
77 _intrinsic(intrinsic) | 79 _intrinsic(intrinsic), |
80 _result(NULL) | |
78 { | 81 { |
79 } | 82 // Check if this is a root compile. In that case we don't have a caller. |
83 if (!jvms->has_method()) { | |
84 _reexecute_sp = sp(); | |
85 } else { | |
86 // Find out how many arguments the interpreter needs when deoptimizing | |
87 // and save the stack pointer value so it can used by uncommon_trap. | |
88 // We find the argument count by looking at the declared signature. | |
89 bool ignored_will_link; | |
90 ciSignature* declared_signature = NULL; | |
91 ciMethod* ignored_callee = caller()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); | |
92 const int nargs = declared_signature->arg_size_for_bc(caller()->java_code_at_bci(bci())); | |
93 _reexecute_sp = sp() + nargs; // "push" arguments back on stack | |
94 } | |
95 } | |
96 | |
97 virtual LibraryCallKit* is_LibraryCallKit() const { return (LibraryCallKit*)this; } | |
80 | 98 |
81 ciMethod* caller() const { return jvms()->method(); } | 99 ciMethod* caller() const { return jvms()->method(); } |
82 int bci() const { return jvms()->bci(); } | 100 int bci() const { return jvms()->bci(); } |
83 LibraryIntrinsic* intrinsic() const { return _intrinsic; } | 101 LibraryIntrinsic* intrinsic() const { return _intrinsic; } |
84 vmIntrinsics::ID intrinsic_id() const { return _intrinsic->intrinsic_id(); } | 102 vmIntrinsics::ID intrinsic_id() const { return _intrinsic->intrinsic_id(); } |
85 ciMethod* callee() const { return _intrinsic->method(); } | 103 ciMethod* callee() const { return _intrinsic->method(); } |
86 ciSignature* signature() const { return callee()->signature(); } | |
87 int arg_size() const { return callee()->arg_size(); } | |
88 | 104 |
89 bool try_to_inline(); | 105 bool try_to_inline(); |
90 Node* try_to_predicate(); | 106 Node* try_to_predicate(); |
91 | 107 |
108 void push_result() { | |
109 // Push the result onto the stack. | |
110 if (!stopped() && result() != NULL) { | |
111 BasicType bt = result()->bottom_type()->basic_type(); | |
112 push_node(bt, result()); | |
113 } | |
114 } | |
115 | |
116 private: | |
117 void fatal_unexpected_iid(vmIntrinsics::ID iid) { | |
118 fatal(err_msg_res("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid))); | |
119 } | |
120 | |
121 void set_result(Node* n) { assert(_result == NULL, "only set once"); _result = n; } | |
122 void set_result(RegionNode* region, PhiNode* value); | |
123 Node* result() { return _result; } | |
124 | |
125 virtual int reexecute_sp() { return _reexecute_sp; } | |
126 | |
92 // Helper functions to inline natives | 127 // Helper functions to inline natives |
93 void push_result(RegionNode* region, PhiNode* value); | |
94 Node* generate_guard(Node* test, RegionNode* region, float true_prob); | 128 Node* generate_guard(Node* test, RegionNode* region, float true_prob); |
95 Node* generate_slow_guard(Node* test, RegionNode* region); | 129 Node* generate_slow_guard(Node* test, RegionNode* region); |
96 Node* generate_fair_guard(Node* test, RegionNode* region); | 130 Node* generate_fair_guard(Node* test, RegionNode* region); |
97 Node* generate_negative_guard(Node* index, RegionNode* region, | 131 Node* generate_negative_guard(Node* index, RegionNode* region, |
98 // resulting CastII of index: | 132 // resulting CastII of index: |
106 Node* generate_current_thread(Node* &tls_output); | 140 Node* generate_current_thread(Node* &tls_output); |
107 address basictype2arraycopy(BasicType t, Node *src_offset, Node *dest_offset, | 141 address basictype2arraycopy(BasicType t, Node *src_offset, Node *dest_offset, |
108 bool disjoint_bases, const char* &name, bool dest_uninitialized); | 142 bool disjoint_bases, const char* &name, bool dest_uninitialized); |
109 Node* load_mirror_from_klass(Node* klass); | 143 Node* load_mirror_from_klass(Node* klass); |
110 Node* load_klass_from_mirror_common(Node* mirror, bool never_see_null, | 144 Node* load_klass_from_mirror_common(Node* mirror, bool never_see_null, |
111 int nargs, | |
112 RegionNode* region, int null_path, | 145 RegionNode* region, int null_path, |
113 int offset); | 146 int offset); |
114 Node* load_klass_from_mirror(Node* mirror, bool never_see_null, int nargs, | 147 Node* load_klass_from_mirror(Node* mirror, bool never_see_null, |
115 RegionNode* region, int null_path) { | 148 RegionNode* region, int null_path) { |
116 int offset = java_lang_Class::klass_offset_in_bytes(); | 149 int offset = java_lang_Class::klass_offset_in_bytes(); |
117 return load_klass_from_mirror_common(mirror, never_see_null, nargs, | 150 return load_klass_from_mirror_common(mirror, never_see_null, |
118 region, null_path, | 151 region, null_path, |
119 offset); | 152 offset); |
120 } | 153 } |
121 Node* load_array_klass_from_mirror(Node* mirror, bool never_see_null, | 154 Node* load_array_klass_from_mirror(Node* mirror, bool never_see_null, |
122 int nargs, | |
123 RegionNode* region, int null_path) { | 155 RegionNode* region, int null_path) { |
124 int offset = java_lang_Class::array_klass_offset_in_bytes(); | 156 int offset = java_lang_Class::array_klass_offset_in_bytes(); |
125 return load_klass_from_mirror_common(mirror, never_see_null, nargs, | 157 return load_klass_from_mirror_common(mirror, never_see_null, |
126 region, null_path, | 158 region, null_path, |
127 offset); | 159 offset); |
128 } | 160 } |
129 Node* generate_access_flags_guard(Node* kls, | 161 Node* generate_access_flags_guard(Node* kls, |
130 int modifier_mask, int modifier_bits, | 162 int modifier_mask, int modifier_bits, |
159 Node* make_string_method_node(int opcode, Node* str1, Node* str2); | 191 Node* make_string_method_node(int opcode, Node* str1, Node* str2); |
160 bool inline_string_compareTo(); | 192 bool inline_string_compareTo(); |
161 bool inline_string_indexOf(); | 193 bool inline_string_indexOf(); |
162 Node* string_indexOf(Node* string_object, ciTypeArray* target_array, jint offset, jint cache_i, jint md2_i); | 194 Node* string_indexOf(Node* string_object, ciTypeArray* target_array, jint offset, jint cache_i, jint md2_i); |
163 bool inline_string_equals(); | 195 bool inline_string_equals(); |
164 Node* pop_math_arg(); | 196 Node* round_double_node(Node* n); |
165 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName); | 197 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName); |
166 bool inline_math_native(vmIntrinsics::ID id); | 198 bool inline_math_native(vmIntrinsics::ID id); |
167 bool inline_trig(vmIntrinsics::ID id); | 199 bool inline_trig(vmIntrinsics::ID id); |
168 bool inline_trans(vmIntrinsics::ID id); | 200 bool inline_math(vmIntrinsics::ID id); |
169 bool inline_abs(vmIntrinsics::ID id); | 201 bool inline_exp(); |
170 bool inline_sqrt(vmIntrinsics::ID id); | 202 bool inline_pow(); |
171 void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); | 203 void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); |
172 bool inline_pow(vmIntrinsics::ID id); | |
173 bool inline_exp(vmIntrinsics::ID id); | |
174 bool inline_min_max(vmIntrinsics::ID id); | 204 bool inline_min_max(vmIntrinsics::ID id); |
175 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); | 205 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); |
176 // This returns Type::AnyPtr, RawPtr, or OopPtr. | 206 // This returns Type::AnyPtr, RawPtr, or OopPtr. |
177 int classify_unsafe_addr(Node* &base, Node* &offset); | 207 int classify_unsafe_addr(Node* &base, Node* &offset); |
178 Node* make_unsafe_address(Node* base, Node* offset); | 208 Node* make_unsafe_address(Node* base, Node* offset); |
179 // Helper for inline_unsafe_access. | 209 // Helper for inline_unsafe_access. |
180 // Generates the guards that check whether the result of | 210 // Generates the guards that check whether the result of |
181 // Unsafe.getObject should be recorded in an SATB log buffer. | 211 // Unsafe.getObject should be recorded in an SATB log buffer. |
182 void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, int nargs, bool need_mem_bar); | 212 void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar); |
183 bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile); | 213 bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile); |
184 bool inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static); | 214 bool inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static); |
185 bool inline_unsafe_allocate(); | 215 bool inline_unsafe_allocate(); |
186 bool inline_unsafe_copyMemory(); | 216 bool inline_unsafe_copyMemory(); |
187 bool inline_native_currentThread(); | 217 bool inline_native_currentThread(); |
251 Node* copy_length, bool dest_uninitialized); | 281 Node* copy_length, bool dest_uninitialized); |
252 typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind; | 282 typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind; |
253 bool inline_unsafe_load_store(BasicType type, LoadStoreKind kind); | 283 bool inline_unsafe_load_store(BasicType type, LoadStoreKind kind); |
254 bool inline_unsafe_ordered_store(BasicType type); | 284 bool inline_unsafe_ordered_store(BasicType type); |
255 bool inline_fp_conversions(vmIntrinsics::ID id); | 285 bool inline_fp_conversions(vmIntrinsics::ID id); |
256 bool inline_numberOfLeadingZeros(vmIntrinsics::ID id); | 286 bool inline_number_methods(vmIntrinsics::ID id); |
257 bool inline_numberOfTrailingZeros(vmIntrinsics::ID id); | |
258 bool inline_bitCount(vmIntrinsics::ID id); | |
259 bool inline_reverseBytes(vmIntrinsics::ID id); | |
260 | |
261 bool inline_reference_get(); | 287 bool inline_reference_get(); |
262 bool inline_aescrypt_Block(vmIntrinsics::ID id); | 288 bool inline_aescrypt_Block(vmIntrinsics::ID id); |
263 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); | 289 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); |
264 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); | 290 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); |
265 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); | 291 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); |
319 bool is_predicted = false; | 345 bool is_predicted = false; |
320 | 346 |
321 switch (id) { | 347 switch (id) { |
322 case vmIntrinsics::_compareTo: | 348 case vmIntrinsics::_compareTo: |
323 if (!SpecialStringCompareTo) return NULL; | 349 if (!SpecialStringCompareTo) return NULL; |
350 if (!Matcher::match_rule_supported(Op_StrComp)) return NULL; | |
324 break; | 351 break; |
325 case vmIntrinsics::_indexOf: | 352 case vmIntrinsics::_indexOf: |
326 if (!SpecialStringIndexOf) return NULL; | 353 if (!SpecialStringIndexOf) return NULL; |
327 break; | 354 break; |
328 case vmIntrinsics::_equals: | 355 case vmIntrinsics::_equals: |
329 if (!SpecialStringEquals) return NULL; | 356 if (!SpecialStringEquals) return NULL; |
357 if (!Matcher::match_rule_supported(Op_StrEquals)) return NULL; | |
330 break; | 358 break; |
331 case vmIntrinsics::_equalsC: | 359 case vmIntrinsics::_equalsC: |
332 if (!SpecialArraysEquals) return NULL; | 360 if (!SpecialArraysEquals) return NULL; |
361 if (!Matcher::match_rule_supported(Op_AryEq)) return NULL; | |
333 break; | 362 break; |
334 case vmIntrinsics::_arraycopy: | 363 case vmIntrinsics::_arraycopy: |
335 if (!InlineArrayCopy) return NULL; | 364 if (!InlineArrayCopy) return NULL; |
336 break; | 365 break; |
337 case vmIntrinsics::_copyMemory: | 366 case vmIntrinsics::_copyMemory: |
378 if (!Matcher::match_rule_supported(Op_CountTrailingZerosI)) return NULL; | 407 if (!Matcher::match_rule_supported(Op_CountTrailingZerosI)) return NULL; |
379 break; | 408 break; |
380 | 409 |
381 case vmIntrinsics::_numberOfTrailingZeros_l: | 410 case vmIntrinsics::_numberOfTrailingZeros_l: |
382 if (!Matcher::match_rule_supported(Op_CountTrailingZerosL)) return NULL; | 411 if (!Matcher::match_rule_supported(Op_CountTrailingZerosL)) return NULL; |
412 break; | |
413 | |
414 case vmIntrinsics::_reverseBytes_c: | |
415 if (!Matcher::match_rule_supported(Op_ReverseBytesUS)) return false; | |
416 break; | |
417 case vmIntrinsics::_reverseBytes_s: | |
418 if (!Matcher::match_rule_supported(Op_ReverseBytesS)) return false; | |
419 break; | |
420 case vmIntrinsics::_reverseBytes_i: | |
421 if (!Matcher::match_rule_supported(Op_ReverseBytesI)) return false; | |
422 break; | |
423 case vmIntrinsics::_reverseBytes_l: | |
424 if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false; | |
383 break; | 425 break; |
384 | 426 |
385 case vmIntrinsics::_Reference_get: | 427 case vmIntrinsics::_Reference_get: |
386 // Use the intrinsic version of Reference.get() so that the value in | 428 // Use the intrinsic version of Reference.get() so that the value in |
387 // the referent field can be registered by the G1 pre-barrier code. | 429 // the referent field can be registered by the G1 pre-barrier code. |
486 char buf[1000]; | 528 char buf[1000]; |
487 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); | 529 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); |
488 tty->print_cr("Intrinsic %s", str); | 530 tty->print_cr("Intrinsic %s", str); |
489 } | 531 } |
490 #endif | 532 #endif |
491 | 533 ciMethod* callee = kit.callee(); |
534 const int bci = kit.bci(); | |
535 | |
536 // Try to inline the intrinsic. | |
492 if (kit.try_to_inline()) { | 537 if (kit.try_to_inline()) { |
493 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { | 538 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { |
494 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); | 539 CompileTask::print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); |
495 } | 540 } |
496 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); | 541 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); |
497 if (C->log()) { | 542 if (C->log()) { |
498 C->log()->elem("intrinsic id='%s'%s nodes='%d'", | 543 C->log()->elem("intrinsic id='%s'%s nodes='%d'", |
499 vmIntrinsics::name_at(intrinsic_id()), | 544 vmIntrinsics::name_at(intrinsic_id()), |
500 (is_virtual() ? " virtual='1'" : ""), | 545 (is_virtual() ? " virtual='1'" : ""), |
501 C->unique() - nodes); | 546 C->unique() - nodes); |
502 } | 547 } |
548 // Push the result from the inlined method onto the stack. | |
549 kit.push_result(); | |
503 return kit.transfer_exceptions_into_jvms(); | 550 return kit.transfer_exceptions_into_jvms(); |
504 } | 551 } |
505 | 552 |
506 // The intrinsic bailed out | 553 // The intrinsic bailed out |
507 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { | 554 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { |
508 if (jvms->has_method()) { | 555 if (jvms->has_method()) { |
509 // Not a root compile. | 556 // Not a root compile. |
510 const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)"; | 557 const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)"; |
511 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), msg); | 558 CompileTask::print_inlining(callee, jvms->depth() - 1, bci, msg); |
512 } else { | 559 } else { |
513 // Root compile | 560 // Root compile |
514 tty->print("Did not generate intrinsic %s%s at bci:%d in", | 561 tty->print("Did not generate intrinsic %s%s at bci:%d in", |
515 vmIntrinsics::name_at(intrinsic_id()), | 562 vmIntrinsics::name_at(intrinsic_id()), |
516 (is_virtual() ? " (virtual)" : ""), kit.bci()); | 563 (is_virtual() ? " (virtual)" : ""), bci); |
517 } | 564 } |
518 } | 565 } |
519 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); | 566 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); |
520 return NULL; | 567 return NULL; |
521 } | 568 } |
530 char buf[1000]; | 577 char buf[1000]; |
531 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); | 578 const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); |
532 tty->print_cr("Predicate for intrinsic %s", str); | 579 tty->print_cr("Predicate for intrinsic %s", str); |
533 } | 580 } |
534 #endif | 581 #endif |
582 ciMethod* callee = kit.callee(); | |
583 const int bci = kit.bci(); | |
535 | 584 |
536 Node* slow_ctl = kit.try_to_predicate(); | 585 Node* slow_ctl = kit.try_to_predicate(); |
537 if (!kit.failing()) { | 586 if (!kit.failing()) { |
587 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { | |
588 CompileTask::print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); | |
589 } | |
590 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); | |
538 if (C->log()) { | 591 if (C->log()) { |
539 C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'", | 592 C->log()->elem("predicate_intrinsic id='%s'%s nodes='%d'", |
540 vmIntrinsics::name_at(intrinsic_id()), | 593 vmIntrinsics::name_at(intrinsic_id()), |
541 (is_virtual() ? " virtual='1'" : ""), | 594 (is_virtual() ? " virtual='1'" : ""), |
542 C->unique() - nodes); | 595 C->unique() - nodes); |
547 // The intrinsic bailed out | 600 // The intrinsic bailed out |
548 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { | 601 if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) { |
549 if (jvms->has_method()) { | 602 if (jvms->has_method()) { |
550 // Not a root compile. | 603 // Not a root compile. |
551 const char* msg = "failed to generate predicate for intrinsic"; | 604 const char* msg = "failed to generate predicate for intrinsic"; |
552 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, kit.bci(), msg); | 605 CompileTask::print_inlining(kit.callee(), jvms->depth() - 1, bci, msg); |
553 } else { | 606 } else { |
554 // Root compile | 607 // Root compile |
555 tty->print("Did not generate predicate for intrinsic %s%s at bci:%d in", | 608 tty->print("Did not generate predicate for intrinsic %s%s at bci:%d in", |
556 vmIntrinsics::name_at(intrinsic_id()), | 609 vmIntrinsics::name_at(intrinsic_id()), |
557 (is_virtual() ? " (virtual)" : ""), kit.bci()); | 610 (is_virtual() ? " (virtual)" : ""), bci); |
558 } | 611 } |
559 } | 612 } |
560 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); | 613 C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed); |
561 return NULL; | 614 return NULL; |
562 } | 615 } |
564 bool LibraryCallKit::try_to_inline() { | 617 bool LibraryCallKit::try_to_inline() { |
565 // Handle symbolic names for otherwise undistinguished boolean switches: | 618 // Handle symbolic names for otherwise undistinguished boolean switches: |
566 const bool is_store = true; | 619 const bool is_store = true; |
567 const bool is_native_ptr = true; | 620 const bool is_native_ptr = true; |
568 const bool is_static = true; | 621 const bool is_static = true; |
622 const bool is_volatile = true; | |
569 | 623 |
570 if (!jvms()->has_method()) { | 624 if (!jvms()->has_method()) { |
571 // Root JVMState has a null method. | 625 // Root JVMState has a null method. |
572 assert(map()->memory()->Opcode() == Op_Parm, ""); | 626 assert(map()->memory()->Opcode() == Op_Parm, ""); |
573 // Insert the memory aliasing node | 627 // Insert the memory aliasing node |
574 set_all_memory(reset_memory()); | 628 set_all_memory(reset_memory()); |
575 } | 629 } |
576 assert(merged_memory(), ""); | 630 assert(merged_memory(), ""); |
577 | 631 |
632 | |
578 switch (intrinsic_id()) { | 633 switch (intrinsic_id()) { |
579 case vmIntrinsics::_hashCode: | 634 case vmIntrinsics::_hashCode: return inline_native_hashcode(intrinsic()->is_virtual(), !is_static); |
580 return inline_native_hashcode(intrinsic()->is_virtual(), !is_static); | 635 case vmIntrinsics::_identityHashCode: return inline_native_hashcode(/*!virtual*/ false, is_static); |
581 case vmIntrinsics::_identityHashCode: | 636 case vmIntrinsics::_getClass: return inline_native_getClass(); |
582 return inline_native_hashcode(/*!virtual*/ false, is_static); | |
583 case vmIntrinsics::_getClass: | |
584 return inline_native_getClass(); | |
585 | 637 |
586 case vmIntrinsics::_dsin: | 638 case vmIntrinsics::_dsin: |
587 case vmIntrinsics::_dcos: | 639 case vmIntrinsics::_dcos: |
588 case vmIntrinsics::_dtan: | 640 case vmIntrinsics::_dtan: |
589 case vmIntrinsics::_dabs: | 641 case vmIntrinsics::_dabs: |
590 case vmIntrinsics::_datan2: | 642 case vmIntrinsics::_datan2: |
591 case vmIntrinsics::_dsqrt: | 643 case vmIntrinsics::_dsqrt: |
592 case vmIntrinsics::_dexp: | 644 case vmIntrinsics::_dexp: |
593 case vmIntrinsics::_dlog: | 645 case vmIntrinsics::_dlog: |
594 case vmIntrinsics::_dlog10: | 646 case vmIntrinsics::_dlog10: |
595 case vmIntrinsics::_dpow: | 647 case vmIntrinsics::_dpow: return inline_math_native(intrinsic_id()); |
596 return inline_math_native(intrinsic_id()); | |
597 | 648 |
598 case vmIntrinsics::_min: | 649 case vmIntrinsics::_min: |
599 case vmIntrinsics::_max: | 650 case vmIntrinsics::_max: return inline_min_max(intrinsic_id()); |
600 return inline_min_max(intrinsic_id()); | 651 |
601 | 652 case vmIntrinsics::_arraycopy: return inline_arraycopy(); |
602 case vmIntrinsics::_arraycopy: | 653 |
603 return inline_arraycopy(); | 654 case vmIntrinsics::_compareTo: return inline_string_compareTo(); |
604 | 655 case vmIntrinsics::_indexOf: return inline_string_indexOf(); |
605 case vmIntrinsics::_compareTo: | 656 case vmIntrinsics::_equals: return inline_string_equals(); |
606 return inline_string_compareTo(); | 657 |
607 case vmIntrinsics::_indexOf: | 658 case vmIntrinsics::_getObject: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, !is_volatile); |
608 return inline_string_indexOf(); | 659 case vmIntrinsics::_getBoolean: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, !is_volatile); |
609 case vmIntrinsics::_equals: | 660 case vmIntrinsics::_getByte: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, !is_volatile); |
610 return inline_string_equals(); | 661 case vmIntrinsics::_getShort: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, !is_volatile); |
611 | 662 case vmIntrinsics::_getChar: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, !is_volatile); |
612 case vmIntrinsics::_getObject: | 663 case vmIntrinsics::_getInt: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, !is_volatile); |
613 return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, false); | 664 case vmIntrinsics::_getLong: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, !is_volatile); |
614 case vmIntrinsics::_getBoolean: | 665 case vmIntrinsics::_getFloat: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, !is_volatile); |
615 return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, false); | 666 case vmIntrinsics::_getDouble: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, !is_volatile); |
616 case vmIntrinsics::_getByte: | 667 |
617 return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, false); | 668 case vmIntrinsics::_putObject: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, !is_volatile); |
618 case vmIntrinsics::_getShort: | 669 case vmIntrinsics::_putBoolean: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, !is_volatile); |
619 return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, false); | 670 case vmIntrinsics::_putByte: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, !is_volatile); |
620 case vmIntrinsics::_getChar: | 671 case vmIntrinsics::_putShort: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, !is_volatile); |
621 return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, false); | 672 case vmIntrinsics::_putChar: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, !is_volatile); |
622 case vmIntrinsics::_getInt: | 673 case vmIntrinsics::_putInt: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, !is_volatile); |
623 return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, false); | 674 case vmIntrinsics::_putLong: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, !is_volatile); |
624 case vmIntrinsics::_getLong: | 675 case vmIntrinsics::_putFloat: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, !is_volatile); |
625 return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, false); | 676 case vmIntrinsics::_putDouble: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, !is_volatile); |
626 case vmIntrinsics::_getFloat: | 677 |
627 return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, false); | 678 case vmIntrinsics::_getByte_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_BYTE, !is_volatile); |
628 case vmIntrinsics::_getDouble: | 679 case vmIntrinsics::_getShort_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_SHORT, !is_volatile); |
629 return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, false); | 680 case vmIntrinsics::_getChar_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_CHAR, !is_volatile); |
630 | 681 case vmIntrinsics::_getInt_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_INT, !is_volatile); |
631 case vmIntrinsics::_putObject: | 682 case vmIntrinsics::_getLong_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_LONG, !is_volatile); |
632 return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, false); | 683 case vmIntrinsics::_getFloat_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_FLOAT, !is_volatile); |
633 case vmIntrinsics::_putBoolean: | 684 case vmIntrinsics::_getDouble_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_DOUBLE, !is_volatile); |
634 return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, false); | 685 case vmIntrinsics::_getAddress_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_ADDRESS, !is_volatile); |
635 case vmIntrinsics::_putByte: | 686 |
636 return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, false); | 687 case vmIntrinsics::_putByte_raw: return inline_unsafe_access( is_native_ptr, is_store, T_BYTE, !is_volatile); |
637 case vmIntrinsics::_putShort: | 688 case vmIntrinsics::_putShort_raw: return inline_unsafe_access( is_native_ptr, is_store, T_SHORT, !is_volatile); |
638 return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, false); | 689 case vmIntrinsics::_putChar_raw: return inline_unsafe_access( is_native_ptr, is_store, T_CHAR, !is_volatile); |
639 case vmIntrinsics::_putChar: | 690 case vmIntrinsics::_putInt_raw: return inline_unsafe_access( is_native_ptr, is_store, T_INT, !is_volatile); |
640 return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, false); | 691 case vmIntrinsics::_putLong_raw: return inline_unsafe_access( is_native_ptr, is_store, T_LONG, !is_volatile); |
641 case vmIntrinsics::_putInt: | 692 case vmIntrinsics::_putFloat_raw: return inline_unsafe_access( is_native_ptr, is_store, T_FLOAT, !is_volatile); |
642 return inline_unsafe_access(!is_native_ptr, is_store, T_INT, false); | 693 case vmIntrinsics::_putDouble_raw: return inline_unsafe_access( is_native_ptr, is_store, T_DOUBLE, !is_volatile); |
643 case vmIntrinsics::_putLong: | 694 case vmIntrinsics::_putAddress_raw: return inline_unsafe_access( is_native_ptr, is_store, T_ADDRESS, !is_volatile); |
644 return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, false); | 695 |
645 case vmIntrinsics::_putFloat: | 696 case vmIntrinsics::_getObjectVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, is_volatile); |
646 return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, false); | 697 case vmIntrinsics::_getBooleanVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, is_volatile); |
647 case vmIntrinsics::_putDouble: | 698 case vmIntrinsics::_getByteVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, is_volatile); |
648 return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, false); | 699 case vmIntrinsics::_getShortVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, is_volatile); |
649 | 700 case vmIntrinsics::_getCharVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, is_volatile); |
650 case vmIntrinsics::_getByte_raw: | 701 case vmIntrinsics::_getIntVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, is_volatile); |
651 return inline_unsafe_access(is_native_ptr, !is_store, T_BYTE, false); | 702 case vmIntrinsics::_getLongVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, is_volatile); |
652 case vmIntrinsics::_getShort_raw: | 703 case vmIntrinsics::_getFloatVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, is_volatile); |
653 return inline_unsafe_access(is_native_ptr, !is_store, T_SHORT, false); | 704 case vmIntrinsics::_getDoubleVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, is_volatile); |
654 case vmIntrinsics::_getChar_raw: | 705 |
655 return inline_unsafe_access(is_native_ptr, !is_store, T_CHAR, false); | 706 case vmIntrinsics::_putObjectVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, is_volatile); |
656 case vmIntrinsics::_getInt_raw: | 707 case vmIntrinsics::_putBooleanVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, is_volatile); |
657 return inline_unsafe_access(is_native_ptr, !is_store, T_INT, false); | 708 case vmIntrinsics::_putByteVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, is_volatile); |
658 case vmIntrinsics::_getLong_raw: | 709 case vmIntrinsics::_putShortVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, is_volatile); |
659 return inline_unsafe_access(is_native_ptr, !is_store, T_LONG, false); | 710 case vmIntrinsics::_putCharVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, is_volatile); |
660 case vmIntrinsics::_getFloat_raw: | 711 case vmIntrinsics::_putIntVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, is_volatile); |
661 return inline_unsafe_access(is_native_ptr, !is_store, T_FLOAT, false); | 712 case vmIntrinsics::_putLongVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, is_volatile); |
662 case vmIntrinsics::_getDouble_raw: | 713 case vmIntrinsics::_putFloatVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, is_volatile); |
663 return inline_unsafe_access(is_native_ptr, !is_store, T_DOUBLE, false); | 714 case vmIntrinsics::_putDoubleVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, is_volatile); |
664 case vmIntrinsics::_getAddress_raw: | 715 |
665 return inline_unsafe_access(is_native_ptr, !is_store, T_ADDRESS, false); | 716 case vmIntrinsics::_prefetchRead: return inline_unsafe_prefetch(!is_native_ptr, !is_store, !is_static); |
666 | 717 case vmIntrinsics::_prefetchWrite: return inline_unsafe_prefetch(!is_native_ptr, is_store, !is_static); |
667 case vmIntrinsics::_putByte_raw: | 718 case vmIntrinsics::_prefetchReadStatic: return inline_unsafe_prefetch(!is_native_ptr, !is_store, is_static); |
668 return inline_unsafe_access(is_native_ptr, is_store, T_BYTE, false); | 719 case vmIntrinsics::_prefetchWriteStatic: return inline_unsafe_prefetch(!is_native_ptr, is_store, is_static); |
669 case vmIntrinsics::_putShort_raw: | 720 |
670 return inline_unsafe_access(is_native_ptr, is_store, T_SHORT, false); | 721 case vmIntrinsics::_compareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmpxchg); |
671 case vmIntrinsics::_putChar_raw: | 722 case vmIntrinsics::_compareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmpxchg); |
672 return inline_unsafe_access(is_native_ptr, is_store, T_CHAR, false); | 723 case vmIntrinsics::_compareAndSwapLong: return inline_unsafe_load_store(T_LONG, LS_cmpxchg); |
673 case vmIntrinsics::_putInt_raw: | 724 |
674 return inline_unsafe_access(is_native_ptr, is_store, T_INT, false); | 725 case vmIntrinsics::_putOrderedObject: return inline_unsafe_ordered_store(T_OBJECT); |
675 case vmIntrinsics::_putLong_raw: | 726 case vmIntrinsics::_putOrderedInt: return inline_unsafe_ordered_store(T_INT); |
676 return inline_unsafe_access(is_native_ptr, is_store, T_LONG, false); | 727 case vmIntrinsics::_putOrderedLong: return inline_unsafe_ordered_store(T_LONG); |
677 case vmIntrinsics::_putFloat_raw: | 728 |
678 return inline_unsafe_access(is_native_ptr, is_store, T_FLOAT, false); | 729 case vmIntrinsics::_getAndAddInt: return inline_unsafe_load_store(T_INT, LS_xadd); |
679 case vmIntrinsics::_putDouble_raw: | 730 case vmIntrinsics::_getAndAddLong: return inline_unsafe_load_store(T_LONG, LS_xadd); |
680 return inline_unsafe_access(is_native_ptr, is_store, T_DOUBLE, false); | 731 case vmIntrinsics::_getAndSetInt: return inline_unsafe_load_store(T_INT, LS_xchg); |
681 case vmIntrinsics::_putAddress_raw: | 732 case vmIntrinsics::_getAndSetLong: return inline_unsafe_load_store(T_LONG, LS_xchg); |
682 return inline_unsafe_access(is_native_ptr, is_store, T_ADDRESS, false); | 733 case vmIntrinsics::_getAndSetObject: return inline_unsafe_load_store(T_OBJECT, LS_xchg); |
683 | 734 |
684 case vmIntrinsics::_getObjectVolatile: | 735 case vmIntrinsics::_currentThread: return inline_native_currentThread(); |
685 return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, true); | 736 case vmIntrinsics::_isInterrupted: return inline_native_isInterrupted(); |
686 case vmIntrinsics::_getBooleanVolatile: | |
687 return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, true); | |
688 case vmIntrinsics::_getByteVolatile: | |
689 return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, true); | |
690 case vmIntrinsics::_getShortVolatile: | |
691 return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, true); | |
692 case vmIntrinsics::_getCharVolatile: | |
693 return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, true); | |
694 case vmIntrinsics::_getIntVolatile: | |
695 return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, true); | |
696 case vmIntrinsics::_getLongVolatile: | |
697 return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, true); | |
698 case vmIntrinsics::_getFloatVolatile: | |
699 return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, true); | |
700 case vmIntrinsics::_getDoubleVolatile: | |
701 return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, true); | |
702 | |
703 case vmIntrinsics::_putObjectVolatile: | |
704 return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, true); | |
705 case vmIntrinsics::_putBooleanVolatile: | |
706 return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, true); | |
707 case vmIntrinsics::_putByteVolatile: | |
708 return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, true); | |
709 case vmIntrinsics::_putShortVolatile: | |
710 return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, true); | |
711 case vmIntrinsics::_putCharVolatile: | |
712 return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, true); | |
713 case vmIntrinsics::_putIntVolatile: | |
714 return inline_unsafe_access(!is_native_ptr, is_store, T_INT, true); | |
715 case vmIntrinsics::_putLongVolatile: | |
716 return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, true); | |
717 case vmIntrinsics::_putFloatVolatile: | |
718 return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, true); | |
719 case vmIntrinsics::_putDoubleVolatile: | |
720 return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, true); | |
721 | |
722 case vmIntrinsics::_prefetchRead: | |
723 return inline_unsafe_prefetch(!is_native_ptr, !is_store, !is_static); | |
724 case vmIntrinsics::_prefetchWrite: | |
725 return inline_unsafe_prefetch(!is_native_ptr, is_store, !is_static); | |
726 case vmIntrinsics::_prefetchReadStatic: | |
727 return inline_unsafe_prefetch(!is_native_ptr, !is_store, is_static); | |
728 case vmIntrinsics::_prefetchWriteStatic: | |
729 return inline_unsafe_prefetch(!is_native_ptr, is_store, is_static); | |
730 | |
731 case vmIntrinsics::_compareAndSwapObject: | |
732 return inline_unsafe_load_store(T_OBJECT, LS_cmpxchg); | |
733 case vmIntrinsics::_compareAndSwapInt: | |
734 return inline_unsafe_load_store(T_INT, LS_cmpxchg); | |
735 case vmIntrinsics::_compareAndSwapLong: | |
736 return inline_unsafe_load_store(T_LONG, LS_cmpxchg); | |
737 | |
738 case vmIntrinsics::_putOrderedObject: | |
739 return inline_unsafe_ordered_store(T_OBJECT); | |
740 case vmIntrinsics::_putOrderedInt: | |
741 return inline_unsafe_ordered_store(T_INT); | |
742 case vmIntrinsics::_putOrderedLong: | |
743 return inline_unsafe_ordered_store(T_LONG); | |
744 | |
745 case vmIntrinsics::_getAndAddInt: | |
746 return inline_unsafe_load_store(T_INT, LS_xadd); | |
747 case vmIntrinsics::_getAndAddLong: | |
748 return inline_unsafe_load_store(T_LONG, LS_xadd); | |
749 case vmIntrinsics::_getAndSetInt: | |
750 return inline_unsafe_load_store(T_INT, LS_xchg); | |
751 case vmIntrinsics::_getAndSetLong: | |
752 return inline_unsafe_load_store(T_LONG, LS_xchg); | |
753 case vmIntrinsics::_getAndSetObject: | |
754 return inline_unsafe_load_store(T_OBJECT, LS_xchg); | |
755 | |
756 case vmIntrinsics::_currentThread: | |
757 return inline_native_currentThread(); | |
758 case vmIntrinsics::_isInterrupted: | |
759 return inline_native_isInterrupted(); | |
760 | 737 |
761 #ifdef TRACE_HAVE_INTRINSICS | 738 #ifdef TRACE_HAVE_INTRINSICS |
762 case vmIntrinsics::_classID: | 739 case vmIntrinsics::_classID: return inline_native_classID(); |
763 return inline_native_classID(); | 740 case vmIntrinsics::_threadID: return inline_native_threadID(); |
764 case vmIntrinsics::_threadID: | 741 case vmIntrinsics::_counterTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime"); |
765 return inline_native_threadID(); | |
766 case vmIntrinsics::_counterTime: | |
767 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime"); | |
768 #endif | 742 #endif |
769 case vmIntrinsics::_currentTimeMillis: | 743 case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); |
770 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); | 744 case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); |
771 case vmIntrinsics::_nanoTime: | 745 case vmIntrinsics::_allocateInstance: return inline_unsafe_allocate(); |
772 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); | 746 case vmIntrinsics::_copyMemory: return inline_unsafe_copyMemory(); |
773 case vmIntrinsics::_allocateInstance: | 747 case vmIntrinsics::_newArray: return inline_native_newArray(); |
774 return inline_unsafe_allocate(); | 748 case vmIntrinsics::_getLength: return inline_native_getLength(); |
775 case vmIntrinsics::_copyMemory: | 749 case vmIntrinsics::_copyOf: return inline_array_copyOf(false); |
776 return inline_unsafe_copyMemory(); | 750 case vmIntrinsics::_copyOfRange: return inline_array_copyOf(true); |
777 case vmIntrinsics::_newArray: | 751 case vmIntrinsics::_equalsC: return inline_array_equals(); |
778 return inline_native_newArray(); | 752 case vmIntrinsics::_clone: return inline_native_clone(intrinsic()->is_virtual()); |
779 case vmIntrinsics::_getLength: | 753 |
780 return inline_native_getLength(); | 754 case vmIntrinsics::_isAssignableFrom: return inline_native_subtype_check(); |
781 case vmIntrinsics::_copyOf: | |
782 return inline_array_copyOf(false); | |
783 case vmIntrinsics::_copyOfRange: | |
784 return inline_array_copyOf(true); | |
785 case vmIntrinsics::_equalsC: | |
786 return inline_array_equals(); | |
787 case vmIntrinsics::_clone: | |
788 return inline_native_clone(intrinsic()->is_virtual()); | |
789 | |
790 case vmIntrinsics::_isAssignableFrom: | |
791 return inline_native_subtype_check(); | |
792 | 755 |
793 case vmIntrinsics::_isInstance: | 756 case vmIntrinsics::_isInstance: |
794 case vmIntrinsics::_getModifiers: | 757 case vmIntrinsics::_getModifiers: |
795 case vmIntrinsics::_isInterface: | 758 case vmIntrinsics::_isInterface: |
796 case vmIntrinsics::_isArray: | 759 case vmIntrinsics::_isArray: |
797 case vmIntrinsics::_isPrimitive: | 760 case vmIntrinsics::_isPrimitive: |
798 case vmIntrinsics::_getSuperclass: | 761 case vmIntrinsics::_getSuperclass: |
799 case vmIntrinsics::_getComponentType: | 762 case vmIntrinsics::_getComponentType: |
800 case vmIntrinsics::_getClassAccessFlags: | 763 case vmIntrinsics::_getClassAccessFlags: return inline_native_Class_query(intrinsic_id()); |
801 return inline_native_Class_query(intrinsic_id()); | |
802 | 764 |
803 case vmIntrinsics::_floatToRawIntBits: | 765 case vmIntrinsics::_floatToRawIntBits: |
804 case vmIntrinsics::_floatToIntBits: | 766 case vmIntrinsics::_floatToIntBits: |
805 case vmIntrinsics::_intBitsToFloat: | 767 case vmIntrinsics::_intBitsToFloat: |
806 case vmIntrinsics::_doubleToRawLongBits: | 768 case vmIntrinsics::_doubleToRawLongBits: |
807 case vmIntrinsics::_doubleToLongBits: | 769 case vmIntrinsics::_doubleToLongBits: |
808 case vmIntrinsics::_longBitsToDouble: | 770 case vmIntrinsics::_longBitsToDouble: return inline_fp_conversions(intrinsic_id()); |
809 return inline_fp_conversions(intrinsic_id()); | |
810 | 771 |
811 case vmIntrinsics::_numberOfLeadingZeros_i: | 772 case vmIntrinsics::_numberOfLeadingZeros_i: |
812 case vmIntrinsics::_numberOfLeadingZeros_l: | 773 case vmIntrinsics::_numberOfLeadingZeros_l: |
813 return inline_numberOfLeadingZeros(intrinsic_id()); | |
814 | |
815 case vmIntrinsics::_numberOfTrailingZeros_i: | 774 case vmIntrinsics::_numberOfTrailingZeros_i: |
816 case vmIntrinsics::_numberOfTrailingZeros_l: | 775 case vmIntrinsics::_numberOfTrailingZeros_l: |
817 return inline_numberOfTrailingZeros(intrinsic_id()); | |
818 | |
819 case vmIntrinsics::_bitCount_i: | 776 case vmIntrinsics::_bitCount_i: |
820 case vmIntrinsics::_bitCount_l: | 777 case vmIntrinsics::_bitCount_l: |
821 return inline_bitCount(intrinsic_id()); | |
822 | |
823 case vmIntrinsics::_reverseBytes_i: | 778 case vmIntrinsics::_reverseBytes_i: |
824 case vmIntrinsics::_reverseBytes_l: | 779 case vmIntrinsics::_reverseBytes_l: |
825 case vmIntrinsics::_reverseBytes_s: | 780 case vmIntrinsics::_reverseBytes_s: |
826 case vmIntrinsics::_reverseBytes_c: | 781 case vmIntrinsics::_reverseBytes_c: return inline_number_methods(intrinsic_id()); |
827 return inline_reverseBytes((vmIntrinsics::ID) intrinsic_id()); | 782 |
828 | 783 case vmIntrinsics::_getCallerClass: return inline_native_Reflection_getCallerClass(); |
829 case vmIntrinsics::_getCallerClass: | 784 |
830 return inline_native_Reflection_getCallerClass(); | 785 case vmIntrinsics::_Reference_get: return inline_reference_get(); |
831 | |
832 case vmIntrinsics::_Reference_get: | |
833 return inline_reference_get(); | |
834 | 786 |
835 case vmIntrinsics::_aescrypt_encryptBlock: | 787 case vmIntrinsics::_aescrypt_encryptBlock: |
836 case vmIntrinsics::_aescrypt_decryptBlock: | 788 case vmIntrinsics::_aescrypt_decryptBlock: return inline_aescrypt_Block(intrinsic_id()); |
837 return inline_aescrypt_Block(intrinsic_id()); | |
838 | 789 |
839 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: | 790 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
840 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: | 791 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
841 return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); | 792 return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); |
842 | 793 |
881 set_control(top()); // No fast path instrinsic | 832 set_control(top()); // No fast path instrinsic |
882 return slow_ctl; | 833 return slow_ctl; |
883 } | 834 } |
884 } | 835 } |
885 | 836 |
886 //------------------------------push_result------------------------------ | 837 //------------------------------set_result------------------------------- |
887 // Helper function for finishing intrinsics. | 838 // Helper function for finishing intrinsics. |
888 void LibraryCallKit::push_result(RegionNode* region, PhiNode* value) { | 839 void LibraryCallKit::set_result(RegionNode* region, PhiNode* value) { |
889 record_for_igvn(region); | 840 record_for_igvn(region); |
890 set_control(_gvn.transform(region)); | 841 set_control(_gvn.transform(region)); |
891 BasicType value_type = value->type()->basic_type(); | 842 set_result( _gvn.transform(value)); |
892 push_node(value_type, _gvn.transform(value)); | 843 assert(value->type()->basic_type() == result()->bottom_type()->basic_type(), "sanity"); |
893 } | 844 } |
894 | 845 |
895 //------------------------------generate_guard--------------------------- | 846 //------------------------------generate_guard--------------------------- |
896 // Helper function for generating guarded fast-slow graph structures. | 847 // Helper function for generating guarded fast-slow graph structures. |
897 // The given 'test', if true, guards a slow path. If the test fails | 848 // The given 'test', if true, guards a slow path. If the test fails |
1076 // Helper method for String intrinsic functions. This version is called | 1027 // Helper method for String intrinsic functions. This version is called |
1077 // with str1 and str2 pointing to char[] nodes, with cnt1 and cnt2 pointing | 1028 // with str1 and str2 pointing to char[] nodes, with cnt1 and cnt2 pointing |
1078 // to Int nodes containing the lenghts of str1 and str2. | 1029 // to Int nodes containing the lenghts of str1 and str2. |
1079 // | 1030 // |
1080 Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2) { | 1031 Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2) { |
1081 | |
1082 Node* result = NULL; | 1032 Node* result = NULL; |
1083 switch (opcode) { | 1033 switch (opcode) { |
1084 case Op_StrIndexOf: | 1034 case Op_StrIndexOf: |
1085 result = new (C) StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), | 1035 result = new (C) StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), |
1086 str1_start, cnt1, str2_start, cnt2); | 1036 str1_start, cnt1, str2_start, cnt2); |
1103 | 1053 |
1104 return _gvn.transform(result); | 1054 return _gvn.transform(result); |
1105 } | 1055 } |
1106 | 1056 |
1107 //------------------------------inline_string_compareTo------------------------ | 1057 //------------------------------inline_string_compareTo------------------------ |
1058 // public int java.lang.String.compareTo(String anotherString); | |
1108 bool LibraryCallKit::inline_string_compareTo() { | 1059 bool LibraryCallKit::inline_string_compareTo() { |
1109 | 1060 Node* receiver = null_check(argument(0)); |
1110 if (!Matcher::has_match_rule(Op_StrComp)) return false; | 1061 Node* arg = null_check(argument(1)); |
1111 | |
1112 _sp += 2; | |
1113 Node *argument = pop(); // pop non-receiver first: it was pushed second | |
1114 Node *receiver = pop(); | |
1115 | |
1116 // Null check on self without removing any arguments. The argument | |
1117 // null check technically happens in the wrong place, which can lead to | |
1118 // invalid stack traces when string compare is inlined into a method | |
1119 // which handles NullPointerExceptions. | |
1120 _sp += 2; | |
1121 receiver = do_null_check(receiver, T_OBJECT); | |
1122 argument = do_null_check(argument, T_OBJECT); | |
1123 _sp -= 2; | |
1124 if (stopped()) { | 1062 if (stopped()) { |
1125 return true; | 1063 return true; |
1126 } | 1064 } |
1127 | 1065 set_result(make_string_method_node(Op_StrComp, receiver, arg)); |
1128 Node* compare = make_string_method_node(Op_StrComp, receiver, argument); | |
1129 push(compare); | |
1130 return true; | 1066 return true; |
1131 } | 1067 } |
1132 | 1068 |
1133 //------------------------------inline_string_equals------------------------ | 1069 //------------------------------inline_string_equals------------------------ |
1134 bool LibraryCallKit::inline_string_equals() { | 1070 bool LibraryCallKit::inline_string_equals() { |
1135 | 1071 Node* receiver = null_check_receiver(); |
1136 if (!Matcher::has_match_rule(Op_StrEquals)) return false; | 1072 // NOTE: Do not null check argument for String.equals() because spec |
1137 | 1073 // allows to specify NULL as argument. |
1138 int nargs = 2; | 1074 Node* argument = this->argument(1); |
1139 _sp += nargs; | |
1140 Node* argument = pop(); // pop non-receiver first: it was pushed second | |
1141 Node* receiver = pop(); | |
1142 | |
1143 // Null check on self without removing any arguments. The argument | |
1144 // null check technically happens in the wrong place, which can lead to | |
1145 // invalid stack traces when string compare is inlined into a method | |
1146 // which handles NullPointerExceptions. | |
1147 _sp += nargs; | |
1148 receiver = do_null_check(receiver, T_OBJECT); | |
1149 //should not do null check for argument for String.equals(), because spec | |
1150 //allows to specify NULL as argument. | |
1151 _sp -= nargs; | |
1152 | |
1153 if (stopped()) { | 1075 if (stopped()) { |
1154 return true; | 1076 return true; |
1155 } | 1077 } |
1156 | 1078 |
1157 // paths (plus control) merge | 1079 // paths (plus control) merge |
1171 | 1093 |
1172 // get String klass for instanceOf | 1094 // get String klass for instanceOf |
1173 ciInstanceKlass* klass = env()->String_klass(); | 1095 ciInstanceKlass* klass = env()->String_klass(); |
1174 | 1096 |
1175 if (!stopped()) { | 1097 if (!stopped()) { |
1176 _sp += nargs; // gen_instanceof might do an uncommon trap | |
1177 Node* inst = gen_instanceof(argument, makecon(TypeKlassPtr::make(klass))); | 1098 Node* inst = gen_instanceof(argument, makecon(TypeKlassPtr::make(klass))); |
1178 _sp -= nargs; | |
1179 Node* cmp = _gvn.transform(new (C) CmpINode(inst, intcon(1))); | 1099 Node* cmp = _gvn.transform(new (C) CmpINode(inst, intcon(1))); |
1180 Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); | 1100 Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); |
1181 | 1101 |
1182 Node* inst_false = generate_guard(bol, NULL, PROB_MIN); | 1102 Node* inst_false = generate_guard(bol, NULL, PROB_MIN); |
1183 //instanceOf == true, fallthrough | 1103 //instanceOf == true, fallthrough |
1205 | 1125 |
1206 // Get length of receiver | 1126 // Get length of receiver |
1207 Node* receiver_cnt = load_String_length(no_ctrl, receiver); | 1127 Node* receiver_cnt = load_String_length(no_ctrl, receiver); |
1208 | 1128 |
1209 // Get start addr of argument | 1129 // Get start addr of argument |
1210 Node* argument_val = load_String_value(no_ctrl, argument); | 1130 Node* argument_val = load_String_value(no_ctrl, argument); |
1211 Node* argument_offset = load_String_offset(no_ctrl, argument); | 1131 Node* argument_offset = load_String_offset(no_ctrl, argument); |
1212 Node* argument_start = array_element_address(argument_val, argument_offset, T_CHAR); | 1132 Node* argument_start = array_element_address(argument_val, argument_offset, T_CHAR); |
1213 | 1133 |
1214 // Get length of argument | 1134 // Get length of argument |
1215 Node* argument_cnt = load_String_length(no_ctrl, argument); | 1135 Node* argument_cnt = load_String_length(no_ctrl, argument); |
1234 | 1154 |
1235 // post merge | 1155 // post merge |
1236 set_control(_gvn.transform(region)); | 1156 set_control(_gvn.transform(region)); |
1237 record_for_igvn(region); | 1157 record_for_igvn(region); |
1238 | 1158 |
1239 push(_gvn.transform(phi)); | 1159 set_result(_gvn.transform(phi)); |
1240 | |
1241 return true; | 1160 return true; |
1242 } | 1161 } |
1243 | 1162 |
1244 //------------------------------inline_array_equals---------------------------- | 1163 //------------------------------inline_array_equals---------------------------- |
1245 bool LibraryCallKit::inline_array_equals() { | 1164 bool LibraryCallKit::inline_array_equals() { |
1246 | 1165 Node* arg1 = argument(0); |
1247 if (!Matcher::has_match_rule(Op_AryEq)) return false; | 1166 Node* arg2 = argument(1); |
1248 | 1167 set_result(_gvn.transform(new (C) AryEqNode(control(), memory(TypeAryPtr::CHARS), arg1, arg2))); |
1249 _sp += 2; | |
1250 Node *argument2 = pop(); | |
1251 Node *argument1 = pop(); | |
1252 | |
1253 Node* equals = | |
1254 _gvn.transform(new (C) AryEqNode(control(), memory(TypeAryPtr::CHARS), | |
1255 argument1, argument2) ); | |
1256 push(equals); | |
1257 return true; | 1168 return true; |
1258 } | 1169 } |
1259 | 1170 |
1260 // Java version of String.indexOf(constant string) | 1171 // Java version of String.indexOf(constant string) |
1261 // class StringDecl { | 1172 // class StringDecl { |
1323 | 1234 |
1324 Node* no_ctrl = NULL; | 1235 Node* no_ctrl = NULL; |
1325 float likely = PROB_LIKELY(0.9); | 1236 float likely = PROB_LIKELY(0.9); |
1326 float unlikely = PROB_UNLIKELY(0.9); | 1237 float unlikely = PROB_UNLIKELY(0.9); |
1327 | 1238 |
1328 const int nargs = 2; // number of arguments to push back for uncommon trap in predicate | 1239 const int nargs = 0; // no arguments to push back for uncommon trap in predicate |
1329 | 1240 |
1330 Node* source = load_String_value(no_ctrl, string_object); | 1241 Node* source = load_String_value(no_ctrl, string_object); |
1331 Node* sourceOffset = load_String_offset(no_ctrl, string_object); | 1242 Node* sourceOffset = load_String_offset(no_ctrl, string_object); |
1332 Node* sourceCount = load_String_length(no_ctrl, string_object); | 1243 Node* sourceCount = load_String_length(no_ctrl, string_object); |
1333 | 1244 |
1394 return result; | 1305 return result; |
1395 } | 1306 } |
1396 | 1307 |
1397 //------------------------------inline_string_indexOf------------------------ | 1308 //------------------------------inline_string_indexOf------------------------ |
1398 bool LibraryCallKit::inline_string_indexOf() { | 1309 bool LibraryCallKit::inline_string_indexOf() { |
1399 | 1310 Node* receiver = argument(0); |
1400 _sp += 2; | 1311 Node* arg = argument(1); |
1401 Node *argument = pop(); // pop non-receiver first: it was pushed second | |
1402 Node *receiver = pop(); | |
1403 | 1312 |
1404 Node* result; | 1313 Node* result; |
1405 // Disable the use of pcmpestri until it can be guaranteed that | 1314 // Disable the use of pcmpestri until it can be guaranteed that |
1406 // the load doesn't cross into the uncommited space. | 1315 // the load doesn't cross into the uncommited space. |
1407 if (Matcher::has_match_rule(Op_StrIndexOf) && | 1316 if (Matcher::has_match_rule(Op_StrIndexOf) && |
1408 UseSSE42Intrinsics) { | 1317 UseSSE42Intrinsics) { |
1409 // Generate SSE4.2 version of indexOf | 1318 // Generate SSE4.2 version of indexOf |
1410 // We currently only have match rules that use SSE4.2 | 1319 // We currently only have match rules that use SSE4.2 |
1411 | 1320 |
1412 // Null check on self without removing any arguments. The argument | 1321 receiver = null_check(receiver); |
1413 // null check technically happens in the wrong place, which can lead to | 1322 arg = null_check(arg); |
1414 // invalid stack traces when string compare is inlined into a method | |
1415 // which handles NullPointerExceptions. | |
1416 _sp += 2; | |
1417 receiver = do_null_check(receiver, T_OBJECT); | |
1418 argument = do_null_check(argument, T_OBJECT); | |
1419 _sp -= 2; | |
1420 | |
1421 if (stopped()) { | 1323 if (stopped()) { |
1422 return true; | 1324 return true; |
1423 } | 1325 } |
1424 | 1326 |
1425 ciInstanceKlass* str_klass = env()->String_klass(); | 1327 ciInstanceKlass* str_klass = env()->String_klass(); |
1437 | 1339 |
1438 // Get length of source string | 1340 // Get length of source string |
1439 Node* source_cnt = load_String_length(no_ctrl, receiver); | 1341 Node* source_cnt = load_String_length(no_ctrl, receiver); |
1440 | 1342 |
1441 // Get start addr of substring | 1343 // Get start addr of substring |
1442 Node* substr = load_String_value(no_ctrl, argument); | 1344 Node* substr = load_String_value(no_ctrl, arg); |
1443 Node* substr_offset = load_String_offset(no_ctrl, argument); | 1345 Node* substr_offset = load_String_offset(no_ctrl, arg); |
1444 Node* substr_start = array_element_address(substr, substr_offset, T_CHAR); | 1346 Node* substr_start = array_element_address(substr, substr_offset, T_CHAR); |
1445 | 1347 |
1446 // Get length of source string | 1348 // Get length of source string |
1447 Node* substr_cnt = load_String_length(no_ctrl, argument); | 1349 Node* substr_cnt = load_String_length(no_ctrl, arg); |
1448 | 1350 |
1449 // Check for substr count > string count | 1351 // Check for substr count > string count |
1450 Node* cmp = _gvn.transform( new(C) CmpINode(substr_cnt, source_cnt) ); | 1352 Node* cmp = _gvn.transform( new(C) CmpINode(substr_cnt, source_cnt) ); |
1451 Node* bol = _gvn.transform( new(C) BoolNode(cmp, BoolTest::gt) ); | 1353 Node* bol = _gvn.transform( new(C) BoolNode(cmp, BoolTest::gt) ); |
1452 Node* if_gt = generate_slow_guard(bol, NULL); | 1354 Node* if_gt = generate_slow_guard(bol, NULL); |
1475 record_for_igvn(result_rgn); | 1377 record_for_igvn(result_rgn); |
1476 result = _gvn.transform(result_phi); | 1378 result = _gvn.transform(result_phi); |
1477 | 1379 |
1478 } else { // Use LibraryCallKit::string_indexOf | 1380 } else { // Use LibraryCallKit::string_indexOf |
1479 // don't intrinsify if argument isn't a constant string. | 1381 // don't intrinsify if argument isn't a constant string. |
1480 if (!argument->is_Con()) { | 1382 if (!arg->is_Con()) { |
1481 return false; | 1383 return false; |
1482 } | 1384 } |
1483 const TypeOopPtr* str_type = _gvn.type(argument)->isa_oopptr(); | 1385 const TypeOopPtr* str_type = _gvn.type(arg)->isa_oopptr(); |
1484 if (str_type == NULL) { | 1386 if (str_type == NULL) { |
1485 return false; | 1387 return false; |
1486 } | 1388 } |
1487 ciInstanceKlass* klass = env()->String_klass(); | 1389 ciInstanceKlass* klass = env()->String_klass(); |
1488 ciObject* str_const = str_type->const_oop(); | 1390 ciObject* str_const = str_type->const_oop(); |
1509 // simplifies the resulting code somewhat so lets optimize for that. | 1411 // simplifies the resulting code somewhat so lets optimize for that. |
1510 if (o != 0 || c != pat->length()) { | 1412 if (o != 0 || c != pat->length()) { |
1511 return false; | 1413 return false; |
1512 } | 1414 } |
1513 | 1415 |
1514 // Null check on self without removing any arguments. The argument | 1416 receiver = null_check(receiver, T_OBJECT); |
1515 // null check technically happens in the wrong place, which can lead to | 1417 // NOTE: No null check on the argument is needed since it's a constant String oop. |
1516 // invalid stack traces when string compare is inlined into a method | |
1517 // which handles NullPointerExceptions. | |
1518 _sp += 2; | |
1519 receiver = do_null_check(receiver, T_OBJECT); | |
1520 // No null check on the argument is needed since it's a constant String oop. | |
1521 _sp -= 2; | |
1522 if (stopped()) { | 1418 if (stopped()) { |
1523 return true; | 1419 return true; |
1524 } | 1420 } |
1525 | 1421 |
1526 // The null string as a pattern always returns 0 (match at beginning of string) | 1422 // The null string as a pattern always returns 0 (match at beginning of string) |
1527 if (c == 0) { | 1423 if (c == 0) { |
1528 push(intcon(0)); | 1424 set_result(intcon(0)); |
1529 return true; | 1425 return true; |
1530 } | 1426 } |
1531 | 1427 |
1532 // Generate default indexOf | 1428 // Generate default indexOf |
1533 jchar lastChar = pat->char_at(o + (c - 1)); | 1429 jchar lastChar = pat->char_at(o + (c - 1)); |
1546 } | 1442 } |
1547 } | 1443 } |
1548 | 1444 |
1549 result = string_indexOf(receiver, pat, o, cache, md2); | 1445 result = string_indexOf(receiver, pat, o, cache, md2); |
1550 } | 1446 } |
1551 | 1447 set_result(result); |
1552 push(result); | |
1553 return true; | 1448 return true; |
1554 } | 1449 } |
1555 | 1450 |
1556 //--------------------------pop_math_arg-------------------------------- | 1451 //--------------------------round_double_node-------------------------------- |
1557 // Pop a double argument to a math function from the stack | 1452 // Round a double node if necessary. |
1558 // rounding it if necessary. | 1453 Node* LibraryCallKit::round_double_node(Node* n) { |
1559 Node * LibraryCallKit::pop_math_arg() { | 1454 if (Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1) |
1560 Node *arg = pop_pair(); | 1455 n = _gvn.transform(new (C) RoundDoubleNode(0, n)); |
1561 if( Matcher::strict_fp_requires_explicit_rounding && UseSSE<=1 ) | 1456 return n; |
1562 arg = _gvn.transform( new (C) RoundDoubleNode(0, arg) ); | 1457 } |
1563 return arg; | 1458 |
1459 //------------------------------inline_math----------------------------------- | |
1460 // public static double Math.abs(double) | |
1461 // public static double Math.sqrt(double) | |
1462 // public static double Math.log(double) | |
1463 // public static double Math.log10(double) | |
1464 bool LibraryCallKit::inline_math(vmIntrinsics::ID id) { | |
1465 Node* arg = round_double_node(argument(0)); | |
1466 Node* n; | |
1467 switch (id) { | |
1468 case vmIntrinsics::_dabs: n = new (C) AbsDNode( arg); break; | |
1469 case vmIntrinsics::_dsqrt: n = new (C) SqrtDNode(0, arg); break; | |
1470 case vmIntrinsics::_dlog: n = new (C) LogDNode( arg); break; | |
1471 case vmIntrinsics::_dlog10: n = new (C) Log10DNode( arg); break; | |
1472 default: fatal_unexpected_iid(id); break; | |
1473 } | |
1474 set_result(_gvn.transform(n)); | |
1475 return true; | |
1564 } | 1476 } |
1565 | 1477 |
1566 //------------------------------inline_trig---------------------------------- | 1478 //------------------------------inline_trig---------------------------------- |
1567 // Inline sin/cos/tan instructions, if possible. If rounding is required, do | 1479 // Inline sin/cos/tan instructions, if possible. If rounding is required, do |
1568 // argument reduction which will turn into a fast/slow diamond. | 1480 // argument reduction which will turn into a fast/slow diamond. |
1569 bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { | 1481 bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { |
1570 _sp += arg_size(); // restore stack pointer | 1482 Node* arg = round_double_node(argument(0)); |
1571 Node* arg = pop_math_arg(); | 1483 Node* n = NULL; |
1572 Node* trig = NULL; | |
1573 | 1484 |
1574 switch (id) { | 1485 switch (id) { |
1575 case vmIntrinsics::_dsin: | 1486 case vmIntrinsics::_dsin: n = new (C) SinDNode(arg); break; |
1576 trig = _gvn.transform((Node*)new (C) SinDNode(arg)); | 1487 case vmIntrinsics::_dcos: n = new (C) CosDNode(arg); break; |
1577 break; | 1488 case vmIntrinsics::_dtan: n = new (C) TanDNode(arg); break; |
1578 case vmIntrinsics::_dcos: | 1489 default: fatal_unexpected_iid(id); break; |
1579 trig = _gvn.transform((Node*)new (C) CosDNode(arg)); | 1490 } |
1580 break; | 1491 n = _gvn.transform(n); |
1581 case vmIntrinsics::_dtan: | |
1582 trig = _gvn.transform((Node*)new (C) TanDNode(arg)); | |
1583 break; | |
1584 default: | |
1585 assert(false, "bad intrinsic was passed in"); | |
1586 return false; | |
1587 } | |
1588 | 1492 |
1589 // Rounding required? Check for argument reduction! | 1493 // Rounding required? Check for argument reduction! |
1590 if( Matcher::strict_fp_requires_explicit_rounding ) { | 1494 if (Matcher::strict_fp_requires_explicit_rounding) { |
1591 | |
1592 static const double pi_4 = 0.7853981633974483; | 1495 static const double pi_4 = 0.7853981633974483; |
1593 static const double neg_pi_4 = -0.7853981633974483; | 1496 static const double neg_pi_4 = -0.7853981633974483; |
1594 // pi/2 in 80-bit extended precision | 1497 // pi/2 in 80-bit extended precision |
1595 // static const unsigned char pi_2_bits_x[] = {0x35,0xc2,0x68,0x21,0xa2,0xda,0x0f,0xc9,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00}; | 1498 // static const unsigned char pi_2_bits_x[] = {0x35,0xc2,0x68,0x21,0xa2,0xda,0x0f,0xc9,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00}; |
1596 // -pi/2 in 80-bit extended precision | 1499 // -pi/2 in 80-bit extended precision |
1621 // requires a special machine instruction to load it. Instead we'll try | 1524 // requires a special machine instruction to load it. Instead we'll try |
1622 // the 'easy' case. If we really need the extra range +/- PI/2 we'll | 1525 // the 'easy' case. If we really need the extra range +/- PI/2 we'll |
1623 // probably do the math inside the SIN encoding. | 1526 // probably do the math inside the SIN encoding. |
1624 | 1527 |
1625 // Make the merge point | 1528 // Make the merge point |
1626 RegionNode *r = new (C) RegionNode(3); | 1529 RegionNode* r = new (C) RegionNode(3); |
1627 Node *phi = new (C) PhiNode(r,Type::DOUBLE); | 1530 Node* phi = new (C) PhiNode(r, Type::DOUBLE); |
1628 | 1531 |
1629 // Flatten arg so we need only 1 test | 1532 // Flatten arg so we need only 1 test |
1630 Node *abs = _gvn.transform(new (C) AbsDNode(arg)); | 1533 Node *abs = _gvn.transform(new (C) AbsDNode(arg)); |
1631 // Node for PI/4 constant | 1534 // Node for PI/4 constant |
1632 Node *pi4 = makecon(TypeD::make(pi_4)); | 1535 Node *pi4 = makecon(TypeD::make(pi_4)); |
1637 // Branch either way | 1540 // Branch either way |
1638 IfNode *iff = create_and_xform_if(control(),bol, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); | 1541 IfNode *iff = create_and_xform_if(control(),bol, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
1639 set_control(opt_iff(r,iff)); | 1542 set_control(opt_iff(r,iff)); |
1640 | 1543 |
1641 // Set fast path result | 1544 // Set fast path result |
1642 phi->init_req(2,trig); | 1545 phi->init_req(2, n); |
1643 | 1546 |
1644 // Slow path - non-blocking leaf call | 1547 // Slow path - non-blocking leaf call |
1645 Node* call = NULL; | 1548 Node* call = NULL; |
1646 switch (id) { | 1549 switch (id) { |
1647 case vmIntrinsics::_dsin: | 1550 case vmIntrinsics::_dsin: |
1659 CAST_FROM_FN_PTR(address, SharedRuntime::dtan), | 1562 CAST_FROM_FN_PTR(address, SharedRuntime::dtan), |
1660 "Tan", NULL, arg, top()); | 1563 "Tan", NULL, arg, top()); |
1661 break; | 1564 break; |
1662 } | 1565 } |
1663 assert(control()->in(0) == call, ""); | 1566 assert(control()->in(0) == call, ""); |
1664 Node* slow_result = _gvn.transform(new (C) ProjNode(call,TypeFunc::Parms)); | 1567 Node* slow_result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); |
1665 r->init_req(1,control()); | 1568 r->init_req(1, control()); |
1666 phi->init_req(1,slow_result); | 1569 phi->init_req(1, slow_result); |
1667 | 1570 |
1668 // Post-merge | 1571 // Post-merge |
1669 set_control(_gvn.transform(r)); | 1572 set_control(_gvn.transform(r)); |
1670 record_for_igvn(r); | 1573 record_for_igvn(r); |
1671 trig = _gvn.transform(phi); | 1574 n = _gvn.transform(phi); |
1672 | 1575 |
1673 C->set_has_split_ifs(true); // Has chance for split-if optimization | 1576 C->set_has_split_ifs(true); // Has chance for split-if optimization |
1674 } | 1577 } |
1675 // Push result back on JVM stack | 1578 set_result(n); |
1676 push_pair(trig); | |
1677 return true; | |
1678 } | |
1679 | |
1680 //------------------------------inline_sqrt------------------------------------- | |
1681 // Inline square root instruction, if possible. | |
1682 bool LibraryCallKit::inline_sqrt(vmIntrinsics::ID id) { | |
1683 assert(id == vmIntrinsics::_dsqrt, "Not square root"); | |
1684 _sp += arg_size(); // restore stack pointer | |
1685 push_pair(_gvn.transform(new (C) SqrtDNode(0, pop_math_arg()))); | |
1686 return true; | |
1687 } | |
1688 | |
1689 //------------------------------inline_abs------------------------------------- | |
1690 // Inline absolute value instruction, if possible. | |
1691 bool LibraryCallKit::inline_abs(vmIntrinsics::ID id) { | |
1692 assert(id == vmIntrinsics::_dabs, "Not absolute value"); | |
1693 _sp += arg_size(); // restore stack pointer | |
1694 push_pair(_gvn.transform(new (C) AbsDNode(pop_math_arg()))); | |
1695 return true; | 1579 return true; |
1696 } | 1580 } |
1697 | 1581 |
1698 void LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { | 1582 void LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { |
1699 //------------------- | 1583 //------------------- |
1700 //result=(result.isNaN())? funcAddr():result; | 1584 //result=(result.isNaN())? funcAddr():result; |
1701 // Check: If isNaN() by checking result!=result? then either trap | 1585 // Check: If isNaN() by checking result!=result? then either trap |
1702 // or go to runtime | 1586 // or go to runtime |
1703 Node* cmpisnan = _gvn.transform(new (C) CmpDNode(result,result)); | 1587 Node* cmpisnan = _gvn.transform(new (C) CmpDNode(result, result)); |
1704 // Build the boolean node | 1588 // Build the boolean node |
1705 Node* bolisnum = _gvn.transform( new (C) BoolNode(cmpisnan, BoolTest::eq) ); | 1589 Node* bolisnum = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::eq)); |
1706 | 1590 |
1707 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { | 1591 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { |
1708 { | 1592 { BuildCutout unless(this, bolisnum, PROB_STATIC_FREQUENT); |
1709 BuildCutout unless(this, bolisnum, PROB_STATIC_FREQUENT); | |
1710 // End the current control-flow path | |
1711 push_pair(x); | |
1712 if (y != NULL) { | |
1713 push_pair(y); | |
1714 } | |
1715 // The pow or exp intrinsic returned a NaN, which requires a call | 1593 // The pow or exp intrinsic returned a NaN, which requires a call |
1716 // to the runtime. Recompile with the runtime call. | 1594 // to the runtime. Recompile with the runtime call. |
1717 uncommon_trap(Deoptimization::Reason_intrinsic, | 1595 uncommon_trap(Deoptimization::Reason_intrinsic, |
1718 Deoptimization::Action_make_not_entrant); | 1596 Deoptimization::Action_make_not_entrant); |
1719 } | 1597 } |
1720 push_pair(result); | 1598 set_result(result); |
1721 } else { | 1599 } else { |
1722 // If this inlining ever returned NaN in the past, we compile a call | 1600 // If this inlining ever returned NaN in the past, we compile a call |
1723 // to the runtime to properly handle corner cases | 1601 // to the runtime to properly handle corner cases |
1724 | 1602 |
1725 IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); | 1603 IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
1726 Node* if_slow = _gvn.transform( new (C) IfFalseNode(iff) ); | 1604 Node* if_slow = _gvn.transform( new (C) IfFalseNode(iff) ); |
1727 Node* if_fast = _gvn.transform( new (C) IfTrueNode(iff) ); | 1605 Node* if_fast = _gvn.transform( new (C) IfTrueNode(iff) ); |
1728 | 1606 |
1729 if (!if_slow->is_top()) { | 1607 if (!if_slow->is_top()) { |
1730 RegionNode* result_region = new(C) RegionNode(3); | 1608 RegionNode* result_region = new (C) RegionNode(3); |
1731 PhiNode* result_val = new (C) PhiNode(result_region, Type::DOUBLE); | 1609 PhiNode* result_val = new (C) PhiNode(result_region, Type::DOUBLE); |
1732 | 1610 |
1733 result_region->init_req(1, if_fast); | 1611 result_region->init_req(1, if_fast); |
1734 result_val->init_req(1, result); | 1612 result_val->init_req(1, result); |
1735 | 1613 |
1745 assert(value_top == top(), "second value must be top"); | 1623 assert(value_top == top(), "second value must be top"); |
1746 #endif | 1624 #endif |
1747 | 1625 |
1748 result_region->init_req(2, control()); | 1626 result_region->init_req(2, control()); |
1749 result_val->init_req(2, value); | 1627 result_val->init_req(2, value); |
1750 push_result(result_region, result_val); | 1628 set_result(result_region, result_val); |
1751 } else { | 1629 } else { |
1752 push_pair(result); | 1630 set_result(result); |
1753 } | 1631 } |
1754 } | 1632 } |
1755 } | 1633 } |
1756 | 1634 |
1757 //------------------------------inline_exp------------------------------------- | 1635 //------------------------------inline_exp------------------------------------- |
1758 // Inline exp instructions, if possible. The Intel hardware only misses | 1636 // Inline exp instructions, if possible. The Intel hardware only misses |
1759 // really odd corner cases (+/- Infinity). Just uncommon-trap them. | 1637 // really odd corner cases (+/- Infinity). Just uncommon-trap them. |
1760 bool LibraryCallKit::inline_exp(vmIntrinsics::ID id) { | 1638 bool LibraryCallKit::inline_exp() { |
1761 assert(id == vmIntrinsics::_dexp, "Not exp"); | 1639 Node* arg = round_double_node(argument(0)); |
1762 | 1640 Node* n = _gvn.transform(new (C) ExpDNode(0, arg)); |
1763 _sp += arg_size(); // restore stack pointer | 1641 |
1764 Node *x = pop_math_arg(); | 1642 finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); |
1765 Node *result = _gvn.transform(new (C) ExpDNode(0,x)); | |
1766 | |
1767 finish_pow_exp(result, x, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); | |
1768 | 1643 |
1769 C->set_has_split_ifs(true); // Has chance for split-if optimization | 1644 C->set_has_split_ifs(true); // Has chance for split-if optimization |
1770 | |
1771 return true; | 1645 return true; |
1772 } | 1646 } |
1773 | 1647 |
1774 //------------------------------inline_pow------------------------------------- | 1648 //------------------------------inline_pow------------------------------------- |
1775 // Inline power instructions, if possible. | 1649 // Inline power instructions, if possible. |
1776 bool LibraryCallKit::inline_pow(vmIntrinsics::ID id) { | 1650 bool LibraryCallKit::inline_pow() { |
1777 assert(id == vmIntrinsics::_dpow, "Not pow"); | |
1778 | |
1779 // Pseudocode for pow | 1651 // Pseudocode for pow |
1780 // if (x <= 0.0) { | 1652 // if (x <= 0.0) { |
1781 // long longy = (long)y; | 1653 // long longy = (long)y; |
1782 // if ((double)longy == y) { // if y is long | 1654 // if ((double)longy == y) { // if y is long |
1783 // if (y + 1 == y) longy = 0; // huge number: even | 1655 // if (y + 1 == y) longy = 0; // huge number: even |
1791 // if (result != result)? { | 1663 // if (result != result)? { |
1792 // result = uncommon_trap() or runtime_call(); | 1664 // result = uncommon_trap() or runtime_call(); |
1793 // } | 1665 // } |
1794 // return result; | 1666 // return result; |
1795 | 1667 |
1796 _sp += arg_size(); // restore stack pointer | 1668 Node* x = round_double_node(argument(0)); |
1797 Node* y = pop_math_arg(); | 1669 Node* y = round_double_node(argument(2)); |
1798 Node* x = pop_math_arg(); | |
1799 | 1670 |
1800 Node* result = NULL; | 1671 Node* result = NULL; |
1801 | 1672 |
1802 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { | 1673 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { |
1803 // Short form: skip the fancy tests and just check for NaN result. | 1674 // Short form: skip the fancy tests and just check for NaN result. |
1804 result = _gvn.transform( new (C) PowDNode(0, x, y) ); | 1675 result = _gvn.transform(new (C) PowDNode(0, x, y)); |
1805 } else { | 1676 } else { |
1806 // If this inlining ever returned NaN in the past, include all | 1677 // If this inlining ever returned NaN in the past, include all |
1807 // checks + call to the runtime. | 1678 // checks + call to the runtime. |
1808 | 1679 |
1809 // Set the merge point for If node with condition of (x <= 0.0) | 1680 // Set the merge point for If node with condition of (x <= 0.0) |
1917 phi->init_req(1,slow_result); | 1788 phi->init_req(1,slow_result); |
1918 | 1789 |
1919 // Post merge | 1790 // Post merge |
1920 set_control(_gvn.transform(r)); | 1791 set_control(_gvn.transform(r)); |
1921 record_for_igvn(r); | 1792 record_for_igvn(r); |
1922 result=_gvn.transform(phi); | 1793 result = _gvn.transform(phi); |
1923 } | 1794 } |
1924 | 1795 |
1925 finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); | 1796 finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); |
1926 | 1797 |
1927 C->set_has_split_ifs(true); // Has chance for split-if optimization | 1798 C->set_has_split_ifs(true); // Has chance for split-if optimization |
1928 | |
1929 return true; | |
1930 } | |
1931 | |
1932 //------------------------------inline_trans------------------------------------- | |
1933 // Inline transcendental instructions, if possible. The Intel hardware gets | |
1934 // these right, no funny corner cases missed. | |
1935 bool LibraryCallKit::inline_trans(vmIntrinsics::ID id) { | |
1936 _sp += arg_size(); // restore stack pointer | |
1937 Node* arg = pop_math_arg(); | |
1938 Node* trans = NULL; | |
1939 | |
1940 switch (id) { | |
1941 case vmIntrinsics::_dlog: | |
1942 trans = _gvn.transform((Node*)new (C) LogDNode(arg)); | |
1943 break; | |
1944 case vmIntrinsics::_dlog10: | |
1945 trans = _gvn.transform((Node*)new (C) Log10DNode(arg)); | |
1946 break; | |
1947 default: | |
1948 assert(false, "bad intrinsic was passed in"); | |
1949 return false; | |
1950 } | |
1951 | |
1952 // Push result back on JVM stack | |
1953 push_pair(trans); | |
1954 return true; | 1799 return true; |
1955 } | 1800 } |
1956 | 1801 |
1957 //------------------------------runtime_math----------------------------- | 1802 //------------------------------runtime_math----------------------------- |
1958 bool LibraryCallKit::runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName) { | 1803 bool LibraryCallKit::runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName) { |
1959 Node* a = NULL; | |
1960 Node* b = NULL; | |
1961 | |
1962 assert(call_type == OptoRuntime::Math_DD_D_Type() || call_type == OptoRuntime::Math_D_D_Type(), | 1804 assert(call_type == OptoRuntime::Math_DD_D_Type() || call_type == OptoRuntime::Math_D_D_Type(), |
1963 "must be (DD)D or (D)D type"); | 1805 "must be (DD)D or (D)D type"); |
1964 | 1806 |
1965 // Inputs | 1807 // Inputs |
1966 _sp += arg_size(); // restore stack pointer | 1808 Node* a = round_double_node(argument(0)); |
1967 if (call_type == OptoRuntime::Math_DD_D_Type()) { | 1809 Node* b = (call_type == OptoRuntime::Math_DD_D_Type()) ? round_double_node(argument(2)) : NULL; |
1968 b = pop_math_arg(); | |
1969 } | |
1970 a = pop_math_arg(); | |
1971 | 1810 |
1972 const TypePtr* no_memory_effects = NULL; | 1811 const TypePtr* no_memory_effects = NULL; |
1973 Node* trig = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, | 1812 Node* trig = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, |
1974 no_memory_effects, | 1813 no_memory_effects, |
1975 a, top(), b, b ? top() : NULL); | 1814 a, top(), b, b ? top() : NULL); |
1977 #ifdef ASSERT | 1816 #ifdef ASSERT |
1978 Node* value_top = _gvn.transform(new (C) ProjNode(trig, TypeFunc::Parms+1)); | 1817 Node* value_top = _gvn.transform(new (C) ProjNode(trig, TypeFunc::Parms+1)); |
1979 assert(value_top == top(), "second value must be top"); | 1818 assert(value_top == top(), "second value must be top"); |
1980 #endif | 1819 #endif |
1981 | 1820 |
1982 push_pair(value); | 1821 set_result(value); |
1983 return true; | 1822 return true; |
1984 } | 1823 } |
1985 | 1824 |
1986 //------------------------------inline_math_native----------------------------- | 1825 //------------------------------inline_math_native----------------------------- |
1987 bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { | 1826 bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { |
1827 #define FN_PTR(f) CAST_FROM_FN_PTR(address, f) | |
1988 switch (id) { | 1828 switch (id) { |
1989 // These intrinsics are not properly supported on all hardware | 1829 // These intrinsics are not properly supported on all hardware |
1990 case vmIntrinsics::_dcos: return Matcher::has_match_rule(Op_CosD) ? inline_trig(id) : | 1830 case vmIntrinsics::_dcos: return Matcher::has_match_rule(Op_CosD) ? inline_trig(id) : |
1991 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dcos), "COS"); | 1831 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dcos), "COS"); |
1992 case vmIntrinsics::_dsin: return Matcher::has_match_rule(Op_SinD) ? inline_trig(id) : | 1832 case vmIntrinsics::_dsin: return Matcher::has_match_rule(Op_SinD) ? inline_trig(id) : |
1993 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dsin), "SIN"); | 1833 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dsin), "SIN"); |
1994 case vmIntrinsics::_dtan: return Matcher::has_match_rule(Op_TanD) ? inline_trig(id) : | 1834 case vmIntrinsics::_dtan: return Matcher::has_match_rule(Op_TanD) ? inline_trig(id) : |
1995 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dtan), "TAN"); | 1835 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan), "TAN"); |
1996 | 1836 |
1997 case vmIntrinsics::_dlog: return Matcher::has_match_rule(Op_LogD) ? inline_trans(id) : | 1837 case vmIntrinsics::_dlog: return Matcher::has_match_rule(Op_LogD) ? inline_math(id) : |
1998 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dlog), "LOG"); | 1838 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog), "LOG"); |
1999 case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_trans(id) : | 1839 case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) : |
2000 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), "LOG10"); | 1840 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); |
2001 | 1841 |
2002 // These intrinsics are supported on all hardware | 1842 // These intrinsics are supported on all hardware |
2003 case vmIntrinsics::_dsqrt: return Matcher::has_match_rule(Op_SqrtD) ? inline_sqrt(id) : false; | 1843 case vmIntrinsics::_dsqrt: return Matcher::has_match_rule(Op_SqrtD) ? inline_math(id) : false; |
2004 case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_abs(id) : false; | 1844 case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_math(id) : false; |
2005 | 1845 |
2006 case vmIntrinsics::_dexp: return | 1846 case vmIntrinsics::_dexp: return Matcher::has_match_rule(Op_ExpD) ? inline_exp() : |
2007 Matcher::has_match_rule(Op_ExpD) ? inline_exp(id) : | 1847 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp), "EXP"); |
2008 runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); | 1848 case vmIntrinsics::_dpow: return Matcher::has_match_rule(Op_PowD) ? inline_pow() : |
2009 case vmIntrinsics::_dpow: return | 1849 runtime_math(OptoRuntime::Math_DD_D_Type(), FN_PTR(SharedRuntime::dpow), "POW"); |
2010 Matcher::has_match_rule(Op_PowD) ? inline_pow(id) : | 1850 #undef FN_PTR |
2011 runtime_math(OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); | |
2012 | 1851 |
2013 // These intrinsics are not yet correctly implemented | 1852 // These intrinsics are not yet correctly implemented |
2014 case vmIntrinsics::_datan2: | 1853 case vmIntrinsics::_datan2: |
2015 return false; | 1854 return false; |
2016 | 1855 |
2017 default: | 1856 default: |
2018 ShouldNotReachHere(); | 1857 fatal_unexpected_iid(id); |
2019 return false; | 1858 return false; |
2020 } | 1859 } |
2021 } | 1860 } |
2022 | 1861 |
2023 static bool is_simple_name(Node* n) { | 1862 static bool is_simple_name(Node* n) { |
2028 ); | 1867 ); |
2029 } | 1868 } |
2030 | 1869 |
2031 //----------------------------inline_min_max----------------------------------- | 1870 //----------------------------inline_min_max----------------------------------- |
2032 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { | 1871 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { |
2033 push(generate_min_max(id, argument(0), argument(1))); | 1872 set_result(generate_min_max(id, argument(0), argument(1))); |
2034 | |
2035 return true; | 1873 return true; |
2036 } | 1874 } |
2037 | 1875 |
2038 Node* | 1876 Node* |
2039 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { | 1877 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { |
2252 } else { | 2090 } else { |
2253 return basic_plus_adr(base, offset); | 2091 return basic_plus_adr(base, offset); |
2254 } | 2092 } |
2255 } | 2093 } |
2256 | 2094 |
2257 //-------------------inline_numberOfLeadingZeros_int/long----------------------- | 2095 //--------------------------inline_number_methods----------------------------- |
2258 // inline int Integer.numberOfLeadingZeros(int) | 2096 // inline int Integer.numberOfLeadingZeros(int) |
2259 // inline int Long.numberOfLeadingZeros(long) | 2097 // inline int Long.numberOfLeadingZeros(long) |
2260 bool LibraryCallKit::inline_numberOfLeadingZeros(vmIntrinsics::ID id) { | 2098 // |
2261 assert(id == vmIntrinsics::_numberOfLeadingZeros_i || id == vmIntrinsics::_numberOfLeadingZeros_l, "not numberOfLeadingZeros"); | 2099 // inline int Integer.numberOfTrailingZeros(int) |
2262 if (id == vmIntrinsics::_numberOfLeadingZeros_i && !Matcher::match_rule_supported(Op_CountLeadingZerosI)) return false; | 2100 // inline int Long.numberOfTrailingZeros(long) |
2263 if (id == vmIntrinsics::_numberOfLeadingZeros_l && !Matcher::match_rule_supported(Op_CountLeadingZerosL)) return false; | 2101 // |
2264 _sp += arg_size(); // restore stack pointer | 2102 // inline int Integer.bitCount(int) |
2103 // inline int Long.bitCount(long) | |
2104 // | |
2105 // inline char Character.reverseBytes(char) | |
2106 // inline short Short.reverseBytes(short) | |
2107 // inline int Integer.reverseBytes(int) | |
2108 // inline long Long.reverseBytes(long) | |
2109 bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) { | |
2110 Node* arg = argument(0); | |
2111 Node* n; | |
2265 switch (id) { | 2112 switch (id) { |
2266 case vmIntrinsics::_numberOfLeadingZeros_i: | 2113 case vmIntrinsics::_numberOfLeadingZeros_i: n = new (C) CountLeadingZerosINode( arg); break; |
2267 push(_gvn.transform(new (C) CountLeadingZerosINode(pop()))); | 2114 case vmIntrinsics::_numberOfLeadingZeros_l: n = new (C) CountLeadingZerosLNode( arg); break; |
2268 break; | 2115 case vmIntrinsics::_numberOfTrailingZeros_i: n = new (C) CountTrailingZerosINode(arg); break; |
2269 case vmIntrinsics::_numberOfLeadingZeros_l: | 2116 case vmIntrinsics::_numberOfTrailingZeros_l: n = new (C) CountTrailingZerosLNode(arg); break; |
2270 push(_gvn.transform(new (C) CountLeadingZerosLNode(pop_pair()))); | 2117 case vmIntrinsics::_bitCount_i: n = new (C) PopCountINode( arg); break; |
2271 break; | 2118 case vmIntrinsics::_bitCount_l: n = new (C) PopCountLNode( arg); break; |
2272 default: | 2119 case vmIntrinsics::_reverseBytes_c: n = new (C) ReverseBytesUSNode(0, arg); break; |
2273 ShouldNotReachHere(); | 2120 case vmIntrinsics::_reverseBytes_s: n = new (C) ReverseBytesSNode( 0, arg); break; |
2274 } | 2121 case vmIntrinsics::_reverseBytes_i: n = new (C) ReverseBytesINode( 0, arg); break; |
2275 return true; | 2122 case vmIntrinsics::_reverseBytes_l: n = new (C) ReverseBytesLNode( 0, arg); break; |
2276 } | 2123 default: fatal_unexpected_iid(id); break; |
2277 | 2124 } |
2278 //-------------------inline_numberOfTrailingZeros_int/long---------------------- | 2125 set_result(_gvn.transform(n)); |
2279 // inline int Integer.numberOfTrailingZeros(int) | |
2280 // inline int Long.numberOfTrailingZeros(long) | |
2281 bool LibraryCallKit::inline_numberOfTrailingZeros(vmIntrinsics::ID id) { | |
2282 assert(id == vmIntrinsics::_numberOfTrailingZeros_i || id == vmIntrinsics::_numberOfTrailingZeros_l, "not numberOfTrailingZeros"); | |
2283 if (id == vmIntrinsics::_numberOfTrailingZeros_i && !Matcher::match_rule_supported(Op_CountTrailingZerosI)) return false; | |
2284 if (id == vmIntrinsics::_numberOfTrailingZeros_l && !Matcher::match_rule_supported(Op_CountTrailingZerosL)) return false; | |
2285 _sp += arg_size(); // restore stack pointer | |
2286 switch (id) { | |
2287 case vmIntrinsics::_numberOfTrailingZeros_i: | |
2288 push(_gvn.transform(new (C) CountTrailingZerosINode(pop()))); | |
2289 break; | |
2290 case vmIntrinsics::_numberOfTrailingZeros_l: | |
2291 push(_gvn.transform(new (C) CountTrailingZerosLNode(pop_pair()))); | |
2292 break; | |
2293 default: | |
2294 ShouldNotReachHere(); | |
2295 } | |
2296 return true; | |
2297 } | |
2298 | |
2299 //----------------------------inline_bitCount_int/long----------------------- | |
2300 // inline int Integer.bitCount(int) | |
2301 // inline int Long.bitCount(long) | |
2302 bool LibraryCallKit::inline_bitCount(vmIntrinsics::ID id) { | |
2303 assert(id == vmIntrinsics::_bitCount_i || id == vmIntrinsics::_bitCount_l, "not bitCount"); | |
2304 if (id == vmIntrinsics::_bitCount_i && !Matcher::has_match_rule(Op_PopCountI)) return false; | |
2305 if (id == vmIntrinsics::_bitCount_l && !Matcher::has_match_rule(Op_PopCountL)) return false; | |
2306 _sp += arg_size(); // restore stack pointer | |
2307 switch (id) { | |
2308 case vmIntrinsics::_bitCount_i: | |
2309 push(_gvn.transform(new (C) PopCountINode(pop()))); | |
2310 break; | |
2311 case vmIntrinsics::_bitCount_l: | |
2312 push(_gvn.transform(new (C) PopCountLNode(pop_pair()))); | |
2313 break; | |
2314 default: | |
2315 ShouldNotReachHere(); | |
2316 } | |
2317 return true; | |
2318 } | |
2319 | |
2320 //----------------------------inline_reverseBytes_int/long/char/short------------------- | |
2321 // inline Integer.reverseBytes(int) | |
2322 // inline Long.reverseBytes(long) | |
2323 // inline Character.reverseBytes(char) | |
2324 // inline Short.reverseBytes(short) | |
2325 bool LibraryCallKit::inline_reverseBytes(vmIntrinsics::ID id) { | |
2326 assert(id == vmIntrinsics::_reverseBytes_i || id == vmIntrinsics::_reverseBytes_l || | |
2327 id == vmIntrinsics::_reverseBytes_c || id == vmIntrinsics::_reverseBytes_s, | |
2328 "not reverse Bytes"); | |
2329 if (id == vmIntrinsics::_reverseBytes_i && !Matcher::has_match_rule(Op_ReverseBytesI)) return false; | |
2330 if (id == vmIntrinsics::_reverseBytes_l && !Matcher::has_match_rule(Op_ReverseBytesL)) return false; | |
2331 if (id == vmIntrinsics::_reverseBytes_c && !Matcher::has_match_rule(Op_ReverseBytesUS)) return false; | |
2332 if (id == vmIntrinsics::_reverseBytes_s && !Matcher::has_match_rule(Op_ReverseBytesS)) return false; | |
2333 _sp += arg_size(); // restore stack pointer | |
2334 switch (id) { | |
2335 case vmIntrinsics::_reverseBytes_i: | |
2336 push(_gvn.transform(new (C) ReverseBytesINode(0, pop()))); | |
2337 break; | |
2338 case vmIntrinsics::_reverseBytes_l: | |
2339 push_pair(_gvn.transform(new (C) ReverseBytesLNode(0, pop_pair()))); | |
2340 break; | |
2341 case vmIntrinsics::_reverseBytes_c: | |
2342 push(_gvn.transform(new (C) ReverseBytesUSNode(0, pop()))); | |
2343 break; | |
2344 case vmIntrinsics::_reverseBytes_s: | |
2345 push(_gvn.transform(new (C) ReverseBytesSNode(0, pop()))); | |
2346 break; | |
2347 default: | |
2348 ; | |
2349 } | |
2350 return true; | 2126 return true; |
2351 } | 2127 } |
2352 | 2128 |
2353 //----------------------------inline_unsafe_access---------------------------- | 2129 //----------------------------inline_unsafe_access---------------------------- |
2354 | 2130 |
2355 const static BasicType T_ADDRESS_HOLDER = T_LONG; | 2131 const static BasicType T_ADDRESS_HOLDER = T_LONG; |
2356 | 2132 |
2357 // Helper that guards and inserts a pre-barrier. | 2133 // Helper that guards and inserts a pre-barrier. |
2358 void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset, | 2134 void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset, |
2359 Node* pre_val, int nargs, bool need_mem_bar) { | 2135 Node* pre_val, bool need_mem_bar) { |
2360 // We could be accessing the referent field of a reference object. If so, when G1 | 2136 // We could be accessing the referent field of a reference object. If so, when G1 |
2361 // is enabled, we need to log the value in the referent field in an SATB buffer. | 2137 // is enabled, we need to log the value in the referent field in an SATB buffer. |
2362 // This routine performs some compile time filters and generates suitable | 2138 // This routine performs some compile time filters and generates suitable |
2363 // runtime filters that guard the pre-barrier code. | 2139 // runtime filters that guard the pre-barrier code. |
2364 // Also add memory barrier for non volatile load from the referent field | 2140 // Also add memory barrier for non volatile load from the referent field |
2404 // if (instance_of(base, java.lang.ref.Reference)) { | 2180 // if (instance_of(base, java.lang.ref.Reference)) { |
2405 // pre_barrier(_, pre_val, ...); | 2181 // pre_barrier(_, pre_val, ...); |
2406 // } | 2182 // } |
2407 // } | 2183 // } |
2408 | 2184 |
2409 float likely = PROB_LIKELY(0.999); | 2185 float likely = PROB_LIKELY( 0.999); |
2410 float unlikely = PROB_UNLIKELY(0.999); | 2186 float unlikely = PROB_UNLIKELY(0.999); |
2411 | 2187 |
2412 IdealKit ideal(this); | 2188 IdealKit ideal(this); |
2413 #define __ ideal. | 2189 #define __ ideal. |
2414 | 2190 |
2415 Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset); | 2191 Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset); |
2417 __ if_then(offset, BoolTest::eq, referent_off, unlikely); { | 2193 __ if_then(offset, BoolTest::eq, referent_off, unlikely); { |
2418 // Update graphKit memory and control from IdealKit. | 2194 // Update graphKit memory and control from IdealKit. |
2419 sync_kit(ideal); | 2195 sync_kit(ideal); |
2420 | 2196 |
2421 Node* ref_klass_con = makecon(TypeKlassPtr::make(env()->Reference_klass())); | 2197 Node* ref_klass_con = makecon(TypeKlassPtr::make(env()->Reference_klass())); |
2422 _sp += nargs; // gen_instanceof might do an uncommon trap | |
2423 Node* is_instof = gen_instanceof(base_oop, ref_klass_con); | 2198 Node* is_instof = gen_instanceof(base_oop, ref_klass_con); |
2424 _sp -= nargs; | |
2425 | 2199 |
2426 // Update IdealKit memory and control from graphKit. | 2200 // Update IdealKit memory and control from graphKit. |
2427 __ sync_kit(this); | 2201 __ sync_kit(this); |
2428 | 2202 |
2429 Node* one = __ ConI(1); | 2203 Node* one = __ ConI(1); |
2503 | 2277 |
2504 #ifndef PRODUCT | 2278 #ifndef PRODUCT |
2505 { | 2279 { |
2506 ResourceMark rm; | 2280 ResourceMark rm; |
2507 // Check the signatures. | 2281 // Check the signatures. |
2508 ciSignature* sig = signature(); | 2282 ciSignature* sig = callee()->signature(); |
2509 #ifdef ASSERT | 2283 #ifdef ASSERT |
2510 if (!is_store) { | 2284 if (!is_store) { |
2511 // Object getObject(Object base, int/long offset), etc. | 2285 // Object getObject(Object base, int/long offset), etc. |
2512 BasicType rtype = sig->return_type()->basic_type(); | 2286 BasicType rtype = sig->return_type()->basic_type(); |
2513 if (rtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::getAddress_name()) | 2287 if (rtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::getAddress_name()) |
2541 } | 2315 } |
2542 #endif //PRODUCT | 2316 #endif //PRODUCT |
2543 | 2317 |
2544 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". | 2318 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
2545 | 2319 |
2546 int type_words = type2size[ (type == T_ADDRESS) ? T_LONG : type ]; | 2320 Node* receiver = argument(0); // type: oop |
2547 | 2321 |
2548 // Argument words: "this" plus (oop/offset) or (lo/hi) args plus maybe 1 or 2 value words | 2322 // Build address expression. See the code in inline_unsafe_prefetch. |
2549 int nargs = 1 + (is_native_ptr ? 2 : 3) + (is_store ? type_words : 0); | 2323 Node* adr; |
2550 assert(callee()->arg_size() == nargs, "must be"); | 2324 Node* heap_base_oop = top(); |
2551 | 2325 Node* offset = top(); |
2552 debug_only(int saved_sp = _sp); | |
2553 _sp += nargs; | |
2554 | |
2555 Node* val; | 2326 Node* val; |
2556 debug_only(val = (Node*)(uintptr_t)-1); | |
2557 | |
2558 | |
2559 if (is_store) { | |
2560 // Get the value being stored. (Pop it first; it was pushed last.) | |
2561 switch (type) { | |
2562 case T_DOUBLE: | |
2563 case T_LONG: | |
2564 case T_ADDRESS: | |
2565 val = pop_pair(); | |
2566 break; | |
2567 default: | |
2568 val = pop(); | |
2569 } | |
2570 } | |
2571 | |
2572 // Build address expression. See the code in inline_unsafe_prefetch. | |
2573 Node *adr; | |
2574 Node *heap_base_oop = top(); | |
2575 Node* offset = top(); | |
2576 | 2327 |
2577 if (!is_native_ptr) { | 2328 if (!is_native_ptr) { |
2329 // The base is either a Java object or a value produced by Unsafe.staticFieldBase | |
2330 Node* base = argument(1); // type: oop | |
2578 // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset | 2331 // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset |
2579 offset = pop_pair(); | 2332 offset = argument(2); // type: long |
2580 // The base is either a Java object or a value produced by Unsafe.staticFieldBase | |
2581 Node* base = pop(); | |
2582 // We currently rely on the cookies produced by Unsafe.xxxFieldOffset | 2333 // We currently rely on the cookies produced by Unsafe.xxxFieldOffset |
2583 // to be plain byte offsets, which are also the same as those accepted | 2334 // to be plain byte offsets, which are also the same as those accepted |
2584 // by oopDesc::field_base. | 2335 // by oopDesc::field_base. |
2585 assert(Unsafe_field_offset_to_byte_offset(11) == 11, | 2336 assert(Unsafe_field_offset_to_byte_offset(11) == 11, |
2586 "fieldOffset must be byte-scaled"); | 2337 "fieldOffset must be byte-scaled"); |
2587 // 32-bit machines ignore the high half! | 2338 // 32-bit machines ignore the high half! |
2588 offset = ConvL2X(offset); | 2339 offset = ConvL2X(offset); |
2589 adr = make_unsafe_address(base, offset); | 2340 adr = make_unsafe_address(base, offset); |
2590 heap_base_oop = base; | 2341 heap_base_oop = base; |
2342 val = is_store ? argument(4) : NULL; | |
2591 } else { | 2343 } else { |
2592 Node* ptr = pop_pair(); | 2344 Node* ptr = argument(1); // type: long |
2593 // Adjust Java long to machine word: | 2345 ptr = ConvL2X(ptr); // adjust Java long to machine word |
2594 ptr = ConvL2X(ptr); | |
2595 adr = make_unsafe_address(NULL, ptr); | 2346 adr = make_unsafe_address(NULL, ptr); |
2596 } | 2347 val = is_store ? argument(3) : NULL; |
2597 | 2348 } |
2598 // Pop receiver last: it was pushed first. | |
2599 Node *receiver = pop(); | |
2600 | |
2601 assert(saved_sp == _sp, "must have correct argument count"); | |
2602 | 2349 |
2603 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); | 2350 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
2604 | 2351 |
2605 // First guess at the value type. | 2352 // First guess at the value type. |
2606 const Type *value_type = Type::get_const_basic_type(type); | 2353 const Type *value_type = Type::get_const_basic_type(type); |
2631 if (tjp != NULL) { | 2378 if (tjp != NULL) { |
2632 value_type = tjp; | 2379 value_type = tjp; |
2633 } | 2380 } |
2634 } | 2381 } |
2635 | 2382 |
2636 // Null check on self without removing any arguments. The argument | 2383 receiver = null_check(receiver); |
2637 // null check technically happens in the wrong place, which can lead to | |
2638 // invalid stack traces when the primitive is inlined into a method | |
2639 // which handles NullPointerExceptions. | |
2640 _sp += nargs; | |
2641 do_null_check(receiver, T_OBJECT); | |
2642 _sp -= nargs; | |
2643 if (stopped()) { | 2384 if (stopped()) { |
2644 return true; | 2385 return true; |
2645 } | 2386 } |
2646 // Heap pointers get a null-check from the interpreter, | 2387 // Heap pointers get a null-check from the interpreter, |
2647 // as a courtesy. However, this is not guaranteed by Unsafe, | 2388 // as a courtesy. However, this is not guaranteed by Unsafe, |
2669 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. | 2410 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. |
2670 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); | 2411 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
2671 | 2412 |
2672 if (!is_store) { | 2413 if (!is_store) { |
2673 Node* p = make_load(control(), adr, value_type, type, adr_type, is_volatile); | 2414 Node* p = make_load(control(), adr, value_type, type, adr_type, is_volatile); |
2674 // load value and push onto stack | 2415 // load value |
2675 switch (type) { | 2416 switch (type) { |
2676 case T_BOOLEAN: | 2417 case T_BOOLEAN: |
2677 case T_CHAR: | 2418 case T_CHAR: |
2678 case T_BYTE: | 2419 case T_BYTE: |
2679 case T_SHORT: | 2420 case T_SHORT: |
2680 case T_INT: | 2421 case T_INT: |
2422 case T_LONG: | |
2681 case T_FLOAT: | 2423 case T_FLOAT: |
2682 push(p); | 2424 case T_DOUBLE: |
2683 break; | 2425 break; |
2684 case T_OBJECT: | 2426 case T_OBJECT: |
2685 if (need_read_barrier) { | 2427 if (need_read_barrier) { |
2686 insert_pre_barrier(heap_base_oop, offset, p, nargs, !(is_volatile || need_mem_bar)); | 2428 insert_pre_barrier(heap_base_oop, offset, p, !(is_volatile || need_mem_bar)); |
2687 } | 2429 } |
2688 push(p); | |
2689 break; | 2430 break; |
2690 case T_ADDRESS: | 2431 case T_ADDRESS: |
2691 // Cast to an int type. | 2432 // Cast to an int type. |
2692 p = _gvn.transform( new (C) CastP2XNode(NULL,p) ); | 2433 p = _gvn.transform(new (C) CastP2XNode(NULL, p)); |
2693 p = ConvX2L(p); | 2434 p = ConvX2L(p); |
2694 push_pair(p); | |
2695 break; | 2435 break; |
2696 case T_DOUBLE: | 2436 default: |
2697 case T_LONG: | 2437 fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); |
2698 push_pair( p ); | |
2699 break; | 2438 break; |
2700 default: ShouldNotReachHere(); | 2439 } |
2701 } | 2440 // The load node has the control of the preceding MemBarCPUOrder. All |
2441 // following nodes will have the control of the MemBarCPUOrder inserted at | |
2442 // the end of this method. So, pushing the load onto the stack at a later | |
2443 // point is fine. | |
2444 set_result(p); | |
2702 } else { | 2445 } else { |
2703 // place effect of store into memory | 2446 // place effect of store into memory |
2704 switch (type) { | 2447 switch (type) { |
2705 case T_DOUBLE: | 2448 case T_DOUBLE: |
2706 val = dstore_rounding(val); | 2449 val = dstore_rounding(val); |
2760 bool LibraryCallKit::inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static) { | 2503 bool LibraryCallKit::inline_unsafe_prefetch(bool is_native_ptr, bool is_store, bool is_static) { |
2761 #ifndef PRODUCT | 2504 #ifndef PRODUCT |
2762 { | 2505 { |
2763 ResourceMark rm; | 2506 ResourceMark rm; |
2764 // Check the signatures. | 2507 // Check the signatures. |
2765 ciSignature* sig = signature(); | 2508 ciSignature* sig = callee()->signature(); |
2766 #ifdef ASSERT | 2509 #ifdef ASSERT |
2767 // Object getObject(Object base, int/long offset), etc. | 2510 // Object getObject(Object base, int/long offset), etc. |
2768 BasicType rtype = sig->return_type()->basic_type(); | 2511 BasicType rtype = sig->return_type()->basic_type(); |
2769 if (!is_native_ptr) { | 2512 if (!is_native_ptr) { |
2770 assert(sig->count() == 2, "oop prefetch has 2 arguments"); | 2513 assert(sig->count() == 2, "oop prefetch has 2 arguments"); |
2778 } | 2521 } |
2779 #endif // !PRODUCT | 2522 #endif // !PRODUCT |
2780 | 2523 |
2781 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". | 2524 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
2782 | 2525 |
2783 // Argument words: "this" if not static, plus (oop/offset) or (lo/hi) args | 2526 const int idx = is_static ? 0 : 1; |
2784 int nargs = (is_static ? 0 : 1) + (is_native_ptr ? 2 : 3); | 2527 if (!is_static) { |
2785 | 2528 null_check_receiver(); |
2786 debug_only(int saved_sp = _sp); | 2529 if (stopped()) { |
2787 _sp += nargs; | 2530 return true; |
2531 } | |
2532 } | |
2788 | 2533 |
2789 // Build address expression. See the code in inline_unsafe_access. | 2534 // Build address expression. See the code in inline_unsafe_access. |
2790 Node *adr; | 2535 Node *adr; |
2791 if (!is_native_ptr) { | 2536 if (!is_native_ptr) { |
2537 // The base is either a Java object or a value produced by Unsafe.staticFieldBase | |
2538 Node* base = argument(idx + 0); // type: oop | |
2792 // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset | 2539 // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset |
2793 Node* offset = pop_pair(); | 2540 Node* offset = argument(idx + 1); // type: long |
2794 // The base is either a Java object or a value produced by Unsafe.staticFieldBase | |
2795 Node* base = pop(); | |
2796 // We currently rely on the cookies produced by Unsafe.xxxFieldOffset | 2541 // We currently rely on the cookies produced by Unsafe.xxxFieldOffset |
2797 // to be plain byte offsets, which are also the same as those accepted | 2542 // to be plain byte offsets, which are also the same as those accepted |
2798 // by oopDesc::field_base. | 2543 // by oopDesc::field_base. |
2799 assert(Unsafe_field_offset_to_byte_offset(11) == 11, | 2544 assert(Unsafe_field_offset_to_byte_offset(11) == 11, |
2800 "fieldOffset must be byte-scaled"); | 2545 "fieldOffset must be byte-scaled"); |
2801 // 32-bit machines ignore the high half! | 2546 // 32-bit machines ignore the high half! |
2802 offset = ConvL2X(offset); | 2547 offset = ConvL2X(offset); |
2803 adr = make_unsafe_address(base, offset); | 2548 adr = make_unsafe_address(base, offset); |
2804 } else { | 2549 } else { |
2805 Node* ptr = pop_pair(); | 2550 Node* ptr = argument(idx + 0); // type: long |
2806 // Adjust Java long to machine word: | 2551 ptr = ConvL2X(ptr); // adjust Java long to machine word |
2807 ptr = ConvL2X(ptr); | |
2808 adr = make_unsafe_address(NULL, ptr); | 2552 adr = make_unsafe_address(NULL, ptr); |
2809 } | |
2810 | |
2811 if (is_static) { | |
2812 assert(saved_sp == _sp, "must have correct argument count"); | |
2813 } else { | |
2814 // Pop receiver last: it was pushed first. | |
2815 Node *receiver = pop(); | |
2816 assert(saved_sp == _sp, "must have correct argument count"); | |
2817 | |
2818 // Null check on self without removing any arguments. The argument | |
2819 // null check technically happens in the wrong place, which can lead to | |
2820 // invalid stack traces when the primitive is inlined into a method | |
2821 // which handles NullPointerExceptions. | |
2822 _sp += nargs; | |
2823 do_null_check(receiver, T_OBJECT); | |
2824 _sp -= nargs; | |
2825 if (stopped()) { | |
2826 return true; | |
2827 } | |
2828 } | 2553 } |
2829 | 2554 |
2830 // Generate the read or write prefetch | 2555 // Generate the read or write prefetch |
2831 Node *prefetch; | 2556 Node *prefetch; |
2832 if (is_store) { | 2557 if (is_store) { |
2839 | 2564 |
2840 return true; | 2565 return true; |
2841 } | 2566 } |
2842 | 2567 |
2843 //----------------------------inline_unsafe_load_store---------------------------- | 2568 //----------------------------inline_unsafe_load_store---------------------------- |
2844 | 2569 // This method serves a couple of different customers (depending on LoadStoreKind): |
2570 // | |
2571 // LS_cmpxchg: | |
2572 // public final native boolean compareAndSwapObject(Object o, long offset, Object expected, Object x); | |
2573 // public final native boolean compareAndSwapInt( Object o, long offset, int expected, int x); | |
2574 // public final native boolean compareAndSwapLong( Object o, long offset, long expected, long x); | |
2575 // | |
2576 // LS_xadd: | |
2577 // public int getAndAddInt( Object o, long offset, int delta) | |
2578 // public long getAndAddLong(Object o, long offset, long delta) | |
2579 // | |
2580 // LS_xchg: | |
2581 // int getAndSet(Object o, long offset, int newValue) | |
2582 // long getAndSet(Object o, long offset, long newValue) | |
2583 // Object getAndSet(Object o, long offset, Object newValue) | |
2584 // | |
2845 bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind) { | 2585 bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind) { |
2846 // This basic scheme here is the same as inline_unsafe_access, but | 2586 // This basic scheme here is the same as inline_unsafe_access, but |
2847 // differs in enough details that combining them would make the code | 2587 // differs in enough details that combining them would make the code |
2848 // overly confusing. (This is a true fact! I originally combined | 2588 // overly confusing. (This is a true fact! I originally combined |
2849 // them, but even I was confused by it!) As much code/comments as | 2589 // them, but even I was confused by it!) As much code/comments as |
2854 | 2594 |
2855 #ifndef PRODUCT | 2595 #ifndef PRODUCT |
2856 BasicType rtype; | 2596 BasicType rtype; |
2857 { | 2597 { |
2858 ResourceMark rm; | 2598 ResourceMark rm; |
2859 ciSignature* sig = signature(); | 2599 // Check the signatures. |
2600 ciSignature* sig = callee()->signature(); | |
2860 rtype = sig->return_type()->basic_type(); | 2601 rtype = sig->return_type()->basic_type(); |
2861 if (kind == LS_xadd || kind == LS_xchg) { | 2602 if (kind == LS_xadd || kind == LS_xchg) { |
2862 // Check the signatures. | 2603 // Check the signatures. |
2863 #ifdef ASSERT | 2604 #ifdef ASSERT |
2864 assert(rtype == type, "get and set must return the expected type"); | 2605 assert(rtype == type, "get and set must return the expected type"); |
2879 ShouldNotReachHere(); | 2620 ShouldNotReachHere(); |
2880 } | 2621 } |
2881 } | 2622 } |
2882 #endif //PRODUCT | 2623 #endif //PRODUCT |
2883 | 2624 |
2884 // number of stack slots per value argument (1 or 2) | |
2885 int type_words = type2size[type]; | |
2886 | |
2887 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". | 2625 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
2888 | 2626 |
2889 // Argument words: "this" plus oop plus offset (plus oldvalue) plus newvalue/delta; | 2627 // Get arguments: |
2890 int nargs = 1 + 1 + 2 + ((kind == LS_cmpxchg) ? type_words : 0) + type_words; | 2628 Node* receiver = NULL; |
2891 | 2629 Node* base = NULL; |
2892 // pop arguments: newval, offset, base, and receiver | 2630 Node* offset = NULL; |
2893 debug_only(int saved_sp = _sp); | 2631 Node* oldval = NULL; |
2894 _sp += nargs; | 2632 Node* newval = NULL; |
2895 Node* newval = (type_words == 1) ? pop() : pop_pair(); | 2633 if (kind == LS_cmpxchg) { |
2896 Node* oldval = (kind == LS_cmpxchg) ? ((type_words == 1) ? pop() : pop_pair()) : NULL; | 2634 const bool two_slot_type = type2size[type] == 2; |
2897 Node *offset = pop_pair(); | 2635 receiver = argument(0); // type: oop |
2898 Node *base = pop(); | 2636 base = argument(1); // type: oop |
2899 Node *receiver = pop(); | 2637 offset = argument(2); // type: long |
2900 assert(saved_sp == _sp, "must have correct argument count"); | 2638 oldval = argument(4); // type: oop, int, or long |
2901 | 2639 newval = argument(two_slot_type ? 6 : 5); // type: oop, int, or long |
2902 // Null check receiver. | 2640 } else if (kind == LS_xadd || kind == LS_xchg){ |
2903 _sp += nargs; | 2641 receiver = argument(0); // type: oop |
2904 do_null_check(receiver, T_OBJECT); | 2642 base = argument(1); // type: oop |
2905 _sp -= nargs; | 2643 offset = argument(2); // type: long |
2644 oldval = NULL; | |
2645 newval = argument(4); // type: oop, int, or long | |
2646 } | |
2647 | |
2648 // Null check receiver. | |
2649 receiver = null_check(receiver); | |
2906 if (stopped()) { | 2650 if (stopped()) { |
2907 return true; | 2651 return true; |
2908 } | 2652 } |
2909 | 2653 |
2910 // Build field offset expression. | 2654 // Build field offset expression. |
3006 } | 2750 } |
3007 } | 2751 } |
3008 post_barrier(control(), load_store, base, adr, alias_idx, newval, T_OBJECT, true); | 2752 post_barrier(control(), load_store, base, adr, alias_idx, newval, T_OBJECT, true); |
3009 break; | 2753 break; |
3010 default: | 2754 default: |
3011 ShouldNotReachHere(); | 2755 fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); |
3012 break; | 2756 break; |
3013 } | 2757 } |
3014 | 2758 |
3015 // SCMemProjNodes represent the memory state of a LoadStore. Their | 2759 // SCMemProjNodes represent the memory state of a LoadStore. Their |
3016 // main role is to prevent LoadStore nodes from being optimized away | 2760 // main role is to prevent LoadStore nodes from being optimized away |
3027 load_store = _gvn.transform(new (C) DecodeNNode(load_store, load_store->bottom_type()->make_ptr())); | 2771 load_store = _gvn.transform(new (C) DecodeNNode(load_store, load_store->bottom_type()->make_ptr())); |
3028 } | 2772 } |
3029 #endif | 2773 #endif |
3030 | 2774 |
3031 assert(type2size[load_store->bottom_type()->basic_type()] == type2size[rtype], "result type should match"); | 2775 assert(type2size[load_store->bottom_type()->basic_type()] == type2size[rtype], "result type should match"); |
3032 push_node(load_store->bottom_type()->basic_type(), load_store); | 2776 set_result(load_store); |
3033 return true; | 2777 return true; |
3034 } | 2778 } |
3035 | 2779 |
2780 //----------------------------inline_unsafe_ordered_store---------------------- | |
2781 // public native void sun.misc.Unsafe.putOrderedObject(Object o, long offset, Object x); | |
2782 // public native void sun.misc.Unsafe.putOrderedInt(Object o, long offset, int x); | |
2783 // public native void sun.misc.Unsafe.putOrderedLong(Object o, long offset, long x); | |
3036 bool LibraryCallKit::inline_unsafe_ordered_store(BasicType type) { | 2784 bool LibraryCallKit::inline_unsafe_ordered_store(BasicType type) { |
3037 // This is another variant of inline_unsafe_access, differing in | 2785 // This is another variant of inline_unsafe_access, differing in |
3038 // that it always issues store-store ("release") barrier and ensures | 2786 // that it always issues store-store ("release") barrier and ensures |
3039 // store-atomicity (which only matters for "long"). | 2787 // store-atomicity (which only matters for "long"). |
3040 | 2788 |
3042 | 2790 |
3043 #ifndef PRODUCT | 2791 #ifndef PRODUCT |
3044 { | 2792 { |
3045 ResourceMark rm; | 2793 ResourceMark rm; |
3046 // Check the signatures. | 2794 // Check the signatures. |
3047 ciSignature* sig = signature(); | 2795 ciSignature* sig = callee()->signature(); |
3048 #ifdef ASSERT | 2796 #ifdef ASSERT |
3049 BasicType rtype = sig->return_type()->basic_type(); | 2797 BasicType rtype = sig->return_type()->basic_type(); |
3050 assert(rtype == T_VOID, "must return void"); | 2798 assert(rtype == T_VOID, "must return void"); |
3051 assert(sig->count() == 3, "has 3 arguments"); | 2799 assert(sig->count() == 3, "has 3 arguments"); |
3052 assert(sig->type_at(0)->basic_type() == T_OBJECT, "base is object"); | 2800 assert(sig->type_at(0)->basic_type() == T_OBJECT, "base is object"); |
3053 assert(sig->type_at(1)->basic_type() == T_LONG, "offset is long"); | 2801 assert(sig->type_at(1)->basic_type() == T_LONG, "offset is long"); |
3054 #endif // ASSERT | 2802 #endif // ASSERT |
3055 } | 2803 } |
3056 #endif //PRODUCT | 2804 #endif //PRODUCT |
3057 | 2805 |
3058 // number of stack slots per value argument (1 or 2) | |
3059 int type_words = type2size[type]; | |
3060 | |
3061 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". | 2806 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
3062 | 2807 |
3063 // Argument words: "this" plus oop plus offset plus value; | 2808 // Get arguments: |
3064 int nargs = 1 + 1 + 2 + type_words; | 2809 Node* receiver = argument(0); // type: oop |
3065 | 2810 Node* base = argument(1); // type: oop |
3066 // pop arguments: val, offset, base, and receiver | 2811 Node* offset = argument(2); // type: long |
3067 debug_only(int saved_sp = _sp); | 2812 Node* val = argument(4); // type: oop, int, or long |
3068 _sp += nargs; | 2813 |
3069 Node* val = (type_words == 1) ? pop() : pop_pair(); | 2814 // Null check receiver. |
3070 Node *offset = pop_pair(); | 2815 receiver = null_check(receiver); |
3071 Node *base = pop(); | |
3072 Node *receiver = pop(); | |
3073 assert(saved_sp == _sp, "must have correct argument count"); | |
3074 | |
3075 // Null check receiver. | |
3076 _sp += nargs; | |
3077 do_null_check(receiver, T_OBJECT); | |
3078 _sp -= nargs; | |
3079 if (stopped()) { | 2816 if (stopped()) { |
3080 return true; | 2817 return true; |
3081 } | 2818 } |
3082 | 2819 |
3083 // Build field offset expression. | 2820 // Build field offset expression. |
3090 Compile::AliasType* alias_type = C->alias_type(adr_type); | 2827 Compile::AliasType* alias_type = C->alias_type(adr_type); |
3091 | 2828 |
3092 insert_mem_bar(Op_MemBarRelease); | 2829 insert_mem_bar(Op_MemBarRelease); |
3093 insert_mem_bar(Op_MemBarCPUOrder); | 2830 insert_mem_bar(Op_MemBarCPUOrder); |
3094 // Ensure that the store is atomic for longs: | 2831 // Ensure that the store is atomic for longs: |
3095 bool require_atomic_access = true; | 2832 const bool require_atomic_access = true; |
3096 Node* store; | 2833 Node* store; |
3097 if (type == T_OBJECT) // reference stores need a store barrier. | 2834 if (type == T_OBJECT) // reference stores need a store barrier. |
3098 store = store_oop_to_unknown(control(), base, adr, adr_type, val, type); | 2835 store = store_oop_to_unknown(control(), base, adr, adr_type, val, type); |
3099 else { | 2836 else { |
3100 store = store_to_memory(control(), adr, val, type, adr_type, require_atomic_access); | 2837 store = store_to_memory(control(), adr, val, type, adr_type, require_atomic_access); |
3101 } | 2838 } |
3102 insert_mem_bar(Op_MemBarCPUOrder); | 2839 insert_mem_bar(Op_MemBarCPUOrder); |
3103 return true; | 2840 return true; |
3104 } | 2841 } |
3105 | 2842 |
2843 //----------------------------inline_unsafe_allocate--------------------------- | |
2844 // public native Object sun.mics.Unsafe.allocateInstance(Class<?> cls); | |
3106 bool LibraryCallKit::inline_unsafe_allocate() { | 2845 bool LibraryCallKit::inline_unsafe_allocate() { |
3107 if (callee()->is_static()) return false; // caller must have the capability! | 2846 if (callee()->is_static()) return false; // caller must have the capability! |
3108 int nargs = 1 + 1; | 2847 |
3109 assert(signature()->size() == nargs-1, "alloc has 1 argument"); | 2848 null_check_receiver(); // null-check, then ignore |
3110 null_check_receiver(callee()); // check then ignore argument(0) | 2849 Node* cls = null_check(argument(1)); |
3111 _sp += nargs; // set original stack for use by uncommon_trap | |
3112 Node* cls = do_null_check(argument(1), T_OBJECT); | |
3113 _sp -= nargs; | |
3114 if (stopped()) return true; | 2850 if (stopped()) return true; |
3115 | 2851 |
3116 Node* kls = load_klass_from_mirror(cls, false, nargs, NULL, 0); | 2852 Node* kls = load_klass_from_mirror(cls, false, NULL, 0); |
3117 _sp += nargs; // set original stack for use by uncommon_trap | 2853 kls = null_check(kls); |
3118 kls = do_null_check(kls, T_OBJECT); | |
3119 _sp -= nargs; | |
3120 if (stopped()) return true; // argument was like int.class | 2854 if (stopped()) return true; // argument was like int.class |
3121 | 2855 |
3122 // Note: The argument might still be an illegal value like | 2856 // Note: The argument might still be an illegal value like |
3123 // Serializable.class or Object[].class. The runtime will handle it. | 2857 // Serializable.class or Object[].class. The runtime will handle it. |
3124 // But we must make an explicit check for initialization. | 2858 // But we must make an explicit check for initialization. |
3125 Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); | 2859 Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); |
3126 // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler | 2860 // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler |
3127 // can generate code to load it as unsigned byte. | 2861 // can generate code to load it as unsigned byte. |
3128 Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN); | 2862 Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN); |
3129 Node* bits = intcon(InstanceKlass::fully_initialized); | 2863 Node* bits = intcon(InstanceKlass::fully_initialized); |
3130 Node* test = _gvn.transform( new (C) SubINode(inst, bits) ); | 2864 Node* test = _gvn.transform(new (C) SubINode(inst, bits)); |
3131 // The 'test' is non-zero if we need to take a slow path. | 2865 // The 'test' is non-zero if we need to take a slow path. |
3132 | 2866 |
3133 Node* obj = new_instance(kls, test); | 2867 Node* obj = new_instance(kls, test); |
3134 push(obj); | 2868 set_result(obj); |
3135 | |
3136 return true; | 2869 return true; |
3137 } | 2870 } |
3138 | 2871 |
3139 #ifdef TRACE_HAVE_INTRINSICS | 2872 #ifdef TRACE_HAVE_INTRINSICS |
3140 /* | 2873 /* |
3141 * oop -> myklass | 2874 * oop -> myklass |
3142 * myklass->trace_id |= USED | 2875 * myklass->trace_id |= USED |
3143 * return myklass->trace_id & ~0x3 | 2876 * return myklass->trace_id & ~0x3 |
3144 */ | 2877 */ |
3145 bool LibraryCallKit::inline_native_classID() { | 2878 bool LibraryCallKit::inline_native_classID() { |
3146 int nargs = 1 + 1; | 2879 null_check_receiver(); // null-check, then ignore |
3147 null_check_receiver(callee()); // check then ignore argument(0) | 2880 Node* cls = null_check(argument(1), T_OBJECT); |
3148 _sp += nargs; | 2881 Node* kls = load_klass_from_mirror(cls, false, NULL, 0); |
3149 Node* cls = do_null_check(argument(1), T_OBJECT); | 2882 kls = null_check(kls, T_OBJECT); |
3150 _sp -= nargs; | |
3151 Node* kls = load_klass_from_mirror(cls, false, nargs, NULL, 0); | |
3152 _sp += nargs; | |
3153 kls = do_null_check(kls, T_OBJECT); | |
3154 _sp -= nargs; | |
3155 ByteSize offset = TRACE_ID_OFFSET; | 2883 ByteSize offset = TRACE_ID_OFFSET; |
3156 Node* insp = basic_plus_adr(kls, in_bytes(offset)); | 2884 Node* insp = basic_plus_adr(kls, in_bytes(offset)); |
3157 Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG); | 2885 Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG); |
3158 Node* bits = longcon(~0x03l); // ignore bit 0 & 1 | 2886 Node* bits = longcon(~0x03l); // ignore bit 0 & 1 |
3159 Node* andl = _gvn.transform(new (C) AndLNode(tvalue, bits)); | 2887 Node* andl = _gvn.transform(new (C) AndLNode(tvalue, bits)); |
3160 Node* clsused = longcon(0x01l); // set the class bit | 2888 Node* clsused = longcon(0x01l); // set the class bit |
3161 Node* orl = _gvn.transform(new (C) OrLNode(tvalue, clsused)); | 2889 Node* orl = _gvn.transform(new (C) OrLNode(tvalue, clsused)); |
3162 | 2890 |
3163 const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); | 2891 const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); |
3164 store_to_memory(control(), insp, orl, T_LONG, adr_type); | 2892 store_to_memory(control(), insp, orl, T_LONG, adr_type); |
3165 push_pair(andl); | 2893 set_result(andl); |
3166 return true; | 2894 return true; |
3167 } | 2895 } |
3168 | 2896 |
3169 bool LibraryCallKit::inline_native_threadID() { | 2897 bool LibraryCallKit::inline_native_threadID() { |
3170 Node* tls_ptr = NULL; | 2898 Node* tls_ptr = NULL; |
3175 | 2903 |
3176 Node* threadid = NULL; | 2904 Node* threadid = NULL; |
3177 size_t thread_id_size = OSThread::thread_id_size(); | 2905 size_t thread_id_size = OSThread::thread_id_size(); |
3178 if (thread_id_size == (size_t) BytesPerLong) { | 2906 if (thread_id_size == (size_t) BytesPerLong) { |
3179 threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG)); | 2907 threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG)); |
3180 push(threadid); | |
3181 } else if (thread_id_size == (size_t) BytesPerInt) { | 2908 } else if (thread_id_size == (size_t) BytesPerInt) { |
3182 threadid = make_load(control(), p, TypeInt::INT, T_INT); | 2909 threadid = make_load(control(), p, TypeInt::INT, T_INT); |
3183 push(threadid); | |
3184 } else { | 2910 } else { |
3185 ShouldNotReachHere(); | 2911 ShouldNotReachHere(); |
3186 } | 2912 } |
2913 set_result(threadid); | |
3187 return true; | 2914 return true; |
3188 } | 2915 } |
3189 #endif | 2916 #endif |
3190 | 2917 |
3191 //------------------------inline_native_time_funcs-------------- | 2918 //------------------------inline_native_time_funcs-------------- |
3192 // inline code for System.currentTimeMillis() and System.nanoTime() | 2919 // inline code for System.currentTimeMillis() and System.nanoTime() |
3193 // these have the same type and signature | 2920 // these have the same type and signature |
3194 bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* funcName) { | 2921 bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* funcName) { |
3195 const TypeFunc *tf = OptoRuntime::void_long_Type(); | 2922 const TypeFunc* tf = OptoRuntime::void_long_Type(); |
3196 const TypePtr* no_memory_effects = NULL; | 2923 const TypePtr* no_memory_effects = NULL; |
3197 Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects); | 2924 Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects); |
3198 Node* value = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms+0)); | 2925 Node* value = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms+0)); |
3199 #ifdef ASSERT | 2926 #ifdef ASSERT |
3200 Node* value_top = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms + 1)); | 2927 Node* value_top = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms+1)); |
3201 assert(value_top == top(), "second value must be top"); | 2928 assert(value_top == top(), "second value must be top"); |
3202 #endif | 2929 #endif |
3203 push_pair(value); | 2930 set_result(value); |
3204 return true; | 2931 return true; |
3205 } | 2932 } |
3206 | 2933 |
3207 //------------------------inline_native_currentThread------------------ | 2934 //------------------------inline_native_currentThread------------------ |
3208 bool LibraryCallKit::inline_native_currentThread() { | 2935 bool LibraryCallKit::inline_native_currentThread() { |
3209 Node* junk = NULL; | 2936 Node* junk = NULL; |
3210 push(generate_current_thread(junk)); | 2937 set_result(generate_current_thread(junk)); |
3211 return true; | 2938 return true; |
3212 } | 2939 } |
3213 | 2940 |
3214 //------------------------inline_native_isInterrupted------------------ | 2941 //------------------------inline_native_isInterrupted------------------ |
2942 // private native boolean java.lang.Thread.isInterrupted(boolean ClearInterrupted); | |
3215 bool LibraryCallKit::inline_native_isInterrupted() { | 2943 bool LibraryCallKit::inline_native_isInterrupted() { |
3216 const int nargs = 1+1; // receiver + boolean | |
3217 assert(nargs == arg_size(), "sanity"); | |
3218 // Add a fast path to t.isInterrupted(clear_int): | 2944 // Add a fast path to t.isInterrupted(clear_int): |
3219 // (t == Thread.current() && (!TLS._osthread._interrupted || !clear_int)) | 2945 // (t == Thread.current() && (!TLS._osthread._interrupted || !clear_int)) |
3220 // ? TLS._osthread._interrupted : /*slow path:*/ t.isInterrupted(clear_int) | 2946 // ? TLS._osthread._interrupted : /*slow path:*/ t.isInterrupted(clear_int) |
3221 // So, in the common case that the interrupt bit is false, | 2947 // So, in the common case that the interrupt bit is false, |
3222 // we avoid making a call into the VM. Even if the interrupt bit | 2948 // we avoid making a call into the VM. Even if the interrupt bit |
3310 | 3036 |
3311 set_all_memory( _gvn.transform(mem_phi) ); | 3037 set_all_memory( _gvn.transform(mem_phi) ); |
3312 set_i_o( _gvn.transform(io_phi) ); | 3038 set_i_o( _gvn.transform(io_phi) ); |
3313 } | 3039 } |
3314 | 3040 |
3315 push_result(result_rgn, result_val); | |
3316 C->set_has_split_ifs(true); // Has chance for split-if optimization | 3041 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3317 | 3042 set_result(result_rgn, result_val); |
3318 return true; | 3043 return true; |
3319 } | 3044 } |
3320 | 3045 |
3321 //---------------------------load_mirror_from_klass---------------------------- | 3046 //---------------------------load_mirror_from_klass---------------------------- |
3322 // Given a klass oop, load its java mirror (a java.lang.Class oop). | 3047 // Given a klass oop, load its java mirror (a java.lang.Class oop). |
3332 // If never_see_null, take an uncommon trap on null, so we can optimistically | 3057 // If never_see_null, take an uncommon trap on null, so we can optimistically |
3333 // compile for the non-null case. | 3058 // compile for the non-null case. |
3334 // If the region is NULL, force never_see_null = true. | 3059 // If the region is NULL, force never_see_null = true. |
3335 Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror, | 3060 Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror, |
3336 bool never_see_null, | 3061 bool never_see_null, |
3337 int nargs, | |
3338 RegionNode* region, | 3062 RegionNode* region, |
3339 int null_path, | 3063 int null_path, |
3340 int offset) { | 3064 int offset) { |
3341 if (region == NULL) never_see_null = true; | 3065 if (region == NULL) never_see_null = true; |
3342 Node* p = basic_plus_adr(mirror, offset); | 3066 Node* p = basic_plus_adr(mirror, offset); |
3343 const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL; | 3067 const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL; |
3344 Node* kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type) ); | 3068 Node* kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type) ); |
3345 _sp += nargs; // any deopt will start just before call to enclosing method | |
3346 Node* null_ctl = top(); | 3069 Node* null_ctl = top(); |
3347 kls = null_check_oop(kls, &null_ctl, never_see_null); | 3070 kls = null_check_oop(kls, &null_ctl, never_see_null); |
3348 if (region != NULL) { | 3071 if (region != NULL) { |
3349 // Set region->in(null_path) if the mirror is a primitive (e.g, int.class). | 3072 // Set region->in(null_path) if the mirror is a primitive (e.g, int.class). |
3350 region->init_req(null_path, null_ctl); | 3073 region->init_req(null_path, null_ctl); |
3351 } else { | 3074 } else { |
3352 assert(null_ctl == top(), "no loose ends"); | 3075 assert(null_ctl == top(), "no loose ends"); |
3353 } | 3076 } |
3354 _sp -= nargs; | |
3355 return kls; | 3077 return kls; |
3356 } | 3078 } |
3357 | 3079 |
3358 //--------------------(inline_native_Class_query helpers)--------------------- | 3080 //--------------------(inline_native_Class_query helpers)--------------------- |
3359 // Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER. | 3081 // Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER. |
3374 return generate_access_flags_guard(kls, JVM_ACC_INTERFACE, 0, region); | 3096 return generate_access_flags_guard(kls, JVM_ACC_INTERFACE, 0, region); |
3375 } | 3097 } |
3376 | 3098 |
3377 //-------------------------inline_native_Class_query------------------- | 3099 //-------------------------inline_native_Class_query------------------- |
3378 bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { | 3100 bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { |
3379 int nargs = 1+0; // just the Class mirror, in most cases | |
3380 const Type* return_type = TypeInt::BOOL; | 3101 const Type* return_type = TypeInt::BOOL; |
3381 Node* prim_return_value = top(); // what happens if it's a primitive class? | 3102 Node* prim_return_value = top(); // what happens if it's a primitive class? |
3382 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); | 3103 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
3383 bool expect_prim = false; // most of these guys expect to work on refs | 3104 bool expect_prim = false; // most of these guys expect to work on refs |
3384 | 3105 |
3385 enum { _normal_path = 1, _prim_path = 2, PATH_LIMIT }; | 3106 enum { _normal_path = 1, _prim_path = 2, PATH_LIMIT }; |
3386 | 3107 |
3108 Node* mirror = argument(0); | |
3109 Node* obj = top(); | |
3110 | |
3387 switch (id) { | 3111 switch (id) { |
3388 case vmIntrinsics::_isInstance: | 3112 case vmIntrinsics::_isInstance: |
3389 nargs = 1+1; // the Class mirror, plus the object getting queried about | |
3390 // nothing is an instance of a primitive type | 3113 // nothing is an instance of a primitive type |
3391 prim_return_value = intcon(0); | 3114 prim_return_value = intcon(0); |
3115 obj = argument(1); | |
3392 break; | 3116 break; |
3393 case vmIntrinsics::_getModifiers: | 3117 case vmIntrinsics::_getModifiers: |
3394 prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); | 3118 prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
3395 assert(is_power_of_2((int)JVM_ACC_WRITTEN_FLAGS+1), "change next line"); | 3119 assert(is_power_of_2((int)JVM_ACC_WRITTEN_FLAGS+1), "change next line"); |
3396 return_type = TypeInt::make(0, JVM_ACC_WRITTEN_FLAGS, Type::WidenMin); | 3120 return_type = TypeInt::make(0, JVM_ACC_WRITTEN_FLAGS, Type::WidenMin); |
3417 case vmIntrinsics::_getClassAccessFlags: | 3141 case vmIntrinsics::_getClassAccessFlags: |
3418 prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); | 3142 prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
3419 return_type = TypeInt::INT; // not bool! 6297094 | 3143 return_type = TypeInt::INT; // not bool! 6297094 |
3420 break; | 3144 break; |
3421 default: | 3145 default: |
3422 ShouldNotReachHere(); | 3146 fatal_unexpected_iid(id); |
3423 } | 3147 break; |
3424 | 3148 } |
3425 Node* mirror = argument(0); | |
3426 Node* obj = (nargs <= 1)? top(): argument(1); | |
3427 | 3149 |
3428 const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr(); | 3150 const TypeInstPtr* mirror_con = _gvn.type(mirror)->isa_instptr(); |
3429 if (mirror_con == NULL) return false; // cannot happen? | 3151 if (mirror_con == NULL) return false; // cannot happen? |
3430 | 3152 |
3431 #ifndef PRODUCT | 3153 #ifndef PRODUCT |
3449 // if it is. See bug 4774291. | 3171 // if it is. See bug 4774291. |
3450 | 3172 |
3451 // For Reflection.getClassAccessFlags(), the null check occurs in | 3173 // For Reflection.getClassAccessFlags(), the null check occurs in |
3452 // the wrong place; see inline_unsafe_access(), above, for a similar | 3174 // the wrong place; see inline_unsafe_access(), above, for a similar |
3453 // situation. | 3175 // situation. |
3454 _sp += nargs; // set original stack for use by uncommon_trap | 3176 mirror = null_check(mirror); |
3455 mirror = do_null_check(mirror, T_OBJECT); | |
3456 _sp -= nargs; | |
3457 // If mirror or obj is dead, only null-path is taken. | 3177 // If mirror or obj is dead, only null-path is taken. |
3458 if (stopped()) return true; | 3178 if (stopped()) return true; |
3459 | 3179 |
3460 if (expect_prim) never_see_null = false; // expect nulls (meaning prims) | 3180 if (expect_prim) never_see_null = false; // expect nulls (meaning prims) |
3461 | 3181 |
3462 // Now load the mirror's klass metaobject, and null-check it. | 3182 // Now load the mirror's klass metaobject, and null-check it. |
3463 // Side-effects region with the control path if the klass is null. | 3183 // Side-effects region with the control path if the klass is null. |
3464 Node* kls = load_klass_from_mirror(mirror, never_see_null, nargs, | 3184 Node* kls = load_klass_from_mirror(mirror, never_see_null, region, _prim_path); |
3465 region, _prim_path); | |
3466 // If kls is null, we have a primitive mirror. | 3185 // If kls is null, we have a primitive mirror. |
3467 phi->init_req(_prim_path, prim_return_value); | 3186 phi->init_req(_prim_path, prim_return_value); |
3468 if (stopped()) { push_result(region, phi); return true; } | 3187 if (stopped()) { set_result(region, phi); return true; } |
3469 | 3188 |
3470 Node* p; // handy temp | 3189 Node* p; // handy temp |
3471 Node* null_ctl; | 3190 Node* null_ctl; |
3472 | 3191 |
3473 // Now that we have the non-null klass, we can perform the real query. | 3192 // Now that we have the non-null klass, we can perform the real query. |
3474 // For constant classes, the query will constant-fold in LoadNode::Value. | 3193 // For constant classes, the query will constant-fold in LoadNode::Value. |
3475 Node* query_value = top(); | 3194 Node* query_value = top(); |
3476 switch (id) { | 3195 switch (id) { |
3477 case vmIntrinsics::_isInstance: | 3196 case vmIntrinsics::_isInstance: |
3478 // nothing is an instance of a primitive type | 3197 // nothing is an instance of a primitive type |
3479 _sp += nargs; // gen_instanceof might do an uncommon trap | |
3480 query_value = gen_instanceof(obj, kls); | 3198 query_value = gen_instanceof(obj, kls); |
3481 _sp -= nargs; | |
3482 break; | 3199 break; |
3483 | 3200 |
3484 case vmIntrinsics::_getModifiers: | 3201 case vmIntrinsics::_getModifiers: |
3485 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); | 3202 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
3486 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3203 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
3551 p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); | 3268 p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
3552 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3269 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
3553 break; | 3270 break; |
3554 | 3271 |
3555 default: | 3272 default: |
3556 ShouldNotReachHere(); | 3273 fatal_unexpected_iid(id); |
3274 break; | |
3557 } | 3275 } |
3558 | 3276 |
3559 // Fall-through is the normal case of a query to a real class. | 3277 // Fall-through is the normal case of a query to a real class. |
3560 phi->init_req(1, query_value); | 3278 phi->init_req(1, query_value); |
3561 region->init_req(1, control()); | 3279 region->init_req(1, control()); |
3562 | 3280 |
3563 push_result(region, phi); | |
3564 C->set_has_split_ifs(true); // Has chance for split-if optimization | 3281 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3565 | 3282 set_result(region, phi); |
3566 return true; | 3283 return true; |
3567 } | 3284 } |
3568 | 3285 |
3569 //--------------------------inline_native_subtype_check------------------------ | 3286 //--------------------------inline_native_subtype_check------------------------ |
3570 // This intrinsic takes the JNI calls out of the heart of | 3287 // This intrinsic takes the JNI calls out of the heart of |
3571 // UnsafeFieldAccessorImpl.set, which improves Field.set, readObject, etc. | 3288 // UnsafeFieldAccessorImpl.set, which improves Field.set, readObject, etc. |
3572 bool LibraryCallKit::inline_native_subtype_check() { | 3289 bool LibraryCallKit::inline_native_subtype_check() { |
3573 int nargs = 1+1; // the Class mirror, plus the other class getting examined | |
3574 | |
3575 // Pull both arguments off the stack. | 3290 // Pull both arguments off the stack. |
3576 Node* args[2]; // two java.lang.Class mirrors: superc, subc | 3291 Node* args[2]; // two java.lang.Class mirrors: superc, subc |
3577 args[0] = argument(0); | 3292 args[0] = argument(0); |
3578 args[1] = argument(1); | 3293 args[1] = argument(1); |
3579 Node* klasses[2]; // corresponding Klasses: superk, subk | 3294 Node* klasses[2]; // corresponding Klasses: superk, subk |
3600 | 3315 |
3601 // First null-check both mirrors and load each mirror's klass metaobject. | 3316 // First null-check both mirrors and load each mirror's klass metaobject. |
3602 int which_arg; | 3317 int which_arg; |
3603 for (which_arg = 0; which_arg <= 1; which_arg++) { | 3318 for (which_arg = 0; which_arg <= 1; which_arg++) { |
3604 Node* arg = args[which_arg]; | 3319 Node* arg = args[which_arg]; |
3605 _sp += nargs; // set original stack for use by uncommon_trap | 3320 arg = null_check(arg); |
3606 arg = do_null_check(arg, T_OBJECT); | |
3607 _sp -= nargs; | |
3608 if (stopped()) break; | 3321 if (stopped()) break; |
3609 args[which_arg] = _gvn.transform(arg); | 3322 args[which_arg] = _gvn.transform(arg); |
3610 | 3323 |
3611 Node* p = basic_plus_adr(arg, class_klass_offset); | 3324 Node* p = basic_plus_adr(arg, class_klass_offset); |
3612 Node* kls = LoadKlassNode::make(_gvn, immutable_memory(), p, adr_type, kls_type); | 3325 Node* kls = LoadKlassNode::make(_gvn, immutable_memory(), p, adr_type, kls_type); |
3616 // Having loaded both klasses, test each for null. | 3329 // Having loaded both klasses, test each for null. |
3617 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); | 3330 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
3618 for (which_arg = 0; which_arg <= 1; which_arg++) { | 3331 for (which_arg = 0; which_arg <= 1; which_arg++) { |
3619 Node* kls = klasses[which_arg]; | 3332 Node* kls = klasses[which_arg]; |
3620 Node* null_ctl = top(); | 3333 Node* null_ctl = top(); |
3621 _sp += nargs; // set original stack for use by uncommon_trap | |
3622 kls = null_check_oop(kls, &null_ctl, never_see_null); | 3334 kls = null_check_oop(kls, &null_ctl, never_see_null); |
3623 _sp -= nargs; | |
3624 int prim_path = (which_arg == 0 ? _prim_0_path : _prim_1_path); | 3335 int prim_path = (which_arg == 0 ? _prim_0_path : _prim_1_path); |
3625 region->init_req(prim_path, null_ctl); | 3336 region->init_req(prim_path, null_ctl); |
3626 if (stopped()) break; | 3337 if (stopped()) break; |
3627 klasses[which_arg] = kls; | 3338 klasses[which_arg] = kls; |
3628 } | 3339 } |
3668 phi->set_req(i, intcon(0)); // all other paths produce 'false' | 3379 phi->set_req(i, intcon(0)); // all other paths produce 'false' |
3669 } | 3380 } |
3670 } | 3381 } |
3671 | 3382 |
3672 set_control(_gvn.transform(region)); | 3383 set_control(_gvn.transform(region)); |
3673 push(_gvn.transform(phi)); | 3384 set_result(_gvn.transform(phi)); |
3674 | |
3675 return true; | 3385 return true; |
3676 } | 3386 } |
3677 | 3387 |
3678 //---------------------generate_array_guard_common------------------------ | 3388 //---------------------generate_array_guard_common------------------------ |
3679 Node* LibraryCallKit::generate_array_guard_common(Node* kls, RegionNode* region, | 3389 Node* LibraryCallKit::generate_array_guard_common(Node* kls, RegionNode* region, |
3717 return generate_fair_guard(bol, region); | 3427 return generate_fair_guard(bol, region); |
3718 } | 3428 } |
3719 | 3429 |
3720 | 3430 |
3721 //-----------------------inline_native_newArray-------------------------- | 3431 //-----------------------inline_native_newArray-------------------------- |
3432 // private static native Object java.lang.reflect.newArray(Class<?> componentType, int length); | |
3722 bool LibraryCallKit::inline_native_newArray() { | 3433 bool LibraryCallKit::inline_native_newArray() { |
3723 int nargs = 2; | |
3724 Node* mirror = argument(0); | 3434 Node* mirror = argument(0); |
3725 Node* count_val = argument(1); | 3435 Node* count_val = argument(1); |
3726 | 3436 |
3727 _sp += nargs; // set original stack for use by uncommon_trap | 3437 mirror = null_check(mirror); |
3728 mirror = do_null_check(mirror, T_OBJECT); | |
3729 _sp -= nargs; | |
3730 // If mirror or obj is dead, only null-path is taken. | 3438 // If mirror or obj is dead, only null-path is taken. |
3731 if (stopped()) return true; | 3439 if (stopped()) return true; |
3732 | 3440 |
3733 enum { _normal_path = 1, _slow_path = 2, PATH_LIMIT }; | 3441 enum { _normal_path = 1, _slow_path = 2, PATH_LIMIT }; |
3734 RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); | 3442 RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); |
3738 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, | 3446 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, |
3739 TypePtr::BOTTOM); | 3447 TypePtr::BOTTOM); |
3740 | 3448 |
3741 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); | 3449 bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); |
3742 Node* klass_node = load_array_klass_from_mirror(mirror, never_see_null, | 3450 Node* klass_node = load_array_klass_from_mirror(mirror, never_see_null, |
3743 nargs, | |
3744 result_reg, _slow_path); | 3451 result_reg, _slow_path); |
3745 Node* normal_ctl = control(); | 3452 Node* normal_ctl = control(); |
3746 Node* no_array_ctl = result_reg->in(_slow_path); | 3453 Node* no_array_ctl = result_reg->in(_slow_path); |
3747 | 3454 |
3748 // Generate code for the slow case. We make a call to newArray(). | 3455 // Generate code for the slow case. We make a call to newArray(). |
3765 set_control(normal_ctl); | 3472 set_control(normal_ctl); |
3766 if (!stopped()) { | 3473 if (!stopped()) { |
3767 // Normal case: The array type has been cached in the java.lang.Class. | 3474 // Normal case: The array type has been cached in the java.lang.Class. |
3768 // The following call works fine even if the array type is polymorphic. | 3475 // The following call works fine even if the array type is polymorphic. |
3769 // It could be a dynamic mix of int[], boolean[], Object[], etc. | 3476 // It could be a dynamic mix of int[], boolean[], Object[], etc. |
3770 Node* obj = new_array(klass_node, count_val, nargs); | 3477 Node* obj = new_array(klass_node, count_val, 0); // no arguments to push |
3771 result_reg->init_req(_normal_path, control()); | 3478 result_reg->init_req(_normal_path, control()); |
3772 result_val->init_req(_normal_path, obj); | 3479 result_val->init_req(_normal_path, obj); |
3773 result_io ->init_req(_normal_path, i_o()); | 3480 result_io ->init_req(_normal_path, i_o()); |
3774 result_mem->init_req(_normal_path, reset_memory()); | 3481 result_mem->init_req(_normal_path, reset_memory()); |
3775 } | 3482 } |
3776 | 3483 |
3777 // Return the combined state. | 3484 // Return the combined state. |
3778 set_i_o( _gvn.transform(result_io) ); | 3485 set_i_o( _gvn.transform(result_io) ); |
3779 set_all_memory( _gvn.transform(result_mem) ); | 3486 set_all_memory( _gvn.transform(result_mem) ); |
3780 push_result(result_reg, result_val); | 3487 |
3781 C->set_has_split_ifs(true); // Has chance for split-if optimization | 3488 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3782 | 3489 set_result(result_reg, result_val); |
3783 return true; | 3490 return true; |
3784 } | 3491 } |
3785 | 3492 |
3786 //----------------------inline_native_getLength-------------------------- | 3493 //----------------------inline_native_getLength-------------------------- |
3494 // public static native int java.lang.reflect.Array.getLength(Object array); | |
3787 bool LibraryCallKit::inline_native_getLength() { | 3495 bool LibraryCallKit::inline_native_getLength() { |
3788 if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; | 3496 if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; |
3789 | 3497 |
3790 int nargs = 1; | 3498 Node* array = null_check(argument(0)); |
3791 Node* array = argument(0); | |
3792 | |
3793 _sp += nargs; // set original stack for use by uncommon_trap | |
3794 array = do_null_check(array, T_OBJECT); | |
3795 _sp -= nargs; | |
3796 | |
3797 // If array is dead, only null-path is taken. | 3499 // If array is dead, only null-path is taken. |
3798 if (stopped()) return true; | 3500 if (stopped()) return true; |
3799 | 3501 |
3800 // Deoptimize if it is a non-array. | 3502 // Deoptimize if it is a non-array. |
3801 Node* non_array = generate_non_array_guard(load_object_klass(array), NULL); | 3503 Node* non_array = generate_non_array_guard(load_object_klass(array), NULL); |
3802 | 3504 |
3803 if (non_array != NULL) { | 3505 if (non_array != NULL) { |
3804 PreserveJVMState pjvms(this); | 3506 PreserveJVMState pjvms(this); |
3805 set_control(non_array); | 3507 set_control(non_array); |
3806 _sp += nargs; // push the arguments back on the stack | |
3807 uncommon_trap(Deoptimization::Reason_intrinsic, | 3508 uncommon_trap(Deoptimization::Reason_intrinsic, |
3808 Deoptimization::Action_maybe_recompile); | 3509 Deoptimization::Action_maybe_recompile); |
3809 } | 3510 } |
3810 | 3511 |
3811 // If control is dead, only non-array-path is taken. | 3512 // If control is dead, only non-array-path is taken. |
3812 if (stopped()) return true; | 3513 if (stopped()) return true; |
3813 | 3514 |
3814 // The works fine even if the array type is polymorphic. | 3515 // The works fine even if the array type is polymorphic. |
3815 // It could be a dynamic mix of int[], boolean[], Object[], etc. | 3516 // It could be a dynamic mix of int[], boolean[], Object[], etc. |
3816 push( load_array_length(array) ); | 3517 Node* result = load_array_length(array); |
3817 | 3518 |
3818 C->set_has_split_ifs(true); // Has chance for split-if optimization | 3519 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3819 | 3520 set_result(result); |
3820 return true; | 3521 return true; |
3821 } | 3522 } |
3822 | 3523 |
3823 //------------------------inline_array_copyOf---------------------------- | 3524 //------------------------inline_array_copyOf---------------------------- |
3525 // public static <T,U> T[] java.util.Arrays.copyOf( U[] original, int newLength, Class<? extends T[]> newType); | |
3526 // public static <T,U> T[] java.util.Arrays.copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType); | |
3824 bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { | 3527 bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { |
3528 return false; | |
3825 if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; | 3529 if (too_many_traps(Deoptimization::Reason_intrinsic)) return false; |
3826 | 3530 |
3827 // Restore the stack and pop off the arguments. | 3531 // Get the arguments. |
3828 int nargs = 3 + (is_copyOfRange? 1: 0); | |
3829 Node* original = argument(0); | 3532 Node* original = argument(0); |
3830 Node* start = is_copyOfRange? argument(1): intcon(0); | 3533 Node* start = is_copyOfRange? argument(1): intcon(0); |
3831 Node* end = is_copyOfRange? argument(2): argument(1); | 3534 Node* end = is_copyOfRange? argument(2): argument(1); |
3832 Node* array_type_mirror = is_copyOfRange? argument(3): argument(2); | 3535 Node* array_type_mirror = is_copyOfRange? argument(3): argument(2); |
3833 | 3536 |
3834 Node* newcopy; | 3537 Node* newcopy; |
3835 | 3538 |
3836 //set the original stack and the reexecute bit for the interpreter to reexecute | 3539 // Set the original stack and the reexecute bit for the interpreter to reexecute |
3837 //the bytecode that invokes Arrays.copyOf if deoptimization happens | 3540 // the bytecode that invokes Arrays.copyOf if deoptimization happens. |
3838 { PreserveReexecuteState preexecs(this); | 3541 { PreserveReexecuteState preexecs(this); |
3839 _sp += nargs; | |
3840 jvms()->set_should_reexecute(true); | 3542 jvms()->set_should_reexecute(true); |
3841 | 3543 |
3842 array_type_mirror = do_null_check(array_type_mirror, T_OBJECT); | 3544 array_type_mirror = null_check(array_type_mirror); |
3843 original = do_null_check(original, T_OBJECT); | 3545 original = null_check(original); |
3844 | 3546 |
3845 // Check if a null path was taken unconditionally. | 3547 // Check if a null path was taken unconditionally. |
3846 if (stopped()) return true; | 3548 if (stopped()) return true; |
3847 | 3549 |
3848 Node* orig_length = load_array_length(original); | 3550 Node* orig_length = load_array_length(original); |
3849 | 3551 |
3850 Node* klass_node = load_klass_from_mirror(array_type_mirror, false, 0, | 3552 Node* klass_node = load_klass_from_mirror(array_type_mirror, false, NULL, 0); |
3851 NULL, 0); | 3553 klass_node = null_check(klass_node); |
3852 klass_node = do_null_check(klass_node, T_OBJECT); | |
3853 | 3554 |
3854 RegionNode* bailout = new (C) RegionNode(1); | 3555 RegionNode* bailout = new (C) RegionNode(1); |
3855 record_for_igvn(bailout); | 3556 record_for_igvn(bailout); |
3856 | 3557 |
3857 // Despite the generic type of Arrays.copyOf, the mirror might be int, int[], etc. | 3558 // Despite the generic type of Arrays.copyOf, the mirror might be int, int[], etc. |
3870 generate_negative_guard(start, bailout, &start); | 3571 generate_negative_guard(start, bailout, &start); |
3871 generate_negative_guard(end, bailout, &end); | 3572 generate_negative_guard(end, bailout, &end); |
3872 | 3573 |
3873 Node* length = end; | 3574 Node* length = end; |
3874 if (_gvn.type(start) != TypeInt::ZERO) { | 3575 if (_gvn.type(start) != TypeInt::ZERO) { |
3875 length = _gvn.transform( new (C) SubINode(end, start) ); | 3576 length = _gvn.transform(new (C) SubINode(end, start)); |
3876 } | 3577 } |
3877 | 3578 |
3878 // Bail out if length is negative. | 3579 // Bail out if length is negative. |
3879 // Without this the new_array would throw | 3580 // Without this the new_array would throw |
3880 // NegativeArraySizeException but IllegalArgumentException is what | 3581 // NegativeArraySizeException but IllegalArgumentException is what |
3881 // should be thrown | 3582 // should be thrown |
3882 generate_negative_guard(length, bailout, &length); | 3583 generate_negative_guard(length, bailout, &length); |
3883 | 3584 |
3884 if (bailout->req() > 1) { | 3585 if (bailout->req() > 1) { |
3885 PreserveJVMState pjvms(this); | 3586 PreserveJVMState pjvms(this); |
3886 set_control( _gvn.transform(bailout) ); | 3587 set_control(_gvn.transform(bailout)); |
3887 uncommon_trap(Deoptimization::Reason_intrinsic, | 3588 uncommon_trap(Deoptimization::Reason_intrinsic, |
3888 Deoptimization::Action_maybe_recompile); | 3589 Deoptimization::Action_maybe_recompile); |
3889 } | 3590 } |
3890 | 3591 |
3891 if (!stopped()) { | 3592 if (!stopped()) { |
3892 | |
3893 // How many elements will we copy from the original? | 3593 // How many elements will we copy from the original? |
3894 // The answer is MinI(orig_length - start, length). | 3594 // The answer is MinI(orig_length - start, length). |
3895 Node* orig_tail = _gvn.transform( new(C) SubINode(orig_length, start) ); | 3595 Node* orig_tail = _gvn.transform(new (C) SubINode(orig_length, start)); |
3896 Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length); | 3596 Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length); |
3897 | 3597 |
3898 newcopy = new_array(klass_node, length, 0); | 3598 newcopy = new_array(klass_node, length, 0); // no argments to push |
3899 | 3599 |
3900 // Generate a direct call to the right arraycopy function(s). | 3600 // Generate a direct call to the right arraycopy function(s). |
3901 // We know the copy is disjoint but we might not know if the | 3601 // We know the copy is disjoint but we might not know if the |
3902 // oop stores need checking. | 3602 // oop stores need checking. |
3903 // Extreme case: Arrays.copyOf((Integer[])x, 10, String[].class). | 3603 // Extreme case: Arrays.copyOf((Integer[])x, 10, String[].class). |
3908 bool length_never_negative = !is_copyOfRange; | 3608 bool length_never_negative = !is_copyOfRange; |
3909 generate_arraycopy(TypeAryPtr::OOPS, T_OBJECT, | 3609 generate_arraycopy(TypeAryPtr::OOPS, T_OBJECT, |
3910 original, start, newcopy, intcon(0), moved, | 3610 original, start, newcopy, intcon(0), moved, |
3911 disjoint_bases, length_never_negative); | 3611 disjoint_bases, length_never_negative); |
3912 } | 3612 } |
3913 } //original reexecute and sp are set back here | 3613 } // original reexecute is set back here |
3914 | |
3915 if(!stopped()) { | |
3916 push(newcopy); | |
3917 } | |
3918 | 3614 |
3919 C->set_has_split_ifs(true); // Has chance for split-if optimization | 3615 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3920 | 3616 if (!stopped()) { |
3617 set_result(newcopy); | |
3618 } | |
3921 return true; | 3619 return true; |
3922 } | 3620 } |
3923 | 3621 |
3924 | 3622 |
3925 //----------------------generate_virtual_guard--------------------------- | 3623 //----------------------generate_virtual_guard--------------------------- |
3967 assert(!is_virtual, ""); | 3665 assert(!is_virtual, ""); |
3968 slow_call = new(C) CallStaticJavaNode(tf, | 3666 slow_call = new(C) CallStaticJavaNode(tf, |
3969 SharedRuntime::get_resolve_static_call_stub(), | 3667 SharedRuntime::get_resolve_static_call_stub(), |
3970 method, bci()); | 3668 method, bci()); |
3971 } else if (is_virtual) { | 3669 } else if (is_virtual) { |
3972 null_check_receiver(method); | 3670 null_check_receiver(); |
3973 int vtable_index = Method::invalid_vtable_index; | 3671 int vtable_index = Method::invalid_vtable_index; |
3974 if (UseInlineCaches) { | 3672 if (UseInlineCaches) { |
3975 // Suppress the vtable call | 3673 // Suppress the vtable call |
3976 } else { | 3674 } else { |
3977 // hashCode and clone are not a miranda methods, | 3675 // hashCode and clone are not a miranda methods, |
3981 } | 3679 } |
3982 slow_call = new(C) CallDynamicJavaNode(tf, | 3680 slow_call = new(C) CallDynamicJavaNode(tf, |
3983 SharedRuntime::get_resolve_virtual_call_stub(), | 3681 SharedRuntime::get_resolve_virtual_call_stub(), |
3984 method, vtable_index, bci()); | 3682 method, vtable_index, bci()); |
3985 } else { // neither virtual nor static: opt_virtual | 3683 } else { // neither virtual nor static: opt_virtual |
3986 null_check_receiver(method); | 3684 null_check_receiver(); |
3987 slow_call = new(C) CallStaticJavaNode(tf, | 3685 slow_call = new(C) CallStaticJavaNode(tf, |
3988 SharedRuntime::get_resolve_opt_virtual_call_stub(), | 3686 SharedRuntime::get_resolve_opt_virtual_call_stub(), |
3989 method, bci()); | 3687 method, bci()); |
3990 slow_call->set_optimized_virtual(true); | 3688 slow_call->set_optimized_virtual(true); |
3991 } | 3689 } |
4010 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, | 3708 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, |
4011 TypePtr::BOTTOM); | 3709 TypePtr::BOTTOM); |
4012 Node* obj = NULL; | 3710 Node* obj = NULL; |
4013 if (!is_static) { | 3711 if (!is_static) { |
4014 // Check for hashing null object | 3712 // Check for hashing null object |
4015 obj = null_check_receiver(callee()); | 3713 obj = null_check_receiver(); |
4016 if (stopped()) return true; // unconditionally null | 3714 if (stopped()) return true; // unconditionally null |
4017 result_reg->init_req(_null_path, top()); | 3715 result_reg->init_req(_null_path, top()); |
4018 result_val->init_req(_null_path, top()); | 3716 result_val->init_req(_null_path, top()); |
4019 } else { | 3717 } else { |
4020 // Do a null check, and return zero if null. | 3718 // Do a null check, and return zero if null. |
4026 result_val->init_req(_null_path, _gvn.intcon(0)); | 3724 result_val->init_req(_null_path, _gvn.intcon(0)); |
4027 } | 3725 } |
4028 | 3726 |
4029 // Unconditionally null? Then return right away. | 3727 // Unconditionally null? Then return right away. |
4030 if (stopped()) { | 3728 if (stopped()) { |
4031 set_control( result_reg->in(_null_path) ); | 3729 set_control( result_reg->in(_null_path)); |
4032 if (!stopped()) | 3730 if (!stopped()) |
4033 push( result_val ->in(_null_path) ); | 3731 set_result(result_val->in(_null_path)); |
4034 return true; | 3732 return true; |
4035 } | 3733 } |
4036 | 3734 |
4037 // After null check, get the object's klass. | 3735 // After null check, get the object's klass. |
4038 Node* obj_klass = load_object_klass(obj); | 3736 Node* obj_klass = load_object_klass(obj); |
4101 // Generate code for the slow case. We make a call to hashCode(). | 3799 // Generate code for the slow case. We make a call to hashCode(). |
4102 set_control(_gvn.transform(slow_region)); | 3800 set_control(_gvn.transform(slow_region)); |
4103 if (!stopped()) { | 3801 if (!stopped()) { |
4104 // No need for PreserveJVMState, because we're using up the present state. | 3802 // No need for PreserveJVMState, because we're using up the present state. |
4105 set_all_memory(init_mem); | 3803 set_all_memory(init_mem); |
4106 vmIntrinsics::ID hashCode_id = vmIntrinsics::_hashCode; | 3804 vmIntrinsics::ID hashCode_id = is_static ? vmIntrinsics::_identityHashCode : vmIntrinsics::_hashCode; |
4107 if (is_static) hashCode_id = vmIntrinsics::_identityHashCode; | |
4108 CallJavaNode* slow_call = generate_method_call(hashCode_id, is_virtual, is_static); | 3805 CallJavaNode* slow_call = generate_method_call(hashCode_id, is_virtual, is_static); |
4109 Node* slow_result = set_results_for_java_call(slow_call); | 3806 Node* slow_result = set_results_for_java_call(slow_call); |
4110 // this->control() comes from set_results_for_java_call | 3807 // this->control() comes from set_results_for_java_call |
4111 result_reg->init_req(_slow_path, control()); | 3808 result_reg->init_req(_slow_path, control()); |
4112 result_val->init_req(_slow_path, slow_result); | 3809 result_val->init_req(_slow_path, slow_result); |
4115 } | 3812 } |
4116 | 3813 |
4117 // Return the combined state. | 3814 // Return the combined state. |
4118 set_i_o( _gvn.transform(result_io) ); | 3815 set_i_o( _gvn.transform(result_io) ); |
4119 set_all_memory( _gvn.transform(result_mem) ); | 3816 set_all_memory( _gvn.transform(result_mem) ); |
4120 push_result(result_reg, result_val); | 3817 |
4121 | 3818 set_result(result_reg, result_val); |
4122 return true; | 3819 return true; |
4123 } | 3820 } |
4124 | 3821 |
4125 //---------------------------inline_native_getClass---------------------------- | 3822 //---------------------------inline_native_getClass---------------------------- |
3823 // public final native Class<?> java.lang.Object.getClass(); | |
3824 // | |
4126 // Build special case code for calls to getClass on an object. | 3825 // Build special case code for calls to getClass on an object. |
4127 bool LibraryCallKit::inline_native_getClass() { | 3826 bool LibraryCallKit::inline_native_getClass() { |
4128 Node* obj = null_check_receiver(callee()); | 3827 Node* obj = null_check_receiver(); |
4129 if (stopped()) return true; | 3828 if (stopped()) return true; |
4130 push( load_mirror_from_klass(load_object_klass(obj)) ); | 3829 set_result(load_mirror_from_klass(load_object_klass(obj))); |
4131 return true; | 3830 return true; |
4132 } | 3831 } |
4133 | 3832 |
4134 //-----------------inline_native_Reflection_getCallerClass--------------------- | 3833 //-----------------inline_native_Reflection_getCallerClass--------------------- |
3834 // public static native Class<?> sun.reflect.Reflection.getCallerClass(int realFramesToSkip); | |
3835 // | |
4135 // In the presence of deep enough inlining, getCallerClass() becomes a no-op. | 3836 // In the presence of deep enough inlining, getCallerClass() becomes a no-op. |
4136 // | 3837 // |
4137 // NOTE that this code must perform the same logic as | 3838 // NOTE that this code must perform the same logic as |
4138 // vframeStream::security_get_caller_frame in that it must skip | 3839 // vframeStream::security_get_caller_frame in that it must skip |
4139 // Method.invoke() and auxiliary frames. | 3840 // Method.invoke() and auxiliary frames. |
4140 | |
4141 | |
4142 | |
4143 | |
4144 bool LibraryCallKit::inline_native_Reflection_getCallerClass() { | 3841 bool LibraryCallKit::inline_native_Reflection_getCallerClass() { |
4145 ciMethod* method = callee(); | |
4146 | |
4147 #ifndef PRODUCT | 3842 #ifndef PRODUCT |
4148 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { | 3843 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { |
4149 tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass"); | 3844 tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass"); |
4150 } | 3845 } |
4151 #endif | 3846 #endif |
4152 | 3847 |
4153 debug_only(int saved_sp = _sp); | 3848 Node* caller_depth_node = argument(0); |
4154 | |
4155 // Argument words: (int depth) | |
4156 int nargs = 1; | |
4157 | |
4158 _sp += nargs; | |
4159 Node* caller_depth_node = pop(); | |
4160 | |
4161 assert(saved_sp == _sp, "must have correct argument count"); | |
4162 | 3849 |
4163 // The depth value must be a constant in order for the runtime call | 3850 // The depth value must be a constant in order for the runtime call |
4164 // to be eliminated. | 3851 // to be eliminated. |
4165 const TypeInt* caller_depth_type = _gvn.type(caller_depth_node)->isa_int(); | 3852 const TypeInt* caller_depth_type = _gvn.type(caller_depth_node)->isa_int(); |
4166 if (caller_depth_type == NULL || !caller_depth_type->is_con()) { | 3853 if (caller_depth_type == NULL || !caller_depth_type->is_con()) { |
4228 #ifndef PRODUCT | 3915 #ifndef PRODUCT |
4229 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { | 3916 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { |
4230 tty->print_cr(" Bailing out because caller depth (%d) exceeded inlining depth (%d)", caller_depth_type->get_con(), _depth); | 3917 tty->print_cr(" Bailing out because caller depth (%d) exceeded inlining depth (%d)", caller_depth_type->get_con(), _depth); |
4231 tty->print_cr(" JVM state at this point:"); | 3918 tty->print_cr(" JVM state at this point:"); |
4232 for (int i = _depth; i >= 1; i--) { | 3919 for (int i = _depth; i >= 1; i--) { |
4233 tty->print_cr(" %d) %s", i, jvms()->of_depth(i)->method()->name()->as_utf8()); | 3920 ciMethod* m = jvms()->of_depth(i)->method(); |
3921 tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); | |
4234 } | 3922 } |
4235 } | 3923 } |
4236 #endif | 3924 #endif |
4237 return false; // Reached end of inlining | 3925 return false; // Reached end of inlining |
4238 } | 3926 } |
4239 | 3927 |
4240 // Acquire method holder as java.lang.Class | 3928 // Acquire method holder as java.lang.Class |
4241 ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); | 3929 ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); |
4242 ciInstance* caller_mirror = caller_klass->java_mirror(); | 3930 ciInstance* caller_mirror = caller_klass->java_mirror(); |
3931 | |
4243 // Push this as a constant | 3932 // Push this as a constant |
4244 push(makecon(TypeInstPtr::make(caller_mirror))); | 3933 set_result(makecon(TypeInstPtr::make(caller_mirror))); |
3934 | |
4245 #ifndef PRODUCT | 3935 #ifndef PRODUCT |
4246 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { | 3936 if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { |
4247 tty->print_cr(" Succeeded: caller = %s.%s, caller depth = %d, depth = %d", caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), caller_depth_type->get_con(), _depth); | 3937 tty->print_cr(" Succeeded: caller = %s.%s, caller depth = %d, depth = %d", caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), caller_depth_type->get_con(), _depth); |
4248 tty->print_cr(" JVM state at this point:"); | 3938 tty->print_cr(" JVM state at this point:"); |
4249 for (int i = _depth; i >= 1; i--) { | 3939 for (int i = _depth; i >= 1; i--) { |
4250 tty->print_cr(" %d) %s", i, jvms()->of_depth(i)->method()->name()->as_utf8()); | 3940 ciMethod* m = jvms()->of_depth(i)->method(); |
3941 tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); | |
4251 } | 3942 } |
4252 } | 3943 } |
4253 #endif | 3944 #endif |
4254 return true; | 3945 return true; |
4255 } | 3946 } |
4281 | 3972 |
4282 return false; | 3973 return false; |
4283 } | 3974 } |
4284 | 3975 |
4285 bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { | 3976 bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { |
4286 // restore the arguments | 3977 Node* arg = argument(0); |
4287 _sp += arg_size(); | 3978 Node* result; |
4288 | 3979 |
4289 switch (id) { | 3980 switch (id) { |
4290 case vmIntrinsics::_floatToRawIntBits: | 3981 case vmIntrinsics::_floatToRawIntBits: result = new (C) MoveF2INode(arg); break; |
4291 push(_gvn.transform( new (C) MoveF2INode(pop()))); | 3982 case vmIntrinsics::_intBitsToFloat: result = new (C) MoveI2FNode(arg); break; |
4292 break; | 3983 case vmIntrinsics::_doubleToRawLongBits: result = new (C) MoveD2LNode(arg); break; |
4293 | 3984 case vmIntrinsics::_longBitsToDouble: result = new (C) MoveL2DNode(arg); break; |
4294 case vmIntrinsics::_intBitsToFloat: | |
4295 push(_gvn.transform( new (C) MoveI2FNode(pop()))); | |
4296 break; | |
4297 | |
4298 case vmIntrinsics::_doubleToRawLongBits: | |
4299 push_pair(_gvn.transform( new (C) MoveD2LNode(pop_pair()))); | |
4300 break; | |
4301 | |
4302 case vmIntrinsics::_longBitsToDouble: | |
4303 push_pair(_gvn.transform( new (C) MoveL2DNode(pop_pair()))); | |
4304 break; | |
4305 | 3985 |
4306 case vmIntrinsics::_doubleToLongBits: { | 3986 case vmIntrinsics::_doubleToLongBits: { |
4307 Node* value = pop_pair(); | |
4308 | |
4309 // two paths (plus control) merge in a wood | 3987 // two paths (plus control) merge in a wood |
4310 RegionNode *r = new (C) RegionNode(3); | 3988 RegionNode *r = new (C) RegionNode(3); |
4311 Node *phi = new (C) PhiNode(r, TypeLong::LONG); | 3989 Node *phi = new (C) PhiNode(r, TypeLong::LONG); |
4312 | 3990 |
4313 Node *cmpisnan = _gvn.transform( new (C) CmpDNode(value, value)); | 3991 Node *cmpisnan = _gvn.transform(new (C) CmpDNode(arg, arg)); |
4314 // Build the boolean node | 3992 // Build the boolean node |
4315 Node *bolisnan = _gvn.transform( new (C) BoolNode( cmpisnan, BoolTest::ne ) ); | 3993 Node *bolisnan = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::ne)); |
4316 | 3994 |
4317 // Branch either way. | 3995 // Branch either way. |
4318 // NaN case is less traveled, which makes all the difference. | 3996 // NaN case is less traveled, which makes all the difference. |
4319 IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); | 3997 IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
4320 Node *opt_isnan = _gvn.transform(ifisnan); | 3998 Node *opt_isnan = _gvn.transform(ifisnan); |
4328 Node *slow_result = longcon(nan_bits); // return NaN | 4006 Node *slow_result = longcon(nan_bits); // return NaN |
4329 phi->init_req(1, _gvn.transform( slow_result )); | 4007 phi->init_req(1, _gvn.transform( slow_result )); |
4330 r->init_req(1, iftrue); | 4008 r->init_req(1, iftrue); |
4331 | 4009 |
4332 // Else fall through | 4010 // Else fall through |
4333 Node *iffalse = _gvn.transform( new (C) IfFalseNode(opt_ifisnan) ); | 4011 Node *iffalse = _gvn.transform(new (C) IfFalseNode(opt_ifisnan)); |
4334 set_control(iffalse); | 4012 set_control(iffalse); |
4335 | 4013 |
4336 phi->init_req(2, _gvn.transform( new (C) MoveD2LNode(value))); | 4014 phi->init_req(2, _gvn.transform(new (C) MoveD2LNode(arg))); |
4337 r->init_req(2, iffalse); | 4015 r->init_req(2, iffalse); |
4338 | 4016 |
4339 // Post merge | 4017 // Post merge |
4340 set_control(_gvn.transform(r)); | 4018 set_control(_gvn.transform(r)); |
4341 record_for_igvn(r); | 4019 record_for_igvn(r); |
4342 | 4020 |
4343 Node* result = _gvn.transform(phi); | 4021 C->set_has_split_ifs(true); // Has chance for split-if optimization |
4022 result = phi; | |
4344 assert(result->bottom_type()->isa_long(), "must be"); | 4023 assert(result->bottom_type()->isa_long(), "must be"); |
4345 push_pair(result); | |
4346 | |
4347 C->set_has_split_ifs(true); // Has chance for split-if optimization | |
4348 | |
4349 break; | 4024 break; |
4350 } | 4025 } |
4351 | 4026 |
4352 case vmIntrinsics::_floatToIntBits: { | 4027 case vmIntrinsics::_floatToIntBits: { |
4353 Node* value = pop(); | |
4354 | |
4355 // two paths (plus control) merge in a wood | 4028 // two paths (plus control) merge in a wood |
4356 RegionNode *r = new (C) RegionNode(3); | 4029 RegionNode *r = new (C) RegionNode(3); |
4357 Node *phi = new (C) PhiNode(r, TypeInt::INT); | 4030 Node *phi = new (C) PhiNode(r, TypeInt::INT); |
4358 | 4031 |
4359 Node *cmpisnan = _gvn.transform( new (C) CmpFNode(value, value)); | 4032 Node *cmpisnan = _gvn.transform(new (C) CmpFNode(arg, arg)); |
4360 // Build the boolean node | 4033 // Build the boolean node |
4361 Node *bolisnan = _gvn.transform( new (C) BoolNode( cmpisnan, BoolTest::ne ) ); | 4034 Node *bolisnan = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::ne)); |
4362 | 4035 |
4363 // Branch either way. | 4036 // Branch either way. |
4364 // NaN case is less traveled, which makes all the difference. | 4037 // NaN case is less traveled, which makes all the difference. |
4365 IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); | 4038 IfNode *ifisnan = create_and_xform_if(control(), bolisnan, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
4366 Node *opt_isnan = _gvn.transform(ifisnan); | 4039 Node *opt_isnan = _gvn.transform(ifisnan); |
4374 Node *slow_result = makecon(TypeInt::make(nan_bits)); // return NaN | 4047 Node *slow_result = makecon(TypeInt::make(nan_bits)); // return NaN |
4375 phi->init_req(1, _gvn.transform( slow_result )); | 4048 phi->init_req(1, _gvn.transform( slow_result )); |
4376 r->init_req(1, iftrue); | 4049 r->init_req(1, iftrue); |
4377 | 4050 |
4378 // Else fall through | 4051 // Else fall through |
4379 Node *iffalse = _gvn.transform( new (C) IfFalseNode(opt_ifisnan) ); | 4052 Node *iffalse = _gvn.transform(new (C) IfFalseNode(opt_ifisnan)); |
4380 set_control(iffalse); | 4053 set_control(iffalse); |
4381 | 4054 |
4382 phi->init_req(2, _gvn.transform( new (C) MoveF2INode(value))); | 4055 phi->init_req(2, _gvn.transform(new (C) MoveF2INode(arg))); |
4383 r->init_req(2, iffalse); | 4056 r->init_req(2, iffalse); |
4384 | 4057 |
4385 // Post merge | 4058 // Post merge |
4386 set_control(_gvn.transform(r)); | 4059 set_control(_gvn.transform(r)); |
4387 record_for_igvn(r); | 4060 record_for_igvn(r); |
4388 | 4061 |
4389 Node* result = _gvn.transform(phi); | 4062 C->set_has_split_ifs(true); // Has chance for split-if optimization |
4063 result = phi; | |
4390 assert(result->bottom_type()->isa_int(), "must be"); | 4064 assert(result->bottom_type()->isa_int(), "must be"); |
4391 push(result); | |
4392 | |
4393 C->set_has_split_ifs(true); // Has chance for split-if optimization | |
4394 | |
4395 break; | 4065 break; |
4396 } | 4066 } |
4397 | 4067 |
4398 default: | 4068 default: |
4399 ShouldNotReachHere(); | 4069 fatal_unexpected_iid(id); |
4400 } | 4070 break; |
4401 | 4071 } |
4072 set_result(_gvn.transform(result)); | |
4402 return true; | 4073 return true; |
4403 } | 4074 } |
4404 | 4075 |
4405 #ifdef _LP64 | 4076 #ifdef _LP64 |
4406 #define XTOP ,top() /*additional argument*/ | 4077 #define XTOP ,top() /*additional argument*/ |
4407 #else //_LP64 | 4078 #else //_LP64 |
4408 #define XTOP /*no additional argument*/ | 4079 #define XTOP /*no additional argument*/ |
4409 #endif //_LP64 | 4080 #endif //_LP64 |
4410 | 4081 |
4411 //----------------------inline_unsafe_copyMemory------------------------- | 4082 //----------------------inline_unsafe_copyMemory------------------------- |
4083 // public native void sun.misc.Unsafe.copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes); | |
4412 bool LibraryCallKit::inline_unsafe_copyMemory() { | 4084 bool LibraryCallKit::inline_unsafe_copyMemory() { |
4413 if (callee()->is_static()) return false; // caller must have the capability! | 4085 if (callee()->is_static()) return false; // caller must have the capability! |
4414 int nargs = 1 + 5 + 3; // 5 args: (src: ptr,off, dst: ptr,off, size) | 4086 null_check_receiver(); // null-check receiver |
4415 assert(signature()->size() == nargs-1, "copy has 5 arguments"); | |
4416 null_check_receiver(callee()); // check then ignore argument(0) | |
4417 if (stopped()) return true; | 4087 if (stopped()) return true; |
4418 | 4088 |
4419 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". | 4089 C->set_has_unsafe_access(true); // Mark eventual nmethod as "unsafe". |
4420 | 4090 |
4421 Node* src_ptr = argument(1); | 4091 Node* src_ptr = argument(1); // type: oop |
4422 Node* src_off = ConvL2X(argument(2)); | 4092 Node* src_off = ConvL2X(argument(2)); // type: long |
4423 assert(argument(3)->is_top(), "2nd half of long"); | 4093 Node* dst_ptr = argument(4); // type: oop |
4424 Node* dst_ptr = argument(4); | 4094 Node* dst_off = ConvL2X(argument(5)); // type: long |
4425 Node* dst_off = ConvL2X(argument(5)); | 4095 Node* size = ConvL2X(argument(7)); // type: long |
4426 assert(argument(6)->is_top(), "2nd half of long"); | |
4427 Node* size = ConvL2X(argument(7)); | |
4428 assert(argument(8)->is_top(), "2nd half of long"); | |
4429 | 4096 |
4430 assert(Unsafe_field_offset_to_byte_offset(11) == 11, | 4097 assert(Unsafe_field_offset_to_byte_offset(11) == 11, |
4431 "fieldOffset must be byte-scaled"); | 4098 "fieldOffset must be byte-scaled"); |
4432 | 4099 |
4433 Node* src = make_unsafe_address(src_ptr, src_off); | 4100 Node* src = make_unsafe_address(src_ptr, src_off); |
4543 insert_mem_bar(Op_MemBarCPUOrder); | 4210 insert_mem_bar(Op_MemBarCPUOrder); |
4544 } | 4211 } |
4545 } | 4212 } |
4546 | 4213 |
4547 //------------------------inline_native_clone---------------------------- | 4214 //------------------------inline_native_clone---------------------------- |
4215 // protected native Object java.lang.Object.clone(); | |
4216 // | |
4548 // Here are the simple edge cases: | 4217 // Here are the simple edge cases: |
4549 // null receiver => normal trap | 4218 // null receiver => normal trap |
4550 // virtual and clone was overridden => slow path to out-of-line clone | 4219 // virtual and clone was overridden => slow path to out-of-line clone |
4551 // not cloneable or finalizer => slow path to out-of-line Object.clone | 4220 // not cloneable or finalizer => slow path to out-of-line Object.clone |
4552 // | 4221 // |
4559 // | 4228 // |
4560 // These steps fold up nicely if and when the cloned object's klass | 4229 // These steps fold up nicely if and when the cloned object's klass |
4561 // can be sharply typed as an object array, a type array, or an instance. | 4230 // can be sharply typed as an object array, a type array, or an instance. |
4562 // | 4231 // |
4563 bool LibraryCallKit::inline_native_clone(bool is_virtual) { | 4232 bool LibraryCallKit::inline_native_clone(bool is_virtual) { |
4564 int nargs = 1; | |
4565 PhiNode* result_val; | 4233 PhiNode* result_val; |
4566 | 4234 |
4567 //set the original stack and the reexecute bit for the interpreter to reexecute | 4235 // Set the reexecute bit for the interpreter to reexecute |
4568 //the bytecode that invokes Object.clone if deoptimization happens | 4236 // the bytecode that invokes Object.clone if deoptimization happens. |
4569 { PreserveReexecuteState preexecs(this); | 4237 { PreserveReexecuteState preexecs(this); |
4570 jvms()->set_should_reexecute(true); | 4238 jvms()->set_should_reexecute(true); |
4571 | 4239 |
4572 //null_check_receiver will adjust _sp (push and pop) | 4240 Node* obj = null_check_receiver(); |
4573 Node* obj = null_check_receiver(callee()); | |
4574 if (stopped()) return true; | 4241 if (stopped()) return true; |
4575 | |
4576 _sp += nargs; | |
4577 | 4242 |
4578 Node* obj_klass = load_object_klass(obj); | 4243 Node* obj_klass = load_object_klass(obj); |
4579 const TypeKlassPtr* tklass = _gvn.type(obj_klass)->isa_klassptr(); | 4244 const TypeKlassPtr* tklass = _gvn.type(obj_klass)->isa_klassptr(); |
4580 const TypeOopPtr* toop = ((tklass != NULL) | 4245 const TypeOopPtr* toop = ((tklass != NULL) |
4581 ? tklass->as_instance_type() | 4246 ? tklass->as_instance_type() |
4609 // It's an array. | 4274 // It's an array. |
4610 PreserveJVMState pjvms(this); | 4275 PreserveJVMState pjvms(this); |
4611 set_control(array_ctl); | 4276 set_control(array_ctl); |
4612 Node* obj_length = load_array_length(obj); | 4277 Node* obj_length = load_array_length(obj); |
4613 Node* obj_size = NULL; | 4278 Node* obj_size = NULL; |
4614 Node* alloc_obj = new_array(obj_klass, obj_length, 0, &obj_size); | 4279 Node* alloc_obj = new_array(obj_klass, obj_length, 0, &obj_size); // no arguments to push |
4615 | 4280 |
4616 if (!use_ReduceInitialCardMarks()) { | 4281 if (!use_ReduceInitialCardMarks()) { |
4617 // If it is an oop array, it requires very special treatment, | 4282 // If it is an oop array, it requires very special treatment, |
4618 // because card marking is required on each card of the array. | 4283 // because card marking is required on each card of the array. |
4619 Node* is_obja = generate_objArray_guard(obj_klass, (RegionNode*)NULL); | 4284 Node* is_obja = generate_objArray_guard(obj_klass, (RegionNode*)NULL); |
4709 | 4374 |
4710 // Return the combined state. | 4375 // Return the combined state. |
4711 set_control( _gvn.transform(result_reg) ); | 4376 set_control( _gvn.transform(result_reg) ); |
4712 set_i_o( _gvn.transform(result_i_o) ); | 4377 set_i_o( _gvn.transform(result_i_o) ); |
4713 set_all_memory( _gvn.transform(result_mem) ); | 4378 set_all_memory( _gvn.transform(result_mem) ); |
4714 } //original reexecute and sp are set back here | 4379 } // original reexecute is set back here |
4715 | 4380 |
4716 push(_gvn.transform(result_val)); | 4381 set_result(_gvn.transform(result_val)); |
4717 | |
4718 return true; | 4382 return true; |
4719 } | 4383 } |
4720 | 4384 |
4721 //------------------------------basictype2arraycopy---------------------------- | 4385 //------------------------------basictype2arraycopy---------------------------- |
4722 address LibraryCallKit::basictype2arraycopy(BasicType t, | 4386 address LibraryCallKit::basictype2arraycopy(BasicType t, |
4753 return StubRoutines::select_arraycopy_function(t, aligned, disjoint, name, dest_uninitialized); | 4417 return StubRoutines::select_arraycopy_function(t, aligned, disjoint, name, dest_uninitialized); |
4754 } | 4418 } |
4755 | 4419 |
4756 | 4420 |
4757 //------------------------------inline_arraycopy----------------------- | 4421 //------------------------------inline_arraycopy----------------------- |
4422 // public static native void java.lang.System.arraycopy(Object src, int srcPos, | |
4423 // Object dest, int destPos, | |
4424 // int length); | |
4758 bool LibraryCallKit::inline_arraycopy() { | 4425 bool LibraryCallKit::inline_arraycopy() { |
4759 // Restore the stack and pop off the arguments. | 4426 // Get the arguments. |
4760 int nargs = 5; // 2 oops, 3 ints, no size_t or long | 4427 Node* src = argument(0); // type: oop |
4761 assert(callee()->signature()->size() == nargs, "copy has 5 arguments"); | 4428 Node* src_offset = argument(1); // type: int |
4762 | 4429 Node* dest = argument(2); // type: oop |
4763 Node *src = argument(0); | 4430 Node* dest_offset = argument(3); // type: int |
4764 Node *src_offset = argument(1); | 4431 Node* length = argument(4); // type: int |
4765 Node *dest = argument(2); | |
4766 Node *dest_offset = argument(3); | |
4767 Node *length = argument(4); | |
4768 | 4432 |
4769 // Compile time checks. If any of these checks cannot be verified at compile time, | 4433 // Compile time checks. If any of these checks cannot be verified at compile time, |
4770 // we do not make a fast path for this call. Instead, we let the call remain as it | 4434 // we do not make a fast path for this call. Instead, we let the call remain as it |
4771 // is. The checks we choose to mandate at compile time are: | 4435 // is. The checks we choose to mandate at compile time are: |
4772 // | 4436 // |
4773 // (1) src and dest are arrays. | 4437 // (1) src and dest are arrays. |
4774 const Type* src_type = src->Value(&_gvn); | 4438 const Type* src_type = src->Value(&_gvn); |
4775 const Type* dest_type = dest->Value(&_gvn); | 4439 const Type* dest_type = dest->Value(&_gvn); |
4776 const TypeAryPtr* top_src = src_type->isa_aryptr(); | 4440 const TypeAryPtr* top_src = src_type->isa_aryptr(); |
4777 const TypeAryPtr* top_dest = dest_type->isa_aryptr(); | 4441 const TypeAryPtr* top_dest = dest_type->isa_aryptr(); |
4778 if (top_src == NULL || top_src->klass() == NULL || | 4442 if (top_src == NULL || top_src->klass() == NULL || |
4779 top_dest == NULL || top_dest->klass() == NULL) { | 4443 top_dest == NULL || top_dest->klass() == NULL) { |
4780 // Conservatively insert a memory barrier on all memory slices. | 4444 // Conservatively insert a memory barrier on all memory slices. |
4781 // Do not let writes into the source float below the arraycopy. | 4445 // Do not let writes into the source float below the arraycopy. |
4826 | 4490 |
4827 RegionNode* slow_region = new (C) RegionNode(1); | 4491 RegionNode* slow_region = new (C) RegionNode(1); |
4828 record_for_igvn(slow_region); | 4492 record_for_igvn(slow_region); |
4829 | 4493 |
4830 // (3) operands must not be null | 4494 // (3) operands must not be null |
4831 // We currently perform our null checks with the do_null_check routine. | 4495 // We currently perform our null checks with the null_check routine. |
4832 // This means that the null exceptions will be reported in the caller | 4496 // This means that the null exceptions will be reported in the caller |
4833 // rather than (correctly) reported inside of the native arraycopy call. | 4497 // rather than (correctly) reported inside of the native arraycopy call. |
4834 // This should be corrected, given time. We do our null check with the | 4498 // This should be corrected, given time. We do our null check with the |
4835 // stack pointer restored. | 4499 // stack pointer restored. |
4836 _sp += nargs; | 4500 src = null_check(src, T_ARRAY); |
4837 src = do_null_check(src, T_ARRAY); | 4501 dest = null_check(dest, T_ARRAY); |
4838 dest = do_null_check(dest, T_ARRAY); | |
4839 _sp -= nargs; | |
4840 | 4502 |
4841 // (4) src_offset must not be negative. | 4503 // (4) src_offset must not be negative. |
4842 generate_negative_guard(src_offset, slow_region); | 4504 generate_negative_guard(src_offset, slow_region); |
4843 | 4505 |
4844 // (5) dest_offset must not be negative. | 4506 // (5) dest_offset must not be negative. |
5177 | 4839 |
5178 // Here are all the slow paths up to this point, in one bundle: | 4840 // Here are all the slow paths up to this point, in one bundle: |
5179 slow_control = top(); | 4841 slow_control = top(); |
5180 if (slow_region != NULL) | 4842 if (slow_region != NULL) |
5181 slow_control = _gvn.transform(slow_region); | 4843 slow_control = _gvn.transform(slow_region); |
5182 debug_only(slow_region = (RegionNode*)badAddress); | 4844 DEBUG_ONLY(slow_region = (RegionNode*)badAddress); |
5183 | 4845 |
5184 set_control(checked_control); | 4846 set_control(checked_control); |
5185 if (!stopped()) { | 4847 if (!stopped()) { |
5186 // Clean up after the checked call. | 4848 // Clean up after the checked call. |
5187 // The returned value is either 0 or -1^K, | 4849 // The returned value is either 0 or -1^K, |
5672 copyfunc_addr, copyfunc_name, adr_type, | 5334 copyfunc_addr, copyfunc_name, adr_type, |
5673 src_start, dest_start, copy_length XTOP); | 5335 src_start, dest_start, copy_length XTOP); |
5674 } | 5336 } |
5675 | 5337 |
5676 //----------------------------inline_reference_get---------------------------- | 5338 //----------------------------inline_reference_get---------------------------- |
5677 | 5339 // public T java.lang.ref.Reference.get(); |
5678 bool LibraryCallKit::inline_reference_get() { | 5340 bool LibraryCallKit::inline_reference_get() { |
5679 const int nargs = 1; // self | 5341 const int referent_offset = java_lang_ref_Reference::referent_offset; |
5680 | 5342 guarantee(referent_offset > 0, "should have already been set"); |
5681 guarantee(java_lang_ref_Reference::referent_offset > 0, | 5343 |
5682 "should have already been set"); | 5344 // Get the argument: |
5683 | 5345 Node* reference_obj = null_check_receiver(); |
5684 int referent_offset = java_lang_ref_Reference::referent_offset; | |
5685 | |
5686 // Restore the stack and pop off the argument | |
5687 _sp += nargs; | |
5688 Node *reference_obj = pop(); | |
5689 | |
5690 // Null check on self without removing any arguments. | |
5691 _sp += nargs; | |
5692 reference_obj = do_null_check(reference_obj, T_OBJECT); | |
5693 _sp -= nargs;; | |
5694 | |
5695 if (stopped()) return true; | 5346 if (stopped()) return true; |
5696 | 5347 |
5697 Node *adr = basic_plus_adr(reference_obj, reference_obj, referent_offset); | 5348 Node* adr = basic_plus_adr(reference_obj, reference_obj, referent_offset); |
5698 | 5349 |
5699 ciInstanceKlass* klass = env()->Object_klass(); | 5350 ciInstanceKlass* klass = env()->Object_klass(); |
5700 const TypeOopPtr* object_type = TypeOopPtr::make_from_klass(klass); | 5351 const TypeOopPtr* object_type = TypeOopPtr::make_from_klass(klass); |
5701 | 5352 |
5702 Node* no_ctrl = NULL; | 5353 Node* no_ctrl = NULL; |
5703 Node *result = make_load(no_ctrl, adr, object_type, T_OBJECT); | 5354 Node* result = make_load(no_ctrl, adr, object_type, T_OBJECT); |
5704 | 5355 |
5705 // Use the pre-barrier to record the value in the referent field | 5356 // Use the pre-barrier to record the value in the referent field |
5706 pre_barrier(false /* do_load */, | 5357 pre_barrier(false /* do_load */, |
5707 control(), | 5358 control(), |
5708 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, | 5359 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, |
5711 | 5362 |
5712 // Add memory barrier to prevent commoning reads from this field | 5363 // Add memory barrier to prevent commoning reads from this field |
5713 // across safepoint since GC can change its value. | 5364 // across safepoint since GC can change its value. |
5714 insert_mem_bar(Op_MemBarCPUOrder); | 5365 insert_mem_bar(Op_MemBarCPUOrder); |
5715 | 5366 |
5716 push(result); | 5367 set_result(result); |
5717 return true; | 5368 return true; |
5718 } | 5369 } |
5719 | 5370 |
5720 | 5371 |
5721 Node * LibraryCallKit::load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, | 5372 Node * LibraryCallKit::load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, |
5768 stubName = "aescrypt_decryptBlock"; | 5419 stubName = "aescrypt_decryptBlock"; |
5769 break; | 5420 break; |
5770 } | 5421 } |
5771 if (stubAddr == NULL) return false; | 5422 if (stubAddr == NULL) return false; |
5772 | 5423 |
5773 // Restore the stack and pop off the arguments. | 5424 Node* aescrypt_object = argument(0); |
5774 int nargs = 5; // this + 2 oop/offset combos | 5425 Node* src = argument(1); |
5775 assert(callee()->signature()->size() == nargs-1, "encryptBlock has 4 arguments"); | 5426 Node* src_offset = argument(2); |
5776 | 5427 Node* dest = argument(3); |
5777 Node *aescrypt_object = argument(0); | 5428 Node* dest_offset = argument(4); |
5778 Node *src = argument(1); | |
5779 Node *src_offset = argument(2); | |
5780 Node *dest = argument(3); | |
5781 Node *dest_offset = argument(4); | |
5782 | 5429 |
5783 // (1) src and dest are arrays. | 5430 // (1) src and dest are arrays. |
5784 const Type* src_type = src->Value(&_gvn); | 5431 const Type* src_type = src->Value(&_gvn); |
5785 const Type* dest_type = dest->Value(&_gvn); | 5432 const Type* dest_type = dest->Value(&_gvn); |
5786 const TypeAryPtr* top_src = src_type->isa_aryptr(); | 5433 const TypeAryPtr* top_src = src_type->isa_aryptr(); |
5827 stubName = "cipherBlockChaining_decryptAESCrypt"; | 5474 stubName = "cipherBlockChaining_decryptAESCrypt"; |
5828 break; | 5475 break; |
5829 } | 5476 } |
5830 if (stubAddr == NULL) return false; | 5477 if (stubAddr == NULL) return false; |
5831 | 5478 |
5832 | 5479 Node* cipherBlockChaining_object = argument(0); |
5833 // Restore the stack and pop off the arguments. | 5480 Node* src = argument(1); |
5834 int nargs = 6; // this + oop/offset + len + oop/offset | 5481 Node* src_offset = argument(2); |
5835 assert(callee()->signature()->size() == nargs-1, "wrong number of arguments"); | 5482 Node* len = argument(3); |
5836 Node *cipherBlockChaining_object = argument(0); | 5483 Node* dest = argument(4); |
5837 Node *src = argument(1); | 5484 Node* dest_offset = argument(5); |
5838 Node *src_offset = argument(2); | |
5839 Node *len = argument(3); | |
5840 Node *dest = argument(4); | |
5841 Node *dest_offset = argument(5); | |
5842 | 5485 |
5843 // (1) src and dest are arrays. | 5486 // (1) src and dest are arrays. |
5844 const Type* src_type = src->Value(&_gvn); | 5487 const Type* src_type = src->Value(&_gvn); |
5845 const Type* dest_type = dest->Value(&_gvn); | 5488 const Type* dest_type = dest->Value(&_gvn); |
5846 const TypeAryPtr* top_src = src_type->isa_aryptr(); | 5489 const TypeAryPtr* top_src = src_type->isa_aryptr(); |
5918 // if ((embeddedCipherObj instanceof AESCrypt) && (cipher!=plain)) do_intrinsic, else do_javapath | 5561 // if ((embeddedCipherObj instanceof AESCrypt) && (cipher!=plain)) do_intrinsic, else do_javapath |
5919 // note cipher==plain is more conservative than the original java code but that's OK | 5562 // note cipher==plain is more conservative than the original java code but that's OK |
5920 // | 5563 // |
5921 Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting) { | 5564 Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting) { |
5922 // First, check receiver for NULL since it is virtual method. | 5565 // First, check receiver for NULL since it is virtual method. |
5923 int nargs = arg_size(); | |
5924 Node* objCBC = argument(0); | 5566 Node* objCBC = argument(0); |
5925 _sp += nargs; | 5567 objCBC = null_check(objCBC); |
5926 objCBC = do_null_check(objCBC, T_OBJECT); | |
5927 _sp -= nargs; | |
5928 | 5568 |
5929 if (stopped()) return NULL; // Always NULL | 5569 if (stopped()) return NULL; // Always NULL |
5930 | 5570 |
5931 // Load embeddedCipher field of CipherBlockChaining object. | 5571 // Load embeddedCipher field of CipherBlockChaining object. |
5932 Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); | 5572 Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); |
5946 set_control(top()); // no regular fast path | 5586 set_control(top()); // no regular fast path |
5947 return ctrl; | 5587 return ctrl; |
5948 } | 5588 } |
5949 ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); | 5589 ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); |
5950 | 5590 |
5951 _sp += nargs; // gen_instanceof might do an uncommon trap | |
5952 Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt))); | 5591 Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt))); |
5953 _sp -= nargs; | |
5954 Node* cmp_instof = _gvn.transform(new (C) CmpINode(instof, intcon(1))); | 5592 Node* cmp_instof = _gvn.transform(new (C) CmpINode(instof, intcon(1))); |
5955 Node* bool_instof = _gvn.transform(new (C) BoolNode(cmp_instof, BoolTest::ne)); | 5593 Node* bool_instof = _gvn.transform(new (C) BoolNode(cmp_instof, BoolTest::ne)); |
5956 | 5594 |
5957 Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); | 5595 Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); |
5958 | 5596 |
5964 // taking the intrinsic path when cipher and plain are the same | 5602 // taking the intrinsic path when cipher and plain are the same |
5965 // see the original java code for why. | 5603 // see the original java code for why. |
5966 RegionNode* region = new(C) RegionNode(3); | 5604 RegionNode* region = new(C) RegionNode(3); |
5967 region->init_req(1, instof_false); | 5605 region->init_req(1, instof_false); |
5968 Node* src = argument(1); | 5606 Node* src = argument(1); |
5969 Node *dest = argument(4); | 5607 Node* dest = argument(4); |
5970 Node* cmp_src_dest = _gvn.transform(new (C) CmpPNode(src, dest)); | 5608 Node* cmp_src_dest = _gvn.transform(new (C) CmpPNode(src, dest)); |
5971 Node* bool_src_dest = _gvn.transform(new (C) BoolNode(cmp_src_dest, BoolTest::eq)); | 5609 Node* bool_src_dest = _gvn.transform(new (C) BoolNode(cmp_src_dest, BoolTest::eq)); |
5972 Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN); | 5610 Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN); |
5973 region->init_req(2, src_dest_conjoint); | 5611 region->init_req(2, src_dest_conjoint); |
5974 | 5612 |
5975 record_for_igvn(region); | 5613 record_for_igvn(region); |
5976 return _gvn.transform(region); | 5614 return _gvn.transform(region); |
5977 | 5615 } |
5978 } | |
5979 | |
5980 |