annotate jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotInstalledCode.java @ 22542:15579668ec3a

renamed constant field to UNSAFE
author Doug Simon <doug.simon@oracle.com>
date Wed, 09 Sep 2015 15:27:45 +0200
parents d2035d841611
children 456800cd1a17
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 */
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21798
diff changeset
23 package jdk.internal.jvmci.hotspot;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22542
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
25 import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE;
22541
d2035d841611 restricted Unsafe capability access to package or class scope
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
26 import jdk.internal.jvmci.code.InstalledCode;
d2035d841611 restricted Unsafe capability access to package or class scope
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
27 import jdk.internal.jvmci.inittimer.SuppressFBWarnings;
d2035d841611 restricted Unsafe capability access to package or class scope
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
28 import sun.misc.Unsafe;
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 /**
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
31 * Implementation of {@link InstalledCode} for HotSpot.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
33 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
34
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
35 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
36 * 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
37 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
38 @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
39
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
40 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
41 * 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
42 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
43 @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
44
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
45 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
46 * Size of the code.
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
47 */
15172
009d945ddc39 Add FindBugs SupressWarnings to HotSpotInstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15161
diff changeset
48 @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
49
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
50 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
51 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
52 }
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
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
54 /**
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
55 * @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
56 */
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
57 public int getSize() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
58 return size;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
59 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
60
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
61 /**
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 11381
diff changeset
62 * @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
63 */
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
64 public byte[] getBlob() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
65 if (!isValid()) {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
66 return null;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
67 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
68 byte[] blob = new byte[size];
22542
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
69 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
70 return blob;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
71 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
72
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 @Override
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
74 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
75
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
76 @Override
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
77 public long getStart() {
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
78 return codeStart;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
79 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
80
17123
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
81 @Override
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
82 public long getCodeSize() {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
83 return codeSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 }
4993
897b7d18bebc added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 4220
diff changeset
85
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
86 @Override
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8215
diff changeset
87 public byte[] getCode() {
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
88 if (!isValid()) {
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
89 return null;
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
90 }
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
91 byte[] code = new byte[codeSize];
22542
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
92 UNSAFE.copyMemory(null, codeStart, code, Unsafe.ARRAY_BYTE_BASE_OFFSET, codeSize);
11381
001c41b01d13 HotSpotInstalledCode: moved getCode to Java and added the ability to get the whole blob
twisti
parents: 9668
diff changeset
93 return code;
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8215
diff changeset
94 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 }