Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/opto/compile.hpp
32285 views
/*1* Copyright (c) 1997, 2014, 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_OPTO_COMPILE_HPP25#define SHARE_VM_OPTO_COMPILE_HPP2627#include "asm/codeBuffer.hpp"28#include "ci/compilerInterface.hpp"29#include "code/debugInfoRec.hpp"30#include "code/exceptionHandlerTable.hpp"31#include "compiler/compilerOracle.hpp"32#include "compiler/compileBroker.hpp"33#include "jfr/jfrEvents.hpp"34#include "libadt/dict.hpp"35#include "libadt/port.hpp"36#include "libadt/vectset.hpp"37#include "memory/resourceArea.hpp"38#include "opto/idealGraphPrinter.hpp"39#include "opto/phasetype.hpp"40#include "opto/phase.hpp"41#include "opto/regmask.hpp"42#include "runtime/deoptimization.hpp"43#include "runtime/vmThread.hpp"44#include "utilities/ticks.hpp"4546class Block;47class Bundle;48class C2Compiler;49class CallGenerator;50class ConnectionGraph;51class InlineTree;52class Int_Array;53class Matcher;54class MachConstantNode;55class MachConstantBaseNode;56class MachNode;57class MachOper;58class MachSafePointNode;59class Node;60class Node_Array;61class Node_Notes;62class OptoReg;63class PhaseCFG;64class PhaseGVN;65class PhaseIterGVN;66class PhaseRegAlloc;67class PhaseCCP;68class PhaseCCP_DCE;69class RootNode;70class relocInfo;71class ShenandoahLoadReferenceBarrierNode;72class Scope;73class StartNode;74class SafePointNode;75class JVMState;76class Type;77class TypeData;78class TypeInt;79class TypePtr;80class TypeOopPtr;81class TypeFunc;82class Unique_Node_List;83class nmethod;84class WarmCallInfo;85class Node_Stack;86struct Final_Reshape_Counts;8788//------------------------------Compile----------------------------------------89// This class defines a top-level Compiler invocation.9091class Compile : public Phase {92friend class VMStructs;9394public:95// Fixed alias indexes. (See also MergeMemNode.)96enum {97AliasIdxTop = 1, // pseudo-index, aliases to nothing (used as sentinel value)98AliasIdxBot = 2, // pseudo-index, aliases to everything99AliasIdxRaw = 3 // hard-wired index for TypeRawPtr::BOTTOM100};101102// Variant of TraceTime(NULL, &_t_accumulator, TimeCompiler);103// Integrated with logging. If logging is turned on, and dolog is true,104// then brackets are put into the log, with time stamps and node counts.105// (The time collection itself is always conditionalized on TimeCompiler.)106class TracePhase : public TraceTime {107private:108Compile* C;109CompileLog* _log;110const char* _phase_name;111bool _dolog;112public:113TracePhase(const char* name, elapsedTimer* accumulator, bool dolog);114~TracePhase();115};116117// Information per category of alias (memory slice)118class AliasType {119private:120friend class Compile;121122int _index; // unique index, used with MergeMemNode123const TypePtr* _adr_type; // normalized address type124ciField* _field; // relevant instance field, or null if none125const Type* _element; // relevant array element type, or null if none126bool _is_rewritable; // false if the memory is write-once only127int _general_index; // if this is type is an instance, the general128// type that this is an instance of129130void Init(int i, const TypePtr* at);131132public:133int index() const { return _index; }134const TypePtr* adr_type() const { return _adr_type; }135ciField* field() const { return _field; }136const Type* element() const { return _element; }137bool is_rewritable() const { return _is_rewritable; }138bool is_volatile() const { return (_field ? _field->is_volatile() : false); }139int general_index() const { return (_general_index != 0) ? _general_index : _index; }140141void set_rewritable(bool z) { _is_rewritable = z; }142void set_field(ciField* f) {143assert(!_field,"");144_field = f;145if (f->is_final() || f->is_stable()) {146// In the case of @Stable, multiple writes are possible but may be assumed to be no-ops.147_is_rewritable = false;148}149}150void set_element(const Type* e) {151assert(_element == NULL, "");152_element = e;153}154155BasicType basic_type() const;156157void print_on(outputStream* st) PRODUCT_RETURN;158};159160enum {161logAliasCacheSize = 6,162AliasCacheSize = (1<<logAliasCacheSize)163};164struct AliasCacheEntry { const TypePtr* _adr_type; int _index; }; // simple duple type165enum {166trapHistLength = MethodData::_trap_hist_limit167};168169// Constant entry of the constant table.170class Constant {171private:172BasicType _type;173union {174jvalue _value;175Metadata* _metadata;176} _v;177int _offset; // offset of this constant (in bytes) relative to the constant table base.178float _freq;179bool _can_be_reused; // true (default) if the value can be shared with other users.180181public:182Constant() : _type(T_ILLEGAL), _offset(-1), _freq(0.0f), _can_be_reused(true) { _v._value.l = 0; }183Constant(BasicType type, jvalue value, float freq = 0.0f, bool can_be_reused = true) :184_type(type),185_offset(-1),186_freq(freq),187_can_be_reused(can_be_reused)188{189assert(type != T_METADATA, "wrong constructor");190_v._value = value;191}192Constant(Metadata* metadata, bool can_be_reused = true) :193_type(T_METADATA),194_offset(-1),195_freq(0.0f),196_can_be_reused(can_be_reused)197{198_v._metadata = metadata;199}200201bool operator==(const Constant& other);202203BasicType type() const { return _type; }204205jlong get_jlong() const { return _v._value.j; }206jfloat get_jfloat() const { return _v._value.f; }207jdouble get_jdouble() const { return _v._value.d; }208jobject get_jobject() const { return _v._value.l; }209210Metadata* get_metadata() const { return _v._metadata; }211212int offset() const { return _offset; }213void set_offset(int offset) { _offset = offset; }214215float freq() const { return _freq; }216void inc_freq(float freq) { _freq += freq; }217218bool can_be_reused() const { return _can_be_reused; }219};220221// Constant table.222class ConstantTable {223private:224GrowableArray<Constant> _constants; // Constants of this table.225int _size; // Size in bytes the emitted constant table takes (including padding).226int _table_base_offset; // Offset of the table base that gets added to the constant offsets.227int _nof_jump_tables; // Number of jump-tables in this constant table.228229static int qsort_comparator(Constant* a, Constant* b);230231// We use negative frequencies to keep the order of the232// jump-tables in which they were added. Otherwise we get into233// trouble with relocation.234float next_jump_table_freq() { return -1.0f * (++_nof_jump_tables); }235236public:237ConstantTable() :238_size(-1),239_table_base_offset(-1), // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).240_nof_jump_tables(0)241{}242243int size() const { assert(_size != -1, "not calculated yet"); return _size; }244245int calculate_table_base_offset() const; // AD specific246void set_table_base_offset(int x) { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; }247int table_base_offset() const { assert(_table_base_offset != -1, "not set yet"); return _table_base_offset; }248249void emit(CodeBuffer& cb);250251// Returns the offset of the last entry (the top) of the constant table.252int top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }253254void calculate_offsets_and_size();255int find_offset(Constant& con) const;256257void add(Constant& con);258Constant add(MachConstantNode* n, BasicType type, jvalue value);259Constant add(Metadata* metadata);260Constant add(MachConstantNode* n, MachOper* oper);261Constant add(MachConstantNode* n, jfloat f) {262jvalue value; value.f = f;263return add(n, T_FLOAT, value);264}265Constant add(MachConstantNode* n, jdouble d) {266jvalue value; value.d = d;267return add(n, T_DOUBLE, value);268}269270// Jump-table271Constant add_jump_table(MachConstantNode* n);272void fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;273};274275private:276// Fixed parameters to this compilation.277const int _compile_id;278const bool _save_argument_registers; // save/restore arg regs for trampolines279const bool _subsume_loads; // Load can be matched as part of a larger op.280const bool _do_escape_analysis; // Do escape analysis.281const bool _eliminate_boxing; // Do boxing elimination.282ciMethod* _method; // The method being compiled.283int _entry_bci; // entry bci for osr methods.284const TypeFunc* _tf; // My kind of signature285InlineTree* _ilt; // Ditto (temporary).286address _stub_function; // VM entry for stub being compiled, or NULL287const char* _stub_name; // Name of stub or adapter being compiled, or NULL288address _stub_entry_point; // Compile code entry for generated stub, or NULL289290// Control of this compilation.291int _num_loop_opts; // Number of iterations for doing loop optimiztions292int _max_inline_size; // Max inline size for this compilation293int _freq_inline_size; // Max hot method inline size for this compilation294int _fixed_slots; // count of frame slots not allocated by the register295// allocator i.e. locks, original deopt pc, etc.296uintx _max_node_limit; // Max unique node count during a single compilation.297// For deopt298int _orig_pc_slot;299int _orig_pc_slot_offset_in_bytes;300301int _major_progress; // Count of something big happening302bool _inlining_progress; // progress doing incremental inlining?303bool _inlining_incrementally;// Are we doing incremental inlining (post parse)304bool _has_loops; // True if the method _may_ have some loops305bool _has_split_ifs; // True if the method _may_ have some split-if306bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.307bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated308bool _has_boxed_value; // True if a boxed object is allocated309int _max_vector_size; // Maximum size of generated vectors310uint _trap_hist[trapHistLength]; // Cumulative traps311bool _trap_can_recompile; // Have we emitted a recompiling trap?312uint _decompile_count; // Cumulative decompilation counts.313bool _do_inlining; // True if we intend to do inlining314bool _do_scheduling; // True if we intend to do scheduling315bool _do_freq_based_layout; // True if we intend to do frequency based block layout316bool _do_count_invocations; // True if we generate code to count invocations317bool _do_method_data_update; // True if we generate code to update MethodData*s318int _AliasLevel; // Locally-adjusted version of AliasLevel flag.319bool _print_assembly; // True if we should dump assembly code for this compilation320bool _print_inlining; // True if we should print inlining for this compilation321bool _print_intrinsics; // True if we should print intrinsics for this compilation322#ifndef PRODUCT323bool _trace_opto_output;324bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing325#endif326bool _has_irreducible_loop; // Found irreducible loops327// JSR 292328bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.329RTMState _rtm_state; // State of Restricted Transactional Memory usage330331// Compilation environment.332Arena _comp_arena; // Arena with lifetime equivalent to Compile333ciEnv* _env; // CI interface334CompileLog* _log; // from CompilerThread335const char* _failure_reason; // for record_failure/failing pattern336GrowableArray<CallGenerator*>* _intrinsics; // List of intrinsics.337GrowableArray<Node*>* _macro_nodes; // List of nodes which need to be expanded before matching.338GrowableArray<Node*>* _predicate_opaqs; // List of Opaque1 nodes for the loop predicates.339GrowableArray<Node*>* _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common340GrowableArray<Node*>* _range_check_casts; // List of CastII nodes with a range check dependency341GrowableArray<ShenandoahLoadReferenceBarrierNode*>* _shenandoah_barriers;342ConnectionGraph* _congraph;343#ifndef PRODUCT344IdealGraphPrinter* _printer;345#endif346347348349// Node management350uint _unique; // Counter for unique Node indices351VectorSet _dead_node_list; // Set of dead nodes352uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).353// So use this to keep count and make the call O(1).354debug_only(static int _debug_idx;) // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>355Arena _node_arena; // Arena for new-space Nodes356Arena _old_arena; // Arena for old-space Nodes, lifetime during xform357RootNode* _root; // Unique root of compilation, or NULL after bail-out.358Node* _top; // Unique top node. (Reset by various phases.)359360Node* _immutable_memory; // Initial memory state361362Node* _recent_alloc_obj;363Node* _recent_alloc_ctl;364365// Constant table366ConstantTable _constant_table; // The constant table for this compile.367MachConstantBaseNode* _mach_constant_base_node; // Constant table base node singleton.368369370// Blocked array of debugging and profiling information,371// tracked per node.372enum { _log2_node_notes_block_size = 8,373_node_notes_block_size = (1<<_log2_node_notes_block_size)374};375GrowableArray<Node_Notes*>* _node_note_array;376Node_Notes* _default_node_notes; // default notes for new nodes377378// After parsing and every bulk phase we hang onto the Root instruction.379// The RootNode instruction is where the whole program begins. It produces380// the initial Control and BOTTOM for everybody else.381382// Type management383Arena _Compile_types; // Arena for all types384Arena* _type_arena; // Alias for _Compile_types except in Initialize_shared()385Dict* _type_dict; // Intern table386void* _type_hwm; // Last allocation (see Type::operator new/delete)387size_t _type_last_size; // Last allocation size (see Type::operator new/delete)388ciMethod* _last_tf_m; // Cache for389const TypeFunc* _last_tf; // TypeFunc::make390AliasType** _alias_types; // List of alias types seen so far.391int _num_alias_types; // Logical length of _alias_types392int _max_alias_types; // Physical length of _alias_types393AliasCacheEntry _alias_cache[AliasCacheSize]; // Gets aliases w/o data structure walking394395// Parsing, optimization396PhaseGVN* _initial_gvn; // Results of parse-time PhaseGVN397Unique_Node_List* _for_igvn; // Initial work-list for next round of Iterative GVN398WarmCallInfo* _warm_calls; // Sorted work-list for heat-based inlining.399400GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after401// main parsing has finished.402GrowableArray<CallGenerator*> _string_late_inlines; // same but for string operations403404GrowableArray<CallGenerator*> _boxing_late_inlines; // same but for boxing operations405406int _late_inlines_pos; // Where in the queue should the next late inlining candidate go (emulate depth first inlining)407uint _number_of_mh_late_inlines; // number of method handle late inlining still pending408409410// Inlining may not happen in parse order which would make411// PrintInlining output confusing. Keep track of PrintInlining412// pieces in order.413class PrintInliningBuffer : public ResourceObj {414private:415CallGenerator* _cg;416stringStream* _ss;417418public:419PrintInliningBuffer()420: _cg(NULL) { _ss = new stringStream(); }421422stringStream* ss() const { return _ss; }423CallGenerator* cg() const { return _cg; }424void set_cg(CallGenerator* cg) { _cg = cg; }425};426427GrowableArray<PrintInliningBuffer>* _print_inlining_list;428int _print_inlining_idx;429430// Only keep nodes in the expensive node list that need to be optimized431void cleanup_expensive_nodes(PhaseIterGVN &igvn);432// Use for sorting expensive nodes to bring similar nodes together433static int cmp_expensive_nodes(Node** n1, Node** n2);434// Expensive nodes list already sorted?435bool expensive_nodes_sorted() const;436// Remove the speculative part of types and clean up the graph437void remove_speculative_types(PhaseIterGVN &igvn);438439void* _replay_inline_data; // Pointer to data loaded from file440441public:442443outputStream* print_inlining_stream() const {444return _print_inlining_list->adr_at(_print_inlining_idx)->ss();445}446447void print_inlining_skip(CallGenerator* cg) {448if (_print_inlining) {449_print_inlining_list->adr_at(_print_inlining_idx)->set_cg(cg);450_print_inlining_idx++;451_print_inlining_list->insert_before(_print_inlining_idx, PrintInliningBuffer());452}453}454455void print_inlining_insert(CallGenerator* cg) {456if (_print_inlining) {457for (int i = 0; i < _print_inlining_list->length(); i++) {458if (_print_inlining_list->adr_at(i)->cg() == cg) {459_print_inlining_list->insert_before(i+1, PrintInliningBuffer());460_print_inlining_idx = i+1;461_print_inlining_list->adr_at(i)->set_cg(NULL);462return;463}464}465ShouldNotReachHere();466}467}468469void print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {470stringStream ss;471CompileTask::print_inlining(&ss, method, inline_level, bci, msg);472print_inlining_stream()->print("%s", ss.as_string());473}474475void* replay_inline_data() const { return _replay_inline_data; }476477// Dump inlining replay data to the stream.478void dump_inline_data(outputStream* out);479480private:481// Matching, CFG layout, allocation, code generation482PhaseCFG* _cfg; // Results of CFG finding483bool _select_24_bit_instr; // We selected an instruction with a 24-bit result484bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results485int _java_calls; // Number of java calls in the method486int _inner_loops; // Number of inner loops in the method487Matcher* _matcher; // Engine to map ideal to machine instructions488PhaseRegAlloc* _regalloc; // Results of register allocation.489int _frame_slots; // Size of total frame in stack slots490CodeOffsets _code_offsets; // Offsets into the code for various interesting entries491RegMask _FIRST_STACK_mask; // All stack slots usable for spills (depends on frame layout)492Arena* _indexSet_arena; // control IndexSet allocation within PhaseChaitin493void* _indexSet_free_block_list; // free list of IndexSet bit blocks494int _interpreter_frame_size;495496uint _node_bundling_limit;497Bundle* _node_bundling_base; // Information for instruction bundling498499// Instruction bits passed off to the VM500int _method_size; // Size of nmethod code segment in bytes501CodeBuffer _code_buffer; // Where the code is assembled502int _first_block_size; // Size of unvalidated entry point code / OSR poison code503ExceptionHandlerTable _handler_table; // Table of native-code exception handlers504ImplicitExceptionTable _inc_table; // Table of implicit null checks in native code505OopMapSet* _oop_map_set; // Table of oop maps (one for each safepoint location)506static int _CompiledZap_count; // counter compared against CompileZap[First/Last]507BufferBlob* _scratch_buffer_blob; // For temporary code buffers.508relocInfo* _scratch_locs_memory; // For temporary code buffers.509int _scratch_const_size; // For temporary code buffers.510bool _in_scratch_emit_size; // true when in scratch_emit_size.511512public:513// Accessors514515// The Compile instance currently active in this (compiler) thread.516static Compile* current() {517return (Compile*) ciEnv::current()->compiler_data();518}519520// ID for this compilation. Useful for setting breakpoints in the debugger.521int compile_id() const { return _compile_id; }522523// Does this compilation allow instructions to subsume loads? User524// instructions that subsume a load may result in an unschedulable525// instruction sequence.526bool subsume_loads() const { return _subsume_loads; }527/** Do escape analysis. */528bool do_escape_analysis() const { return _do_escape_analysis; }529/** Do boxing elimination. */530bool eliminate_boxing() const { return _eliminate_boxing; }531/** Do aggressive boxing elimination. */532bool aggressive_unboxing() const { return _eliminate_boxing && AggressiveUnboxing; }533bool save_argument_registers() const { return _save_argument_registers; }534535536// Other fixed compilation parameters.537ciMethod* method() const { return _method; }538int entry_bci() const { return _entry_bci; }539bool is_osr_compilation() const { return _entry_bci != InvocationEntryBci; }540bool is_method_compilation() const { return (_method != NULL && !_method->flags().is_native()); }541const TypeFunc* tf() const { assert(_tf!=NULL, ""); return _tf; }542void init_tf(const TypeFunc* tf) { assert(_tf==NULL, ""); _tf = tf; }543InlineTree* ilt() const { return _ilt; }544address stub_function() const { return _stub_function; }545const char* stub_name() const { return _stub_name; }546address stub_entry_point() const { return _stub_entry_point; }547548// Control of this compilation.549int fixed_slots() const { assert(_fixed_slots >= 0, ""); return _fixed_slots; }550void set_fixed_slots(int n) { _fixed_slots = n; }551int major_progress() const { return _major_progress; }552void set_inlining_progress(bool z) { _inlining_progress = z; }553int inlining_progress() const { return _inlining_progress; }554void set_inlining_incrementally(bool z) { _inlining_incrementally = z; }555int inlining_incrementally() const { return _inlining_incrementally; }556void set_major_progress() { _major_progress++; }557void clear_major_progress() { _major_progress = 0; }558int num_loop_opts() const { return _num_loop_opts; }559void set_num_loop_opts(int n) { _num_loop_opts = n; }560int max_inline_size() const { return _max_inline_size; }561void set_freq_inline_size(int n) { _freq_inline_size = n; }562int freq_inline_size() const { return _freq_inline_size; }563void set_max_inline_size(int n) { _max_inline_size = n; }564bool has_loops() const { return _has_loops; }565void set_has_loops(bool z) { _has_loops = z; }566bool has_split_ifs() const { return _has_split_ifs; }567void set_has_split_ifs(bool z) { _has_split_ifs = z; }568bool has_unsafe_access() const { return _has_unsafe_access; }569void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }570bool has_stringbuilder() const { return _has_stringbuilder; }571void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }572bool has_boxed_value() const { return _has_boxed_value; }573void set_has_boxed_value(bool z) { _has_boxed_value = z; }574int max_vector_size() const { return _max_vector_size; }575void set_max_vector_size(int s) { _max_vector_size = s; }576void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }577uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }578bool trap_can_recompile() const { return _trap_can_recompile; }579void set_trap_can_recompile(bool z) { _trap_can_recompile = z; }580uint decompile_count() const { return _decompile_count; }581void set_decompile_count(uint c) { _decompile_count = c; }582bool allow_range_check_smearing() const;583bool do_inlining() const { return _do_inlining; }584void set_do_inlining(bool z) { _do_inlining = z; }585bool do_scheduling() const { return _do_scheduling; }586void set_do_scheduling(bool z) { _do_scheduling = z; }587bool do_freq_based_layout() const{ return _do_freq_based_layout; }588void set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }589bool do_count_invocations() const{ return _do_count_invocations; }590void set_do_count_invocations(bool z){ _do_count_invocations = z; }591bool do_method_data_update() const { return _do_method_data_update; }592void set_do_method_data_update(bool z) { _do_method_data_update = z; }593int AliasLevel() const { return _AliasLevel; }594bool print_assembly() const { return _print_assembly; }595void set_print_assembly(bool z) { _print_assembly = z; }596bool print_inlining() const { return _print_inlining; }597void set_print_inlining(bool z) { _print_inlining = z; }598bool print_intrinsics() const { return _print_intrinsics; }599void set_print_intrinsics(bool z) { _print_intrinsics = z; }600RTMState rtm_state() const { return _rtm_state; }601void set_rtm_state(RTMState s) { _rtm_state = s; }602bool use_rtm() const { return (_rtm_state & NoRTM) == 0; }603bool profile_rtm() const { return _rtm_state == ProfileRTM; }604uint max_node_limit() const { return (uint)_max_node_limit; }605void set_max_node_limit(uint n) { _max_node_limit = n; }606607// check the CompilerOracle for special behaviours for this compile608bool method_has_option(const char * option) {609return method() != NULL && method()->has_option(option);610}611template<typename T>612bool method_has_option_value(const char * option, T& value) {613return method() != NULL && method()->has_option_value(option, value);614}615#ifndef PRODUCT616bool trace_opto_output() const { return _trace_opto_output; }617bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }618void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }619int _in_dump_cnt; // Required for dumping ir nodes.620#endif621bool has_irreducible_loop() const { return _has_irreducible_loop; }622void set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }623624// JSR 292625bool has_method_handle_invokes() const { return _has_method_handle_invokes; }626void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }627628Ticks _latest_stage_start_counter;629630void begin_method() {631#ifndef PRODUCT632if (_printer) _printer->begin_method(this);633#endif634C->_latest_stage_start_counter.stamp();635}636637void print_method(CompilerPhaseType cpt, int level = 1) {638EventCompilerPhase event;639if (event.should_commit()) {640event.set_starttime(C->_latest_stage_start_counter);641event.set_phase((u1) cpt);642event.set_compileId(C->_compile_id);643event.set_phaseLevel(level);644event.commit();645}646647648#ifndef PRODUCT649if (_printer) _printer->print_method(this, CompilerPhaseTypeHelper::to_string(cpt), level);650#endif651C->_latest_stage_start_counter.stamp();652}653654void end_method(int level = 1) {655EventCompilerPhase event;656if (event.should_commit()) {657event.set_starttime(C->_latest_stage_start_counter);658event.set_phase((u1) PHASE_END);659event.set_compileId(C->_compile_id);660event.set_phaseLevel(level);661event.commit();662}663#ifndef PRODUCT664if (_printer) _printer->end_method();665#endif666}667668int macro_count() const { return _macro_nodes->length(); }669int predicate_count() const { return _predicate_opaqs->length();}670int expensive_count() const { return _expensive_nodes->length(); }671int shenandoah_barriers_count() const { return _shenandoah_barriers->length(); }672Node* macro_node(int idx) const { return _macro_nodes->at(idx); }673Node* predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}674Node* expensive_node(int idx) const { return _expensive_nodes->at(idx); }675ShenandoahLoadReferenceBarrierNode* shenandoah_barrier(int idx) const { return _shenandoah_barriers->at(idx); }676ConnectionGraph* congraph() { return _congraph;}677void set_congraph(ConnectionGraph* congraph) { _congraph = congraph;}678void add_macro_node(Node * n) {679//assert(n->is_macro(), "must be a macro node");680assert(!_macro_nodes->contains(n), "duplicate entry in expand list");681_macro_nodes->append(n);682}683void remove_macro_node(Node * n) {684// this function may be called twice for a node so check685// that the node is in the array before attempting to remove it686if (_macro_nodes->contains(n))687_macro_nodes->remove(n);688// remove from _predicate_opaqs list also if it is there689if (predicate_count() > 0 && _predicate_opaqs->contains(n)){690_predicate_opaqs->remove(n);691}692}693void add_expensive_node(Node * n);694void remove_expensive_node(Node * n) {695if (_expensive_nodes->contains(n)) {696_expensive_nodes->remove(n);697}698}699void add_shenandoah_barrier(ShenandoahLoadReferenceBarrierNode * n) {700assert(!_shenandoah_barriers->contains(n), "duplicate entry in barrier list");701_shenandoah_barriers->append(n);702}703void remove_shenandoah_barrier(ShenandoahLoadReferenceBarrierNode * n) {704if (_shenandoah_barriers->contains(n)) {705_shenandoah_barriers->remove(n);706}707}708void add_predicate_opaq(Node * n) {709assert(!_predicate_opaqs->contains(n), "duplicate entry in predicate opaque1");710assert(_macro_nodes->contains(n), "should have already been in macro list");711_predicate_opaqs->append(n);712}713714// Range check dependent CastII nodes that can be removed after loop optimizations715void add_range_check_cast(Node* n);716void remove_range_check_cast(Node* n) {717if (_range_check_casts->contains(n)) {718_range_check_casts->remove(n);719}720}721Node* range_check_cast_node(int idx) const { return _range_check_casts->at(idx); }722int range_check_cast_count() const { return _range_check_casts->length(); }723// Remove all range check dependent CastIINodes.724void remove_range_check_casts(PhaseIterGVN &igvn);725726// remove the opaque nodes that protect the predicates so that the unused checks and727// uncommon traps will be eliminated from the graph.728void cleanup_loop_predicates(PhaseIterGVN &igvn);729bool is_predicate_opaq(Node * n) {730return _predicate_opaqs->contains(n);731}732733// Are there candidate expensive nodes for optimization?734bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);735// Check whether n1 and n2 are similar736static int cmp_expensive_nodes(Node* n1, Node* n2);737// Sort expensive nodes to locate similar expensive nodes738void sort_expensive_nodes();739740GrowableArray<ShenandoahLoadReferenceBarrierNode*>* shenandoah_barriers() { return _shenandoah_barriers; }741742// Compilation environment.743Arena* comp_arena() { return &_comp_arena; }744ciEnv* env() const { return _env; }745CompileLog* log() const { return _log; }746bool failing() const { return _env->failing() || _failure_reason != NULL; }747const char* failure_reason() { return _failure_reason; }748bool failure_reason_is(const char* r) { return (r==_failure_reason) || (r!=NULL && _failure_reason!=NULL && strcmp(r, _failure_reason)==0); }749750void record_failure(const char* reason);751void record_method_not_compilable(const char* reason, bool all_tiers = false) {752// All bailouts cover "all_tiers" when TieredCompilation is off.753if (!TieredCompilation) all_tiers = true;754env()->record_method_not_compilable(reason, all_tiers);755// Record failure reason.756record_failure(reason);757}758void record_method_not_compilable_all_tiers(const char* reason) {759record_method_not_compilable(reason, true);760}761bool check_node_count(uint margin, const char* reason) {762if (live_nodes() + margin > max_node_limit()) {763record_method_not_compilable(reason);764return true;765} else {766return false;767}768}769770// Node management771uint unique() const { return _unique; }772uint next_unique() { return _unique++; }773void set_unique(uint i) { _unique = i; }774static int debug_idx() { return debug_only(_debug_idx)+0; }775static void set_debug_idx(int i) { debug_only(_debug_idx = i); }776Arena* node_arena() { return &_node_arena; }777Arena* old_arena() { return &_old_arena; }778RootNode* root() const { return _root; }779void set_root(RootNode* r) { _root = r; }780StartNode* start() const; // (Derived from root.)781void init_start(StartNode* s);782Node* immutable_memory();783784Node* recent_alloc_ctl() const { return _recent_alloc_ctl; }785Node* recent_alloc_obj() const { return _recent_alloc_obj; }786void set_recent_alloc(Node* ctl, Node* obj) {787_recent_alloc_ctl = ctl;788_recent_alloc_obj = obj;789}790void record_dead_node(uint idx) { if (_dead_node_list.test_set(idx)) return;791_dead_node_count++;792}793bool is_dead_node(uint idx) { return _dead_node_list.test(idx) != 0; }794uint dead_node_count() { return _dead_node_count; }795void reset_dead_node_list() { _dead_node_list.Reset();796_dead_node_count = 0;797}798uint live_nodes() const {799int val = _unique - _dead_node_count;800assert (val >= 0, err_msg_res("number of tracked dead nodes %d more than created nodes %d", _unique, _dead_node_count));801return (uint) val;802}803#ifdef ASSERT804uint count_live_nodes_by_graph_walk();805void print_missing_nodes();806#endif807808// Constant table809ConstantTable& constant_table() { return _constant_table; }810811MachConstantBaseNode* mach_constant_base_node();812bool has_mach_constant_base_node() const { return _mach_constant_base_node != NULL; }813// Generated by adlc, true if CallNode requires MachConstantBase.814bool needs_clone_jvms();815816// Handy undefined Node817Node* top() const { return _top; }818819// these are used by guys who need to know about creation and transformation of top:820Node* cached_top_node() { return _top; }821void set_cached_top_node(Node* tn);822823GrowableArray<Node_Notes*>* node_note_array() const { return _node_note_array; }824void set_node_note_array(GrowableArray<Node_Notes*>* arr) { _node_note_array = arr; }825Node_Notes* default_node_notes() const { return _default_node_notes; }826void set_default_node_notes(Node_Notes* n) { _default_node_notes = n; }827828Node_Notes* node_notes_at(int idx) {829return locate_node_notes(_node_note_array, idx, false);830}831inline bool set_node_notes_at(int idx, Node_Notes* value);832833// Copy notes from source to dest, if they exist.834// Overwrite dest only if source provides something.835// Return true if information was moved.836bool copy_node_notes_to(Node* dest, Node* source);837838// Workhorse function to sort out the blocked Node_Notes array:839inline Node_Notes* locate_node_notes(GrowableArray<Node_Notes*>* arr,840int idx, bool can_grow = false);841842void grow_node_notes(GrowableArray<Node_Notes*>* arr, int grow_by);843844// Type management845Arena* type_arena() { return _type_arena; }846Dict* type_dict() { return _type_dict; }847void* type_hwm() { return _type_hwm; }848size_t type_last_size() { return _type_last_size; }849int num_alias_types() { return _num_alias_types; }850851void init_type_arena() { _type_arena = &_Compile_types; }852void set_type_arena(Arena* a) { _type_arena = a; }853void set_type_dict(Dict* d) { _type_dict = d; }854void set_type_hwm(void* p) { _type_hwm = p; }855void set_type_last_size(size_t sz) { _type_last_size = sz; }856857const TypeFunc* last_tf(ciMethod* m) {858return (m == _last_tf_m) ? _last_tf : NULL;859}860void set_last_tf(ciMethod* m, const TypeFunc* tf) {861assert(m != NULL || tf == NULL, "");862_last_tf_m = m;863_last_tf = tf;864}865866AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }867AliasType* alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }868bool have_alias_type(const TypePtr* adr_type);869AliasType* alias_type(ciField* field);870871int get_alias_index(const TypePtr* at) { return alias_type(at)->index(); }872const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }873int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }874875// Building nodes876void rethrow_exceptions(JVMState* jvms);877void return_values(JVMState* jvms);878JVMState* build_start_state(StartNode* start, const TypeFunc* tf);879880// Decide how to build a call.881// The profile factor is a discount to apply to this site's interp. profile.882CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,883JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,884bool allow_intrinsics = true, bool delayed_forbidden = false);885bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {886return should_delay_string_inlining(call_method, jvms) ||887should_delay_boxing_inlining(call_method, jvms);888}889bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);890bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);891892// Helper functions to identify inlining potential at call-site893ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,894ciKlass* holder, ciMethod* callee,895const TypeOopPtr* receiver_type, bool is_virtual,896bool &call_does_dispatch, int &vtable_index,897bool check_access = true);898ciMethod* optimize_inlining(ciMethod* caller, int bci, ciInstanceKlass* klass,899ciMethod* callee, const TypeOopPtr* receiver_type,900bool check_access = true);901902// Report if there were too many traps at a current method and bci.903// Report if a trap was recorded, and/or PerMethodTrapLimit was exceeded.904// If there is no MDO at all, report no trap unless told to assume it.905bool too_many_traps(ciMethod* method, int bci, Deoptimization::DeoptReason reason);906// This version, unspecific to a particular bci, asks if907// PerMethodTrapLimit was exceeded for all inlined methods seen so far.908bool too_many_traps(Deoptimization::DeoptReason reason,909// Privately used parameter for logging:910ciMethodData* logmd = NULL);911// Report if there were too many recompiles at a method and bci.912bool too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason);913// Return a bitset with the reasons where deoptimization is allowed,914// i.e., where there were not too many uncommon traps.915int _allowed_reasons;916int allowed_deopt_reasons() { return _allowed_reasons; }917void set_allowed_deopt_reasons();918919// Parsing, optimization920PhaseGVN* initial_gvn() { return _initial_gvn; }921Unique_Node_List* for_igvn() { return _for_igvn; }922inline void record_for_igvn(Node* n); // Body is after class Unique_Node_List.923void set_initial_gvn(PhaseGVN *gvn) { _initial_gvn = gvn; }924void set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }925926// Replace n by nn using initial_gvn, calling hash_delete and927// record_for_igvn as needed.928void gvn_replace_by(Node* n, Node* nn);929930931void identify_useful_nodes(Unique_Node_List &useful);932void update_dead_node_list(Unique_Node_List &useful);933void remove_useless_nodes (Unique_Node_List &useful);934935WarmCallInfo* warm_calls() const { return _warm_calls; }936void set_warm_calls(WarmCallInfo* l) { _warm_calls = l; }937WarmCallInfo* pop_warm_call();938939// Record this CallGenerator for inlining at the end of parsing.940void add_late_inline(CallGenerator* cg) {941_late_inlines.insert_before(_late_inlines_pos, cg);942_late_inlines_pos++;943}944945void prepend_late_inline(CallGenerator* cg) {946_late_inlines.insert_before(0, cg);947}948949void add_string_late_inline(CallGenerator* cg) {950_string_late_inlines.push(cg);951}952953void add_boxing_late_inline(CallGenerator* cg) {954_boxing_late_inlines.push(cg);955}956957void remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful);958959void dump_inlining();960961bool over_inlining_cutoff() const {962if (!inlining_incrementally()) {963return unique() > (uint)NodeCountInliningCutoff;964} else {965return live_nodes() > (uint)LiveNodeCountInliningCutoff;966}967}968969void inc_number_of_mh_late_inlines() { _number_of_mh_late_inlines++; }970void dec_number_of_mh_late_inlines() { assert(_number_of_mh_late_inlines > 0, "_number_of_mh_late_inlines < 0 !"); _number_of_mh_late_inlines--; }971bool has_mh_late_inlines() const { return _number_of_mh_late_inlines > 0; }972973void inline_incrementally_one(PhaseIterGVN& igvn);974void inline_incrementally(PhaseIterGVN& igvn);975void inline_string_calls(bool parse_time);976void inline_boxing_calls(PhaseIterGVN& igvn);977void remove_root_to_sfpts_edges(PhaseIterGVN& igvn);978979// Matching, CFG layout, allocation, code generation980PhaseCFG* cfg() { return _cfg; }981bool select_24_bit_instr() const { return _select_24_bit_instr; }982bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }983bool has_java_calls() const { return _java_calls > 0; }984int java_calls() const { return _java_calls; }985int inner_loops() const { return _inner_loops; }986Matcher* matcher() { return _matcher; }987PhaseRegAlloc* regalloc() { return _regalloc; }988int frame_slots() const { return _frame_slots; }989int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'990int frame_size_in_bytes() const { return _frame_slots << LogBytesPerInt; }991RegMask& FIRST_STACK_mask() { return _FIRST_STACK_mask; }992Arena* indexSet_arena() { return _indexSet_arena; }993void* indexSet_free_block_list() { return _indexSet_free_block_list; }994uint node_bundling_limit() { return _node_bundling_limit; }995Bundle* node_bundling_base() { return _node_bundling_base; }996void set_node_bundling_limit(uint n) { _node_bundling_limit = n; }997void set_node_bundling_base(Bundle* b) { _node_bundling_base = b; }998bool starts_bundle(const Node *n) const;999bool need_stack_bang(int frame_size_in_bytes) const;1000bool need_register_stack_bang() const;10011002void update_interpreter_frame_size(int size) {1003if (_interpreter_frame_size < size) {1004_interpreter_frame_size = size;1005}1006}1007int bang_size_in_bytes() const;10081009void set_matcher(Matcher* m) { _matcher = m; }1010//void set_regalloc(PhaseRegAlloc* ra) { _regalloc = ra; }1011void set_indexSet_arena(Arena* a) { _indexSet_arena = a; }1012void set_indexSet_free_block_list(void* p) { _indexSet_free_block_list = p; }10131014// Remember if this compilation changes hardware mode to 24-bit precision1015void set_24_bit_selection_and_mode(bool selection, bool mode) {1016_select_24_bit_instr = selection;1017_in_24_bit_fp_mode = mode;1018}10191020void set_java_calls(int z) { _java_calls = z; }1021void set_inner_loops(int z) { _inner_loops = z; }10221023// Instruction bits passed off to the VM1024int code_size() { return _method_size; }1025CodeBuffer* code_buffer() { return &_code_buffer; }1026int first_block_size() { return _first_block_size; }1027void set_frame_complete(int off) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); }1028ExceptionHandlerTable* handler_table() { return &_handler_table; }1029ImplicitExceptionTable* inc_table() { return &_inc_table; }1030OopMapSet* oop_map_set() { return _oop_map_set; }1031DebugInformationRecorder* debug_info() { return env()->debug_info(); }1032Dependencies* dependencies() { return env()->dependencies(); }1033static int CompiledZap_count() { return _CompiledZap_count; }1034BufferBlob* scratch_buffer_blob() { return _scratch_buffer_blob; }1035void init_scratch_buffer_blob(int const_size);1036void clear_scratch_buffer_blob();1037void set_scratch_buffer_blob(BufferBlob* b) { _scratch_buffer_blob = b; }1038relocInfo* scratch_locs_memory() { return _scratch_locs_memory; }1039void set_scratch_locs_memory(relocInfo* b) { _scratch_locs_memory = b; }10401041// emit to scratch blob, report resulting size1042uint scratch_emit_size(const Node* n);1043void set_in_scratch_emit_size(bool x) { _in_scratch_emit_size = x; }1044bool in_scratch_emit_size() const { return _in_scratch_emit_size; }10451046enum ScratchBufferBlob {1047MAX_inst_size = 1024,1048MAX_locs_size = 128, // number of relocInfo elements1049MAX_const_size = 128,1050MAX_stubs_size = 1281051};10521053// Major entry point. Given a Scope, compile the associated method.1054// For normal compilations, entry_bci is InvocationEntryBci. For on stack1055// replacement, entry_bci indicates the bytecode for which to compile a1056// continuation.1057Compile(ciEnv* ci_env, C2Compiler* compiler, ciMethod* target,1058int entry_bci, bool subsume_loads, bool do_escape_analysis,1059bool eliminate_boxing);10601061// Second major entry point. From the TypeFunc signature, generate code1062// to pass arguments from the Java calling convention to the C calling1063// convention.1064Compile(ciEnv* ci_env, const TypeFunc *(*gen)(),1065address stub_function, const char *stub_name,1066int is_fancy_jump, bool pass_tls,1067bool save_arg_registers, bool return_pc);10681069// From the TypeFunc signature, generate code to pass arguments1070// from Compiled calling convention to Interpreter's calling convention1071void Generate_Compiled_To_Interpreter_Graph(const TypeFunc *tf, address interpreter_entry);10721073// From the TypeFunc signature, generate code to pass arguments1074// from Interpreter's calling convention to Compiler's calling convention1075void Generate_Interpreter_To_Compiled_Graph(const TypeFunc *tf);10761077// Are we compiling a method?1078bool has_method() { return method() != NULL; }10791080// Maybe print some information about this compile.1081void print_compile_messages();10821083// Final graph reshaping, a post-pass after the regular optimizer is done.1084bool final_graph_reshaping();10851086// returns true if adr is completely contained in the given alias category1087bool must_alias(const TypePtr* adr, int alias_idx);10881089// returns true if adr overlaps with the given alias category1090bool can_alias(const TypePtr* adr, int alias_idx);10911092// Driver for converting compiler's IR into machine code bits1093void Output();10941095// Accessors for node bundling info.1096Bundle* node_bundling(const Node *n);1097bool valid_bundle_info(const Node *n);10981099// Schedule and Bundle the instructions1100void ScheduleAndBundle();11011102// Build OopMaps for each GC point1103void BuildOopMaps();11041105// Append debug info for the node "local" at safepoint node "sfpt" to the1106// "array", May also consult and add to "objs", which describes the1107// scalar-replaced objects.1108void FillLocArray( int idx, MachSafePointNode* sfpt,1109Node *local, GrowableArray<ScopeValue*> *array,1110GrowableArray<ScopeValue*> *objs );11111112// If "objs" contains an ObjectValue whose id is "id", returns it, else NULL.1113static ObjectValue* sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id);1114// Requres that "objs" does not contains an ObjectValue whose id matches1115// that of "sv. Appends "sv".1116static void set_sv_for_object_node(GrowableArray<ScopeValue*> *objs,1117ObjectValue* sv );11181119// Process an OopMap Element while emitting nodes1120void Process_OopMap_Node(MachNode *mach, int code_offset);11211122// Initialize code buffer1123CodeBuffer* init_buffer(uint* blk_starts);11241125// Write out basic block data to code buffer1126void fill_buffer(CodeBuffer* cb, uint* blk_starts);11271128// Determine which variable sized branches can be shortened1129void shorten_branches(uint* blk_starts, int& code_size, int& reloc_size, int& stub_size);11301131// Compute the size of first NumberOfLoopInstrToAlign instructions1132// at the head of a loop.1133void compute_loop_first_inst_sizes();11341135// Compute the information for the exception tables1136void FillExceptionTables(uint cnt, uint *call_returns, uint *inct_starts, Label *blk_labels);11371138// Stack slots that may be unused by the calling convention but must1139// otherwise be preserved. On Intel this includes the return address.1140// On PowerPC it includes the 4 words holding the old TOC & LR glue.1141uint in_preserve_stack_slots();11421143// "Top of Stack" slots that may be unused by the calling convention but must1144// otherwise be preserved.1145// On Intel these are not necessary and the value can be zero.1146// On Sparc this describes the words reserved for storing a register window1147// when an interrupt occurs.1148static uint out_preserve_stack_slots();11491150// Number of outgoing stack slots killed above the out_preserve_stack_slots1151// for calls to C. Supports the var-args backing area for register parms.1152uint varargs_C_out_slots_killed() const;11531154// Number of Stack Slots consumed by a synchronization entry1155int sync_stack_slots() const;11561157// Compute the name of old_SP. See <arch>.ad for frame layout.1158OptoReg::Name compute_old_SP();11591160#ifdef ENABLE_ZAP_DEAD_LOCALS1161static bool is_node_getting_a_safepoint(Node*);1162void Insert_zap_nodes();1163Node* call_zap_node(MachSafePointNode* n, int block_no);1164#endif11651166private:1167// Phase control:1168void Init(int aliaslevel); // Prepare for a single compilation1169int Inline_Warm(); // Find more inlining work.1170void Finish_Warm(); // Give up on further inlines.1171void Optimize(); // Given a graph, optimize it1172void Code_Gen(); // Generate code from a graph11731174// Management of the AliasType table.1175void grow_alias_types();1176AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);1177const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;1178AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);11791180void verify_top(Node*) const PRODUCT_RETURN;11811182// Intrinsic setup.1183void register_library_intrinsics(); // initializer1184CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual); // constructor1185int intrinsic_insertion_index(ciMethod* m, bool is_virtual); // helper1186CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual); // query fn1187void register_intrinsic(CallGenerator* cg); // update fn11881189#ifndef PRODUCT1190static juint _intrinsic_hist_count[vmIntrinsics::ID_LIMIT];1191static jubyte _intrinsic_hist_flags[vmIntrinsics::ID_LIMIT];1192#endif1193// Function calls made by the public function final_graph_reshaping.1194// No need to be made public as they are not called elsewhere.1195void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc);1196void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc );1197void eliminate_redundant_card_marks(Node* n);11981199public:12001201// Note: Histogram array size is about 1 Kb.1202enum { // flag bits:1203_intrinsic_worked = 1, // succeeded at least once1204_intrinsic_failed = 2, // tried it but it failed1205_intrinsic_disabled = 4, // was requested but disabled (e.g., -XX:-InlineUnsafeOps)1206_intrinsic_virtual = 8, // was seen in the virtual form (rare)1207_intrinsic_both = 16 // was seen in the non-virtual form (usual)1208};1209// Update histogram. Return boolean if this is a first-time occurrence.1210static bool gather_intrinsic_statistics(vmIntrinsics::ID id,1211bool is_virtual, int flags) PRODUCT_RETURN0;1212static void print_intrinsic_statistics() PRODUCT_RETURN;12131214// Graph verification code1215// Walk the node list, verifying that there is a one-to-one1216// correspondence between Use-Def edges and Def-Use edges1217// The option no_dead_code enables stronger checks that the1218// graph is strongly connected from root in both directions.1219void verify_graph_edges(bool no_dead_code = false) PRODUCT_RETURN;12201221// Verify GC barrier patterns1222void verify_barriers() PRODUCT_RETURN;12231224// End-of-run dumps.1225static void print_statistics() PRODUCT_RETURN;12261227// Dump formatted assembly1228void dump_asm(int *pcs = NULL, uint pc_limit = 0) PRODUCT_RETURN;1229void dump_pc(int *pcs, int pc_limit, Node *n);12301231// Verify ADLC assumptions during startup1232static void adlc_verification() PRODUCT_RETURN;12331234// Definitions of pd methods1235static void pd_compiler2_init();12361237// Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)1238static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl);12391240// Auxiliary method for randomized fuzzing/stressing1241static bool randomized_select(int count);1242#ifdef ASSERT1243bool _type_verify_symmetry;1244#endif12451246void shenandoah_eliminate_g1_wb_pre(Node* call, PhaseIterGVN* igvn);1247};12481249#endif // SHARE_VM_OPTO_COMPILE_HPP125012511252