< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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  */


 465         HotSpotResolvedJavaMethodImpl method = null;
 466         if (methodCache == null) {
 467             methodCache = new HashMap<>(8);
 468         } else {
 469             method = methodCache.get(metaspaceMethod);
 470         }
 471         if (method == null) {
 472             method = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod);
 473             methodCache.put(metaspaceMethod, method);
 474             context.add(method);
 475         }
 476         return method;
 477     }
 478 
 479     public int getVtableLength() {
 480         HotSpotVMConfig config = config();
 481         if (isInterface() || isArray()) {
 482             /* Everything has the core vtable of java.lang.Object */
 483             return config.baseVtableLength();
 484         }
 485         int result = UNSAFE.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
 486         assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) + " " + config.vtableEntrySize;
 487         return result;
 488     }
 489 
 490     public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) {
 491         HotSpotResolvedJavaField result = null;
 492 
 493         final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers();
 494 
 495         final long id = offset + ((long) flags << 32);
 496 
 497         // Must cache the fields, because the local load elimination only works if the
 498         // objects from two field lookups are identical.
 499         if (fieldCache == null) {
 500             fieldCache = new HashMap<>(8);
 501         } else {
 502             result = fieldCache.get(id);
 503         }
 504 
 505         if (result == null) {
 506             result = new HotSpotResolvedJavaFieldImpl(this, fieldName, type, offset, rawFlags);


   1 /*
   2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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  */


 465         HotSpotResolvedJavaMethodImpl method = null;
 466         if (methodCache == null) {
 467             methodCache = new HashMap<>(8);
 468         } else {
 469             method = methodCache.get(metaspaceMethod);
 470         }
 471         if (method == null) {
 472             method = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod);
 473             methodCache.put(metaspaceMethod, method);
 474             context.add(method);
 475         }
 476         return method;
 477     }
 478 
 479     public int getVtableLength() {
 480         HotSpotVMConfig config = config();
 481         if (isInterface() || isArray()) {
 482             /* Everything has the core vtable of java.lang.Object */
 483             return config.baseVtableLength();
 484         }
 485         int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
 486         assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize;
 487         return result;
 488     }
 489 
 490     public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) {
 491         HotSpotResolvedJavaField result = null;
 492 
 493         final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers();
 494 
 495         final long id = offset + ((long) flags << 32);
 496 
 497         // Must cache the fields, because the local load elimination only works if the
 498         // objects from two field lookups are identical.
 499         if (fieldCache == null) {
 500             fieldCache = new HashMap<>(8);
 501         } else {
 502             result = fieldCache.get(id);
 503         }
 504 
 505         if (result == null) {
 506             result = new HotSpotResolvedJavaFieldImpl(this, fieldName, type, offset, rawFlags);


< prev index next >