Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/library_call.cpp @ 958:c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
Summary: Removed second CheckCastPP and use MembarCPUOrder after arraycopy to cloned object.
Reviewed-by: never
author | kvn |
---|---|
date | Thu, 10 Sep 2009 18:18:06 -0700 |
parents | 8fe1963e3964 |
children | 62001a362ce9 |
comparison
equal
deleted
inserted
replaced
957:159d56b94894 | 958:c7e94e8fff43 |
---|---|
3892 // Helper function for inline_native_clone. | 3892 // Helper function for inline_native_clone. |
3893 void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark) { | 3893 void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark) { |
3894 assert(obj_size != NULL, ""); | 3894 assert(obj_size != NULL, ""); |
3895 Node* raw_obj = alloc_obj->in(1); | 3895 Node* raw_obj = alloc_obj->in(1); |
3896 assert(alloc_obj->is_CheckCastPP() && raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), ""); | 3896 assert(alloc_obj->is_CheckCastPP() && raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), ""); |
3897 assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL, "should be more precise than Object"); | |
3898 | 3897 |
3899 if (ReduceBulkZeroing) { | 3898 if (ReduceBulkZeroing) { |
3900 // We will be completely responsible for initializing this object - | 3899 // We will be completely responsible for initializing this object - |
3901 // mark Initialize node as complete. | 3900 // mark Initialize node as complete. |
3902 AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn); | 3901 AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn); |
3903 // The object was just allocated - there should be no any stores! | 3902 // The object was just allocated - there should be no any stores! |
3904 guarantee(alloc != NULL && alloc->maybe_set_complete(&_gvn), ""); | 3903 guarantee(alloc != NULL && alloc->maybe_set_complete(&_gvn), ""); |
3905 } | 3904 } |
3906 | 3905 |
3907 // Cast to Object for arraycopy. | |
3908 // We can't use the original CheckCastPP since it should be moved | |
3909 // after the arraycopy to prevent stores flowing above it. | |
3910 Node* new_obj = new(C, 2) CheckCastPPNode(alloc_obj->in(0), raw_obj, | |
3911 TypeInstPtr::NOTNULL); | |
3912 new_obj = _gvn.transform(new_obj); | |
3913 // Substitute in the locally valid dest_oop. | |
3914 replace_in_map(alloc_obj, new_obj); | |
3915 | |
3916 // Copy the fastest available way. | 3906 // Copy the fastest available way. |
3917 // TODO: generate fields copies for small objects instead. | 3907 // TODO: generate fields copies for small objects instead. |
3918 Node* src = obj; | 3908 Node* src = obj; |
3919 Node* dest = new_obj; | 3909 Node* dest = alloc_obj; |
3920 Node* size = _gvn.transform(obj_size); | 3910 Node* size = _gvn.transform(obj_size); |
3921 | 3911 |
3922 // Exclude the header but include array length to copy by 8 bytes words. | 3912 // Exclude the header but include array length to copy by 8 bytes words. |
3923 // Can't use base_offset_in_bytes(bt) since basic type is unknown. | 3913 // Can't use base_offset_in_bytes(bt) since basic type is unknown. |
3924 int base_off = is_array ? arrayOopDesc::length_offset_in_bytes() : | 3914 int base_off = is_array ? arrayOopDesc::length_offset_in_bytes() : |
3960 Node* no_particular_value = NULL; | 3950 Node* no_particular_value = NULL; |
3961 Node* no_particular_field = NULL; | 3951 Node* no_particular_field = NULL; |
3962 int raw_adr_idx = Compile::AliasIdxRaw; | 3952 int raw_adr_idx = Compile::AliasIdxRaw; |
3963 post_barrier(control(), | 3953 post_barrier(control(), |
3964 memory(raw_adr_type), | 3954 memory(raw_adr_type), |
3965 new_obj, | 3955 alloc_obj, |
3966 no_particular_field, | 3956 no_particular_field, |
3967 raw_adr_idx, | 3957 raw_adr_idx, |
3968 no_particular_value, | 3958 no_particular_value, |
3969 T_OBJECT, | 3959 T_OBJECT, |
3970 false); | 3960 false); |
3971 } | 3961 } |
3972 | 3962 |
3973 // Move the original CheckCastPP after arraycopy. | 3963 // Do not let reads from the cloned object float above the arraycopy. |
3974 _gvn.hash_delete(alloc_obj); | 3964 insert_mem_bar(Op_MemBarCPUOrder); |
3975 alloc_obj->set_req(0, control()); | |
3976 // Replace raw memory edge with new CheckCastPP to have a live oop | |
3977 // at safepoints instead of raw value. | |
3978 assert(new_obj->is_CheckCastPP() && new_obj->in(1) == alloc_obj->in(1), "sanity"); | |
3979 alloc_obj->set_req(1, new_obj); // cast to the original type | |
3980 _gvn.hash_find_insert(alloc_obj); // put back into GVN table | |
3981 // Restore in the locally valid dest_oop. | |
3982 replace_in_map(new_obj, alloc_obj); | |
3983 } | 3965 } |
3984 | 3966 |
3985 //------------------------inline_native_clone---------------------------- | 3967 //------------------------inline_native_clone---------------------------- |
3986 // Here are the simple edge cases: | 3968 // Here are the simple edge cases: |
3987 // null receiver => normal trap | 3969 // null receiver => normal trap |
4446 && alloc->maybe_set_complete(&_gvn)) { | 4428 && alloc->maybe_set_complete(&_gvn)) { |
4447 // "You break it, you buy it." | 4429 // "You break it, you buy it." |
4448 InitializeNode* init = alloc->initialization(); | 4430 InitializeNode* init = alloc->initialization(); |
4449 assert(init->is_complete(), "we just did this"); | 4431 assert(init->is_complete(), "we just did this"); |
4450 assert(dest->is_CheckCastPP(), "sanity"); | 4432 assert(dest->is_CheckCastPP(), "sanity"); |
4451 assert(dest->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL, "type should be more precise than Object"); | |
4452 assert(dest->in(0)->in(0) == init, "dest pinned"); | 4433 assert(dest->in(0)->in(0) == init, "dest pinned"); |
4453 | |
4454 // Cast to Object for arraycopy. | |
4455 // We can't use the original CheckCastPP since it should be moved | |
4456 // after the arraycopy to prevent stores flowing above it. | |
4457 Node* new_obj = new(C, 2) CheckCastPPNode(dest->in(0), dest->in(1), | |
4458 TypeInstPtr::NOTNULL); | |
4459 dest = _gvn.transform(new_obj); | |
4460 // Substitute in the locally valid dest_oop. | |
4461 replace_in_map(original_dest, dest); | |
4462 adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory | 4434 adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory |
4463 // From this point on, every exit path is responsible for | 4435 // From this point on, every exit path is responsible for |
4464 // initializing any non-copied parts of the object to zero. | 4436 // initializing any non-copied parts of the object to zero. |
4465 must_clear_dest = true; | 4437 must_clear_dest = true; |
4466 } else { | 4438 } else { |
4786 // Finished; return the combined state. | 4758 // Finished; return the combined state. |
4787 set_control( _gvn.transform(result_region) ); | 4759 set_control( _gvn.transform(result_region) ); |
4788 set_i_o( _gvn.transform(result_i_o) ); | 4760 set_i_o( _gvn.transform(result_i_o) ); |
4789 set_memory( _gvn.transform(result_memory), adr_type ); | 4761 set_memory( _gvn.transform(result_memory), adr_type ); |
4790 | 4762 |
4791 if (dest != original_dest) { | |
4792 // Pin the "finished" array node after the arraycopy/zeroing operations. | |
4793 _gvn.hash_delete(original_dest); | |
4794 original_dest->set_req(0, control()); | |
4795 // Replace raw memory edge with new CheckCastPP to have a live oop | |
4796 // at safepoints instead of raw value. | |
4797 assert(dest->is_CheckCastPP() && dest->in(1) == original_dest->in(1), "sanity"); | |
4798 original_dest->set_req(1, dest); // cast to the original type | |
4799 _gvn.hash_find_insert(original_dest); // put back into GVN table | |
4800 // Restore in the locally valid dest_oop. | |
4801 replace_in_map(dest, original_dest); | |
4802 } | |
4803 // The memory edges above are precise in order to model effects around | 4763 // The memory edges above are precise in order to model effects around |
4804 // array copies accurately to allow value numbering of field loads around | 4764 // array copies accurately to allow value numbering of field loads around |
4805 // arraycopy. Such field loads, both before and after, are common in Java | 4765 // arraycopy. Such field loads, both before and after, are common in Java |
4806 // collections and similar classes involving header/array data structures. | 4766 // collections and similar classes involving header/array data structures. |
4807 // | 4767 // |
4808 // But with low number of register or when some registers are used or killed | 4768 // But with low number of register or when some registers are used or killed |
4809 // by arraycopy calls it causes registers spilling on stack. See 6544710. | 4769 // by arraycopy calls it causes registers spilling on stack. See 6544710. |
4810 // The next memory barrier is added to avoid it. If the arraycopy can be | 4770 // The next memory barrier is added to avoid it. If the arraycopy can be |
4811 // optimized away (which it can, sometimes) then we can manually remove | 4771 // optimized away (which it can, sometimes) then we can manually remove |
4812 // the membar also. | 4772 // the membar also. |
4813 if (InsertMemBarAfterArraycopy) | 4773 // |
4774 // Do not let reads from the cloned object float above the arraycopy. | |
4775 if (InsertMemBarAfterArraycopy || alloc != NULL) | |
4814 insert_mem_bar(Op_MemBarCPUOrder); | 4776 insert_mem_bar(Op_MemBarCPUOrder); |
4815 } | 4777 } |
4816 | 4778 |
4817 | 4779 |
4818 // Helper function which determines if an arraycopy immediately follows | 4780 // Helper function which determines if an arraycopy immediately follows |