Mercurial > hg > truffle
annotate src/share/vm/ci/ciCallProfile.hpp @ 7090:05ce1defa4f9
Common out some parts of UnsafeLoad/Store in UnsafeAccess
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 29 Nov 2012 13:24:08 +0100 |
parents | 04b9a2566eec |
children | b8f261ba79c6 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CI_CICALLPROFILE_HPP |
26 #define SHARE_VM_CI_CICALLPROFILE_HPP | |
27 | |
28 #include "ci/ciClassList.hpp" | |
1983
c760f78e0a53
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
1972
diff
changeset
|
29 #include "memory/allocation.hpp" |
1972 | 30 |
0 | 31 // ciCallProfile |
32 // | |
33 // This class is used to determine the frequently called method | |
34 // at some call site | |
35 class ciCallProfile : StackObj { | |
36 private: | |
37 // Fields are initialized directly by ciMethod::call_profile_at_bci. | |
38 friend class ciMethod; | |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
1983
diff
changeset
|
39 friend class ciMethodHandle; |
0 | 40 |
41 enum { MorphismLimit = 2 }; // Max call site's morphism we care about | |
42 int _limit; // number of receivers have been determined | |
43 int _morphism; // determined call site's morphism | |
44 int _count; // # times has this call been executed | |
45 int _receiver_count[MorphismLimit + 1]; // # times receivers have been seen | |
46 ciMethod* _method[MorphismLimit + 1]; // receivers methods | |
47 ciKlass* _receiver[MorphismLimit + 1]; // receivers (exact) | |
48 | |
49 ciCallProfile() { | |
50 _limit = 0; | |
51 _morphism = 0; | |
52 _count = -1; | |
53 _receiver_count[0] = -1; | |
54 _method[0] = NULL; | |
55 _receiver[0] = NULL; | |
56 } | |
57 | |
58 void add_receiver(ciKlass* receiver, int receiver_count); | |
59 | |
60 public: | |
61 // Note: The following predicates return false for invalid profiles: | |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
1983
diff
changeset
|
62 bool has_receiver(int i) const { return _limit > i; } |
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
1983
diff
changeset
|
63 int morphism() const { return _morphism; } |
3464 | 64 int limit() const { return _limit; } |
0 | 65 |
3441
f56542cb325a
7050554: JSR 292 - need optimization for selectAlternative
never
parents:
1983
diff
changeset
|
66 int count() const { return _count; } |
0 | 67 int receiver_count(int i) { |
68 assert(i < _limit, "out of Call Profile MorphismLimit"); | |
69 return _receiver_count[i]; | |
70 } | |
71 float receiver_prob(int i) { | |
72 assert(i < _limit, "out of Call Profile MorphismLimit"); | |
73 return (float)_receiver_count[i]/(float)_count; | |
74 } | |
75 ciMethod* method(int i) { | |
76 assert(i < _limit, "out of Call Profile MorphismLimit"); | |
77 return _method[i]; | |
78 } | |
79 ciKlass* receiver(int i) { | |
80 assert(i < _limit, "out of Call Profile MorphismLimit"); | |
81 return _receiver[i]; | |
82 } | |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
83 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
84 // Rescale the current profile based on the incoming scale |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
85 ciCallProfile rescale(double scale) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
86 assert(scale >= 0 && scale <= 1.0, "out of range"); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
87 ciCallProfile call = *this; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
88 call._count = (int)(call._count * scale); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
89 for (int i = 0; i < _morphism; i++) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
90 call._receiver_count[i] = (int)(call._receiver_count[i] * scale); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
91 } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
92 return call; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3441
diff
changeset
|
93 } |
0 | 94 }; |
1972 | 95 |
96 #endif // SHARE_VM_CI_CICALLPROFILE_HPP |