annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotInstalledCode.java @ 21546:7306a4dba8ce

removed dependency from JVMCI class HotSpotResolvedJavaMethodImpl to non-JVMCI class StructuredGraph (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Tue, 26 May 2015 00:40:36 +0200
parents 5e868236654f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
21541
5e868236654f moved UnsafeAccess to com.oracle.jvmci.common (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17123
diff changeset
23 package com.oracle.graal.hotspot.jvmci;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
21541
5e868236654f moved UnsafeAccess to com.oracle.jvmci.common (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 17123
diff changeset
25 import static com.oracle.jvmci.common.UnsafeAccess.*;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14906
diff changeset
26 import sun.misc.*;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 9041
diff changeset
27
5855
0278da961319 moved InstalledCode from graal.api.meta to graal.api.code
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
28 import com.oracle.graal.api.code.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
30 import edu.umd.cs.findbugs.annotations.*;
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
31
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 /**
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
33 * Implementation of {@link InstalledCode} for HotSpot.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
35 public abstract class HotSpotInstalledCode extends InstalledCode {
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
36
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
37 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
38 * Total size of the code blob.
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
39 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
40 @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int size;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
42 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
43 * Start address of the code.
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
44 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
45 @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private long codeStart;
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
46
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
47 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
48 * Size of the code.
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
49 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
50 @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int codeSize;
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
51
16401
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15291
diff changeset
52 public HotSpotInstalledCode(String name) {
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15291
diff changeset
53 super(name);
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15291
diff changeset
54 }
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15291
diff changeset
55
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
56 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
57 * @return the total size of this code blob
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
58 */
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
59 public int getSize() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
60 return size;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
61 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
62
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
63 /**
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 11381
diff changeset
64 * @return a copy of this code blob if it is {@linkplain #isValid() valid}, null otherwise.
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
65 */
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
66 public byte[] getBlob() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
67 if (!isValid()) {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
68 return null;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
69 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
70 byte[] blob = new byte[size];
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
71 unsafe.copyMemory(null, getAddress(), blob, Unsafe.ARRAY_BYTE_BASE_OFFSET, size);
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
72 return blob;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
73 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
74
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 @Override
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
76 public abstract String toString();
9023
f94bb5d20e5d Rename MethodInvalidatedException to InvalidInstalledCodeException (and make it a checked exception). Make sure that a compiled code object can always be directly called without first doing a check on the native method pointer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8580
diff changeset
77
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
78 @Override
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
79 public long getStart() {
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
80 return codeStart;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
81 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
82
17123
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
83 @Override
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
84 public long getCodeSize() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
85 return codeSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 }
4993
897b7d18bebc added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 4220
diff changeset
87
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
88 @Override
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8215
diff changeset
89 public byte[] getCode() {
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
90 if (!isValid()) {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
91 return null;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
92 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
93 byte[] code = new byte[codeSize];
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
94 unsafe.copyMemory(null, codeStart, code, Unsafe.ARRAY_BYTE_BASE_OFFSET, codeSize);
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
95 return code;
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8215
diff changeset
96 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }