mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
Merge
This commit is contained in:
commit
dff9c7f852
3 changed files with 52 additions and 28 deletions
|
@ -272,9 +272,10 @@ public class Bytecodes {
|
|||
public static final int _fast_aldc = 229;
|
||||
public static final int _fast_aldc_w = 230;
|
||||
public static final int _return_register_finalizer = 231;
|
||||
public static final int _shouldnotreachhere = 232; // For debugging
|
||||
public static final int _invokehandle = 232;
|
||||
public static final int _shouldnotreachhere = 233; // For debugging
|
||||
|
||||
public static final int number_of_codes = 233;
|
||||
public static final int number_of_codes = 234;
|
||||
|
||||
// Flag bits derived from format strings, can_trap, can_rewrite, etc.:
|
||||
// semantic flags:
|
||||
|
@ -787,20 +788,22 @@ public class Bytecodes {
|
|||
def(_fast_aaccess_0 , "fast_aaccess_0" , "b_JJ" , null , BasicType.getTObject() , 1, true , _aload_0 );
|
||||
def(_fast_faccess_0 , "fast_faccess_0" , "b_JJ" , null , BasicType.getTObject() , 1, true , _aload_0 );
|
||||
|
||||
def(_fast_iload , "fast_iload" , "bi" , null , BasicType.getTInt() , 1, false, _iload);
|
||||
def(_fast_iload2 , "fast_iload2" , "bi_i" , null , BasicType.getTInt() , 2, false, _iload);
|
||||
def(_fast_icaload , "fast_icaload" , "bi_" , null , BasicType.getTInt() , 0, false, _iload);
|
||||
def(_fast_iload , "fast_iload" , "bi" , null , BasicType.getTInt() , 1, false, _iload );
|
||||
def(_fast_iload2 , "fast_iload2" , "bi_i" , null , BasicType.getTInt() , 2, false, _iload );
|
||||
def(_fast_icaload , "fast_icaload" , "bi_" , null , BasicType.getTInt() , 0, false, _iload );
|
||||
|
||||
// Faster method invocation.
|
||||
def(_fast_invokevfinal , "fast_invokevfinal" , "bJJ" , null , BasicType.getTIllegal(), -1, true, _invokevirtual);
|
||||
def(_fast_invokevfinal , "fast_invokevfinal" , "bJJ" , null , BasicType.getTIllegal(), -1, true, _invokevirtual );
|
||||
|
||||
def(_fast_linearswitch , "fast_linearswitch" , "" , null , BasicType.getTVoid() , -1, false, _lookupswitch );
|
||||
def(_fast_binaryswitch , "fast_binaryswitch" , "" , null , BasicType.getTVoid() , -1, false, _lookupswitch );
|
||||
def(_fast_aldc , "fast_aldc" , "bj" , null , BasicType.getTObject(), 1, true, _ldc );
|
||||
def(_fast_aldc_w , "fast_aldc_w" , "bJJ" , null , BasicType.getTObject(), 1, true, _ldc_w );
|
||||
|
||||
def(_return_register_finalizer, "return_register_finalizer", "b" , null , BasicType.getTVoid() , 0, true, _return );
|
||||
|
||||
def(_fast_aldc , "fast_aldc" , "bj" , null , BasicType.getTObject(), 1, true, _ldc );
|
||||
def(_fast_aldc_w , "fast_aldc_w" , "bJJ" , null , BasicType.getTObject(), 1, true, _ldc_w );
|
||||
// special handling of signature-polymorphic methods
|
||||
def(_invokehandle , "invokehandle" , "bJJ" , null , BasicType.getTIllegal(), -1, true, _invokevirtual );
|
||||
|
||||
def(_shouldnotreachhere , "_shouldnotreachhere" , "b" , null , BasicType.getTVoid() , 0, false);
|
||||
|
||||
|
|
|
@ -30,24 +30,10 @@ import sun.jvm.hotspot.utilities.PlatformInfo;
|
|||
/** Encapsulates some byte-swapping operations defined in the VM */
|
||||
|
||||
public class Bytes {
|
||||
// swap if client platform is different from server's.
|
||||
private boolean swap;
|
||||
|
||||
public Bytes(MachineDescription machDesc) {
|
||||
String cpu = PlatformInfo.getCPU();
|
||||
if (cpu.equals("sparc")) {
|
||||
if (machDesc.isBigEndian()) {
|
||||
swap = false;
|
||||
} else {
|
||||
swap = true;
|
||||
}
|
||||
} else { // intel
|
||||
if (machDesc.isBigEndian()) {
|
||||
swap = true;
|
||||
} else {
|
||||
swap = false;
|
||||
}
|
||||
}
|
||||
swap = !machDesc.isBigEndian();
|
||||
}
|
||||
|
||||
/** Should only swap if the hardware's underlying byte order is
|
||||
|
|
|
@ -29,6 +29,11 @@ import sun.jvm.hotspot.interpreter.*;
|
|||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
|
||||
public class ByteCodeRewriter
|
||||
{
|
||||
|
@ -38,8 +43,20 @@ public class ByteCodeRewriter
|
|||
private byte[] code;
|
||||
private Bytes bytes;
|
||||
|
||||
public static final boolean DEBUG = false;
|
||||
private static final int jintSize = 4;
|
||||
public static final boolean DEBUG;
|
||||
|
||||
static {
|
||||
String debug = (String) AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public Object run() {
|
||||
return System.getProperty("sun.jvm.hotspot.tools.jcore.ByteCodeRewriter.DEBUG");
|
||||
}
|
||||
}
|
||||
);
|
||||
DEBUG = (debug != null ? debug.equalsIgnoreCase("true") : false);
|
||||
}
|
||||
|
||||
|
||||
protected void debugMessage(String message) {
|
||||
System.out.println(message);
|
||||
|
@ -54,6 +71,18 @@ public class ByteCodeRewriter
|
|||
|
||||
}
|
||||
|
||||
protected short getConstantPoolIndexFromRefMap(int rawcode, int bci) {
|
||||
int refIndex;
|
||||
String fmt = Bytecodes.format(rawcode);
|
||||
switch (fmt.length()) {
|
||||
case 2: refIndex = 0xFF & method.getBytecodeByteArg(bci); break;
|
||||
case 3: refIndex = 0xFFFF & bytes.swapShort(method.getBytecodeShortArg(bci)); break;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return (short)cpool.objectToCPIndex(refIndex);
|
||||
}
|
||||
|
||||
protected short getConstantPoolIndex(int rawcode, int bci) {
|
||||
// get ConstantPool index from ConstantPoolCacheIndex at given bci
|
||||
String fmt = Bytecodes.format(rawcode);
|
||||
|
@ -95,6 +124,12 @@ public class ByteCodeRewriter
|
|||
int hotspotcode = Bytecodes._illegal;
|
||||
int len = 0;
|
||||
|
||||
if (DEBUG) {
|
||||
String msg = method.getMethodHolder().getName().asString() + "." +
|
||||
method.getName().asString() +
|
||||
method.getSignature().asString();
|
||||
debugMessage(msg);
|
||||
}
|
||||
for (int bci = 0; bci < code.length;) {
|
||||
hotspotcode = Bytecodes.codeAt(method, bci);
|
||||
bytecode = Bytecodes.javaCode(hotspotcode);
|
||||
|
@ -133,15 +168,15 @@ public class ByteCodeRewriter
|
|||
|
||||
case Bytecodes._ldc_w:
|
||||
if (hotspotcode != bytecode) {
|
||||
// fast_aldc_w puts constant in CP cache
|
||||
cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
|
||||
// fast_aldc_w puts constant in reference map
|
||||
cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
|
||||
writeShort(code, bci + 1, cpoolIndex);
|
||||
}
|
||||
break;
|
||||
case Bytecodes._ldc:
|
||||
if (hotspotcode != bytecode) {
|
||||
// fast_aldc puts constant in CP cache
|
||||
cpoolIndex = getConstantPoolIndex(hotspotcode, bci + 1);
|
||||
// fast_aldc puts constant in reference map
|
||||
cpoolIndex = getConstantPoolIndexFromRefMap(hotspotcode, bci + 1);
|
||||
code[bci + 1] = (byte)(cpoolIndex);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue