< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2014, 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  */


 580             // Go to the next LocalVariableTableElement
 581             localVariableTableElement += config.localVariableTableElementSize;
 582         }
 583 
 584         return new LocalVariableTableImpl(locals);
 585     }
 586 
 587     /**
 588      * Returns the offset of this method into the v-table. The method must have a v-table entry as
 589      * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
 590      * thrown.
 591      *
 592      * @return the offset of this method into the v-table
 593      */
 594     public int vtableEntryOffset(ResolvedJavaType resolved) {
 595         if (!isInVirtualMethodTable(resolved)) {
 596             throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved);
 597         }
 598         HotSpotVMConfig config = config();
 599         final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved);
 600         return config.instanceKlassVtableStartOffset() + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
 601     }
 602 
 603     @Override
 604     public boolean isInVirtualMethodTable(ResolvedJavaType resolved) {
 605         if (resolved instanceof HotSpotResolvedObjectTypeImpl) {
 606             HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved;
 607             int vtableIndex = getVtableIndex(hotspotResolved);
 608             return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength();
 609         }
 610         return false;
 611     }
 612 
 613     private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) {
 614         if (!holder.isLinked()) {
 615             return config().invalidVtableIndex;
 616         }
 617         if (holder.isInterface()) {
 618             if (resolved.isInterface()) {
 619                 return config().invalidVtableIndex;
 620             }


   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  */


 580             // Go to the next LocalVariableTableElement
 581             localVariableTableElement += config.localVariableTableElementSize;
 582         }
 583 
 584         return new LocalVariableTableImpl(locals);
 585     }
 586 
 587     /**
 588      * Returns the offset of this method into the v-table. The method must have a v-table entry as
 589      * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
 590      * thrown.
 591      *
 592      * @return the offset of this method into the v-table
 593      */
 594     public int vtableEntryOffset(ResolvedJavaType resolved) {
 595         if (!isInVirtualMethodTable(resolved)) {
 596             throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved);
 597         }
 598         HotSpotVMConfig config = config();
 599         final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved);
 600         return config.instanceKlassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
 601     }
 602 
 603     @Override
 604     public boolean isInVirtualMethodTable(ResolvedJavaType resolved) {
 605         if (resolved instanceof HotSpotResolvedObjectTypeImpl) {
 606             HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved;
 607             int vtableIndex = getVtableIndex(hotspotResolved);
 608             return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength();
 609         }
 610         return false;
 611     }
 612 
 613     private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) {
 614         if (!holder.isLinked()) {
 615             return config().invalidVtableIndex;
 616         }
 617         if (holder.isInterface()) {
 618             if (resolved.isInterface()) {
 619                 return config().invalidVtableIndex;
 620             }


< prev index next >