Mercurial > hg > graal-compiler
annotate c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerImpl.java @ 2288:8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 11 Apr 2011 10:37:24 +0200 |
parents | 762de4b26788 |
children | 175e7b4d7322 |
rev | line source |
---|---|
2285
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011 Sun Microsystems, Inc. All rights reserved. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * that is described in this document. In particular, and without limitation, these intellectual property |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * more additional patents or pending patent applications in the U.S. and in other countries. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * supplements. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * U.S. and other countries. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Company, Ltd. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 */ |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 package com.sun.hotspot.c1x; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 import java.io.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 import java.lang.management.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
25 import java.net.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
26 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import com.sun.c1x.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import com.sun.c1x.target.amd64.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import com.sun.cri.xir.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import com.sun.hotspot.c1x.logging.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.sun.hotspot.c1x.server.*; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 /** |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 * Singleton class holding the instance of the C1XCompiler. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 * |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 * @author Thomas Wuerthinger, Lukas Stadler |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 */ |
2288
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
38 public final class CompilerImpl implements Compiler, Remote { |
2285
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 private static Compiler theInstance; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 private static boolean PrintGCStats = false; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 private final VMEntries vmEntries; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 private final VMExits vmExits; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 private final C1XCompiler compiler; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 public static Compiler getInstance() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 if (theInstance == null) { |
2288
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
50 // remote compilation (will not create a C1XCompiler) |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
51 String remote = System.getProperty("c1x.remote"); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
52 if (remote != null) { |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
53 try { |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
54 System.out.println("C1X compiler started in client/server mode, server: " + remote); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
55 Socket socket = new Socket(remote, 1199); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
56 ReplacingStreams streams = new ReplacingStreams(socket.getOutputStream(), socket.getInputStream()); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
57 streams.getInvocation().sendResult(new VMEntriesNative()); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
58 |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
59 theInstance = (Compiler) streams.getInvocation().waitForResult(); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
60 } catch (IOException e1) { |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
61 System.out.println("Connection to compilation server FAILED."); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
62 throw new RuntimeException(e1); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
63 } catch (ClassNotFoundException e2) { |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
64 System.out.println("Connection to compilation server FAILED."); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
65 throw new RuntimeException(e2); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
66 } |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
67 } else { |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
68 theInstance = new CompilerImpl(null); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
69 Runtime.getRuntime().addShutdownHook(new ShutdownThread()); |
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
70 } |
2285
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
72 return theInstance; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
73 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 public static class ShutdownThread extends Thread { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
76 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
77 @Override |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
78 public void run() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
79 VMExitsNative.compileMethods = false; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
80 if (C1XOptions.PrintMetrics) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
81 C1XMetrics.print(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 if (C1XOptions.PrintTimers) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 C1XTimers.print(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 if (PrintGCStats) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
87 printGCStats(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 public static void printGCStats() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
93 long totalGarbageCollections = 0; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 long garbageCollectionTime = 0; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 long count = gc.getCollectionCount(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 if (count >= 0) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 totalGarbageCollections += count; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 long time = gc.getCollectionTime(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 if (time >= 0) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 garbageCollectionTime += time; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 System.out.println("Total Garbage Collections: " + totalGarbageCollections); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 public static Compiler initializeServer(VMEntries entries) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 assert theInstance == null; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 theInstance = new CompilerImpl(entries); |
2288
8c426c2891c8
client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents:
2285
diff
changeset
|
115 Runtime.getRuntime().addShutdownHook(new ShutdownThread()); |
2285
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 return theInstance; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 @Override |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 public VMEntries getVMEntries() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 return vmEntries; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 @Override |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 public VMExits getVMExits() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 return vmExits; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
127 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 private CompilerImpl(VMEntries entries) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 // initialize VMEntries |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 if (entries == null) |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 entries = new VMEntriesNative(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 // initialize VMExits |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 VMExits exits = new VMExitsNative(this); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 // logging, etc. |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 if (CountingProxy.ENABLED) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 exits = CountingProxy.getProxy(VMExits.class, exits); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 entries = CountingProxy.getProxy(VMEntries.class, entries); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
142 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 if (Logger.ENABLED) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 exits = LoggingProxy.getProxy(VMExits.class, exits); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 entries = LoggingProxy.getProxy(VMEntries.class, entries); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 // set the final fields |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
149 vmEntries = entries; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 vmExits = exits; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
151 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
152 // initialize compiler and C1XOptions |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
153 HotSpotVMConfig config = vmEntries.getConfiguration(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
154 config.check(); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
155 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 // these options are important - c1x4hotspot will not generate correct code without them |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
157 C1XOptions.GenSpecialDivChecks = true; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 C1XOptions.NullCheckUniquePc = true; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 C1XOptions.InvokeSnippetAfterArguments = true; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 C1XOptions.StackShadowPages = config.stackShadowPages; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 HotSpotRuntime runtime = new HotSpotRuntime(config, this); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
163 HotSpotRegisterConfig registerConfig = runtime.globalStubRegConfig; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
164 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 final int wordSize = 8; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 final int stackFrameAlignment = 16; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 HotSpotTarget target = new HotSpotTarget(new AMD64(), true, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, true); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 RiXirGenerator generator = new HotSpotXirGenerator(config, target, registerConfig, this); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 if (Logger.ENABLED) { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 generator = LoggingProxy.getProxy(RiXirGenerator.class, generator); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 compiler = new C1XCompiler(runtime, target, generator, registerConfig); |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
176 @Override |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 public C1XCompiler getCompiler() { |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 return compiler; |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 } |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
180 |
762de4b26788
turn Compiler and HotSpotTypeResolved into interfaces
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 } |