Mon, 26 Apr 2010 23:59:45 -0700
6943485: JVMTI always on capabilities change code generation too much
Reviewed-by: twisti, dcubed
duke@435 | 1 | /* |
twisti@1573 | 2 | * Copyright 1999-2009 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 | // ------------------------------------------------------------------ |
twisti@1573 | 63 | // ciSymbol::starts_with |
twisti@1573 | 64 | // |
twisti@1573 | 65 | // Tests if the symbol starts with the given prefix. |
twisti@1573 | 66 | bool ciSymbol::starts_with(const char* prefix, int len) const { |
twisti@1573 | 67 | GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);) |
twisti@1573 | 68 | } |
twisti@1573 | 69 | |
twisti@1573 | 70 | // ------------------------------------------------------------------ |
twisti@1573 | 71 | // ciSymbol::index_of |
twisti@1573 | 72 | // |
twisti@1573 | 73 | // Determines where the symbol contains the given substring. |
twisti@1573 | 74 | int ciSymbol::index_of_at(int i, const char* str, int len) const { |
twisti@1573 | 75 | GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);) |
twisti@1573 | 76 | } |
twisti@1573 | 77 | |
twisti@1573 | 78 | // ------------------------------------------------------------------ |
duke@435 | 79 | // ciSymbol::utf8_length |
duke@435 | 80 | int ciSymbol::utf8_length() { |
duke@435 | 81 | GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();) |
duke@435 | 82 | } |
duke@435 | 83 | |
duke@435 | 84 | // ------------------------------------------------------------------ |
duke@435 | 85 | // ciSymbol::print_impl |
duke@435 | 86 | // |
duke@435 | 87 | // Implementation of the print method |
duke@435 | 88 | void ciSymbol::print_impl(outputStream* st) { |
duke@435 | 89 | st->print(" value="); |
duke@435 | 90 | print_symbol_on(st); |
duke@435 | 91 | } |
duke@435 | 92 | |
duke@435 | 93 | // ------------------------------------------------------------------ |
duke@435 | 94 | // ciSymbol::print_symbol_on |
duke@435 | 95 | // |
duke@435 | 96 | // Print the value of this symbol on an outputStream |
duke@435 | 97 | void ciSymbol::print_symbol_on(outputStream *st) { |
duke@435 | 98 | GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);) |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | // ------------------------------------------------------------------ |
duke@435 | 102 | // ciSymbol::make_impl |
duke@435 | 103 | // |
duke@435 | 104 | // Make a ciSymbol from a C string (implementation). |
duke@435 | 105 | ciSymbol* ciSymbol::make_impl(const char* s) { |
duke@435 | 106 | EXCEPTION_CONTEXT; |
duke@435 | 107 | // For some reason, oopFactory::new_symbol doesn't declare its |
duke@435 | 108 | // char* argument as const. |
duke@435 | 109 | symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD); |
duke@435 | 110 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 111 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 112 | CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
duke@435 | 113 | return ciEnv::_unloaded_cisymbol; |
duke@435 | 114 | } |
duke@435 | 115 | return CURRENT_THREAD_ENV->get_object(sym)->as_symbol(); |
duke@435 | 116 | } |
duke@435 | 117 | |
duke@435 | 118 | // ------------------------------------------------------------------ |
duke@435 | 119 | // ciSymbol::make |
duke@435 | 120 | // |
duke@435 | 121 | // Make a ciSymbol from a C string. |
duke@435 | 122 | ciSymbol* ciSymbol::make(const char* s) { |
duke@435 | 123 | GUARDED_VM_ENTRY(return make_impl(s);) |
duke@435 | 124 | } |