src/share/vm/ci/ciSymbol.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_CI_CISYMBOL_HPP
aoqi@0 26 #define SHARE_VM_CI_CISYMBOL_HPP
aoqi@0 27
aoqi@0 28 #include "ci/ciBaseObject.hpp"
aoqi@0 29 #include "ci/ciObject.hpp"
aoqi@0 30 #include "ci/ciObjectFactory.hpp"
aoqi@0 31 #include "classfile/vmSymbols.hpp"
aoqi@0 32 #include "oops/symbol.hpp"
aoqi@0 33
aoqi@0 34 // ciSymbol
aoqi@0 35 //
aoqi@0 36 // This class represents a Symbol* in the HotSpot virtual
aoqi@0 37 // machine.
aoqi@0 38 class ciSymbol : public ciBaseObject {
aoqi@0 39 Symbol* _symbol;
aoqi@0 40
aoqi@0 41 CI_PACKAGE_ACCESS
aoqi@0 42 // These friends all make direct use of get_symbol:
aoqi@0 43 friend class ciEnv;
aoqi@0 44 friend class ciInstanceKlass;
aoqi@0 45 friend class ciSignature;
aoqi@0 46 friend class ciMethod;
aoqi@0 47 friend class ciField;
aoqi@0 48 friend class ciObjArrayKlass;
aoqi@0 49
aoqi@0 50 private:
aoqi@0 51 const vmSymbols::SID _sid;
aoqi@0 52 DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbol()) == _sid; } )
aoqi@0 53
aoqi@0 54 ciSymbol(Symbol* s); // normal case, for symbols not mentioned in vmSymbols
aoqi@0 55 ciSymbol(Symbol* s, vmSymbols::SID sid); // for use with vmSymbols
aoqi@0 56
aoqi@0 57 Symbol* get_symbol() const { return _symbol; }
aoqi@0 58
aoqi@0 59 const char* type_string() { return "ciSymbol"; }
aoqi@0 60
aoqi@0 61 void print_impl(outputStream* st);
aoqi@0 62
aoqi@0 63 // This is public in Symbol* but private here, because the base can move:
aoqi@0 64 const jbyte* base();
aoqi@0 65
aoqi@0 66 // Make a ciSymbol from a C string (implementation).
aoqi@0 67 static ciSymbol* make_impl(const char* s);
aoqi@0 68
aoqi@0 69 public:
aoqi@0 70 // The enumeration ID from vmSymbols, or vmSymbols::NO_SID if none.
aoqi@0 71 vmSymbols::SID sid() const { return _sid; }
aoqi@0 72
aoqi@0 73 // The text of the symbol as a null-terminated utf8 string.
aoqi@0 74 const char* as_utf8();
aoqi@0 75 int utf8_length();
aoqi@0 76
aoqi@0 77 // The text of the symbol as ascii with all non-printable characters quoted as \u####
aoqi@0 78 const char* as_quoted_ascii();
aoqi@0 79
aoqi@0 80 // Return the i-th utf8 byte, where i < utf8_length
aoqi@0 81 int byte_at(int i);
aoqi@0 82
aoqi@0 83 // Tests if the symbol starts with the given prefix.
aoqi@0 84 bool starts_with(const char* prefix, int len) const;
aoqi@0 85
aoqi@0 86 // Determines where the symbol contains the given substring.
aoqi@0 87 int index_of_at(int i, const char* str, int len) const;
aoqi@0 88
aoqi@0 89 void print_symbol_on(outputStream* st);
aoqi@0 90 void print_symbol() {
aoqi@0 91 print_symbol_on(tty);
aoqi@0 92 }
aoqi@0 93
aoqi@0 94 // Make a ciSymbol from a C string.
aoqi@0 95 // Consider adding to vmSymbols.hpp instead of using this constructor.
aoqi@0 96 // (Your code will be less subject to typographical bugs.)
aoqi@0 97 static ciSymbol* make(const char* s);
aoqi@0 98
aoqi@0 99 #define CI_SYMBOL_DECLARE(name, ignore_def) \
aoqi@0 100 static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); }
aoqi@0 101 VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE)
aoqi@0 102 #undef CI_SYMBOL_DECLARE
aoqi@0 103
aoqi@0 104 void print() {
aoqi@0 105 _symbol->print();
aoqi@0 106 }
aoqi@0 107
aoqi@0 108 virtual bool is_symbol() const { return true; }
aoqi@0 109
aoqi@0 110 // Are two ciSymbols equal?
aoqi@0 111 bool equals(ciSymbol* obj) { return this->_symbol == obj->get_symbol(); }
aoqi@0 112
aoqi@0 113 bool is_signature_polymorphic_name() const;
aoqi@0 114 };
aoqi@0 115
aoqi@0 116 #endif // SHARE_VM_CI_CISYMBOL_HPP

mercurial