Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/ciMethod.hpp
32285 views
/*1* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CI_CIMETHOD_HPP25#define SHARE_VM_CI_CIMETHOD_HPP2627#include "ci/ciFlags.hpp"28#include "ci/ciInstanceKlass.hpp"29#include "ci/ciObject.hpp"30#include "ci/ciSignature.hpp"31#include "compiler/methodLiveness.hpp"32#include "prims/methodHandles.hpp"33#include "utilities/bitMap.hpp"3435class ciMethodBlocks;36class MethodLiveness;37class BitMap;38class Arena;39class BCEscapeAnalyzer;404142// ciMethod43//44// This class represents a Method* in the HotSpot virtual45// machine.46class ciMethod : public ciMetadata {47friend class CompileBroker;48CI_PACKAGE_ACCESS49friend class ciEnv;50friend class ciExceptionHandlerStream;51friend class ciBytecodeStream;52friend class ciMethodHandle;53friend class ciReplay;5455private:56// General method information.57ciFlags _flags;58ciSymbol* _name;59ciInstanceKlass* _holder;60ciSignature* _signature;61ciMethodData* _method_data;62ciMethodBlocks* _method_blocks;6364// Code attributes.65int _code_size;66int _max_stack;67int _max_locals;68vmIntrinsics::ID _intrinsic_id;69int _handler_count;70int _interpreter_invocation_count;71int _interpreter_throwout_count;72int _instructions_size;73int _size_of_parameters;7475bool _uses_monitors;76bool _balanced_monitors;77bool _is_c1_compilable;78bool _is_c2_compilable;79bool _can_be_statically_bound;8081// Lazy fields, filled in on demand82address _code;83ciExceptionHandler** _exception_handlers;8485// Optional liveness analyzer.86MethodLiveness* _liveness;87#if defined(COMPILER2) || defined(SHARK)88ciTypeFlow* _flow;89BCEscapeAnalyzer* _bcea;90#endif9192ciMethod(methodHandle h_m, ciInstanceKlass* holder);93ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);9495oop loader() const { return _holder->loader(); }9697const char* type_string() { return "ciMethod"; }9899void print_impl(outputStream* st);100101void load_code();102103void check_is_loaded() const { assert(is_loaded(), "not loaded"); }104105bool ensure_method_data(methodHandle h_m);106107void code_at_put(int bci, Bytecodes::Code code) {108Bytecodes::check(code);109assert(0 <= bci && bci < code_size(), "valid bci");110address bcp = _code + bci;111*bcp = code;112}113114// Check bytecode and profile data collected are compatible115void assert_virtual_call_type_ok(int bci);116void assert_call_type_ok(int bci);117118public:119// Basic method information.120ciFlags flags() const { check_is_loaded(); return _flags; }121ciSymbol* name() const { return _name; }122ciInstanceKlass* holder() const { return _holder; }123ciMethodData* method_data();124ciMethodData* method_data_or_null();125126// Signature information.127ciSignature* signature() const { return _signature; }128ciType* return_type() const { return _signature->return_type(); }129int arg_size_no_receiver() const { return _signature->size(); }130// Can only be used on loaded ciMethods131int arg_size() const {132check_is_loaded();133return _signature->size() + (_flags.is_static() ? 0 : 1);134}135// Report the number of elements on stack when invoking this method.136// This is different than the regular arg_size because invokedynamic137// has an implicit receiver.138int invoke_arg_size(Bytecodes::Code code) const {139if (is_loaded()) {140return arg_size();141} else {142int arg_size = _signature->size();143// Add a receiver argument, maybe:144if (code != Bytecodes::_invokestatic &&145code != Bytecodes::_invokedynamic) {146arg_size++;147}148return arg_size;149}150}151152Method* get_Method() const {153Method* m = (Method*)_metadata;154assert(m != NULL, "illegal use of unloaded method");155return m;156}157158// Method code and related information.159address code() { if (_code == NULL) load_code(); return _code; }160int code_size() const { check_is_loaded(); return _code_size; }161int max_stack() const { check_is_loaded(); return _max_stack; }162int max_locals() const { check_is_loaded(); return _max_locals; }163vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }164bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }165int exception_table_length() const { check_is_loaded(); return _handler_count; }166int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }167int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }168int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }169170// Code size for inlining decisions.171int code_size_for_inlining();172173bool caller_sensitive() const { return get_Method()->caller_sensitive(); }174bool force_inline() const { return get_Method()->force_inline(); }175bool dont_inline() const { return get_Method()->dont_inline(); }176177int comp_level();178int highest_osr_comp_level();179180Bytecodes::Code java_code_at_bci(int bci) {181address bcp = code() + bci;182return Bytecodes::java_code_at(NULL, bcp);183}184Bytecodes::Code raw_code_at_bci(int bci) {185address bcp = code() + bci;186return Bytecodes::code_at(NULL, bcp);187}188BCEscapeAnalyzer *get_bcea();189ciMethodBlocks *get_method_blocks();190191bool has_linenumber_table() const; // length unknown until decompression192u_char* compressed_linenumber_table() const; // not preserved by gc193194int line_number_from_bci(int bci) const;195196// Runtime information.197int vtable_index();198#ifdef SHARK199int itable_index();200#endif // SHARK201address native_entry();202address interpreter_entry();203204// Analysis and profiling.205//206// Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks.207bool has_monitor_bytecodes() const { return _uses_monitors; }208bool has_balanced_monitors();209210// Returns a bitmap indicating which locals are required to be211// maintained as live for deopt. raw_liveness_at_bci is always the212// direct output of the liveness computation while liveness_at_bci213// may mark all locals as live to improve support for debugging Java214// code by maintaining the state of as many locals as possible.215MethodLivenessResult raw_liveness_at_bci(int bci);216MethodLivenessResult liveness_at_bci(int bci);217218// Get the interpreters viewpoint on oop liveness. MethodLiveness is219// conservative in the sense that it may consider locals to be live which220// cannot be live, like in the case where a local could contain an oop or221// a primitive along different paths. In that case the local must be222// dead when those paths merge. Since the interpreter's viewpoint is223// used when gc'ing an interpreter frame we need to use its viewpoint224// during OSR when loading the locals.225226BitMap live_local_oops_at_bci(int bci);227228#ifdef COMPILER1229const BitMap bci_block_start();230#endif231232ciTypeFlow* get_flow_analysis();233ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point234ciCallProfile call_profile_at_bci(int bci);235int interpreter_call_site_count(int bci);236237// Does type profiling provide a useful type at this point?238ciKlass* argument_profiled_type(int bci, int i);239ciKlass* parameter_profiled_type(int i);240ciKlass* return_profiled_type(int bci);241242ciField* get_field_at_bci( int bci, bool &will_link);243ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);244245ciSignature* get_declared_signature_at_bci(int bci) {246bool ignored_will_link;247ciSignature* declared_signature;248get_method_at_bci(bci, ignored_will_link, &declared_signature);249assert(declared_signature != NULL, "cannot be null");250return declared_signature;251}252253ciMethod* get_method_at_bci(int bci) {254bool ignored_will_link;255ciSignature* ignored_declared_signature;256return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);257}258259// Given a certain calling environment, find the monomorphic target260// for the call. Return NULL if the call is not monomorphic in261// its calling environment.262ciMethod* find_monomorphic_target(ciInstanceKlass* caller,263ciInstanceKlass* callee_holder,264ciInstanceKlass* actual_receiver,265bool check_access = true);266267// Given a known receiver klass, find the target for the call.268// Return NULL if the call has no target or is abstract.269ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access = true);270271// Find the proper vtable index to invoke this method.272int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);273274// Compilation directives275bool should_exclude();276bool should_inline();277bool should_not_inline();278bool should_print_assembly();279bool break_at_execute();280bool has_option(const char *option);281template<typename T>282bool has_option_value(const char* option, T& value);283bool can_be_compiled();284bool can_be_osr_compiled(int entry_bci);285void set_not_compilable(const char* reason = NULL);286bool has_compiled_code();287void log_nmethod_identity(xmlStream* log);288bool is_not_reached(int bci);289bool was_executed_more_than(int times);290bool has_unloaded_classes_in_signature();291bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;292bool check_call(int refinfo_index, bool is_static) const;293bool ensure_method_data(); // make sure it exists in the VM also294MethodCounters* ensure_method_counters();295int instructions_size();296int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC297298// Stack walking support299bool is_ignored_by_security_stack_walk() const;300301// JSR 292 support302bool is_method_handle_intrinsic() const;303bool is_compiled_lambda_form() const;304bool has_member_arg() const;305306// What kind of ciObject is this?307bool is_method() const { return true; }308309// Java access flags310bool is_public () const { return flags().is_public(); }311bool is_private () const { return flags().is_private(); }312bool is_protected () const { return flags().is_protected(); }313bool is_static () const { return flags().is_static(); }314bool is_final () const { return flags().is_final(); }315bool is_synchronized() const { return flags().is_synchronized(); }316bool is_native () const { return flags().is_native(); }317bool is_interface () const { return flags().is_interface(); }318bool is_abstract () const { return flags().is_abstract(); }319bool is_strict () const { return flags().is_strict(); }320321// Other flags322bool is_empty_method() const;323bool is_vanilla_constructor() const;324bool is_final_method() const { return is_final() || holder()->is_final(); }325bool has_loops () const;326bool has_jsrs () const;327bool is_accessor () const;328bool is_initializer () const;329bool can_be_statically_bound() const { return _can_be_statically_bound; }330bool is_boxing_method() const;331bool is_unboxing_method() const;332bool is_object_initializer() const;333334// Replay data methods335void dump_name_as_ascii(outputStream* st);336void dump_replay_data(outputStream* st);337338// Print the bytecodes of this method.339void print_codes_on(outputStream* st);340void print_codes() {341print_codes_on(tty);342}343void print_codes_on(int from, int to, outputStream* st);344345// Print the name of this method in various incarnations.346void print_name(outputStream* st = tty);347void print_short_name(outputStream* st = tty);348};349350#endif // SHARE_VM_CI_CIMETHOD_HPP351352353