annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/MethodFilter.java @ 23394:964f28c04d7b default tip

Don't fill the code cache with nmethods from CTW
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 05 Feb 2016 22:48:36 -0800
parents 615f3bbbb174
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
22300
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
23 package com.oracle.graal.debug;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22300
diff changeset
25 import java.util.Arrays;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22300
diff changeset
26 import java.util.regex.Pattern;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
22790
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
28 import jdk.vm.ci.meta.JavaMethod;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
29 import jdk.vm.ci.meta.JavaType;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
30 import jdk.vm.ci.meta.Signature;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21798
diff changeset
31
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
33 * This class implements a method filter that can filter based on class name, method name and
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
34 * parameters. The syntax for the source pattern that is passed to the constructor is as follows:
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
35 *
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 * <pre>
13090
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
37 * SourcePatterns = SourcePattern ["," SourcePatterns] .
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 * SourcePattern = [ Class "." ] method [ "(" [ Parameter { ";" Parameter } ] ")" ] .
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 * Parameter = Class | "int" | "long" | "float" | "double" | "short" | "char" | "boolean" .
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 * Class = { package "." } class .
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
42 *
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
43 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
44 * Glob pattern matching (*, ?) is allowed in all parts of the source pattern. Examples for valid
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
45 * filters are:
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
46 *
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 * <ul>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
48 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
49 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
50 * <pre>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
51 * visit(Argument;BlockScope)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
52 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
53 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
54 * Matches all methods named "visit", with the first parameter of type "Argument", and the second
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
55 * parameter of type "BlockScope". The packages of the parameter types are irrelevant.</li>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
56 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
57 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
58 * <pre>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
59 * arraycopy(Object;;;;)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
60 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
61 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
62 * Matches all methods named "arraycopy", with the first parameter of type "Object", and four more
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
63 * parameters of any type. The packages of the parameter types are irrelevant.</li>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
64 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
65 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
66 * <pre>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
67 * com.oracle.graal.compiler.graph.PostOrderNodeIterator.*
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
68 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
69 *
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 * Matches all methods in the class "com.oracle.graal.compiler.graph.PostOrderNodeIterator".</li>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
71 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
72 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
73 * <pre>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
74 * *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
75 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
76 *
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 * Matches all methods in all classes</li>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
78 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
79 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
80 * <pre>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
81 * com.oracle.graal.compiler.graph.*.visit
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7318
diff changeset
82 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
83 *
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
84 * Matches all methods named "visit" in classes in the package "com.oracle.graal.compiler.graph".
13090
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
85 * <li>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
86 *
13090
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
87 * <pre>
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
88 * arraycopy,toString
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
89 * </pre>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13090
diff changeset
90 *
13090
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
91 * Matches all methods named "arraycopy" or "toString", meaning that ',' acts as an <i>or</i>
4fcc7d778e0f MethodFilter: add documentation about comma seperator
Bernhard Urban <bernhard.urban@jku.at>
parents: 11491
diff changeset
92 * operator.</li>
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 * </ul>
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 */
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 public class MethodFilter {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 private final Pattern clazz;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 private final Pattern methodName;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 private final Pattern[] signature;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
101 /**
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
102 * Parses a string containing list of comma separated filter patterns into an array of
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
103 * {@link MethodFilter}s.
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
104 */
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
105 public static MethodFilter[] parse(String commaSeparatedPatterns) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
106 String[] filters = commaSeparatedPatterns.split(",");
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
107 MethodFilter[] methodFilters = new MethodFilter[filters.length];
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
108 for (int i = 0; i < filters.length; i++) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
109 methodFilters[i] = new MethodFilter(filters[i]);
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
110 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
111 return methodFilters;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
112 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
113
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
114 /**
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
115 * Determines if a given method is matched by a given array of filters.
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
116 */
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
117 public static boolean matches(MethodFilter[] filters, JavaMethod method) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
118 for (MethodFilter filter : filters) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
119 if (filter.matches(method)) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
120 return true;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
121 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
122 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
123 return false;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
124 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
125
20018
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
126 /**
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
127 * Determines if a given class name is matched by a given array of filters.
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
128 */
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
129 public static boolean matchesClassName(MethodFilter[] filters, String className) {
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
130 for (MethodFilter filter : filters) {
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
131 if (filter.matchesClassName(className)) {
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
132 return true;
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
133 }
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
134 }
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
135 return false;
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
136 }
3cbb0846337c added -G:CompileTheWorldMethodFilter option
Doug Simon <doug.simon@oracle.com>
parents: 18866
diff changeset
137
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 public MethodFilter(String sourcePattern) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 String pattern = sourcePattern.trim();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 // extract parameter part
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 int pos = pattern.indexOf('(');
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 if (pos != -1) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 if (pattern.charAt(pattern.length() - 1) != ')') {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 throw new IllegalArgumentException("missing ')' at end of method filter pattern: " + pattern);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 String[] signatureClasses = pattern.substring(pos + 1, pattern.length() - 1).split(";", -1);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 signature = new Pattern[signatureClasses.length];
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 for (int i = 0; i < signatureClasses.length; i++) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 signature[i] = createClassGlobPattern(signatureClasses[i].trim());
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 pattern = pattern.substring(0, pos);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 } else {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 signature = null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 // If there is at least one "." then everything before the last "." is the class name.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 // Otherwise, the pattern contains only the method name.
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 pos = pattern.lastIndexOf('.');
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 if (pos != -1) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 clazz = createClassGlobPattern(pattern.substring(0, pos));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 methodName = Pattern.compile(createGlobString(pattern.substring(pos + 1)));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 } else {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 clazz = null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165 methodName = Pattern.compile(createGlobString(pattern));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168
22300
7b4a47fcc4c0 Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
169 public static String createGlobString(String pattern) {
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 return Pattern.quote(pattern).replace("?", "\\E.\\Q").replace("*", "\\E.*\\Q");
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 private static Pattern createClassGlobPattern(String pattern) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 if (pattern.length() == 0) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 return null;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 } else if (pattern.contains(".")) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 return Pattern.compile(createGlobString(pattern));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 } else {
20046
116c600253e5 allow unqualified nested class names in the class part of a MethodFilter pattern
Doug Simon <doug.simon@oracle.com>
parents: 20018
diff changeset
179 return Pattern.compile("([^\\.\\$]*[\\.\\$])*" + createGlobString(pattern));
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182
18866
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
183 /**
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
184 * Determines if the class part of this filter matches a given class name.
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
185 */
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
186 public boolean matchesClassName(String className) {
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
187 return clazz == null || clazz.matcher(className).matches();
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
188 }
0d23a97ba488 added MethodFilter.matchesClassName
Doug Simon <doug.simon@oracle.com>
parents: 16479
diff changeset
189
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 public boolean matches(JavaMethod o) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 // check method name first, since MetaUtil.toJavaName is expensive
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 if (methodName != null && !methodName.matcher(o.getName()).matches()) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 return false;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 }
16479
558cf39c646b moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 14906
diff changeset
195 if (clazz != null && !clazz.matcher(o.getDeclaringClass().toJavaName()).matches()) {
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 return false;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 if (signature != null) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 Signature sig = o.getSignature();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 if (sig.getParameterCount(false) != signature.length) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 return false;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 for (int i = 0; i < signature.length; i++) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204 JavaType type = sig.getParameterType(i, null);
16479
558cf39c646b moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 14906
diff changeset
205 String javaName = type.toJavaName();
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 if (signature[i] != null && !signature[i].matcher(javaName).matches()) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 return false;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 return true;
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 @Override
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 public String toString() {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 StringBuilder buf = new StringBuilder("MethodFilter[");
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 String sep = "";
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 if (clazz != null) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 buf.append(sep).append("clazz=").append(clazz);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 sep = ", ";
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 if (methodName != null) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 buf.append(sep).append("methodName=").append(methodName);
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 sep = ", ";
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 if (signature != null) {
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 buf.append(sep).append("signature=").append(Arrays.toString(signature));
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 sep = ", ";
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 return buf.append("]").toString();
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }