hotspot/src/share/vm/ci/ciCallProfile.hpp
author minqi
Mon, 12 Nov 2012 14:03:53 -0800
changeset 14477 95e66ea71f71
parent 10514 e229a19078cf
permissions -rw-r--r--
6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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: 5547
diff changeset
    25
#ifndef SHARE_VM_CI_CICALLPROFILE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CI_CICALLPROFILE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "ci/ciClassList.hpp"
7408
c04a5c989f26 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 7397
diff changeset
    29
#include "memory/allocation.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// ciCallProfile
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// This class is used to determine the frequently called method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// at some call site
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class ciCallProfile : StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  // Fields are initialized directly by ciMethod::call_profile_at_bci.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  friend class ciMethod;
9975
82190b49ce14 7050554: JSR 292 - need optimization for selectAlternative
never
parents: 7408
diff changeset
    39
  friend class ciMethodHandle;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  enum { MorphismLimit = 2 }; // Max call site's morphism we care about
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  int  _limit;                // number of receivers have been determined
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  int  _morphism;             // determined call site's morphism
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  int  _count;                // # times has this call been executed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  int  _receiver_count[MorphismLimit + 1]; // # times receivers have been seen
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  ciMethod* _method[MorphismLimit + 1];    // receivers methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  ciKlass*  _receiver[MorphismLimit + 1];  // receivers (exact)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  ciCallProfile() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    _limit = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    _morphism    = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    _count = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    _receiver_count[0] = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    _method[0]   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _receiver[0] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  void add_receiver(ciKlass* receiver, int receiver_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Note:  The following predicates return false for invalid profiles:
9975
82190b49ce14 7050554: JSR 292 - need optimization for selectAlternative
never
parents: 7408
diff changeset
    62
  bool      has_receiver(int i) const { return _limit > i; }
82190b49ce14 7050554: JSR 292 - need optimization for selectAlternative
never
parents: 7408
diff changeset
    63
  int       morphism() const          { return _morphism; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
9975
82190b49ce14 7050554: JSR 292 - need optimization for selectAlternative
never
parents: 7408
diff changeset
    65
  int       count() const             { return _count; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  int       receiver_count(int i)  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    assert(i < _limit, "out of Call Profile MorphismLimit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    return _receiver_count[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  float     receiver_prob(int i)  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    assert(i < _limit, "out of Call Profile MorphismLimit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    return (float)_receiver_count[i]/(float)_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  ciMethod* method(int i)          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    assert(i < _limit, "out of Call Profile MorphismLimit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    return _method[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  ciKlass*  receiver(int i)        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    assert(i < _limit, "out of Call Profile MorphismLimit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    return _receiver[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
10514
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    82
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    83
  // Rescale the current profile based on the incoming scale
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    84
  ciCallProfile rescale(double scale) {
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    85
    assert(scale >= 0 && scale <= 1.0, "out of range");
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    86
    ciCallProfile call = *this;
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    87
    call._count = (int)(call._count * scale);
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    88
    for (int i = 0; i < _morphism; i++) {
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    89
      call._receiver_count[i] = (int)(call._receiver_count[i] * scale);
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    90
    }
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    91
    return call;
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 9975
diff changeset
    92
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    94
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    95
#endif // SHARE_VM_CI_CICALLPROFILE_HPP