Mercurial > hg > truffle
comparison src/share/vm/opto/library_call.cpp @ 4762:069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
Summary: Moved sizeof(klassOopDesc), changed the return type to ByteSize and removed the _in_bytes suffix.
Reviewed-by: never, bdelsart, coleenp, jrose
author | stefank |
---|---|
date | Wed, 07 Dec 2011 11:35:03 +0100 |
parents | a92cdbac8b9e |
children | 1dc233a8c7fe |
comparison
equal
deleted
inserted
replaced
4761:65149e74c706 | 4762:069ab3f976d3 |
---|---|
2163 float unlikely = PROB_UNLIKELY(0.999); | 2163 float unlikely = PROB_UNLIKELY(0.999); |
2164 | 2164 |
2165 IdealKit ideal(this); | 2165 IdealKit ideal(this); |
2166 #define __ ideal. | 2166 #define __ ideal. |
2167 | 2167 |
2168 const int reference_type_offset = instanceKlass::reference_type_offset_in_bytes() + | 2168 const int reference_type_offset = in_bytes(instanceKlass::reference_type_offset()); |
2169 sizeof(oopDesc); | |
2170 | 2169 |
2171 Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset); | 2170 Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset); |
2172 | 2171 |
2173 __ if_then(offset, BoolTest::eq, referent_off, unlikely); { | 2172 __ if_then(offset, BoolTest::eq, referent_off, unlikely); { |
2174 __ if_then(base_oop, BoolTest::ne, null(), likely); { | 2173 __ if_then(base_oop, BoolTest::ne, null(), likely); { |
2804 if (stopped()) return true; // argument was like int.class | 2803 if (stopped()) return true; // argument was like int.class |
2805 | 2804 |
2806 // Note: The argument might still be an illegal value like | 2805 // Note: The argument might still be an illegal value like |
2807 // Serializable.class or Object[].class. The runtime will handle it. | 2806 // Serializable.class or Object[].class. The runtime will handle it. |
2808 // But we must make an explicit check for initialization. | 2807 // But we must make an explicit check for initialization. |
2809 Node* insp = basic_plus_adr(kls, instanceKlass::init_state_offset_in_bytes() + sizeof(oopDesc)); | 2808 Node* insp = basic_plus_adr(kls, in_bytes(instanceKlass::init_state_offset())); |
2810 Node* inst = make_load(NULL, insp, TypeInt::INT, T_INT); | 2809 Node* inst = make_load(NULL, insp, TypeInt::INT, T_INT); |
2811 Node* bits = intcon(instanceKlass::fully_initialized); | 2810 Node* bits = intcon(instanceKlass::fully_initialized); |
2812 Node* test = _gvn.transform( new (C, 3) SubINode(inst, bits) ); | 2811 Node* test = _gvn.transform( new (C, 3) SubINode(inst, bits) ); |
2813 // The 'test' is non-zero if we need to take a slow path. | 2812 // The 'test' is non-zero if we need to take a slow path. |
2814 | 2813 |
2952 } | 2951 } |
2953 | 2952 |
2954 //---------------------------load_mirror_from_klass---------------------------- | 2953 //---------------------------load_mirror_from_klass---------------------------- |
2955 // Given a klass oop, load its java mirror (a java.lang.Class oop). | 2954 // Given a klass oop, load its java mirror (a java.lang.Class oop). |
2956 Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { | 2955 Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { |
2957 Node* p = basic_plus_adr(klass, Klass::java_mirror_offset_in_bytes() + sizeof(oopDesc)); | 2956 Node* p = basic_plus_adr(klass, in_bytes(Klass::java_mirror_offset())); |
2958 return make_load(NULL, p, TypeInstPtr::MIRROR, T_OBJECT); | 2957 return make_load(NULL, p, TypeInstPtr::MIRROR, T_OBJECT); |
2959 } | 2958 } |
2960 | 2959 |
2961 //-----------------------load_klass_from_mirror_common------------------------- | 2960 //-----------------------load_klass_from_mirror_common------------------------- |
2962 // Given a java mirror (a java.lang.Class oop), load its corresponding klass oop. | 2961 // Given a java mirror (a java.lang.Class oop), load its corresponding klass oop. |
2992 // Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER. | 2991 // Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE, JVM_ACC_HAS_FINALIZER. |
2993 // Fall through if (mods & mask) == bits, take the guard otherwise. | 2992 // Fall through if (mods & mask) == bits, take the guard otherwise. |
2994 Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { | 2993 Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { |
2995 // Branch around if the given klass has the given modifier bit set. | 2994 // Branch around if the given klass has the given modifier bit set. |
2996 // Like generate_guard, adds a new path onto the region. | 2995 // Like generate_guard, adds a new path onto the region. |
2997 Node* modp = basic_plus_adr(kls, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc)); | 2996 Node* modp = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
2998 Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT); | 2997 Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT); |
2999 Node* mask = intcon(modifier_mask); | 2998 Node* mask = intcon(modifier_mask); |
3000 Node* bits = intcon(modifier_bits); | 2999 Node* bits = intcon(modifier_bits); |
3001 Node* mbit = _gvn.transform( new (C, 3) AndINode(mods, mask) ); | 3000 Node* mbit = _gvn.transform( new (C, 3) AndINode(mods, mask) ); |
3002 Node* cmp = _gvn.transform( new (C, 3) CmpINode(mbit, bits) ); | 3001 Node* cmp = _gvn.transform( new (C, 3) CmpINode(mbit, bits) ); |
3113 query_value = gen_instanceof(obj, kls); | 3112 query_value = gen_instanceof(obj, kls); |
3114 _sp -= nargs; | 3113 _sp -= nargs; |
3115 break; | 3114 break; |
3116 | 3115 |
3117 case vmIntrinsics::_getModifiers: | 3116 case vmIntrinsics::_getModifiers: |
3118 p = basic_plus_adr(kls, Klass::modifier_flags_offset_in_bytes() + sizeof(oopDesc)); | 3117 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
3119 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3118 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
3120 break; | 3119 break; |
3121 | 3120 |
3122 case vmIntrinsics::_isInterface: | 3121 case vmIntrinsics::_isInterface: |
3123 // (To verify this code sequence, check the asserts in JVM_IsInterface.) | 3122 // (To verify this code sequence, check the asserts in JVM_IsInterface.) |
3153 phi->add_req(null()); | 3152 phi->add_req(null()); |
3154 if (generate_array_guard(kls, region) != NULL) | 3153 if (generate_array_guard(kls, region) != NULL) |
3155 // A guard was added. If the guard is taken, it was an array. | 3154 // A guard was added. If the guard is taken, it was an array. |
3156 phi->add_req(makecon(TypeInstPtr::make(env()->Object_klass()->java_mirror()))); | 3155 phi->add_req(makecon(TypeInstPtr::make(env()->Object_klass()->java_mirror()))); |
3157 // If we fall through, it's a plain class. Get its _super. | 3156 // If we fall through, it's a plain class. Get its _super. |
3158 p = basic_plus_adr(kls, Klass::super_offset_in_bytes() + sizeof(oopDesc)); | 3157 p = basic_plus_adr(kls, in_bytes(Klass::super_offset())); |
3159 kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL) ); | 3158 kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL) ); |
3160 null_ctl = top(); | 3159 null_ctl = top(); |
3161 kls = null_check_oop(kls, &null_ctl); | 3160 kls = null_check_oop(kls, &null_ctl); |
3162 if (null_ctl != top()) { | 3161 if (null_ctl != top()) { |
3163 // If the guard is taken, Object.superClass is null (both klass and mirror). | 3162 // If the guard is taken, Object.superClass is null (both klass and mirror). |
3171 | 3170 |
3172 case vmIntrinsics::_getComponentType: | 3171 case vmIntrinsics::_getComponentType: |
3173 if (generate_array_guard(kls, region) != NULL) { | 3172 if (generate_array_guard(kls, region) != NULL) { |
3174 // Be sure to pin the oop load to the guard edge just created: | 3173 // Be sure to pin the oop load to the guard edge just created: |
3175 Node* is_array_ctrl = region->in(region->req()-1); | 3174 Node* is_array_ctrl = region->in(region->req()-1); |
3176 Node* cma = basic_plus_adr(kls, in_bytes(arrayKlass::component_mirror_offset()) + sizeof(oopDesc)); | 3175 Node* cma = basic_plus_adr(kls, in_bytes(arrayKlass::component_mirror_offset())); |
3177 Node* cmo = make_load(is_array_ctrl, cma, TypeInstPtr::MIRROR, T_OBJECT); | 3176 Node* cmo = make_load(is_array_ctrl, cma, TypeInstPtr::MIRROR, T_OBJECT); |
3178 phi->add_req(cmo); | 3177 phi->add_req(cmo); |
3179 } | 3178 } |
3180 query_value = null(); // non-array case is null | 3179 query_value = null(); // non-array case is null |
3181 break; | 3180 break; |
3182 | 3181 |
3183 case vmIntrinsics::_getClassAccessFlags: | 3182 case vmIntrinsics::_getClassAccessFlags: |
3184 p = basic_plus_adr(kls, Klass::access_flags_offset_in_bytes() + sizeof(oopDesc)); | 3183 p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
3185 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3184 query_value = make_load(NULL, p, TypeInt::INT, T_INT); |
3186 break; | 3185 break; |
3187 | 3186 |
3188 default: | 3187 default: |
3189 ShouldNotReachHere(); | 3188 ShouldNotReachHere(); |
4855 // Plug failing path into checked_oop_disjoint_arraycopy | 4854 // Plug failing path into checked_oop_disjoint_arraycopy |
4856 if (not_subtype_ctrl != top()) { | 4855 if (not_subtype_ctrl != top()) { |
4857 PreserveJVMState pjvms(this); | 4856 PreserveJVMState pjvms(this); |
4858 set_control(not_subtype_ctrl); | 4857 set_control(not_subtype_ctrl); |
4859 // (At this point we can assume disjoint_bases, since types differ.) | 4858 // (At this point we can assume disjoint_bases, since types differ.) |
4860 int ek_offset = objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc); | 4859 int ek_offset = in_bytes(objArrayKlass::element_klass_offset()); |
4861 Node* p1 = basic_plus_adr(dest_klass, ek_offset); | 4860 Node* p1 = basic_plus_adr(dest_klass, ek_offset); |
4862 Node* n1 = LoadKlassNode::make(_gvn, immutable_memory(), p1, TypeRawPtr::BOTTOM); | 4861 Node* n1 = LoadKlassNode::make(_gvn, immutable_memory(), p1, TypeRawPtr::BOTTOM); |
4863 Node* dest_elem_klass = _gvn.transform(n1); | 4862 Node* dest_elem_klass = _gvn.transform(n1); |
4864 Node* cv = generate_checkcast_arraycopy(adr_type, | 4863 Node* cv = generate_checkcast_arraycopy(adr_type, |
4865 dest_elem_klass, | 4864 dest_elem_klass, |
5306 | 5305 |
5307 // Pick out the parameters required to perform a store-check | 5306 // Pick out the parameters required to perform a store-check |
5308 // for the target array. This is an optimistic check. It will | 5307 // for the target array. This is an optimistic check. It will |
5309 // look in each non-null element's class, at the desired klass's | 5308 // look in each non-null element's class, at the desired klass's |
5310 // super_check_offset, for the desired klass. | 5309 // super_check_offset, for the desired klass. |
5311 int sco_offset = Klass::super_check_offset_offset_in_bytes() + sizeof(oopDesc); | 5310 int sco_offset = in_bytes(Klass::super_check_offset_offset()); |
5312 Node* p3 = basic_plus_adr(dest_elem_klass, sco_offset); | 5311 Node* p3 = basic_plus_adr(dest_elem_klass, sco_offset); |
5313 Node* n3 = new(C, 3) LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr()); | 5312 Node* n3 = new(C, 3) LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr()); |
5314 Node* check_offset = ConvI2X(_gvn.transform(n3)); | 5313 Node* check_offset = ConvI2X(_gvn.transform(n3)); |
5315 Node* check_value = dest_elem_klass; | 5314 Node* check_value = dest_elem_klass; |
5316 | 5315 |