Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java @ 21556:48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 00:36:16 +0200 |
parents | 5324104ac4f3 |
children | 6df25b1418be |
rev | line source |
---|---|
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
1 /* |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
4 * |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
8 * |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
14 * |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
18 * |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
21 * questions. |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
22 */ |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
25 import com.oracle.jvmci.code.Register; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
26 import com.oracle.jvmci.code.TargetDescription; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
27 import com.oracle.jvmci.meta.JavaConstant; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
28 import com.oracle.jvmci.meta.Value; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
29 import com.oracle.jvmci.meta.Kind; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
30 import static com.oracle.jvmci.code.ValueUtil.*; |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
31 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
32 import java.util.*; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
33 |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.asm.*; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.hotspot.debug.*; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.hotspot.meta.*; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.lir.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
38 import com.oracle.jvmci.common.*; |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21543
diff
changeset
|
39 import com.oracle.jvmci.hotspot.*; |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
40 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
41 public abstract class HotSpotCounterOp extends LIRInstruction { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
42 public static final LIRInstructionClass<HotSpotCounterOp> TYPE = LIRInstructionClass.create(HotSpotCounterOp.class); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
43 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
44 private final String[] names; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
45 private final String[] groups; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
46 protected final Register thread; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
47 protected final HotSpotVMConfig config; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
48 @Alive({OperandFlag.CONST, OperandFlag.REG}) protected Value[] increments; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
49 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
50 public HotSpotCounterOp(LIRInstructionClass<? extends HotSpotCounterOp> c, String name, String group, Value increment, HotSpotRegistersProvider registers, HotSpotVMConfig config) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
51 this(c, new String[]{name}, new String[]{group}, new Value[]{increment}, registers, config); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
52 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
53 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
54 public HotSpotCounterOp(LIRInstructionClass<? extends HotSpotCounterOp> c, String[] names, String[] groups, Value[] increments, HotSpotRegistersProvider registers, HotSpotVMConfig config) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
55 super(c); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
56 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
57 assert names.length == groups.length; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
58 assert groups.length == increments.length; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
59 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
60 this.names = names; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
61 this.groups = groups; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
62 this.increments = increments; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
63 this.thread = registers.getThreadRegister(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
64 this.config = config; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
65 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
66 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
67 protected static int getDisplacementForLongIndex(TargetDescription target, long index) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
68 long finalDisp = index * target.getSizeInBytes(Kind.Long); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
69 if (!NumUtil.isInt(finalDisp)) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
70 throw JVMCIError.unimplemented("cannot deal with indices that big: " + index); |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
71 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
72 return (int) finalDisp; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
73 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
74 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
75 protected interface CounterProcedure { |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
76 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
77 * Lambda interface for iterating over counters declared in this op. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
78 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
79 * @param counterIndex Index in this CounterOp object. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
80 * @param increment Value for increment |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
81 * @param displacement Displacement in bytes in the counter array |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
82 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
83 void apply(int counterIndex, Value increment, int displacement); |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
84 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
85 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
86 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
87 * Calls the {@link CounterProcedure} for each counter in ascending order of their displacement |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
88 * in the counter array. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
89 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
90 * @param proc The procedure to be called |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
91 * @param target Target architecture (used to calculate the array displacements) |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
92 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
93 protected void forEachCounter(CounterProcedure proc, TargetDescription target) { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
94 if (names.length == 1) { // fast path |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
95 int arrayIndex = getIndex(names[0], groups[0], increments[0]); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
96 int displacement = getDisplacementForLongIndex(target, arrayIndex); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
97 proc.apply(0, increments[0], displacement); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
98 } else { // Slow path with sort by displacements ascending |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
99 int[] displacements = new int[names.length]; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
100 HashMap<Integer, Integer> offsetMap = new HashMap<>(names.length); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
101 for (int i = 0; i < names.length; i++) { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
102 int arrayIndex = getIndex(names[i], groups[i], increments[i]); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
103 displacements[i] = getDisplacementForLongIndex(target, arrayIndex); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
104 offsetMap.put(displacements[i], i); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
105 } |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
106 Arrays.sort(displacements); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
107 // Now apply in order |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
108 for (int offset : displacements) { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
109 int idx = offsetMap.get(offset); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
110 proc.apply(idx, increments[idx], displacements[idx]); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
111 } |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
112 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
113 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
114 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
115 protected int getIndex(String name, String group, Value increment) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
116 if (isConstant(increment)) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
117 // get index for the counter |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
118 return BenchmarkCounters.getIndexConstantIncrement(name, group, config, asLong(asConstant(increment))); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
119 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
120 assert isRegister(increment) : "Unexpected Value: " + increment; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
121 // get index for the counter |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
122 return BenchmarkCounters.getIndex(name, group, config); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
123 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
124 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
125 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
126 * Patches the increment value in the instruction emitted by this instruction. Use only, if |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
127 * patching is needed after assembly. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
128 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
129 * @param asm |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
130 * @param increment |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
131 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
132 public void patchCounterIncrement(Assembler asm, int[] increment) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
133 throw JVMCIError.unimplemented(); |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
134 } |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
135 |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
136 private static long asLong(JavaConstant value) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
137 Kind kind = value.getKind(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
138 switch (kind) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
139 case Byte: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
140 case Short: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
141 case Char: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
142 case Int: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
143 return value.asInt(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
144 case Long: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
145 return value.asLong(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
146 default: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
147 throw new IllegalArgumentException("not an integer kind: " + kind); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
148 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
149 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
150 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
151 protected static int asInt(JavaConstant value) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
152 long l = asLong(value); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
153 if (!NumUtil.isInt(l)) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
154 throw JVMCIError.shouldNotReachHere("value does not fit into int: " + l); |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
155 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
156 return (int) l; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
157 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
158 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
159 public String[] getNames() { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
160 return names; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
161 } |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
162 |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
163 public String[] getGroups() { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
164 return groups; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
165 } |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
166 } |