src/share/vm/ci/ciSymbol.cpp

Thu, 24 May 2018 18:41:44 +0800

author
aoqi
date
Thu, 24 May 2018 18:41:44 +0800
changeset 8856
ac27a9c85bea
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1999, 2012, 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 #include "precompiled.hpp"
aoqi@0 26 #include "ci/ciSymbol.hpp"
aoqi@0 27 #include "ci/ciUtilities.hpp"
aoqi@0 28 #include "memory/oopFactory.hpp"
aoqi@0 29
aoqi@0 30 // ------------------------------------------------------------------
aoqi@0 31 // ciSymbol::ciSymbol
aoqi@0 32 //
aoqi@0 33 // Preallocated symbol variant. Used with symbols from vmSymbols.
aoqi@0 34 ciSymbol::ciSymbol(Symbol* s, vmSymbols::SID sid)
aoqi@0 35 : _symbol(s), _sid(sid)
aoqi@0 36 {
aoqi@0 37 assert(_symbol != NULL, "adding null symbol");
aoqi@0 38 _symbol->increment_refcount(); // increment ref count
aoqi@0 39 assert(sid_ok(), "must be in vmSymbols");
aoqi@0 40 }
aoqi@0 41
aoqi@0 42 // Normal case for non-famous symbols.
aoqi@0 43 ciSymbol::ciSymbol(Symbol* s)
aoqi@0 44 : _symbol(s), _sid(vmSymbols::NO_SID)
aoqi@0 45 {
aoqi@0 46 assert(_symbol != NULL, "adding null symbol");
aoqi@0 47 _symbol->increment_refcount(); // increment ref count
aoqi@0 48 assert(sid_ok(), "must not be in vmSymbols");
aoqi@0 49 }
aoqi@0 50
aoqi@0 51 // ciSymbol
aoqi@0 52 //
aoqi@0 53 // This class represents a Symbol* in the HotSpot virtual
aoqi@0 54 // machine.
aoqi@0 55
aoqi@0 56 // ------------------------------------------------------------------
aoqi@0 57 // ciSymbol::as_utf8
aoqi@0 58 //
aoqi@0 59 // The text of the symbol as a null-terminated C string.
aoqi@0 60 const char* ciSymbol::as_utf8() {
aoqi@0 61 VM_QUICK_ENTRY_MARK;
aoqi@0 62 Symbol* s = get_symbol();
aoqi@0 63 return s->as_utf8();
aoqi@0 64 }
aoqi@0 65
aoqi@0 66 // The text of the symbol as a null-terminated C string.
aoqi@0 67 const char* ciSymbol::as_quoted_ascii() {
aoqi@0 68 GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();)
aoqi@0 69 }
aoqi@0 70
aoqi@0 71 // ------------------------------------------------------------------
aoqi@0 72 // ciSymbol::base
aoqi@0 73 const jbyte* ciSymbol::base() {
aoqi@0 74 GUARDED_VM_ENTRY(return get_symbol()->base();)
aoqi@0 75 }
aoqi@0 76
aoqi@0 77 // ------------------------------------------------------------------
aoqi@0 78 // ciSymbol::byte_at
aoqi@0 79 int ciSymbol::byte_at(int i) {
aoqi@0 80 GUARDED_VM_ENTRY(return get_symbol()->byte_at(i);)
aoqi@0 81 }
aoqi@0 82
aoqi@0 83 // ------------------------------------------------------------------
aoqi@0 84 // ciSymbol::starts_with
aoqi@0 85 //
aoqi@0 86 // Tests if the symbol starts with the given prefix.
aoqi@0 87 bool ciSymbol::starts_with(const char* prefix, int len) const {
aoqi@0 88 GUARDED_VM_ENTRY(return get_symbol()->starts_with(prefix, len);)
aoqi@0 89 }
aoqi@0 90
aoqi@0 91 bool ciSymbol::is_signature_polymorphic_name() const {
aoqi@0 92 GUARDED_VM_ENTRY(return MethodHandles::is_signature_polymorphic_name(get_symbol());)
aoqi@0 93 }
aoqi@0 94
aoqi@0 95 // ------------------------------------------------------------------
aoqi@0 96 // ciSymbol::index_of
aoqi@0 97 //
aoqi@0 98 // Determines where the symbol contains the given substring.
aoqi@0 99 int ciSymbol::index_of_at(int i, const char* str, int len) const {
aoqi@0 100 GUARDED_VM_ENTRY(return get_symbol()->index_of_at(i, str, len);)
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 // ------------------------------------------------------------------
aoqi@0 104 // ciSymbol::utf8_length
aoqi@0 105 int ciSymbol::utf8_length() {
aoqi@0 106 GUARDED_VM_ENTRY(return get_symbol()->utf8_length();)
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 // ------------------------------------------------------------------
aoqi@0 110 // ciSymbol::print_impl
aoqi@0 111 //
aoqi@0 112 // Implementation of the print method
aoqi@0 113 void ciSymbol::print_impl(outputStream* st) {
aoqi@0 114 st->print(" value=");
aoqi@0 115 print_symbol_on(st);
aoqi@0 116 }
aoqi@0 117
aoqi@0 118 // ------------------------------------------------------------------
aoqi@0 119 // ciSymbol::print_symbol_on
aoqi@0 120 //
aoqi@0 121 // Print the value of this symbol on an outputStream
aoqi@0 122 void ciSymbol::print_symbol_on(outputStream *st) {
aoqi@0 123 GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);)
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 // ------------------------------------------------------------------
aoqi@0 127 // ciSymbol::make_impl
aoqi@0 128 //
aoqi@0 129 // Make a ciSymbol from a C string (implementation).
aoqi@0 130 ciSymbol* ciSymbol::make_impl(const char* s) {
aoqi@0 131 EXCEPTION_CONTEXT;
aoqi@0 132 TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD);
aoqi@0 133 if (HAS_PENDING_EXCEPTION) {
aoqi@0 134 CLEAR_PENDING_EXCEPTION;
aoqi@0 135 CURRENT_THREAD_ENV->record_out_of_memory_failure();
aoqi@0 136 return ciEnv::_unloaded_cisymbol;
aoqi@0 137 }
aoqi@0 138 return CURRENT_THREAD_ENV->get_symbol(sym);
aoqi@0 139 }
aoqi@0 140
aoqi@0 141 // ------------------------------------------------------------------
aoqi@0 142 // ciSymbol::make
aoqi@0 143 //
aoqi@0 144 // Make a ciSymbol from a C string.
aoqi@0 145 ciSymbol* ciSymbol::make(const char* s) {
aoqi@0 146 GUARDED_VM_ENTRY(return make_impl(s);)
aoqi@0 147 }

mercurial