src/share/vm/opto/compile.hpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
   1 /*
   2  * Copyright (c) 1997, 2012, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_OPTO_COMPILE_HPP
  26 #define SHARE_VM_OPTO_COMPILE_HPP
  27 
  28 #include "asm/codeBuffer.hpp"
  29 #include "ci/compilerInterface.hpp"
  30 #include "code/debugInfoRec.hpp"
  31 #include "code/exceptionHandlerTable.hpp"
  32 #include "compiler/compilerOracle.hpp"
  33 #include "compiler/compileBroker.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/phase.hpp"
  40 #include "opto/regmask.hpp"
  41 #include "runtime/deoptimization.hpp"
  42 #include "runtime/vmThread.hpp"

  43 
  44 class Block;
  45 class Bundle;
  46 class C2Compiler;
  47 class CallGenerator;
  48 class ConnectionGraph;
  49 class InlineTree;
  50 class Int_Array;
  51 class Matcher;
  52 class MachConstantNode;
  53 class MachConstantBaseNode;
  54 class MachNode;
  55 class MachOper;
  56 class MachSafePointNode;
  57 class Node;
  58 class Node_Array;
  59 class Node_Notes;
  60 class OptoReg;
  61 class PhaseCFG;
  62 class PhaseGVN;


 305   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 306 #endif
 307 
 308   // JSR 292
 309   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 310 
 311   // Compilation environment.
 312   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 313   ciEnv*                _env;                   // CI interface
 314   CompileLog*           _log;                   // from CompilerThread
 315   const char*           _failure_reason;        // for record_failure/failing pattern
 316   GrowableArray<CallGenerator*>* _intrinsics;   // List of intrinsics.
 317   GrowableArray<Node*>* _macro_nodes;           // List of nodes which need to be expanded before matching.
 318   GrowableArray<Node*>* _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 319   GrowableArray<Node*>* _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 320   ConnectionGraph*      _congraph;
 321 #ifndef PRODUCT
 322   IdealGraphPrinter*    _printer;
 323 #endif
 324 

 325   // Node management
 326   uint                  _unique;                // Counter for unique Node indices
 327   VectorSet             _dead_node_list;        // Set of dead nodes
 328   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 329                                                 // So use this to keep count and make the call O(1).
 330   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 331   Arena                 _node_arena;            // Arena for new-space Nodes
 332   Arena                 _old_arena;             // Arena for old-space Nodes, lifetime during xform
 333   RootNode*             _root;                  // Unique root of compilation, or NULL after bail-out.
 334   Node*                 _top;                   // Unique top node.  (Reset by various phases.)
 335 
 336   Node*                 _immutable_memory;      // Initial memory state
 337 
 338   Node*                 _recent_alloc_obj;
 339   Node*                 _recent_alloc_ctl;
 340 
 341   // Constant table
 342   ConstantTable         _constant_table;        // The constant table for this compile.
 343   MachConstantBaseNode* _mach_constant_base_node;  // Constant table base node singleton.
 344 


 556   void          set_do_count_invocations(bool z){ _do_count_invocations = z; }
 557   bool              do_method_data_update() const { return _do_method_data_update; }
 558   void          set_do_method_data_update(bool z) { _do_method_data_update = z; }
 559   int               AliasLevel() const          { return _AliasLevel; }
 560   bool              print_assembly() const       { return _print_assembly; }
 561   void          set_print_assembly(bool z)       { _print_assembly = z; }
 562   // check the CompilerOracle for special behaviours for this compile
 563   bool          method_has_option(const char * option) {
 564     return method() != NULL && method()->has_option(option);
 565   }
 566 #ifndef PRODUCT
 567   bool          trace_opto_output() const       { return _trace_opto_output; }
 568   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 569   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 570 #endif
 571 
 572   // JSR 292
 573   bool              has_method_handle_invokes() const { return _has_method_handle_invokes;     }
 574   void          set_has_method_handle_invokes(bool z) {        _has_method_handle_invokes = z; }
 575 


 576   void begin_method() {
 577 #ifndef PRODUCT
 578     if (_printer) _printer->begin_method(this);
 579 #endif












 580   }
 581   void print_method(const char * name, int level = 1) {

 582 #ifndef PRODUCT
 583     if (_printer) _printer->print_method(this, name, level);
 584 #endif












 585   }
 586   void end_method() {
 587 #ifndef PRODUCT
 588     if (_printer) _printer->end_method();
 589 #endif
 590   }
 591 
 592   int           macro_count()             const { return _macro_nodes->length(); }
 593   int           predicate_count()         const { return _predicate_opaqs->length();}
 594   int           expensive_count()         const { return _expensive_nodes->length(); }
 595   Node*         macro_node(int idx)       const { return _macro_nodes->at(idx); }
 596   Node*         predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
 597   Node*         expensive_node(int idx)   const { return _expensive_nodes->at(idx); }
 598   ConnectionGraph* congraph()                   { return _congraph;}
 599   void set_congraph(ConnectionGraph* congraph)  { _congraph = congraph;}
 600   void add_macro_node(Node * n) {
 601     //assert(n->is_macro(), "must be a macro node");
 602     assert(!_macro_nodes->contains(n), " duplicate entry in expand list");
 603     _macro_nodes->append(n);
 604   }
 605   void remove_macro_node(Node * n) {
 606     // this function may be called twice for a node so check


   1 /*
   2  * Copyright (c) 1997, 2013, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_OPTO_COMPILE_HPP
  26 #define SHARE_VM_OPTO_COMPILE_HPP
  27 
  28 #include "asm/codeBuffer.hpp"
  29 #include "ci/compilerInterface.hpp"
  30 #include "code/debugInfoRec.hpp"
  31 #include "code/exceptionHandlerTable.hpp"
  32 #include "compiler/compilerOracle.hpp"
  33 #include "compiler/compileBroker.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 "trace/tracing.hpp"
  45 
  46 class Block;
  47 class Bundle;
  48 class C2Compiler;
  49 class CallGenerator;
  50 class ConnectionGraph;
  51 class InlineTree;
  52 class Int_Array;
  53 class Matcher;
  54 class MachConstantNode;
  55 class MachConstantBaseNode;
  56 class MachNode;
  57 class MachOper;
  58 class MachSafePointNode;
  59 class Node;
  60 class Node_Array;
  61 class Node_Notes;
  62 class OptoReg;
  63 class PhaseCFG;
  64 class PhaseGVN;


 307   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 308 #endif
 309 
 310   // JSR 292
 311   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 312 
 313   // Compilation environment.
 314   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 315   ciEnv*                _env;                   // CI interface
 316   CompileLog*           _log;                   // from CompilerThread
 317   const char*           _failure_reason;        // for record_failure/failing pattern
 318   GrowableArray<CallGenerator*>* _intrinsics;   // List of intrinsics.
 319   GrowableArray<Node*>* _macro_nodes;           // List of nodes which need to be expanded before matching.
 320   GrowableArray<Node*>* _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 321   GrowableArray<Node*>* _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 322   ConnectionGraph*      _congraph;
 323 #ifndef PRODUCT
 324   IdealGraphPrinter*    _printer;
 325 #endif
 326 
 327 
 328   // Node management
 329   uint                  _unique;                // Counter for unique Node indices
 330   VectorSet             _dead_node_list;        // Set of dead nodes
 331   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 332                                                 // So use this to keep count and make the call O(1).
 333   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 334   Arena                 _node_arena;            // Arena for new-space Nodes
 335   Arena                 _old_arena;             // Arena for old-space Nodes, lifetime during xform
 336   RootNode*             _root;                  // Unique root of compilation, or NULL after bail-out.
 337   Node*                 _top;                   // Unique top node.  (Reset by various phases.)
 338 
 339   Node*                 _immutable_memory;      // Initial memory state
 340 
 341   Node*                 _recent_alloc_obj;
 342   Node*                 _recent_alloc_ctl;
 343 
 344   // Constant table
 345   ConstantTable         _constant_table;        // The constant table for this compile.
 346   MachConstantBaseNode* _mach_constant_base_node;  // Constant table base node singleton.
 347 


 559   void          set_do_count_invocations(bool z){ _do_count_invocations = z; }
 560   bool              do_method_data_update() const { return _do_method_data_update; }
 561   void          set_do_method_data_update(bool z) { _do_method_data_update = z; }
 562   int               AliasLevel() const          { return _AliasLevel; }
 563   bool              print_assembly() const       { return _print_assembly; }
 564   void          set_print_assembly(bool z)       { _print_assembly = z; }
 565   // check the CompilerOracle for special behaviours for this compile
 566   bool          method_has_option(const char * option) {
 567     return method() != NULL && method()->has_option(option);
 568   }
 569 #ifndef PRODUCT
 570   bool          trace_opto_output() const       { return _trace_opto_output; }
 571   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 572   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 573 #endif
 574 
 575   // JSR 292
 576   bool              has_method_handle_invokes() const { return _has_method_handle_invokes;     }
 577   void          set_has_method_handle_invokes(bool z) {        _has_method_handle_invokes = z; }
 578 
 579   jlong _latest_stage_start_counter;
 580 
 581   void begin_method() {
 582 #ifndef PRODUCT
 583     if (_printer) _printer->begin_method(this);
 584 #endif
 585     C->_latest_stage_start_counter = os::elapsed_counter();
 586   }
 587 
 588   void print_method(CompilerPhaseType cpt, int level = 1) {
 589     EventCompilerPhase event(UNTIMED);
 590     if (event.should_commit()) {
 591       event.set_starttime(C->_latest_stage_start_counter);
 592       event.set_endtime(os::elapsed_counter());
 593       event.set_phase((u1) cpt);
 594       event.set_compileID(C->_compile_id);
 595       event.set_phaseLevel(level);
 596       event.commit();
 597     }
 598 
 599 
 600 #ifndef PRODUCT
 601     if (_printer) _printer->print_method(this, CompilerPhaseTypeHelper::to_string(cpt), level);
 602 #endif
 603     C->_latest_stage_start_counter = os::elapsed_counter();
 604   }
 605 
 606   void end_method(int level = 1) {
 607     EventCompilerPhase event(UNTIMED);
 608     if (event.should_commit()) {
 609       event.set_starttime(C->_latest_stage_start_counter);
 610       event.set_endtime(os::elapsed_counter());
 611       event.set_phase((u1) PHASE_END);
 612       event.set_compileID(C->_compile_id);
 613       event.set_phaseLevel(level);
 614       event.commit();
 615     }

 616 #ifndef PRODUCT
 617     if (_printer) _printer->end_method();
 618 #endif
 619   }
 620 
 621   int           macro_count()             const { return _macro_nodes->length(); }
 622   int           predicate_count()         const { return _predicate_opaqs->length();}
 623   int           expensive_count()         const { return _expensive_nodes->length(); }
 624   Node*         macro_node(int idx)       const { return _macro_nodes->at(idx); }
 625   Node*         predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
 626   Node*         expensive_node(int idx)   const { return _expensive_nodes->at(idx); }
 627   ConnectionGraph* congraph()                   { return _congraph;}
 628   void set_congraph(ConnectionGraph* congraph)  { _congraph = congraph;}
 629   void add_macro_node(Node * n) {
 630     //assert(n->is_macro(), "must be a macro node");
 631     assert(!_macro_nodes->contains(n), " duplicate entry in expand list");
 632     _macro_nodes->append(n);
 633   }
 634   void remove_macro_node(Node * n) {
 635     // this function may be called twice for a node so check