comparison graal/Runtime/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java @ 2297:099e697d8934

Renaming c1x4hotspotsrc => graal and HotSpotVM => Runtime
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 22 Apr 2011 15:08:53 +0200
parents
children
comparison
equal deleted inserted replaced
2296:34354e2e40a3 2297:099e697d8934
1 /*
2 * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
5 * that is described in this document. In particular, and without limitation, these intellectual property
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
7 * more additional patents or pending patent applications in the U.S. and in other countries.
8 *
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
11 * supplements.
12 *
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
16 * U.S. and other countries.
17 *
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
19 * Company, Ltd.
20 */
21 package com.sun.hotspot.c1x;
22
23 import java.util.*;
24
25 import com.sun.cri.ci.*;
26 import com.sun.cri.ci.CiTargetMethod.*;
27 import com.sun.hotspot.c1x.logging.*;
28
29 /**
30 * CiTargetMethod augmented with HotSpot-specific information.
31 *
32 * @author Lukas Stadler
33 */
34 public final class HotSpotTargetMethod extends CompilerObject {
35
36 public final CiTargetMethod targetMethod;
37 public final HotSpotMethodResolved method; // used only for methods
38 public final String name; // used only for stubs
39
40 public final Site[] sites;
41 public final ExceptionHandler[] exceptionHandlers;
42
43 private HotSpotTargetMethod(Compiler compiler, HotSpotMethodResolved method, CiTargetMethod targetMethod) {
44 super(compiler);
45 this.method = method;
46 this.targetMethod = targetMethod;
47 this.name = null;
48
49 sites = getSortedSites(targetMethod);
50 if (targetMethod.exceptionHandlers == null) {
51 exceptionHandlers = null;
52 } else {
53 exceptionHandlers = targetMethod.exceptionHandlers.toArray(new ExceptionHandler[targetMethod.exceptionHandlers.size()]);
54 }
55 }
56
57 private HotSpotTargetMethod(Compiler compiler, CiTargetMethod targetMethod, String name) {
58 super(compiler);
59 this.method = null;
60 this.targetMethod = targetMethod;
61 this.name = name;
62
63 sites = getSortedSites(targetMethod);
64 assert targetMethod.exceptionHandlers == null || targetMethod.exceptionHandlers.size() == 0;
65 exceptionHandlers = null;
66 }
67
68 private Site[] getSortedSites(CiTargetMethod target) {
69 List<?>[] lists = new List<?>[] {target.directCalls, target.indirectCalls, target.safepoints, target.dataReferences, target.marks};
70 int count = 0;
71 for (List<?> list : lists) {
72 count += list.size();
73 }
74 Site[] result = new Site[count];
75 int pos = 0;
76 for (List<?> list : lists) {
77 for (Object elem : list) {
78 result[pos++] = (Site) elem;
79 }
80 }
81 Arrays.sort(result, new Comparator<Site>() {
82
83 public int compare(Site s1, Site s2) {
84 if (s1.pcOffset == s2.pcOffset && (s1 instanceof Mark ^ s2 instanceof Mark)) {
85 return s1 instanceof Mark ? -1 : 1;
86 }
87 return s1.pcOffset - s2.pcOffset;
88 }
89 });
90 if (Logger.ENABLED) {
91 for (Site site : result) {
92 Logger.log(site.pcOffset + ": " + site);
93 }
94 }
95 return result;
96 }
97
98 public static void installMethod(Compiler compiler, HotSpotMethodResolved method, CiTargetMethod targetMethod) {
99 compiler.getVMEntries().installMethod(new HotSpotTargetMethod(compiler, method, targetMethod));
100 }
101
102 public static Object installStub(Compiler compiler, CiTargetMethod targetMethod, String name) {
103 return compiler.getVMEntries().installStub(new HotSpotTargetMethod(compiler, targetMethod, name));
104 }
105
106 }