1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/ci/ciSymbol.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,116 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_CI_CISYMBOL_HPP 1.29 +#define SHARE_VM_CI_CISYMBOL_HPP 1.30 + 1.31 +#include "ci/ciBaseObject.hpp" 1.32 +#include "ci/ciObject.hpp" 1.33 +#include "ci/ciObjectFactory.hpp" 1.34 +#include "classfile/vmSymbols.hpp" 1.35 +#include "oops/symbol.hpp" 1.36 + 1.37 +// ciSymbol 1.38 +// 1.39 +// This class represents a Symbol* in the HotSpot virtual 1.40 +// machine. 1.41 +class ciSymbol : public ciBaseObject { 1.42 + Symbol* _symbol; 1.43 + 1.44 + CI_PACKAGE_ACCESS 1.45 + // These friends all make direct use of get_symbol: 1.46 + friend class ciEnv; 1.47 + friend class ciInstanceKlass; 1.48 + friend class ciSignature; 1.49 + friend class ciMethod; 1.50 + friend class ciField; 1.51 + friend class ciObjArrayKlass; 1.52 + 1.53 +private: 1.54 + const vmSymbols::SID _sid; 1.55 + DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbol()) == _sid; } ) 1.56 + 1.57 + ciSymbol(Symbol* s); // normal case, for symbols not mentioned in vmSymbols 1.58 + ciSymbol(Symbol* s, vmSymbols::SID sid); // for use with vmSymbols 1.59 + 1.60 + Symbol* get_symbol() const { return _symbol; } 1.61 + 1.62 + const char* type_string() { return "ciSymbol"; } 1.63 + 1.64 + void print_impl(outputStream* st); 1.65 + 1.66 + // This is public in Symbol* but private here, because the base can move: 1.67 + const jbyte* base(); 1.68 + 1.69 + // Make a ciSymbol from a C string (implementation). 1.70 + static ciSymbol* make_impl(const char* s); 1.71 + 1.72 +public: 1.73 + // The enumeration ID from vmSymbols, or vmSymbols::NO_SID if none. 1.74 + vmSymbols::SID sid() const { return _sid; } 1.75 + 1.76 + // The text of the symbol as a null-terminated utf8 string. 1.77 + const char* as_utf8(); 1.78 + int utf8_length(); 1.79 + 1.80 + // The text of the symbol as ascii with all non-printable characters quoted as \u#### 1.81 + const char* as_quoted_ascii(); 1.82 + 1.83 + // Return the i-th utf8 byte, where i < utf8_length 1.84 + int byte_at(int i); 1.85 + 1.86 + // Tests if the symbol starts with the given prefix. 1.87 + bool starts_with(const char* prefix, int len) const; 1.88 + 1.89 + // Determines where the symbol contains the given substring. 1.90 + int index_of_at(int i, const char* str, int len) const; 1.91 + 1.92 + void print_symbol_on(outputStream* st); 1.93 + void print_symbol() { 1.94 + print_symbol_on(tty); 1.95 + } 1.96 + 1.97 + // Make a ciSymbol from a C string. 1.98 + // Consider adding to vmSymbols.hpp instead of using this constructor. 1.99 + // (Your code will be less subject to typographical bugs.) 1.100 + static ciSymbol* make(const char* s); 1.101 + 1.102 +#define CI_SYMBOL_DECLARE(name, ignore_def) \ 1.103 + static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); } 1.104 + VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE) 1.105 +#undef CI_SYMBOL_DECLARE 1.106 + 1.107 + void print() { 1.108 + _symbol->print(); 1.109 + } 1.110 + 1.111 + virtual bool is_symbol() const { return true; } 1.112 + 1.113 + // Are two ciSymbols equal? 1.114 + bool equals(ciSymbol* obj) { return this->_symbol == obj->get_symbol(); } 1.115 + 1.116 + bool is_signature_polymorphic_name() const; 1.117 +}; 1.118 + 1.119 +#endif // SHARE_VM_CI_CISYMBOL_HPP