Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java @ 21538:c1e2fdb5fea3
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 May 2015 17:20:39 +0200 |
parents | de0cf192779c |
children |
rev | line source |
---|---|
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
21529
de0cf192779c
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21414
diff
changeset
|
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
21529
de0cf192779c
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21414
diff
changeset
|
23 package com.oracle.graal.hotspot.jvmci; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
21529
de0cf192779c
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21414
diff
changeset
|
25 import static com.oracle.graal.hotspot.jvmci.HotSpotCompressedNullConstant.*; |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
26 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import java.lang.reflect.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
13725
8d8732e14447
Refactor reference maps.
Roland Schatz <roland.schatz@oracle.com>
parents:
13697
diff
changeset
|
31 import com.oracle.graal.api.code.CodeUtil.DefaultRefMapFormatter; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.api.code.CompilationResult.Call; |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
34 import com.oracle.graal.api.code.CompilationResult.ConstantReference; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.api.code.CompilationResult.DataPatch; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.api.code.CompilationResult.Infopoint; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.api.code.CompilationResult.Mark; |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
38 import com.oracle.graal.api.code.DataSection.Data; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
39 import com.oracle.graal.api.code.DataSection.DataBuilder; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.api.meta.*; |
13233
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
41 import com.oracle.graal.debug.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 /** |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 * HotSpot implementation of {@link CodeCacheProvider}. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 */ |
17447
f861021b49b8
Restructure CodeCacheProvider hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
17377
diff
changeset
|
46 public class HotSpotCodeCacheProvider implements CodeCacheProvider { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
21529
de0cf192779c
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21414
diff
changeset
|
48 protected final HotSpotJVMCIRuntimeProvider runtime; |
21413
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
49 public final HotSpotVMConfig config; |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
50 protected final TargetDescription target; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 protected final RegisterConfig regConfig; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
21529
de0cf192779c
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21414
diff
changeset
|
53 public HotSpotCodeCacheProvider(HotSpotJVMCIRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
54 this.runtime = runtime; |
21413
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
55 this.config = config; |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
56 this.target = target; |
17447
f861021b49b8
Restructure CodeCacheProvider hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
17377
diff
changeset
|
57 this.regConfig = regConfig; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 @Override |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 public String disassemble(CompilationResult compResult, InstalledCode installedCode) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode(); |
14929
de31e0f56fe7
don't try to disassemble deoptimized/invalidated nmethods
Doug Simon <doug.simon@oracle.com>
parents:
14574
diff
changeset
|
63 if (code == null) { |
de31e0f56fe7
don't try to disassemble deoptimized/invalidated nmethods
Doug Simon <doug.simon@oracle.com>
parents:
14574
diff
changeset
|
64 // Method was deoptimized/invalidated |
de31e0f56fe7
don't try to disassemble deoptimized/invalidated nmethods
Doug Simon <doug.simon@oracle.com>
parents:
14574
diff
changeset
|
65 return ""; |
de31e0f56fe7
don't try to disassemble deoptimized/invalidated nmethods
Doug Simon <doug.simon@oracle.com>
parents:
14574
diff
changeset
|
66 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 long start = installedCode == null ? 0L : installedCode.getStart(); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 if (compResult != null) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 HexCodeFile.addAnnotations(hcf, compResult.getAnnotations()); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 addExceptionHandlersComment(compResult, hcf); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 Register fp = regConfig.getFrameRegister(); |
13725
8d8732e14447
Refactor reference maps.
Roland Schatz <roland.schatz@oracle.com>
parents:
13697
diff
changeset
|
73 RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.arch, target.wordSize, fp, 0); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 for (Infopoint infopoint : compResult.getInfopoints()) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 if (infopoint instanceof Call) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 Call call = (Call) infopoint; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 if (call.debugInfo != null) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString()); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 addOperandComment(hcf, call.pcOffset, "{" + getTargetName(call) + "}"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 } else { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 if (infopoint.debugInfo != null) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString()); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
88 for (DataPatch site : compResult.getDataPatches()) { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
89 hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}"); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 for (Mark mark : compResult.getMarks()) { |
21413
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
92 hcf.addComment(mark.pcOffset, getMarkIdName((int) mark.id)); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 } |
18346
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
95 String hcfEmbeddedString = hcf.toEmbeddedString(); |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
96 return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString); |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
97 } |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
98 |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
99 /** |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
100 * Interface to the tool for disassembling an {@link HexCodeFile#toEmbeddedString() embedded} |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
101 * {@link HexCodeFile}. |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
102 */ |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
103 static class HexCodeFileDisTool { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
104 static final Method processMethod; |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
105 static { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
106 Method toolMethod = null; |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
107 try { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
108 Class<?> toolClass = Class.forName("com.oracle.max.hcfdis.HexCodeFileDis", true, ClassLoader.getSystemClassLoader()); |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
109 toolMethod = toolClass.getDeclaredMethod("processEmbeddedString", String.class); |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
110 } catch (Exception e) { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
111 // Tool not available on the class path |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
112 } |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
113 processMethod = toolMethod; |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
114 } |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
115 |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
116 public static String tryDisassemble(String hcfEmbeddedString) { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
117 if (processMethod != null) { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
118 try { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
119 return (String) processMethod.invoke(null, hcfEmbeddedString); |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
120 } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
121 // If the tool is available, for now let's be noisy when it fails |
21538
c1e2fdb5fea3
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21529
diff
changeset
|
122 throw new InternalError(e); |
18346
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
123 } |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
124 } |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
125 return hcfEmbeddedString; |
ddd7829c45b1
made HotSpotCodeCacheProvider attempt to load and use the hcfdis tool
Doug Simon <doug.simon@oracle.com>
parents:
18318
diff
changeset
|
126 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 |
21413
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
129 private String getMarkIdName(int markId) { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
130 Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
131 for (Field f : fields) { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
132 if (f.getName().startsWith("MARKID_")) { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
133 f.setAccessible(true); |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
134 try { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
135 if (f.getInt(runtime.getConfig()) == markId) { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
136 return f.getName(); |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
137 } |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
138 } catch (Exception e) { |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
139 } |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
140 } |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
141 } |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
142 return String.valueOf(markId); |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
143 } |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19766
diff
changeset
|
144 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 /** |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 * Decodes a call target to a mnemonic if possible. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 */ |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 private String getTargetName(Call call) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
149 Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 for (Field f : fields) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 if (f.getName().endsWith("Stub")) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 f.setAccessible(true); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 try { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
154 Object address = f.get(runtime.getConfig()); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 if (address.equals(call.target)) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 return f.getName() + ":0x" + Long.toHexString((Long) address); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 } catch (Exception e) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 return String.valueOf(call.target); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 if (!compResult.getExceptionHandlers().isEmpty()) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 String nl = HexCodeFile.NEW_LINE; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 for (CompilationResult.ExceptionHandler e : compResult.getExceptionHandlers()) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 buf.append(" ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 hcf.addComment(0, buf.toString()); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 private static void addOperandComment(HexCodeFile hcf, int pos, String comment) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 String oldValue = hcf.addOperandComment(pos, comment); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 assert oldValue == null : "multiple comments for operand of instruction at " + pos + ": " + comment + ", " + oldValue; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 @Override |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 public RegisterConfig getRegisterConfig() { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 return regConfig; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 @Override |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 public int getMinimumOutgoingSize() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
190 return runtime.getConfig().runtimeCallStackSize; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 |
15162
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
193 public InstalledCode logOrDump(InstalledCode installedCode, CompilationResult compResult) { |
13233
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
194 if (Debug.isDumpEnabled()) { |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
195 Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
196 } |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
197 if (Debug.isLogEnabled()) { |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
198 Debug.log("%s", disassemble(installedCode)); |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
199 } |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
200 return installedCode; |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
201 } |
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
202 |
19321
98592ae4b1fa
only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents:
19188
diff
changeset
|
203 public InstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv, boolean isDefault) { |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
204 if (compResult.getId() == -1) { |
14104 | 205 compResult.setId(method.allocateCompileId(compResult.getEntryBCI())); |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
206 } |
17377
58f45b63b802
CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents:
17341
diff
changeset
|
207 HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), isDefault); |
19321
98592ae4b1fa
only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents:
19188
diff
changeset
|
208 runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult, graalEnv), installedCode, method.getSpeculationLog()); |
13233
8ea51438445c
consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents:
12536
diff
changeset
|
209 return logOrDump(installedCode, compResult); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 @Override |
15162
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
213 public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log, InstalledCode predefinedInstalledCode) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
215 if (compResult.getId() == -1) { |
14104 | 216 compResult.setId(hotspotMethod.allocateCompileId(compResult.getEntryBCI())); |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
217 } |
15162
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
218 InstalledCode installedCode = predefinedInstalledCode; |
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
219 if (installedCode == null) { |
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
220 HotSpotInstalledCode code = new HotSpotNmethod(hotspotMethod, compResult.getName(), false); |
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
221 installedCode = code; |
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
222 } |
19426
dd8989d5547f
provide more detail when Graal code installation fails due to a failed dependency check
Doug Simon <doug.simon@oracle.com>
parents:
19321
diff
changeset
|
223 HotSpotCompiledNmethod compiledCode = new HotSpotCompiledNmethod(hotspotMethod, compResult); |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
224 int result = runtime.getCompilerToVM().installCode(compiledCode, installedCode, log); |
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
225 if (result != config.codeInstallResultOk) { |
19426
dd8989d5547f
provide more detail when Graal code installation fails due to a failed dependency check
Doug Simon <doug.simon@oracle.com>
parents:
19321
diff
changeset
|
226 String msg = compiledCode.getInstallationFailureMessage(); |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
227 String resultDesc = config.getCodeInstallResultDescription(result); |
19426
dd8989d5547f
provide more detail when Graal code installation fails due to a failed dependency check
Doug Simon <doug.simon@oracle.com>
parents:
19321
diff
changeset
|
228 if (msg != null) { |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
229 msg = String.format("Code installation failed: %s%n%s", resultDesc, msg); |
19766
29916dcee0b8
Verify dependencies when assertions are enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19678
diff
changeset
|
230 } else { |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
231 msg = String.format("Code installation failed: %s", resultDesc); |
19426
dd8989d5547f
provide more detail when Graal code installation fails due to a failed dependency check
Doug Simon <doug.simon@oracle.com>
parents:
19321
diff
changeset
|
232 } |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
233 if (result == config.codeInstallResultDependenciesInvalid) { |
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
234 throw new AssertionError(resultDesc + " " + msg); |
19766
29916dcee0b8
Verify dependencies when assertions are enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19678
diff
changeset
|
235 } |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
236 throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 } |
15162
dbb1fe8348e6
Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15161
diff
changeset
|
238 return logOrDump(installedCode, compResult); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
239 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 |
13669
034706a93f27
CodeCacheProvider.addMethod: add speculationLog argument
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13630
diff
changeset
|
241 @Override |
12531
7d5c3ffbee64
Refactoring of the frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12526
diff
changeset
|
242 public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { |
12526
04671d59e93b
Allow CodeCacheProvider to install default methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12456
diff
changeset
|
243 HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; |
17377
58f45b63b802
CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents:
17341
diff
changeset
|
244 return installMethod(hotspotMethod, compResult, 0L, true); |
12526
04671d59e93b
Allow CodeCacheProvider to install default methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12456
diff
changeset
|
245 } |
04671d59e93b
Allow CodeCacheProvider to install default methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
12456
diff
changeset
|
246 |
13697
e8bd4f3776ee
changed return type of HotSpotCodeCacheProvider.addExternalMethod to be HotSpotNmethod
Doug Simon <doug.simon@oracle.com>
parents:
13676
diff
changeset
|
247 public HotSpotNmethod addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method; |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
249 if (compResult.getId() == -1) { |
14104 | 250 compResult.setId(javaMethod.allocateCompileId(compResult.getEntryBCI())); |
13816
d006a6332db8
Make sure a compile id is assigned
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13725
diff
changeset
|
251 } |
13697
e8bd4f3776ee
changed return type of HotSpotCodeCacheProvider.addExternalMethod to be HotSpotNmethod
Doug Simon <doug.simon@oracle.com>
parents:
13676
diff
changeset
|
252 HotSpotNmethod code = new HotSpotNmethod(javaMethod, compResult.getName(), false, true); |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
253 HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compResult); |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
254 CompilerToVM vm = runtime.getCompilerToVM(); |
21414
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
255 int result = vm.installCode(compiled, code, null); |
b04f579c803f
removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21413
diff
changeset
|
256 if (result != runtime.getConfig().codeInstallResultOk) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 return null; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 } |
13697
e8bd4f3776ee
changed return type of HotSpotCodeCacheProvider.addExternalMethod to be HotSpotNmethod
Doug Simon <doug.simon@oracle.com>
parents:
13676
diff
changeset
|
259 return code; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
260 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
261 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
262 public boolean needsDataPatch(JavaConstant constant) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14929
diff
changeset
|
263 return constant instanceof HotSpotMetaspaceConstant; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
264 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
265 |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
266 public Data createDataItem(Constant constant) { |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
267 int size; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
268 DataBuilder builder; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
269 if (constant instanceof VMConstant) { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
270 VMConstant vmConstant = (VMConstant) constant; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
271 boolean compressed; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
272 long raw; |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
273 if (constant instanceof HotSpotObjectConstant) { |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
274 HotSpotObjectConstant c = (HotSpotObjectConstant) vmConstant; |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
275 compressed = c.isCompressed(); |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
276 raw = 0xDEADDEADDEADDEADL; |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
277 } else if (constant instanceof HotSpotMetaspaceConstant) { |
18543
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18525
diff
changeset
|
278 HotSpotMetaspaceConstant meta = (HotSpotMetaspaceConstant) constant; |
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18525
diff
changeset
|
279 compressed = meta.isCompressed(); |
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18525
diff
changeset
|
280 raw = meta.rawValue(); |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
281 } else { |
21538
c1e2fdb5fea3
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21529
diff
changeset
|
282 throw new InternalError(String.valueOf(constant)); |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
283 } |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
284 |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
285 size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
286 if (size == 4) { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
287 builder = (buffer, patch) -> { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
288 patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
289 buffer.putInt((int) raw); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
290 }; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
291 } else { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
292 assert size == 8; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
293 builder = (buffer, patch) -> { |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
294 patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
295 buffer.putLong(raw); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
296 }; |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
297 } |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
298 } else if (JavaConstant.isNull(constant)) { |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
299 boolean compressed = COMPRESSED_NULL.equals(constant); |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
300 size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
301 builder = DataBuilder.zero(size); |
19188
c79d0ed46368
Remove redundant code for Constant serialization.
Roland Schatz <roland.schatz@oracle.com>
parents:
18661
diff
changeset
|
302 } else if (constant instanceof SerializableConstant) { |
c79d0ed46368
Remove redundant code for Constant serialization.
Roland Schatz <roland.schatz@oracle.com>
parents:
18661
diff
changeset
|
303 SerializableConstant s = (SerializableConstant) constant; |
c79d0ed46368
Remove redundant code for Constant serialization.
Roland Schatz <roland.schatz@oracle.com>
parents:
18661
diff
changeset
|
304 size = s.getSerializedSize(); |
c79d0ed46368
Remove redundant code for Constant serialization.
Roland Schatz <roland.schatz@oracle.com>
parents:
18661
diff
changeset
|
305 builder = DataBuilder.serializable(s); |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14559
diff
changeset
|
306 } else { |
21538
c1e2fdb5fea3
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21529
diff
changeset
|
307 throw new InternalError(String.valueOf(constant)); |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14559
diff
changeset
|
308 } |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
309 |
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
17447
diff
changeset
|
310 return new Data(size, size, builder); |
14561
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14559
diff
changeset
|
311 } |
e14198669e5c
Make data patch system use vm specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14559
diff
changeset
|
312 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
313 @Override |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
314 public TargetDescription getTarget() { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
315 return target; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
316 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
317 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
318 public String disassemble(InstalledCode code) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 if (code.isValid()) { |
18318
0459da9d94c0
Fix HotSpotCodeCacheProvider.disassemble
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18289
diff
changeset
|
320 long codeBlob = code.getAddress(); |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
321 return runtime.getCompilerToVM().disassembleCodeBlob(codeBlob); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
322 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
323 return null; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
324 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 |
15358
c17d593ccafb
Add createSpeculationLog to CodeCacheProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
326 public SpeculationLog createSpeculationLog() { |
c17d593ccafb
Add createSpeculationLog to CodeCacheProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
327 return new HotSpotSpeculationLog(); |
c17d593ccafb
Add createSpeculationLog to CodeCacheProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
328 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
329 } |