Path: blob/master/src/hotspot/share/compiler/methodMatcher.hpp
40930 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_COMPILER_METHODMATCHER_HPP25#define SHARE_COMPILER_METHODMATCHER_HPP2627#include "memory/allocation.hpp"28#include "runtime/handles.hpp"29#include "memory/resourceArea.hpp"3031class MethodMatcher : public CHeapObj<mtCompiler> {32public:33enum Mode {34Exact,35Prefix = 1,36Suffix = 2,37Substring = Prefix | Suffix,38Any,39Unknown = -140};4142protected:43Symbol* _class_name;44Symbol* _method_name;45Symbol* _signature;46Mode _class_mode;47Mode _method_mode;4849public:50Symbol* class_name() const { return _class_name; }51Mode class_mode() const { return _class_mode; }52Symbol* method_name() const { return _method_name; }53Mode method_mode() const { return _method_mode; }54Symbol* signature() const { return _signature; }5556MethodMatcher();57~MethodMatcher();5859void init(Symbol* class_name, Mode class_mode, Symbol* method_name, Mode method_mode, Symbol* signature);60static void parse_method_pattern(char*& line, const char*& error_msg, MethodMatcher* m);61static void print_symbol(outputStream* st, Symbol* h, Mode mode);62bool matches(const methodHandle& method) const;63void print_base(outputStream* st);6465private:66static bool canonicalize(char * line, const char *& error_msg);67bool match(Symbol* candidate, Symbol* match, Mode match_mode) const;68};6970class BasicMatcher : public MethodMatcher {71private:72BasicMatcher* _next;73public:7475BasicMatcher() : MethodMatcher(),76_next(NULL) {77}7879BasicMatcher(BasicMatcher* next) :80_next(next) {81}8283static BasicMatcher* parse_method_pattern(char* line, const char*& error_msg, bool expect_trailing_chars);84bool match(const methodHandle& method);85void set_next(BasicMatcher* next) { _next = next; }86BasicMatcher* next() { return _next; }8788void print(outputStream* st) { print_base(st); }89void print_all(outputStream* st) {90print_base(st);91if (_next != NULL) {92_next->print_all(st);93}94}95};9697class InlineMatcher : public MethodMatcher {98public:99enum InlineType {100unknown_inline,101dont_inline,102force_inline103};104105private:106InlineType _inline_action;107InlineMatcher * _next;108109InlineMatcher() : MethodMatcher(),110_inline_action(unknown_inline), _next(NULL) {111}112113public:114static InlineMatcher* parse_method_pattern(char* line, const char*& error_msg);115bool match(const methodHandle& method, int inline_action);116void print(outputStream* st);117void set_next(InlineMatcher* next) { _next = next; }118InlineMatcher* next() { return _next; }119void set_action(InlineType inline_action) { _inline_action = inline_action; }120int inline_action() { return _inline_action; }121static InlineMatcher* parse_inline_pattern(char* line, const char*& error_msg);122InlineMatcher* clone();123};124125#endif // SHARE_COMPILER_METHODMATCHER_HPP126127128