comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java @ 1423:760213a60e8b

* rewrite of the code installation * partial support for safepoints * macro-based CiTargetMethod interface * code stub support
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 16 Aug 2010 18:59:36 -0700
parents 3483ec571caf
children abc670a709dc
comparison
equal deleted inserted replaced
1422:3483ec571caf 1423:760213a60e8b
1 /* 1 /*
2 * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. 2 * Copyright (c) 2009-2010 Sun Microsystems, Inc. All rights reserved.
3 * 3 *
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is 4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is
5 * described in this document. In particular, and without limitation, these intellectual property rights may include one 5 * described in this document. In particular, and without limitation, these intellectual property rights may include one
6 * or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent 6 * or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent
7 * applications in the U.S. and in other countries. 7 * applications in the U.S. and in other countries.
16 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. 16 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd.
17 */ 17 */
18 18
19 package com.sun.hotspot.c1x; 19 package com.sun.hotspot.c1x;
20 20
21 import java.lang.reflect.*; 21 import java.io.*;
22 22
23 import com.sun.cri.ci.*; 23 import com.sun.cri.ci.*;
24 import com.sun.cri.ri.*; 24 import com.sun.cri.ri.*;
25 import com.sun.hotspot.c1x.logging.*;
25 26
26 /** 27 /**
27 * Exits from the HotSpot VM into Java code. 28 * Exits from the HotSpot VM into Java code.
28 * 29 *
29 * @author Thomas Wuerthinger, Lukas Stadler 30 * @author Thomas Wuerthinger, Lukas Stadler
30 */ 31 */
31 public class VMExitsNative implements VMExits { 32 public class VMExitsNative implements VMExits {
32 33
33 @Override 34 @Override
34 public void compileMethod(Method method, int entry_bci) { 35 public void compileMethod(long methodVmId, String name, int entry_bci) {
35 try { 36 try {
37 Logger.info("compiling " + name + " (" + methodVmId + ")");
36 Compiler compiler = Compiler.getInstance(); 38 Compiler compiler = Compiler.getInstance();
37 HotSpotMethod riMethod = new HotSpotMethod(method); 39 HotSpotMethod riMethod = new HotSpotMethod(methodVmId, name);
38 CiResult result = compiler.getCompiler().compileMethod(riMethod, null); 40 CiResult result = compiler.getCompiler().compileMethod(riMethod, null);
39 41
40 if (result.bailout() != null) { 42 if (result.bailout() != null) {
41 System.out.println("Bailout:"); 43 StringWriter out = new StringWriter();
42 result.bailout().printStackTrace(); 44 result.bailout().printStackTrace(new PrintWriter(out));
45 Logger.info("Bailout:\n" + out.toString());
43 } else { 46 } else {
44 Logger.log("Compilation result: " + result.targetMethod()); 47 Logger.log("Compilation result: " + result.targetMethod());
45 HotSpotTargetMethod.installCode(compiler.getConfig(), riMethod, result.targetMethod()); 48 HotSpotTargetMethod.installMethod(riMethod, result.targetMethod());
46 } 49 }
47 } catch (Throwable t) { 50 } catch (Throwable t) {
48 System.out.println("Compilation interrupted:"); 51 StringWriter out = new StringWriter();
49 t.printStackTrace(); 52 t.printStackTrace(new PrintWriter(out));
50 if (t instanceof RuntimeException) { 53 Logger.info("Compilation interrupted:\n" + out.toString());
51 throw (RuntimeException) t;
52 }
53 throw new RuntimeException(t);
54 } 54 }
55 } 55 }
56 56
57 @Override 57 @Override
58 public RiMethod createRiMethod(Method method) { 58 public RiMethod createRiMethod(long vmId, String name) {
59 RiMethod m = new HotSpotMethod(method); 59 RiMethod m = new HotSpotMethod(vmId, name);
60 return m; 60 return m;
61 } 61 }
62 62
63 @Override 63 @Override
64 public RiSignature createRiSignature(String signature) { 64 public RiSignature createRiSignature(String signature) {
69 public RiField createRiField(RiType holder, String name, RiType type, int offset) { 69 public RiField createRiField(RiType holder, String name, RiType type, int offset) {
70 return new HotSpotField(holder, name, type, offset); 70 return new HotSpotField(holder, name, type, offset);
71 } 71 }
72 72
73 @Override 73 @Override
74 public RiType createRiType(Class<?> klassOop) { 74 public RiType createRiType(long vmId, String name) {
75 return new HotSpotType(klassOop); 75 return new HotSpotTypeResolved(vmId, name);
76 } 76 }
77 77
78 @Override 78 @Override
79 public RiType createRiTypePrimitive(int basicType) { 79 public RiType createRiTypePrimitive(int basicType) {
80 CiKind kind = null; 80 CiKind kind = null;
111 } 111 }
112 return new HotSpotTypePrimitive(kind); 112 return new HotSpotTypePrimitive(kind);
113 } 113 }
114 114
115 @Override 115 @Override
116 public RiType createRiTypeUnresolved(String name, Class<?> accessingKlassOop) { 116 public RiType createRiTypeUnresolved(String name, long accessingClassVmId) {
117 return new HotSpotTypeUnresolved(name); 117 return new HotSpotTypeUnresolved(name, accessingClassVmId);
118 } 118 }
119 119
120 @Override 120 @Override
121 public RiConstantPool createRiConstantPool(Class<?> constantPoolOop) { 121 public RiConstantPool createRiConstantPool(long vmId) {
122 return new HotSpotConstantPool(constantPoolOop); 122 return new HotSpotConstantPool(vmId);
123 } 123 }
124 124
125 @Override 125 @Override
126 public CiConstant createCiConstantInt(int value) { 126 public CiConstant createCiConstantInt(int value) {
127 return CiConstant.forInt(value); 127 return CiConstant.forInt(value);
141 public CiConstant createCiConstantDouble(double value) { 141 public CiConstant createCiConstantDouble(double value) {
142 return CiConstant.forDouble(value); 142 return CiConstant.forDouble(value);
143 } 143 }
144 144
145 @Override 145 @Override
146 public CiConstant createCiConstantObject(Object value) { 146 public CiConstant createCiConstantObject(long vmId) {
147 return CiConstant.forObject(value); 147 return CiConstant.forObject(vmId);
148 } 148 }
149 } 149 }