< prev index next >

src/hotspot/share/ci/ciObject.cpp

Print this page

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "ci/ciObject.hpp"
 27 #include "ci/ciUtilities.inline.hpp"

 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "oops/oop.inline.hpp"
 30 #include "runtime/jniHandles.inline.hpp"
 31 
 32 // ciObject
 33 //
 34 // This class represents an oop in the HotSpot virtual machine.
 35 // Its subclasses are structured in a hierarchy which mirrors
 36 // an aggregate of the VM's oop and klass hierarchies (see
 37 // oopHierarchy.hpp).  Each instance of ciObject holds a handle
 38 // to a corresponding oop on the VM side and provides routines
 39 // for accessing the information in its oop.  By using the ciObject
 40 // hierarchy for accessing oops in the VM, the compiler ensures
 41 // that it is safe with respect to garbage collection; that is,
 42 // GC and compilation can proceed independently without
 43 // interference.
 44 //
 45 // Within the VM, the oop and klass hierarchies are separate.
 46 // The compiler interface does not preserve this separation --
 47 // the distinction between `Klass*' and `Klass' are not

186   return ciConstant();
187 }
188 
189 // ------------------------------------------------------------------
190 // ciObject::add_to_constant_value_cache()
191 //
192 // Add a constant value to the cache.
193 void ciObject::add_to_constant_value_cache(int off, ciConstant val) {
194   assert(val.is_valid(), "value must be valid");
195   assert(!check_constant_value_cache(off, val.basic_type()).is_valid(), "duplicate");
196   if (_constant_values == nullptr) {
197     Arena* arena = CURRENT_ENV->arena();
198     _constant_values = new (arena) GrowableArray<ConstantValue>(arena, 1, 0, ConstantValue());
199   }
200   _constant_values->append(ConstantValue(off, val));
201 }
202 
203 // ------------------------------------------------------------------
204 // ciObject::should_be_constant()
205 bool ciObject::should_be_constant() {
206   if (ScavengeRootsInCode >= 2)  return true;  // force everybody to be a constant
207   if (is_null_object()) return true;
208 



209   ciEnv* env = CURRENT_ENV;
210 
211     // We want Strings and Classes to be embeddable by default since
212     // they used to be in the perm world.  Not all Strings used to be
213     // embeddable but there's no easy way to distinguish the interned
214     // from the regulars ones so just treat them all that way.
215     if (klass() == env->String_klass() || klass() == env->Class_klass()) {
216       return true;
217     }
218   if (klass()->is_subclass_of(env->MethodHandle_klass()) ||
219       klass()->is_subclass_of(env->CallSite_klass())) {

220     // We want to treat these aggressively.
221     return true;
222   }
223 
224   return handle() == nullptr;
225 }
226 
227 // ------------------------------------------------------------------
228 // ciObject::print
229 //
230 // Print debugging output about this ciObject.
231 //
232 // Implementation note: dispatch to the virtual print_impl behavior
233 // for this ciObject.
234 void ciObject::print(outputStream* st) {
235   st->print("<%s", type_string());
236   GUARDED_VM_ENTRY(print_impl(st);)
237   st->print(" ident=%d address=" INTPTR_FORMAT ">", ident(), p2i(this));
238 }
239 

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "ci/ciObject.hpp"
 27 #include "ci/ciUtilities.inline.hpp"
 28 #include "code/SCCache.hpp"
 29 #include "gc/shared/collectedHeap.inline.hpp"
 30 #include "oops/oop.inline.hpp"
 31 #include "runtime/jniHandles.inline.hpp"
 32 
 33 // ciObject
 34 //
 35 // This class represents an oop in the HotSpot virtual machine.
 36 // Its subclasses are structured in a hierarchy which mirrors
 37 // an aggregate of the VM's oop and klass hierarchies (see
 38 // oopHierarchy.hpp).  Each instance of ciObject holds a handle
 39 // to a corresponding oop on the VM side and provides routines
 40 // for accessing the information in its oop.  By using the ciObject
 41 // hierarchy for accessing oops in the VM, the compiler ensures
 42 // that it is safe with respect to garbage collection; that is,
 43 // GC and compilation can proceed independently without
 44 // interference.
 45 //
 46 // Within the VM, the oop and klass hierarchies are separate.
 47 // The compiler interface does not preserve this separation --
 48 // the distinction between `Klass*' and `Klass' are not

187   return ciConstant();
188 }
189 
190 // ------------------------------------------------------------------
191 // ciObject::add_to_constant_value_cache()
192 //
193 // Add a constant value to the cache.
194 void ciObject::add_to_constant_value_cache(int off, ciConstant val) {
195   assert(val.is_valid(), "value must be valid");
196   assert(!check_constant_value_cache(off, val.basic_type()).is_valid(), "duplicate");
197   if (_constant_values == nullptr) {
198     Arena* arena = CURRENT_ENV->arena();
199     _constant_values = new (arena) GrowableArray<ConstantValue>(arena, 1, 0, ConstantValue());
200   }
201   _constant_values->append(ConstantValue(off, val));
202 }
203 
204 // ------------------------------------------------------------------
205 // ciObject::should_be_constant()
206 bool ciObject::should_be_constant() {
207   if (ScavengeRootsInCode >= 2 && !(SCCache::is_on_for_write())) {
208     return true;  // force everybody to be a constant
209   }
210   if (is_null_object()) {
211     return true;
212   }
213   ciEnv* env = CURRENT_ENV;
214 
215   // We want Strings and Classes to be embeddable by default since
216   // they used to be in the perm world.  Not all Strings used to be
217   // embeddable but there's no easy way to distinguish the interned
218   // from the regulars ones so just treat them all that way.
219   if (klass() == env->String_klass() || klass() == env->Class_klass()) {
220     return true;
221   }
222   if ((klass()->is_subclass_of(env->MethodHandle_klass()) ||
223        klass()->is_subclass_of(env->CallSite_klass())) &&
224       !(SCCache::is_on_for_write())) { // For now disable it when caching startup code.
225     // We want to treat these aggressively.
226     return true;
227   }
228 
229   return handle() == nullptr;
230 }
231 
232 // ------------------------------------------------------------------
233 // ciObject::print
234 //
235 // Print debugging output about this ciObject.
236 //
237 // Implementation note: dispatch to the virtual print_impl behavior
238 // for this ciObject.
239 void ciObject::print(outputStream* st) {
240   st->print("<%s", type_string());
241   GUARDED_VM_ENTRY(print_impl(st);)
242   st->print(" ident=%d address=" INTPTR_FORMAT ">", ident(), p2i(this));
243 }
244 
< prev index next >