author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 46329 | hotspot/src/share/vm/jvmci/jvmciEnv.hpp@53ccc37bda19 |
child 48299 | e8f5fc8f5f67 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
2 |
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. |
33160 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_JVMCI_JVMCIENV_HPP |
|
26 |
#define SHARE_VM_JVMCI_JVMCIENV_HPP |
|
27 |
||
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "code/debugInfoRec.hpp" |
|
30 |
#include "code/dependencies.hpp" |
|
31 |
#include "code/exceptionHandlerTable.hpp" |
|
32 |
#include "compiler/oopMap.hpp" |
|
33 |
#include "runtime/thread.hpp" |
|
34 |
||
35 |
class CompileTask; |
|
36 |
||
37 |
// Bring the JVMCI compiler thread into the VM state. |
|
38 |
#define JVMCI_VM_ENTRY_MARK \ |
|
39 |
JavaThread* thread = JavaThread::current(); \ |
|
40 |
ThreadInVMfromNative __tiv(thread); \ |
|
41 |
ResetNoHandleMark rnhm; \ |
|
42 |
HandleMarkCleaner __hm(thread); \ |
|
43 |
Thread* THREAD = thread; \ |
|
44 |
debug_only(VMNativeEntryWrapper __vew;) |
|
45 |
||
46 |
#define JVMCI_EXCEPTION_CONTEXT \ |
|
47 |
JavaThread* thread=JavaThread::current(); \ |
|
48 |
Thread* THREAD = thread; |
|
49 |
||
50 |
// |
|
51 |
// This class is the top level broker for requests from the compiler |
|
52 |
// to the VM. |
|
53 |
class JVMCIEnv : StackObj { |
|
54 |
CI_PACKAGE_ACCESS_TO |
|
55 |
||
35123
b0b89d83bcf5
8134994: use separate VMStructs databases for SA and JVMCI
twisti
parents:
34317
diff
changeset
|
56 |
friend class JVMCIVMStructs; |
33160 | 57 |
friend class CompileBroker; |
58 |
friend class Dependencies; // for get_object, during logging |
|
59 |
||
60 |
public: |
|
61 |
||
62 |
enum CodeInstallResult { |
|
63 |
ok, |
|
64 |
dependencies_failed, |
|
65 |
dependencies_invalid, |
|
66 |
cache_full, |
|
67 |
code_too_large |
|
68 |
}; |
|
69 |
||
70 |
// Look up a klass by name from a particular class loader (the accessor's). |
|
71 |
// If require_local, result must be defined in that class loader, or NULL. |
|
72 |
// If !require_local, a result from remote class loader may be reported, |
|
73 |
// if sufficient class loader constraints exist such that initiating |
|
74 |
// a class loading request from the given loader is bound to return |
|
75 |
// the class defined in the remote loader (or throw an error). |
|
76 |
// |
|
77 |
// Return an unloaded klass if !require_local and no class at all is found. |
|
78 |
// |
|
79 |
// The CI treats a klass as loaded if it is consistently defined in |
|
80 |
// another loader, even if it hasn't yet been loaded in all loaders |
|
81 |
// that could potentially see it via delegation. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
82 |
static Klass* get_klass_by_name(Klass* accessing_klass, Symbol* klass_name, bool require_local); |
33160 | 83 |
|
84 |
// Constant pool access. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
85 |
static Klass* get_klass_by_index(const constantPoolHandle& cpool, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
86 |
int klass_index, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
87 |
bool& is_accessible, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
88 |
Klass* loading_klass); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
89 |
static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
90 |
int field_index); |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
91 |
static methodHandle get_method_by_index(const constantPoolHandle& cpool, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
92 |
int method_index, Bytecodes::Code bc, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
93 |
InstanceKlass* loading_klass); |
33160 | 94 |
|
95 |
JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter); |
|
96 |
||
97 |
private: |
|
98 |
CompileTask* _task; |
|
99 |
int _system_dictionary_modification_counter; |
|
100 |
||
35592
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
101 |
// Compilation result values |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
102 |
const char* _failure_reason; |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
103 |
bool _retryable; |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
104 |
|
33160 | 105 |
// Cache JVMTI state |
106 |
bool _jvmti_can_hotswap_or_post_breakpoint; |
|
107 |
bool _jvmti_can_access_local_variables; |
|
108 |
bool _jvmti_can_post_on_exceptions; |
|
109 |
||
110 |
// Implementation methods for loading and constant pool access. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
111 |
static Klass* get_klass_by_name_impl(Klass* accessing_klass, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
112 |
const constantPoolHandle& cpool, |
33160 | 113 |
Symbol* klass_name, |
114 |
bool require_local); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
115 |
static Klass* get_klass_by_index_impl(const constantPoolHandle& cpool, |
33160 | 116 |
int klass_index, |
117 |
bool& is_accessible, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
118 |
Klass* loading_klass); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
119 |
static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd, |
33160 | 120 |
int field_index); |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
121 |
static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool, |
33160 | 122 |
int method_index, Bytecodes::Code bc, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
123 |
InstanceKlass* loading_klass); |
33160 | 124 |
|
125 |
// Helper methods |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
126 |
static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
127 |
static methodHandle lookup_method(InstanceKlass* accessor, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
128 |
Klass* holder, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
129 |
Symbol* name, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
130 |
Symbol* sig, |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
35592
diff
changeset
|
131 |
Bytecodes::Code bc, |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
35592
diff
changeset
|
132 |
constantTag tag); |
33160 | 133 |
|
134 |
private: |
|
135 |
||
136 |
// Is this thread currently in the VM state? |
|
137 |
static bool is_in_vm(); |
|
138 |
||
139 |
// Helper routine for determining the validity of a compilation |
|
140 |
// with respect to concurrent class loading. |
|
141 |
static JVMCIEnv::CodeInstallResult check_for_system_dictionary_modification(Dependencies* target, Handle compiled_code, |
|
142 |
JVMCIEnv* env, char** failure_detail); |
|
143 |
||
144 |
public: |
|
145 |
CompileTask* task() { return _task; } |
|
146 |
||
35592
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
147 |
const char* failure_reason() { return _failure_reason; } |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
148 |
bool retryable() { return _retryable; } |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
149 |
|
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
150 |
void set_failure(const char* reason, bool retryable) { |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
151 |
_failure_reason = reason; |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
152 |
_retryable = retryable; |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
153 |
} |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35123
diff
changeset
|
154 |
|
33160 | 155 |
// Register the result of a compilation. |
156 |
static JVMCIEnv::CodeInstallResult register_method( |
|
34165 | 157 |
const methodHandle& target, |
33160 | 158 |
nmethod*& nm, |
159 |
int entry_bci, |
|
160 |
CodeOffsets* offsets, |
|
161 |
int orig_pc_offset, |
|
162 |
CodeBuffer* code_buffer, |
|
163 |
int frame_words, |
|
164 |
OopMapSet* oop_map_set, |
|
165 |
ExceptionHandlerTable* handler_table, |
|
166 |
AbstractCompiler* compiler, |
|
167 |
DebugInformationRecorder* debug_info, |
|
168 |
Dependencies* dependencies, |
|
169 |
JVMCIEnv* env, |
|
170 |
int compile_id, |
|
171 |
bool has_unsafe_access, |
|
172 |
bool has_wide_vector, |
|
173 |
Handle installed_code, |
|
174 |
Handle compiled_code, |
|
175 |
Handle speculation_log); |
|
176 |
||
177 |
// converts the Klass* representing the holder of a method into a |
|
178 |
// InstanceKlass*. This is needed since the holder of a method in |
|
179 |
// the bytecodes could be an array type. Basically this converts |
|
180 |
// array types into java/lang/Object and other types stay as they are. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
43938
diff
changeset
|
181 |
static InstanceKlass* get_instance_klass_for_declared_method_holder(Klass* klass); |
33160 | 182 |
}; |
183 |
||
184 |
#endif // SHARE_VM_JVMCI_JVMCIENV_HPP |