annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java @ 7530:5e3d1a68664e

applied mx eclipseformat to all Java files
author Doug Simon <doug.simon@oracle.com>
date Wed, 23 Jan 2013 16:34:57 +0100
parents 19e5dc8d0891
children a200d10867f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
1 /*
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
4 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
7 * published by the Free Software Foundation.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
8 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
13 * accompanied this code).
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
14 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
15 * You should have received a copy of the GNU General Public License version
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
18 *
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
21 * questions.
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.debug.internal;
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5386
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
25 import java.util.*;
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
26
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
27 public abstract class DebugValue {
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
5386
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
29 public static final Comparator<DebugValue> ORDER_BY_NAME = new Comparator<DebugValue>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5386
diff changeset
30
5386
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
31 @Override
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
32 public int compare(DebugValue o1, DebugValue o2) {
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
33 // this keeps the "Runs" metric at the top of the list
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
34 if (o1.getName().equals("Runs")) {
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
35 return o2.getName().equals("Runs") ? 0 : -1;
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
36 }
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
37 if (o2.getName().equals("Runs")) {
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
38 return o1.getName().equals("Runs") ? 0 : 1;
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
39 }
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
40 return o1.getName().compareTo(o2.getName());
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
41 }
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
42 };
19e5dc8d0891 alphabetically sort debug values for Metric and Time
Lukas Stadler <lukas.stadler@jku.at>
parents: 5134
diff changeset
43
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
44 private String name;
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
45 private int index;
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
46
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
47 protected DebugValue(String name) {
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 this.name = name;
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
49 this.index = -1;
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
51
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
52 protected long getCurrentValue() {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
53 ensureInitialized();
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
54 return DebugScope.getInstance().getCurrentValue(index);
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
55 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
56
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
57 protected void setCurrentValue(long l) {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
58 ensureInitialized();
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
59 DebugScope.getInstance().setCurrentValue(index, l);
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
60 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
61
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
62 private void ensureInitialized() {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
63 if (index == -1) {
4406
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
64 index = KeyRegistry.register(name, this);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
65 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
66 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
67
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
68 protected void addToCurrentValue(long timeSpan) {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
69 setCurrentValue(getCurrentValue() + timeSpan);
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
70 }
4406
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
71
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
72 public int getIndex() {
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
73 return index;
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
74 }
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
75
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
76 public String getName() {
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
77 return name;
961895157a38 Tentative implementation of Meter and Time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
78 }
5134
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
79
4eb9895d9afe Refactoring of the debug framework. Move compiler thread implementation to its own file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
80 public abstract String toString(long value);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
81 }