Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java @ 21708:6df25b1418be
moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 18:06:44 +0200 |
parents | 48c1ebd24120 |
children | d915361cc3a1 |
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 |
21708
6df25b1418be
moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
25 import com.oracle.jvmci.asm.*; |
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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 import com.oracle.jvmci.meta.Kind; |
21708
6df25b1418be
moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
31 |
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
|
32 import static com.oracle.jvmci.code.ValueUtil.*; |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
33 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
34 import java.util.*; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
35 |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.hotspot.debug.*; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.hotspot.meta.*; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
38 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
|
39 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
|
40 import com.oracle.jvmci.hotspot.*; |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
41 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
42 public abstract class HotSpotCounterOp extends LIRInstruction { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
43 public static final LIRInstructionClass<HotSpotCounterOp> TYPE = LIRInstructionClass.create(HotSpotCounterOp.class); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
44 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
45 private final String[] names; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
46 private final String[] groups; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
47 protected final Register thread; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
48 protected final HotSpotVMConfig config; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
49 @Alive({OperandFlag.CONST, OperandFlag.REG}) protected Value[] increments; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
50 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
51 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
|
52 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
|
53 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
54 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
55 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
|
56 super(c); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
57 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
58 assert names.length == groups.length; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
59 assert groups.length == increments.length; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
60 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
61 this.names = names; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
62 this.groups = groups; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
63 this.increments = increments; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
64 this.thread = registers.getThreadRegister(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
65 this.config = config; |
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 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
68 protected static int getDisplacementForLongIndex(TargetDescription target, long index) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
69 long finalDisp = index * target.getSizeInBytes(Kind.Long); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
70 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
|
71 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
|
72 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
73 return (int) finalDisp; |
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 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
76 protected interface CounterProcedure { |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
77 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
78 * 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
|
79 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
80 * @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
|
81 * @param increment Value for increment |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
82 * @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
|
83 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
84 void apply(int counterIndex, Value increment, int displacement); |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
85 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
86 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
87 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
88 * 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
|
89 * in the counter array. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
90 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
91 * @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
|
92 * @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
|
93 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
94 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
|
95 if (names.length == 1) { // fast path |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
96 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
|
97 int displacement = getDisplacementForLongIndex(target, arrayIndex); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
98 proc.apply(0, increments[0], displacement); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
99 } 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
|
100 int[] displacements = new int[names.length]; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
101 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
|
102 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
|
103 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
|
104 displacements[i] = getDisplacementForLongIndex(target, arrayIndex); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
105 offsetMap.put(displacements[i], i); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
106 } |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
107 Arrays.sort(displacements); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
108 // Now apply in order |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
109 for (int offset : displacements) { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
110 int idx = offsetMap.get(offset); |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
111 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
|
112 } |
19909
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 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
116 protected int getIndex(String name, String group, Value increment) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
117 if (isConstant(increment)) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
118 // get index for the counter |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
119 return BenchmarkCounters.getIndexConstantIncrement(name, group, config, asLong(asConstant(increment))); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
120 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
121 assert isRegister(increment) : "Unexpected Value: " + increment; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
122 // get index for the counter |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
123 return BenchmarkCounters.getIndex(name, group, config); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
124 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
125 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
126 /** |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
127 * 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
|
128 * patching is needed after assembly. |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
129 * |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
130 * @param asm |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
131 * @param increment |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
132 */ |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
133 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
|
134 throw JVMCIError.unimplemented(); |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
135 } |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
136 |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
137 private static long asLong(JavaConstant value) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
138 Kind kind = value.getKind(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
139 switch (kind) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
140 case Byte: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
141 case Short: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
142 case Char: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
143 case Int: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
144 return value.asInt(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
145 case Long: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
146 return value.asLong(); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
147 default: |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
148 throw new IllegalArgumentException("not an integer kind: " + kind); |
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 |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
152 protected static int asInt(JavaConstant value) { |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
153 long l = asLong(value); |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
154 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
|
155 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
|
156 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
157 return (int) l; |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
158 } |
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
159 |
20003
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
160 public String[] getNames() { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
161 return names; |
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 |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
164 public String[] getGroups() { |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
165 return groups; |
422e60a2f4b9
Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19909
diff
changeset
|
166 } |
19909
1fed7073f288
Add AMD64HotSpotCounterOp and SPARCHotSpotCounterOp.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
167 } |