src/share/vm/ci/ciSymbol.cpp

Mon, 26 Apr 2010 23:59:45 -0700

author
never
date
Mon, 26 Apr 2010 23:59:45 -0700
changeset 1832
b4776199210f
parent 1573
dd57230ba8fe
child 1862
cd5dbf694d45
permissions
-rw-r--r--

6943485: JVMTI always on capabilities change code generation too much
Reviewed-by: twisti, dcubed

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

mercurial