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_CODE_COMPILEDMETHOD_HPP
26 #define SHARE_VM_CODE_COMPILEDMETHOD_HPP
27
28 #include "code/codeBlob.hpp"
29 #include "code/pcDesc.hpp"
30 #include "oops/metadata.hpp"
31
32 class Dependencies;
33 class ExceptionHandlerTable;
34 class ImplicitExceptionTable;
35 class AbstractCompiler;
36 class xmlStream;
37 class CompiledStaticCall;
38 class NativeCallWrapper;
39
40 // This class is used internally by nmethods, to cache
41 // exception/pc/handler information.
42
43 class ExceptionCache : public CHeapObj<mtCode> {
44 friend class VMStructs;
45 private:
46 enum { cache_size = 16 };
47 Klass* _exception_type;
48 address _pc[cache_size];
288 ExceptionCache* exception_cache() const { return _exception_cache; }
289 void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; }
290 void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); }
291 address handler_for_exception_and_pc(Handle exception, address pc);
292 void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
293 void clean_exception_cache(BoolObjectClosure* is_alive);
294
295 void add_exception_cache_entry(ExceptionCache* new_entry);
296 ExceptionCache* exception_cache_entry_for_exception(Handle exception);
297
298 // MethodHandle
299 bool is_method_handle_return(address return_pc);
300 address deopt_mh_handler_begin() const { return _deopt_mh_handler_begin; }
301
302 address deopt_handler_begin() const { return _deopt_handler_begin; }
303 virtual address get_original_pc(const frame* fr) = 0;
304 // Deopt
305 // Return true is the PC is one would expect if the frame is being deopted.
306 bool is_deopt_pc (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); }
307 bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
308 bool is_deopt_entry(address pc);
309
310 virtual bool can_convert_to_zombie() = 0;
311 virtual const char* compile_kind() const = 0;
312 virtual int get_state() const = 0;
313
314 const char* state() const;
315
316 bool is_far_code() const { return _is_far_code; }
317
318 bool inlinecache_check_contains(address addr) const {
319 return (addr >= code_begin() && addr < verified_entry_point());
320 }
321
322 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
323
324 // implicit exceptions support
325 virtual address continuation_for_implicit_exception(address pc) { return NULL; }
326
327 static address get_deopt_original_pc(const frame* fr);
328
329 // Inline cache support
330 void cleanup_inline_caches(bool clean_all = false);
331 virtual void clear_inline_caches();
332 void clear_ic_stubs();
333
334 // Verify and count cached icholder relocations.
335 int verify_icholder_relocations();
336 void verify_oop_relocations();
337
338 virtual bool is_evol_dependent_on(Klass* dependee) = 0;
339 // Fast breakpoint support. Tells if this compiled method is
340 // dependent on the given method. Returns true if this nmethod
341 // corresponds to the given method as well.
342 virtual bool is_dependent_on_method(Method* dependee) = 0;
343
344 virtual NativeCallWrapper* call_wrapper_at(address call) const = 0;
345 virtual NativeCallWrapper* call_wrapper_before(address return_pc) const = 0;
346 virtual address call_instruction_address(address pc) const = 0;
347
|
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_CODE_COMPILEDMETHOD_HPP
26 #define SHARE_VM_CODE_COMPILEDMETHOD_HPP
27
28 #include "code/codeBlob.hpp"
29 #include "code/nativeInst.hpp"
30 #include "code/pcDesc.hpp"
31 #include "oops/metadata.hpp"
32
33 class Dependencies;
34 class ExceptionHandlerTable;
35 class ImplicitExceptionTable;
36 class AbstractCompiler;
37 class xmlStream;
38 class CompiledStaticCall;
39 class NativeCallWrapper;
40
41 // This class is used internally by nmethods, to cache
42 // exception/pc/handler information.
43
44 class ExceptionCache : public CHeapObj<mtCode> {
45 friend class VMStructs;
46 private:
47 enum { cache_size = 16 };
48 Klass* _exception_type;
49 address _pc[cache_size];
289 ExceptionCache* exception_cache() const { return _exception_cache; }
290 void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; }
291 void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); }
292 address handler_for_exception_and_pc(Handle exception, address pc);
293 void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
294 void clean_exception_cache(BoolObjectClosure* is_alive);
295
296 void add_exception_cache_entry(ExceptionCache* new_entry);
297 ExceptionCache* exception_cache_entry_for_exception(Handle exception);
298
299 // MethodHandle
300 bool is_method_handle_return(address return_pc);
301 address deopt_mh_handler_begin() const { return _deopt_mh_handler_begin; }
302
303 address deopt_handler_begin() const { return _deopt_handler_begin; }
304 virtual address get_original_pc(const frame* fr) = 0;
305 // Deopt
306 // Return true is the PC is one would expect if the frame is being deopted.
307 bool is_deopt_pc (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); }
308 bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
309 bool is_deopt_entry(address pc) {
310 return pc == deopt_handler_begin()
311 #if INCLUDE_JVMCI
312 // When using JVMCI the address might be off by the size of a call instruction.
313 || (is_compiled_by_jvmci() && pc == (deopt_handler_begin() + NativeCall::instruction_size))
314 #endif
315 ;
316 }
317
318 virtual bool can_convert_to_zombie() = 0;
319 virtual const char* compile_kind() const = 0;
320 virtual int get_state() const = 0;
321
322 const char* state() const;
323
324 bool is_far_code() const { return _is_far_code; }
325
326 bool inlinecache_check_contains(address addr) const {
327 return (addr >= code_begin() && addr < verified_entry_point());
328 }
329
330 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f);
331
332 // implicit exceptions support
333 virtual address continuation_for_implicit_exception(address pc) { return NULL; }
334
335 static address get_deopt_original_pc(const frame* fr) {
336 if (fr->cb() == NULL) return NULL;
337
338 CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
339 if (cm != NULL && cm->is_deopt_pc(fr->pc()))
340 return cm->get_original_pc(fr);
341
342 return NULL;
343 }
344
345 // Inline cache support
346 void cleanup_inline_caches(bool clean_all = false);
347 virtual void clear_inline_caches();
348 void clear_ic_stubs();
349
350 // Verify and count cached icholder relocations.
351 int verify_icholder_relocations();
352 void verify_oop_relocations();
353
354 virtual bool is_evol_dependent_on(Klass* dependee) = 0;
355 // Fast breakpoint support. Tells if this compiled method is
356 // dependent on the given method. Returns true if this nmethod
357 // corresponds to the given method as well.
358 virtual bool is_dependent_on_method(Method* dependee) = 0;
359
360 virtual NativeCallWrapper* call_wrapper_at(address call) const = 0;
361 virtual NativeCallWrapper* call_wrapper_before(address return_pc) const = 0;
362 virtual address call_instruction_address(address pc) const = 0;
363
|