annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/InstalledCode.java @ 21730:b9f9b8af17ff

Simplify interface to reference map
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 03 Jun 2015 19:57:38 -0700
parents 48c1ebd24120
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 */
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21367
diff changeset
23 package com.oracle.jvmci.code;
5855
0278da961319 moved InstalledCode from graal.api.meta to graal.api.code
Doug Simon <doug.simon@oracle.com>
parents: 5541
diff changeset
24
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
26 * Represents a compiled instance of a method. It may have been invalidated or removed in the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
27 * meantime.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 */
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
29 public class InstalledCode {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
6331
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
31 /**
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
32 * Raw address of this code blob.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
34 private long address;
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
35
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
36 /**
15166
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
37 * Counts how often the address field was reassigned.
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
38 */
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
39 private long version;
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
40
16401
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
41 protected final String name;
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
42
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
43 public InstalledCode(String name) {
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
44 this.name = name;
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
45 }
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15174
diff changeset
46
17123
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
47 public final void setAddress(long address) {
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
48 this.address = address;
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
49 version++;
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
50 }
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
51
15166
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
52 /**
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
53 * @return the address of this code blob
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
54 */
15166
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
55 public final long getAddress() {
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
56 return address;
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
57 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 /**
15166
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
60 * @return the address of this code blob
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
61 */
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
62 public final long getVersion() {
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
63 return version;
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
64 }
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
65
7bc92bdfd322 Introduce versioning of installed code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15162
diff changeset
66 /**
21367
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
67 * Returns the name of this code blob.
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
68 */
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
69 public String getName() {
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
70 return name;
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
71 }
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
72
c9744d2095e0 Make name available
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17123
diff changeset
73 /**
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
74 * Returns the start address of this installed code if it is {@linkplain #isValid() valid}, 0
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
75 * otherwise.
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
76 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
77 public long getStart() {
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
78 return 0;
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
79 }
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
80
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
81 /**
17123
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
82 * Returns the number of instruction bytes for this code.
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
83 */
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
84 public long getCodeSize() {
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
85 return 0;
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
86 }
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
87
deab46118819 Add methods to InstalledCode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16401
diff changeset
88 /**
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
89 * Returns a copy of this installed code if it is {@linkplain #isValid() valid}, null otherwise.
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
90 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
91 public byte[] getCode() {
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
92 return null;
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
93 }
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
94
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
95 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
96 * @return true if the code represented by this object is still valid, false otherwise (may
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
97 * happen due to deopt, etc.)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
99 public boolean isValid() {
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
100 return address != 0;
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
101 }
4993
897b7d18bebc added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
102
6331
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
103 /**
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: 8349
diff changeset
104 * Invalidates this installed code such that any subsequent invocation will throw an
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: 8349
diff changeset
105 * {@link InvalidInstalledCodeException}.
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: 8349
diff changeset
106 */
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
107 public void invalidate() {
15174
20cd3e31b87d Truffle: Fix regression happening when methods are invalidated.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15166
diff changeset
108 throw new UnsupportedOperationException();
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
109 }
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: 8349
diff changeset
110
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: 8349
diff changeset
111 /**
6331
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
112 * Executes the installed code with a variable number of arguments.
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9023
diff changeset
113 *
6331
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
114 * @param args the array of object arguments
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
115 * @return the value returned by the executed code
4241af3ec314 More comments on InstalledCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5855
diff changeset
116 */
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
117 @SuppressWarnings("unused")
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
118 public Object executeVarargs(Object... args) throws InvalidInstalledCodeException {
15174
20cd3e31b87d Truffle: Fix regression happening when methods are invalidated.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15166
diff changeset
119 throw new UnsupportedOperationException();
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14991
diff changeset
120 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 }