1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
85 static Klass* get_klass_by_index(const constantPoolHandle& cpool,
86 int klass_index,
87 bool& is_accessible,
88 Klass* loading_klass);
89 static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
90 int field_index);
91 static methodHandle get_method_by_index(const constantPoolHandle& cpool,
92 int method_index, Bytecodes::Code bc,
93 InstanceKlass* loading_klass);
94
95 JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter);
96
97 private:
98 CompileTask* _task;
99 int _system_dictionary_modification_counter;
100
101 // Compilation result values
102 const char* _failure_reason;
103 bool _retryable;
104
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.
111 static Klass* get_klass_by_name_impl(Klass* accessing_klass,
112 const constantPoolHandle& cpool,
113 Symbol* klass_name,
114 bool require_local);
115 static Klass* get_klass_by_index_impl(const constantPoolHandle& cpool,
116 int klass_index,
117 bool& is_accessible,
118 Klass* loading_klass);
119 static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
120 int field_index);
121 static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool,
122 int method_index, Bytecodes::Code bc,
123 InstanceKlass* loading_klass);
124
125 // Helper methods
126 static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass);
127 static methodHandle lookup_method(InstanceKlass* accessor,
128 Klass* holder,
129 Symbol* name,
130 Symbol* sig,
131 Bytecodes::Code bc,
132 constantTag tag);
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 validate_compile_task_dependencies(Dependencies* target, Handle compiled_code,
142 JVMCIEnv* env, char** failure_detail);
143
144 public:
145 CompileTask* task() { return _task; }
146
147 const char* failure_reason() { return _failure_reason; }
148 bool retryable() { return _retryable; }
149
150 void set_failure(const char* reason, bool retryable) {
151 _failure_reason = reason;
152 _retryable = retryable;
153 }
154
155 // Register the result of a compilation.
156 static JVMCIEnv::CodeInstallResult register_method(
157 const methodHandle& target,
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,
|
1 /*
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
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 *
85 static Klass* get_klass_by_index(const constantPoolHandle& cpool,
86 int klass_index,
87 bool& is_accessible,
88 Klass* loading_klass);
89 static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
90 int field_index);
91 static methodHandle get_method_by_index(const constantPoolHandle& cpool,
92 int method_index, Bytecodes::Code bc,
93 InstanceKlass* loading_klass);
94
95 JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter);
96
97 private:
98 CompileTask* _task;
99 int _system_dictionary_modification_counter;
100
101 // Compilation result values
102 const char* _failure_reason;
103 bool _retryable;
104
105 // Cache JVMTI state. Defined as bytes so that reading them from Java
106 // via Unsafe is well defined (the C++ type for bool is implementation
107 // defined and may not be the same as a Java boolean).
108 jbyte _jvmti_can_hotswap_or_post_breakpoint;
109 jbyte _jvmti_can_access_local_variables;
110 jbyte _jvmti_can_post_on_exceptions;
111 jbyte _jvmti_can_pop_frame;
112
113 // Implementation methods for loading and constant pool access.
114 static Klass* get_klass_by_name_impl(Klass* accessing_klass,
115 const constantPoolHandle& cpool,
116 Symbol* klass_name,
117 bool require_local);
118 static Klass* get_klass_by_index_impl(const constantPoolHandle& cpool,
119 int klass_index,
120 bool& is_accessible,
121 Klass* loading_klass);
122 static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
123 int field_index);
124 static methodHandle get_method_by_index_impl(const constantPoolHandle& cpool,
125 int method_index, Bytecodes::Code bc,
126 InstanceKlass* loading_klass);
127
128 // Helper methods
129 static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass);
130 static methodHandle lookup_method(InstanceKlass* accessor,
131 Klass* holder,
132 Symbol* name,
133 Symbol* sig,
134 Bytecodes::Code bc,
135 constantTag tag);
136
137 private:
138
139 // Is this thread currently in the VM state?
140 static bool is_in_vm();
141
142 // Helper routine for determining the validity of a compilation
143 // with respect to concurrent class loading.
144 static JVMCIEnv::CodeInstallResult validate_compile_task_dependencies(Dependencies* target, Handle compiled_code,
145 JVMCIEnv* env, char** failure_detail);
146
147 public:
148 CompileTask* task() { return _task; }
149
150 bool jvmti_state_changed() const;
151 bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint != 0; }
152 bool jvmti_can_access_local_variables() const { return _jvmti_can_access_local_variables != 0; }
153 bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions != 0; }
154 bool jvmti_can_pop_frame() const { return _jvmti_can_pop_frame != 0; }
155
156 const char* failure_reason() { return _failure_reason; }
157 bool retryable() { return _retryable; }
158
159 void set_failure(const char* reason, bool retryable) {
160 _failure_reason = reason;
161 _retryable = retryable;
162 }
163
164 // Register the result of a compilation.
165 static JVMCIEnv::CodeInstallResult register_method(
166 const methodHandle& target,
167 nmethod*& nm,
168 int entry_bci,
169 CodeOffsets* offsets,
170 int orig_pc_offset,
171 CodeBuffer* code_buffer,
172 int frame_words,
173 OopMapSet* oop_map_set,
174 ExceptionHandlerTable* handler_table,
175 AbstractCompiler* compiler,
|