src/share/vm/ci/ciSymbol.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1573
dd57230ba8fe
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_ciSymbol.cpp.incl"
duke@435 27
duke@435 28 // ------------------------------------------------------------------
duke@435 29 // ciSymbol::ciSymbol
duke@435 30 //
duke@435 31 // Preallocated handle variant. Used with handles from vmSymboHandles.
duke@435 32 ciSymbol::ciSymbol(symbolHandle h_s) : ciObject(h_s) {
duke@435 33 }
duke@435 34
duke@435 35 // ciSymbol
duke@435 36 //
duke@435 37 // This class represents a symbolOop in the HotSpot virtual
duke@435 38 // machine.
duke@435 39
duke@435 40 // ------------------------------------------------------------------
duke@435 41 // ciSymbol::as_utf8
duke@435 42 //
duke@435 43 // The text of the symbol as a null-terminated C string.
duke@435 44 const char* ciSymbol::as_utf8() {
duke@435 45 VM_QUICK_ENTRY_MARK;
duke@435 46 symbolOop s = get_symbolOop();
duke@435 47 return s->as_utf8();
duke@435 48 }
duke@435 49
duke@435 50 // ------------------------------------------------------------------
duke@435 51 // ciSymbol::base
duke@435 52 jbyte* ciSymbol::base() {
duke@435 53 GUARDED_VM_ENTRY(return get_symbolOop()->base();)
duke@435 54 }
duke@435 55
duke@435 56 // ------------------------------------------------------------------
duke@435 57 // ciSymbol::byte_at
duke@435 58 int ciSymbol::byte_at(int i) {
duke@435 59 GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);)
duke@435 60 }
duke@435 61
duke@435 62 // ------------------------------------------------------------------
duke@435 63 // ciSymbol::utf8_length
duke@435 64 int ciSymbol::utf8_length() {
duke@435 65 GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();)
duke@435 66 }
duke@435 67
duke@435 68 // ------------------------------------------------------------------
duke@435 69 // ciSymbol::print_impl
duke@435 70 //
duke@435 71 // Implementation of the print method
duke@435 72 void ciSymbol::print_impl(outputStream* st) {
duke@435 73 st->print(" value=");
duke@435 74 print_symbol_on(st);
duke@435 75 }
duke@435 76
duke@435 77 // ------------------------------------------------------------------
duke@435 78 // ciSymbol::print_symbol_on
duke@435 79 //
duke@435 80 // Print the value of this symbol on an outputStream
duke@435 81 void ciSymbol::print_symbol_on(outputStream *st) {
duke@435 82 GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);)
duke@435 83 }
duke@435 84
duke@435 85 // ------------------------------------------------------------------
duke@435 86 // ciSymbol::make_impl
duke@435 87 //
duke@435 88 // Make a ciSymbol from a C string (implementation).
duke@435 89 ciSymbol* ciSymbol::make_impl(const char* s) {
duke@435 90 EXCEPTION_CONTEXT;
duke@435 91 // For some reason, oopFactory::new_symbol doesn't declare its
duke@435 92 // char* argument as const.
duke@435 93 symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD);
duke@435 94 if (HAS_PENDING_EXCEPTION) {
duke@435 95 CLEAR_PENDING_EXCEPTION;
duke@435 96 CURRENT_THREAD_ENV->record_out_of_memory_failure();
duke@435 97 return ciEnv::_unloaded_cisymbol;
duke@435 98 }
duke@435 99 return CURRENT_THREAD_ENV->get_object(sym)->as_symbol();
duke@435 100 }
duke@435 101
duke@435 102 // ------------------------------------------------------------------
duke@435 103 // ciSymbol::make
duke@435 104 //
duke@435 105 // Make a ciSymbol from a C string.
duke@435 106 ciSymbol* ciSymbol::make(const char* s) {
duke@435 107 GUARDED_VM_ENTRY(return make_impl(s);)
duke@435 108 }

mercurial