hotspot/src/share/vm/opto/parse.hpp
author vlivanov
Fri, 01 Feb 2013 03:02:01 -0800
changeset 15472 ae13b6ad6c25
parent 15118 1a1a6d1dfaab
child 15816 33b9a6b4f9df
permissions -rw-r--r--
8005439: no message about inline method if it specifed by CompileCommand Reviewed-by: kvn, vlivanov Contributed-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13963
e5b53c306fb5 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 13391
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5228
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5228
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5228
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    25
#ifndef SHARE_VM_OPTO_PARSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    26
#define SHARE_VM_OPTO_PARSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    28
#include "ci/ciMethodData.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    29
#include "ci/ciTypeFlow.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    30
#include "compiler/methodLiveness.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    31
#include "libadt/vectset.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    32
#include "oops/generateOopMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    33
#include "opto/graphKit.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    34
#include "opto/subnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    35
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class BytecodeParseHistogram;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class InlineTree;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class Parse;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class SwitchRange;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//------------------------------InlineTree-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class InlineTree : public ResourceObj {
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
    44
  friend class VMStructs;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
    45
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  Compile*    C;                  // cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  JVMState*   _caller_jvms;       // state of caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  ciMethod*   _method;            // method being called by the caller_jvms
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  InlineTree* _caller_tree;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  uint        _count_inline_bcs;  // Accumulated count of inlined bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Call-site count / interpreter invocation count, scaled recursively.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Always between 0.0 and 1.0.  Represents the percentage of the method's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // total execution time used at this call site.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  const float _site_invoke_ratio;
10007
43d4a6542551 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 9633
diff changeset
    55
  const int   _max_inline_level;  // the maximum inline level for this sub-tree (may be adjusted)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  float compute_callee_frequency( int caller_bci ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  GrowableArray<InlineTree*> _subtrees;
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
    59
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
    60
  void print_impl(outputStream* stj, int indent) const PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  InlineTree(Compile* C,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
             const InlineTree* caller_tree,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
             ciMethod* callee_method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
             JVMState* caller_jvms,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
             int caller_bci,
4586
f1c484fca023 6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents: 3908
diff changeset
    68
             float site_invoke_ratio,
10007
43d4a6542551 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 9633
diff changeset
    69
             int max_inline_level);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  InlineTree *build_inline_tree_for_callee(ciMethod* callee_method,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
                                           JVMState* caller_jvms,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
                                           int caller_bci);
15113
823590505eb4 8005071: Incremental inlining for JSR 292
roland
parents: 13963
diff changeset
    73
  const char* try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result, bool& should_delay);
9633
92a7a2841a16 7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents: 9446
diff changeset
    74
  const char* should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const;
92a7a2841a16 7042122: JSR 292: adjust various inline thresholds for JSR 292 API methods and method handle adapters
twisti
parents: 9446
diff changeset
    75
  const char* should_not_inline(ciMethod* callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const;
15472
ae13b6ad6c25 8005439: no message about inline method if it specifed by CompileCommand
vlivanov
parents: 15118
diff changeset
    76
  void        print_inlining(ciMethod* callee_method, int caller_bci,
ae13b6ad6c25 8005439: no message about inline method if it specifed by CompileCommand
vlivanov
parents: 15118
diff changeset
    77
                             const char* msg, bool success) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  InlineTree *caller_tree()       const { return _caller_tree;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  InlineTree* callee_at(int bci, ciMethod* m) const;
10007
43d4a6542551 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 9633
diff changeset
    81
  int         inline_level()      const { return stack_depth(); }
4586
f1c484fca023 6912063: inlining parameters need to be adjusted for some uses of the JVM
jrose
parents: 3908
diff changeset
    82
  int         stack_depth()       const { return _caller_jvms ? _caller_jvms->depth() : 0; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
public:
10509
43d670e5701e 7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents: 10007
diff changeset
    85
  static const char* check_can_parse(ciMethod* callee);
43d670e5701e 7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents: 10007
diff changeset
    86
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  static InlineTree* build_inline_tree_root();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12945
diff changeset
    88
  static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // For temporary (stack-allocated, stateless) ilts:
10007
43d4a6542551 7057587: JSR 292 - crash with jruby in test/test_respond_to.rb
never
parents: 9633
diff changeset
    91
  InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int max_inline_level);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // InlineTree enum
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  enum InlineStyle {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    Inline_do_not_inline             =   0, //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    Inline_cha_is_monomorphic        =   1, //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    Inline_type_profile_monomorphic  =   2  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // See if it is OK to inline.
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1554
diff changeset
   101
  // The receiver is the inline tree for the caller.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // The result is a temperature indication.  If it is hot or cold,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // inlining is immediate or undesirable.  Otherwise, the info block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // returned is newly allocated and may be enqueued.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // If the method is inlinable, a new inline subtree is created on the fly,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // and may be accessed by find_subtree_from_root.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // The call_method is the dest_method for a special or static invocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // The call_method is an optimized virtual method candidate otherwise.
15113
823590505eb4 8005071: Incremental inlining for JSR 292
roland
parents: 13963
diff changeset
   111
  WarmCallInfo* ok_to_inline(ciMethod *call_method, JVMState* caller_jvms, ciCallProfile& profile, WarmCallInfo* wci, bool& should_delay);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Information about inlined method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  JVMState*   caller_jvms()       const { return _caller_jvms; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  ciMethod   *method()            const { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  int         caller_bci()        const { return _caller_jvms ? _caller_jvms->bci() : InvocationEntryBci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  uint        count_inline_bcs()  const { return _count_inline_bcs; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  float       site_invoke_ratio() const { return _site_invoke_ratio; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  uint        _count_inlines;     // Count of inlined methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Debug information collected during parse
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  uint        count_inlines()     const { return _count_inlines; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  GrowableArray<InlineTree*> subtrees() { return _subtrees; }
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
   128
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10509
diff changeset
   129
  void print_value_on(outputStream* st) const PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
//------------------------------Parse------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
// Parse bytecodes, build a Graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
class Parse : public GraphKit {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Per-block information needed by the parser:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  class Block {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
   private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    ciTypeFlow::Block* _flow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    int                _pred_count;     // how many predecessors in CFG?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    int                _preds_parsed;   // how many of these have been parsed?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    uint               _count;          // how many times executed?  Currently only set by _goto's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    bool               _is_parsed;      // has this block been parsed yet?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    bool               _is_handler;     // is this block an exception handler?
8732
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   147
    bool               _has_merged_backedge; // does this block have merged backedge?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    SafePointNode*     _start_map;      // all values flowing into this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    MethodLivenessResult _live_locals;  // lazily initialized liveness bitmap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    int                _num_successors; // Includes only normal control flow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    int                _all_successors; // Include exception paths also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    Block**            _successors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    // Use init_node/init_graph to initialize Blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    // Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    Block() : _live_locals(NULL,0) { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
   public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    // Set up the block data structure itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    void init_node(Parse* outer, int po);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    // Set up the block's relations to other blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    void init_graph(Parse* outer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    ciTypeFlow::Block* flow() const        { return _flow; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    int pred_count() const                 { return _pred_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    int preds_parsed() const               { return _preds_parsed; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    bool is_parsed() const                 { return _is_parsed; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    bool is_handler() const                { return _is_handler; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    void set_count( uint x )               { _count = x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    uint count() const                     { return _count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    SafePointNode* start_map() const       { assert(is_merged(),"");   return _start_map; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    void set_start_map(SafePointNode* m)   { assert(!is_merged(), ""); _start_map = m; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    // True after any predecessor flows control into this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    bool is_merged() const                 { return _start_map != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
8732
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   180
#ifdef ASSERT
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   181
    // True after backedge predecessor flows control into this block
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   182
    bool has_merged_backedge() const       { return _has_merged_backedge; }
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   183
    void mark_merged_backedge(Block* pred) {
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   184
      assert(is_SEL_head(), "should be loop head");
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   185
      if (pred != NULL && is_SEL_backedge(pred)) {
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   186
        assert(is_parsed(), "block should be parsed before merging backedges");
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   187
        _has_merged_backedge = true;
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   188
      }
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   189
    }
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   190
#endif
16fc1c68714b 7008866: Missing loop predicate for loop with multiple entries
kvn
parents: 7397
diff changeset
   191
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    // True when all non-exception predecessors have been parsed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    bool is_ready() const                  { return preds_parsed() == pred_count(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    int num_successors() const             { return _num_successors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    int all_successors() const             { return _all_successors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    Block* successor_at(int i) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      assert((uint)i < (uint)all_successors(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      return _successors[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    Block* successor_for_bci(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    int start() const                      { return flow()->start(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    int limit() const                      { return flow()->limit(); }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   205
    int rpo() const                        { return flow()->rpo(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    int start_sp() const                   { return flow()->stack_size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   208
    bool is_loop_head() const              { return flow()->is_loop_head(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   209
    bool is_SEL_head() const               { return flow()->is_single_entry_loop_head(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   210
    bool is_SEL_backedge(Block* pred) const{ return is_SEL_head() && pred->rpo() >= rpo(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   211
    bool is_invariant_local(uint i) const  {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   212
      const JVMState* jvms = start_map()->jvms();
1554
59019800a87c 6766316: assert(!nocreate,"Cannot build a phi for a block already parsed.")
kvn
parents: 1399
diff changeset
   213
      if (!jvms->is_loc(i) || flow()->outer()->has_irreducible_entry()) return false;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   214
      return flow()->is_invariant_local(i - jvms->locoff());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   215
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   216
    bool can_elide_SEL_phi(uint i) const  { assert(is_SEL_head(),""); return is_invariant_local(i); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   217
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    const Type* peek(int off=0) const      { return stack_type_at(start_sp() - (off+1)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    const Type* stack_type_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    const Type* local_type_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    static const Type* get_type(ciType* t) { return Type::get_typeflow_type(t); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    bool has_trap_at(int bci) const        { return flow()->has_trap() && flow()->trap_bci() == bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    // Call this just before parsing a block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    void mark_parsed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      assert(!_is_parsed, "must parse each block exactly once");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      _is_parsed = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    // Return the phi/region input index for the "current" pred,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    // and bump the pred number.  For historical reasons these index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    // numbers are handed out in descending order.  The last index is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    // always PhiNode::Input (i.e., 1).  The value returned is known
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    // as a "path number" because it distinguishes by which path we are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    // entering the block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    int next_path_num() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      assert(preds_parsed() < pred_count(), "too many preds?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      return pred_count() - _preds_parsed++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    // Add a previously unaccounted predecessor to this block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    // This operates by increasing the size of the block's region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    // and all its phi nodes (if any).  The value returned is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    // path number ("pnum").
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    int add_new_path();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    // Initialize me by recording the parser's map.  My own map must be NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    void record_state(Parse* outer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // BytecodeParseHistogram collects number of bytecodes parsed, nodes constructed, and transformations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  class BytecodeParseHistogram : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
   private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    enum BPHType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      BPH_transforms,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      BPH_values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    static bool _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    static uint _bytecodes_parsed [Bytecodes::number_of_codes];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    static uint _nodes_constructed[Bytecodes::number_of_codes];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    static uint _nodes_transformed[Bytecodes::number_of_codes];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    static uint _new_values       [Bytecodes::number_of_codes];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    Bytecodes::Code _initial_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    int             _initial_node_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    int             _initial_transforms;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    int             _initial_values;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    Parse     *_parser;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    Compile   *_compiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    static void reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    // Return info being collected, select with global flag 'BytecodeParseInfo'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    int current_count(BPHType info_selector);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
   public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    BytecodeParseHistogram(Parse *p, Compile *c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    static bool initialized();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    // Record info when starting to parse one bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    void set_initial_state( Bytecodes::Code bc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    // Record results of parsing one bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    void record_change();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    // Profile printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    static void print(float cutoff = 0.01F); // cutoff in percent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // Record work done during parsing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    BytecodeParseHistogram* _parse_histogram;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    void set_parse_histogram(BytecodeParseHistogram *bph) { _parse_histogram = bph; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    BytecodeParseHistogram* parse_histogram()      { return _parse_histogram; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  friend class Block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // Variables which characterize this compilation as a whole:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  JVMState*     _caller;        // JVMS which carries incoming args & state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  float         _expected_uses; // expected number of calls to this code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  float         _prof_factor;   // discount applied to my profile counts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  int           _depth;         // Inline tree depth, for debug printouts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  const TypeFunc*_tf;           // My kind of function type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  int           _entry_bci;     // the osr bci or InvocationEntryBci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  ciTypeFlow*   _flow;          // Results of previous flow pass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  Block*        _blocks;        // Array of basic-block structs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  int           _block_count;   // Number of elements in _blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  GraphKit      _exits;         // Record all normal returns and throws here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  bool          _wrote_final;   // Did we write a final field?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  bool          _count_invocations; // update and test invocation counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  bool          _method_data_update; // update method data oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  // Variables which track Java semantics during bytecode parsing:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  Block*            _block;     // block currently getting parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  ciBytecodeStream  _iter;      // stream of this method's bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  int           _blocks_merged; // Progress meter: state merges from BB preds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  int           _blocks_parsed; // Progress meter: BBs actually parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  const FastLockNode* _synch_lock; // FastLockNode for synchronized method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  int _max_switch_depth;        // Debugging SwitchRanges.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  int _est_switch_depth;        // Debugging SwitchRanges.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  Parse(JVMState* caller, ciMethod* parse_method, float expected_uses);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  virtual Parse* is_Parse() const { return (Parse*)this; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // Accessors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  JVMState*     caller()        const { return _caller; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  float         expected_uses() const { return _expected_uses; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  float         prof_factor()   const { return _prof_factor; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  int           depth()         const { return _depth; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  const TypeFunc* tf()          const { return _tf; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  //            entry_bci()     -- see osr_bci, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  ciTypeFlow*   flow()          const { return _flow; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   353
  //            blocks()        -- see rpo_at, start_block, etc.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  int           block_count()   const { return _block_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  GraphKit&     exits()               { return _exits; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  bool          wrote_final() const   { return _wrote_final; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  void      set_wrote_final(bool z)   { _wrote_final = z; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  bool          count_invocations() const  { return _count_invocations; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  bool          method_data_update() const { return _method_data_update; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  Block*             block()    const { return _block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  ciBytecodeStream&  iter()           { return _iter; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  Bytecodes::Code    bc()       const { return _iter.cur_bc(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  void set_block(Block* b)            { _block = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // Derived accessors:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  bool is_normal_parse() const  { return _entry_bci == InvocationEntryBci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  bool is_osr_parse() const     { return _entry_bci != InvocationEntryBci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  int osr_bci() const           { assert(is_osr_parse(),""); return _entry_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  void set_parse_bci(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // Must this parse be aborted?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  bool failing()                { return C->failing(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   378
  Block* rpo_at(int rpo) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   379
    assert(0 <= rpo && rpo < _block_count, "oob");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   380
    return &_blocks[rpo];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  Block* start_block() {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 956
diff changeset
   383
    return rpo_at(flow()->start_block()->rpo());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  // Can return NULL if the flow pass did not complete a block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  Block* successor_for_bci(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    return block()->successor_for_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  // Create a JVMS & map for the initial state of this method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  SafePointNode* create_entry_map();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  // OSR helpers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  Node *fetch_interpreter_state(int index, BasicType bt, Node *local_addrs, Node *local_addrs_base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  Node* check_interpreter_type(Node* l, const Type* type, SafePointNode* &bad_type_exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  void  load_interpreter_state(Node* osr_buf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // Functions for managing basic blocks:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  void init_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  void load_state_from(Block* b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  void store_state_to(Block* b) { b->record_state(this); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // Parse all the basic blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  void do_all_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // Parse the current basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  void do_one_block();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // Raise an error if we get a bad ciTypeFlow CFG.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  void handle_missing_successor(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // first actions (before BCI 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  void do_method_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // implementation of monitorenter/monitorexit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  void do_monitor_enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  void do_monitor_exit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // Eagerly create phie throughout the state, to cope with back edges.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  void ensure_phis_everywhere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // Merge the current mapping into the basic block starting at bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  void merge(          int target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  // Same as plain merge, except that it allocates a new path number.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  void merge_new_path( int target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // Merge the current mapping into an exception handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  void merge_exception(int target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  // Helper: Merge the current mapping into the given basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  void merge_common(Block* target, int pnum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // Helper functions for merging individual cells.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  PhiNode *ensure_phi(       int idx, bool nocreate = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  PhiNode *ensure_memory_phi(int idx, bool nocreate = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Helper to merge the current memory state into the given basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  void merge_memory_edges(MergeMemNode* n, int pnum, bool nophi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // Parse this bytecode, and alter the Parsers JVM->Node mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  void do_one_bytecode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  // helper function to generate array store check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  void array_store_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  // Helper function to generate array load
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  void array_load(BasicType etype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  // Helper function to generate array store
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  void array_store(BasicType etype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // Helper function to compute array addressing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  Node* array_addressing(BasicType type, int vals, const Type* *result2=NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  // Pass current map to exits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  void return_current(Node* value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  // Register finalizers on return from Object.<init>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  void call_register_finalizer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // Insert a compiler safepoint into the graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  void add_safepoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  // Insert a compiler safepoint into the graph, if there is a back-branch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  void maybe_add_safepoint(int target_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    if (UseLoopSafepoints && target_bci <= bci()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
      add_safepoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  // Note:  Intrinsic generation routines may be found in library_call.cpp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  // Helper function to setup Ideal Call nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  void do_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // Helper function to uncommon-trap or bailout for non-compilable call-sites
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  bool can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass *klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  // Helper function to setup for type-profile based inlining
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  bool prepare_type_profile_inline(ciInstanceKlass* prof_klass, ciMethod* prof_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  // Helper functions for type checking bytecodes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  void  do_checkcast();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  void  do_instanceof();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  // Helper functions for shifting & arithmetic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  void modf();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  void modd();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  void l2f();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  void do_irem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // implementation of _get* and _put* bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  void do_getstatic() { do_field_access(true,  false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  void do_getfield () { do_field_access(true,  true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  void do_putstatic() { do_field_access(false, false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  void do_putfield () { do_field_access(false, true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // common code for making initial checks and forming addresses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  void do_field_access(bool is_get, bool is_field);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  bool static_field_ok_in_clinit(ciField *field, ciMethod *method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  // common code for actually performing the load or store
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
   498
  void do_get_xxx(Node* obj, ciField* field, bool is_field);
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
   499
  void do_put_xxx(Node* obj, ciField* field, bool is_field);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  // loading from a constant field or the constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  // returns false if push failed (non-perm field constants only, not ldcs)
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 3261
diff changeset
   503
  bool push_constant(ciConstant con, bool require_constant = false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  // implementation of object creation bytecodes
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   506
  void emit_guard_for_new(ciInstanceKlass* klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  void do_new();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  void do_newarray(BasicType elemtype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  void do_anewarray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  void do_multianewarray();
2574
1d5f85c2d755 6589834: deoptimization problem with -XX:+DeoptimizeALot
cfang
parents: 2131
diff changeset
   511
  Node* expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  // implementation of jsr/ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  void do_jsr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  void do_ret();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  float   dynamic_branch_prediction(float &cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  float   branch_prediction(float &cnt, BoolTest::mask btest, int target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  bool    seems_never_taken(float prob);
6416
d49b65c9425a 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 5925
diff changeset
   520
  bool    seems_stable_comparison(BoolTest::mask btest, Node* c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
956
f1aadc829f59 6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents: 670
diff changeset
   522
  void    do_ifnull(BoolTest::mask btest, Node* c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  void    do_if(BoolTest::mask btest, Node* c);
4643
61c659c91c57 6894779: Loop Predication for Loop Optimizer in C2
cfang
parents: 4586
diff changeset
   524
  int     repush_if_args();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  void    adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
                              Block* path, Block* other_path);
12945
e63d6176cbd1 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 10547
diff changeset
   527
  void    sharpen_type_after_if(BoolTest::mask btest,
e63d6176cbd1 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 10547
diff changeset
   528
                                Node* con, const Type* tcon,
e63d6176cbd1 7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents: 10547
diff changeset
   529
                                Node* val, const Type* tval);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  IfNode* jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  Node*   jump_if_join(Node* iffalse, Node* iftrue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  void    jump_if_true_fork(IfNode *ifNode, int dest_bci_if_true, int prof_table_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  void    jump_if_false_fork(IfNode *ifNode, int dest_bci_if_false, int prof_table_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  void    jump_if_always_fork(int dest_bci_if_true, int prof_table_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  friend class SwitchRange;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  void    do_tableswitch();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  void    do_lookupswitch();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  void    jump_switch_ranges(Node* a, SwitchRange* lo, SwitchRange* hi, int depth = 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  bool    create_jump_tables(Node* a, SwitchRange* lo, SwitchRange* hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  // helper functions for methodData style profiling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  void test_counter_against_threshold(Node* cnt, int limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  void increment_and_test_invocation_counter(int limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  void test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, int limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  Node* method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  void increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize offset, Node* idx = NULL, uint stride = 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  void set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  void profile_method_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  void profile_taken_branch(int target_bci, bool force_update = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  void profile_not_taken_branch(bool force_update = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  void profile_call(Node* receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  void profile_generic_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  void profile_receiver_type(Node* receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  void profile_ret(int target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  void profile_null_checkcast();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  void profile_switch_case(int table_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  // helper function for call statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  void count_compiled_calls(bool at_method_entry, bool is_inline) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  Node_Notes* make_node_notes(Node_Notes* caller_nn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  // Helper functions for handling normal and abnormal exits.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  void build_exits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  // Fix up all exceptional control flow exiting a single bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  void do_exceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  // Fix up all exiting control flow at the end of the parse.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  void do_exits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  // Add Catch/CatchProjs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  // The call is either a Java call or the VM's rethrow stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  void catch_call_exceptions(ciExceptionHandlerStream&);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  // Handle all exceptions thrown by the inlined method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  // Also handles exceptions for individual bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  void catch_inline_exceptions(SafePointNode* ex_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  // Merge the given map into correct exceptional exit state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  // Assumes that there is no applicable local handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  void throw_to_exit(SafePointNode* ex_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  // Handle PrintOpto, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  void show_parse_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  void dump_map_adr_mem() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  static void print_statistics(); // Print some performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  void dump_bci(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
   596
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
   597
#endif // SHARE_VM_OPTO_PARSE_HPP