Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "ci/ciSymbol.hpp" |
stefank@2314 | 27 | #include "ci/ciUtilities.hpp" |
stefank@2314 | 28 | #include "memory/oopFactory.hpp" |
duke@435 | 29 | |
duke@435 | 30 | // ------------------------------------------------------------------ |
duke@435 | 31 | // ciSymbol::ciSymbol |
duke@435 | 32 | // |
duke@435 | 33 | // Preallocated handle variant. Used with handles from vmSymboHandles. |
jrose@1862 | 34 | ciSymbol::ciSymbol(symbolHandle h_s, vmSymbols::SID sid) |
jrose@1862 | 35 | : ciObject(h_s), _sid(sid) |
jrose@1862 | 36 | { |
jrose@1862 | 37 | assert(sid_ok(), "must be in vmSymbols"); |
jrose@1862 | 38 | } |
jrose@1862 | 39 | |
jrose@1862 | 40 | // Normal case for non-famous symbols. |
jrose@1862 | 41 | ciSymbol::ciSymbol(symbolOop s) |
jrose@1862 | 42 | : ciObject(s), _sid(vmSymbols::NO_SID) |
jrose@1862 | 43 | { |
jrose@1862 | 44 | assert(sid_ok(), "must not be in vmSymbols"); |
duke@435 | 45 | } |
duke@435 | 46 | |
duke@435 | 47 | // ciSymbol |
duke@435 | 48 | // |
duke@435 | 49 | // This class represents a symbolOop in the HotSpot virtual |
duke@435 | 50 | // machine. |
duke@435 | 51 | |
duke@435 | 52 | // ------------------------------------------------------------------ |
duke@435 | 53 | // ciSymbol::as_utf8 |
duke@435 | 54 | // |
duke@435 | 55 | // The text of the symbol as a null-terminated C string. |
duke@435 | 56 | const char* ciSymbol::as_utf8() { |
duke@435 | 57 | VM_QUICK_ENTRY_MARK; |
duke@435 | 58 | symbolOop s = get_symbolOop(); |
duke@435 | 59 | return s->as_utf8(); |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | // ------------------------------------------------------------------ |
duke@435 | 63 | // ciSymbol::base |
duke@435 | 64 | jbyte* ciSymbol::base() { |
duke@435 | 65 | GUARDED_VM_ENTRY(return get_symbolOop()->base();) |
duke@435 | 66 | } |
duke@435 | 67 | |
duke@435 | 68 | // ------------------------------------------------------------------ |
duke@435 | 69 | // ciSymbol::byte_at |
duke@435 | 70 | int ciSymbol::byte_at(int i) { |
duke@435 | 71 | GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);) |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | // ------------------------------------------------------------------ |
twisti@1573 | 75 | // ciSymbol::starts_with |
twisti@1573 | 76 | // |
twisti@1573 | 77 | // Tests if the symbol starts with the given prefix. |
twisti@1573 | 78 | bool ciSymbol::starts_with(const char* prefix, int len) const { |
twisti@1573 | 79 | GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);) |
twisti@1573 | 80 | } |
twisti@1573 | 81 | |
twisti@1573 | 82 | // ------------------------------------------------------------------ |
twisti@1573 | 83 | // ciSymbol::index_of |
twisti@1573 | 84 | // |
twisti@1573 | 85 | // Determines where the symbol contains the given substring. |
twisti@1573 | 86 | int ciSymbol::index_of_at(int i, const char* str, int len) const { |
twisti@1573 | 87 | GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);) |
twisti@1573 | 88 | } |
twisti@1573 | 89 | |
twisti@1573 | 90 | // ------------------------------------------------------------------ |
duke@435 | 91 | // ciSymbol::utf8_length |
duke@435 | 92 | int ciSymbol::utf8_length() { |
duke@435 | 93 | GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();) |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | // ------------------------------------------------------------------ |
duke@435 | 97 | // ciSymbol::print_impl |
duke@435 | 98 | // |
duke@435 | 99 | // Implementation of the print method |
duke@435 | 100 | void ciSymbol::print_impl(outputStream* st) { |
duke@435 | 101 | st->print(" value="); |
duke@435 | 102 | print_symbol_on(st); |
duke@435 | 103 | } |
duke@435 | 104 | |
duke@435 | 105 | // ------------------------------------------------------------------ |
duke@435 | 106 | // ciSymbol::print_symbol_on |
duke@435 | 107 | // |
duke@435 | 108 | // Print the value of this symbol on an outputStream |
duke@435 | 109 | void ciSymbol::print_symbol_on(outputStream *st) { |
duke@435 | 110 | GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);) |
duke@435 | 111 | } |
duke@435 | 112 | |
duke@435 | 113 | // ------------------------------------------------------------------ |
duke@435 | 114 | // ciSymbol::make_impl |
duke@435 | 115 | // |
duke@435 | 116 | // Make a ciSymbol from a C string (implementation). |
duke@435 | 117 | ciSymbol* ciSymbol::make_impl(const char* s) { |
duke@435 | 118 | EXCEPTION_CONTEXT; |
duke@435 | 119 | // For some reason, oopFactory::new_symbol doesn't declare its |
duke@435 | 120 | // char* argument as const. |
duke@435 | 121 | symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD); |
duke@435 | 122 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 123 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 124 | CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
duke@435 | 125 | return ciEnv::_unloaded_cisymbol; |
duke@435 | 126 | } |
duke@435 | 127 | return CURRENT_THREAD_ENV->get_object(sym)->as_symbol(); |
duke@435 | 128 | } |
duke@435 | 129 | |
duke@435 | 130 | // ------------------------------------------------------------------ |
duke@435 | 131 | // ciSymbol::make |
duke@435 | 132 | // |
duke@435 | 133 | // Make a ciSymbol from a C string. |
duke@435 | 134 | ciSymbol* ciSymbol::make(const char* s) { |
duke@435 | 135 | GUARDED_VM_ENTRY(return make_impl(s);) |
duke@435 | 136 | } |