1 /* 2 * Copyright (c) 2017, 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 */ 23 24 25 26 package jdk.tools.jaotc; 27 28 public final class StubInformation { 29 private int stubOffset; // the offset inside the code (text + stubOffset) 30 private int stubSize; // the stub size 31 private int dispatchJumpOffset; // offset after main dispatch jump instruction 32 private int resolveJumpOffset; // offset after jump instruction to runtime call resolution 33 // function. 34 private int resolveJumpStart; // offset of jump instruction to VM runtime call resolution 35 // function. 36 private int c2iJumpOffset; // offset after jump instruction to c2i adapter for static 37 // calls. 38 private int movOffset; // offset after move instruction which loads from got cell: 39 // - Method* for static call 40 // - Klass* for virtual call 41 42 private boolean isVirtual; // virtual call stub 43 44 // maybe add type of stub as well, right now we only have static stubs 45 46 StubInformation(int stubOffset, boolean isVirtual) { 47 this.stubOffset = stubOffset; 48 this.isVirtual = isVirtual; 49 this.stubSize = -1; 50 this.movOffset = -1; 51 this.c2iJumpOffset = -1; 52 this.resolveJumpOffset = -1; 53 this.resolveJumpStart = -1; 54 this.dispatchJumpOffset = -1; 55 } 56 57 int getOffset() { 58 return stubOffset; 59 } 60 61 boolean isVirtual() { 62 return isVirtual; 63 } 64 65 public void setSize(int stubSize) { 66 this.stubSize = stubSize; 67 } 68 69 int getSize() { 70 return stubSize; 71 } 72 73 public void setMovOffset(int movOffset) { 74 this.movOffset = movOffset + stubOffset; 75 } 76 77 int getMovOffset() { 78 return movOffset; 79 } 80 81 public void setC2IJumpOffset(int c2iJumpOffset) { 82 this.c2iJumpOffset = c2iJumpOffset + stubOffset; 83 } 84 85 int getC2IJumpOffset() { 86 return c2iJumpOffset; 87 } 88 89 public void setResolveJumpOffset(int resolveJumpOffset) { 90 this.resolveJumpOffset = resolveJumpOffset + stubOffset; 91 } 92 93 int getResolveJumpOffset() { 94 return resolveJumpOffset; 95 } 96 97 public void setResolveJumpStart(int resolveJumpStart) { 98 this.resolveJumpStart = resolveJumpStart + stubOffset; 99 } 100 101 int getResolveJumpStart() { 102 return resolveJumpStart; 103 } 104 105 public void setDispatchJumpOffset(int dispatchJumpOffset) { 106 this.dispatchJumpOffset = dispatchJumpOffset + stubOffset; 107 } 108 109 int getDispatchJumpOffset() { 110 return dispatchJumpOffset; 111 } 112 113 void verify() { 114 assert stubOffset > 0 : "incorrect stubOffset: " + stubOffset; 115 assert stubSize > 0 : "incorrect stubSize: " + stubSize; 116 assert movOffset > 0 : "incorrect movOffset: " + movOffset; 117 assert dispatchJumpOffset > 0 : "incorrect dispatchJumpOffset: " + dispatchJumpOffset; 118 assert resolveJumpStart > 0 : "incorrect resolveJumpStart: " + resolveJumpStart; 119 assert resolveJumpOffset > 0 : "incorrect resolveJumpOffset: " + resolveJumpOffset; 120 if (!isVirtual) { 121 assert c2iJumpOffset > 0 : "incorrect c2iJumpOffset: " + c2iJumpOffset; 122 } 123 } 124 }