Mercurial > hg > truffle
annotate c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java @ 2284:569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 07 Apr 2011 15:32:25 +0200 |
parents | 76607939e139 |
children | 762de4b26788 |
rev | line source |
---|---|
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
1 /* |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
2 * Copyright (c) 2011 Sun Microsystems, Inc. All rights reserved. |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
3 * |
1437
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
5 * that is described in this document. In particular, and without limitation, these intellectual property |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
7 * more additional patents or pending patent applications in the U.S. and in other countries. |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
8 * |
1437
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
11 * supplements. |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
12 * |
1437
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
16 * U.S. and other countries. |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
17 * |
1437
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open |
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
19 * Company, Ltd. |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
20 */ |
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
21 package com.sun.hotspot.c1x; |
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
22 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
23 import java.io.*; |
2054
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
24 import java.lang.management.*; |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
25 import java.lang.reflect.Proxy; |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
26 import java.net.*; |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
27 |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
28 import com.sun.c1x.*; |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
29 import com.sun.c1x.target.amd64.*; |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
30 import com.sun.cri.xir.*; |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
31 import com.sun.hotspot.c1x.logging.*; |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
32 import com.sun.hotspot.c1x.server.CompilationServer.ReplacingInputStream; |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
33 import com.sun.hotspot.c1x.server.CompilationServer.ReplacingOutputStream; |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
34 |
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
35 /** |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
36 * Singleton class holding the instance of the C1XCompiler. |
1420
44efca8a02d6
reformatting similar to other maxine projects (tabs, etc.)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1419
diff
changeset
|
37 * |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
38 * @author Thomas Wuerthinger, Lukas Stadler |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
39 */ |
1437
9e5e83ca2259
Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1434
diff
changeset
|
40 public final class Compiler { |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
41 |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
42 private static Compiler theInstance; |
2054
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
43 private static boolean PrintGCStats = false; |
1420
44efca8a02d6
reformatting similar to other maxine projects (tabs, etc.)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1419
diff
changeset
|
44 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
45 private final VMEntries vmEntries; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
46 private final VMExits vmExits; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
47 |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
48 public static Compiler getInstance() { |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
49 if (theInstance == null) { |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
50 theInstance = new Compiler(null); |
1438
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
51 Runtime.getRuntime().addShutdownHook(new ShutdownThread()); |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
52 } |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
53 return theInstance; |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
54 } |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
55 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
56 public static class ShutdownThread extends Thread { |
1420
44efca8a02d6
reformatting similar to other maxine projects (tabs, etc.)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1419
diff
changeset
|
57 |
1438
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
58 @Override |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
59 public void run() { |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
60 VMExitsNative.compileMethods = false; |
1465
2c754f3a2722
Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1458
diff
changeset
|
61 if (C1XOptions.PrintMetrics) { |
2c754f3a2722
Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1458
diff
changeset
|
62 C1XMetrics.print(); |
2c754f3a2722
Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1458
diff
changeset
|
63 } |
1438
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
64 if (C1XOptions.PrintTimers) { |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
65 C1XTimers.print(); |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
66 } |
2054
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
67 if (PrintGCStats) { |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
68 printGCStats(); |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
69 } |
1438
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
70 } |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
71 } |
a7a0ef3c6858
Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1437
diff
changeset
|
72 |
2054
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
73 public static void printGCStats() { |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
74 long totalGarbageCollections = 0; |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
75 long garbageCollectionTime = 0; |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
76 |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
77 for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) { |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
78 long count = gc.getCollectionCount(); |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
79 if (count >= 0) { |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
80 totalGarbageCollections += count; |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
81 } |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
82 |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
83 long time = gc.getCollectionTime(); |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
84 if (time >= 0) { |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
85 garbageCollectionTime += time; |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
86 } |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
87 } |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
88 |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
89 System.out.println("Total Garbage Collections: " + totalGarbageCollections); |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
90 System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime); |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
91 } |
3c0a889a176b
Added GC stats. Enabling intrinsics.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1933
diff
changeset
|
92 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
93 public static Compiler initializeServer(VMEntries entries) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
94 assert theInstance == null; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
95 theInstance = new Compiler(entries); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
96 return theInstance; |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
97 } |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
98 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
99 public VMEntries getVMEntries() { |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
100 return vmEntries; |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
101 } |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
102 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
103 public VMExits getVMExits() { |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
104 return vmExits; |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
105 } |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
106 |
2278
76607939e139
Up-to-date with CRI changes.
Doug Simon <doug.simon@oracle.com>
parents:
2057
diff
changeset
|
107 private final C1XCompiler compiler; |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
108 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
109 private Compiler(VMEntries entries) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
110 // remote compilation (will not create a C1XCompiler) |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
111 String remote = System.getProperty("c1x.remote"); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
112 if (remote != null) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
113 try { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
114 System.out.println("C1X compiler started in client/server mode, server: " + remote); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
115 Socket socket = new Socket(remote, 1199); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
116 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
117 ReplacingOutputStream output = new ReplacingOutputStream(new BufferedOutputStream(socket.getOutputStream())); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
118 // required, because creating an ObjectOutputStream writes a header, but doesn't flush the stream |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
119 output.flush(); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
120 ReplacingInputStream input = new ReplacingInputStream(new BufferedInputStream(socket.getInputStream())); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
121 input.setCompiler(this); |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
122 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
123 InvocationSocket invocation = new InvocationSocket(output, input); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
124 vmEntries = new VMEntriesNative(); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
125 vmExits = (VMExits) Proxy.newProxyInstance(VMExits.class.getClassLoader(), new Class<?>[] { VMExits.class}, invocation); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
126 invocation.setDelegate(vmEntries); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
127 compiler = null; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
128 return; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
129 } catch (IOException t) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
130 System.out.println("Connection to compilation server FAILED."); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
131 throw new RuntimeException(t); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
132 } |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
133 } |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
134 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
135 // initialize VMEntries |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
136 if (entries == null) |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
137 entries = new VMEntriesNative(); |
1433
efba53f86c4f
various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
138 |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
139 // initialize VMExits |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
140 VMExits exits = new VMExitsNative(this); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
141 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
142 // logging, etc. |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
143 if (CountingProxy.ENABLED) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
144 exits = CountingProxy.getProxy(VMExits.class, exits); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
145 entries = CountingProxy.getProxy(VMEntries.class, entries); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
146 } |
1433
efba53f86c4f
various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
147 if (Logger.ENABLED) { |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
148 exits = LoggingProxy.getProxy(VMExits.class, exits); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
149 entries = LoggingProxy.getProxy(VMEntries.class, entries); |
1433
efba53f86c4f
various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
150 } |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
151 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
152 // set the final fields |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
153 vmEntries = entries; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
154 vmExits = exits; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
155 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
156 // initialize compiler and C1XOptions |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
157 HotSpotVMConfig config = vmEntries.getConfiguration(); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
158 config.check(); |
1420
44efca8a02d6
reformatting similar to other maxine projects (tabs, etc.)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1419
diff
changeset
|
159 |
1434
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1433
diff
changeset
|
160 // these options are important - c1x4hotspot will not generate correct code without them |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
161 C1XOptions.GenSpecialDivChecks = true; |
1433
efba53f86c4f
various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1429
diff
changeset
|
162 C1XOptions.NullCheckUniquePc = true; |
2057
89bf01e6b049
Treat C1XOptions fields as final.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
2054
diff
changeset
|
163 C1XOptions.InvokeSnippetAfterArguments = true; |
1434
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1433
diff
changeset
|
164 C1XOptions.StackShadowPages = config.stackShadowPages; |
2284
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
165 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
166 HotSpotRuntime runtime = new HotSpotRuntime(config, this); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
167 HotSpotRegisterConfig registerConfig = runtime.globalStubRegConfig; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
168 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
169 final int wordSize = 8; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
170 final int stackFrameAlignment = 16; |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
171 HotSpotTarget target = new HotSpotTarget(new AMD64(), true, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, true); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
172 |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
173 RiXirGenerator generator = new HotSpotXirGenerator(config, target, registerConfig, this); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
174 if (Logger.ENABLED) { |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
175 generator = LoggingProxy.getProxy(RiXirGenerator.class, generator); |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
176 } |
569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
2278
diff
changeset
|
177 compiler = new C1XCompiler(runtime, target, generator, registerConfig); |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
178 } |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
179 |
2278
76607939e139
Up-to-date with CRI changes.
Doug Simon <doug.simon@oracle.com>
parents:
2057
diff
changeset
|
180 public C1XCompiler getCompiler() { |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
181 return compiler; |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
182 } |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1420
diff
changeset
|
183 |
1416
1b41af477605
Added HotSpotVM project Java source files.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
184 } |