Sat, 01 May 2010 02:42:18 -0700
6939134: JSR 292 adjustments to method handle invocation
Summary: split MethodHandle.invoke into invokeExact and invokeGeneric; also clean up JVM-to-Java interfaces
Reviewed-by: twisti
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. |
jrose@1862 | 32 | ciSymbol::ciSymbol(symbolHandle h_s, vmSymbols::SID sid) |
jrose@1862 | 33 | : ciObject(h_s), _sid(sid) |
jrose@1862 | 34 | { |
jrose@1862 | 35 | assert(sid_ok(), "must be in vmSymbols"); |
jrose@1862 | 36 | } |
jrose@1862 | 37 | |
jrose@1862 | 38 | // Normal case for non-famous symbols. |
jrose@1862 | 39 | ciSymbol::ciSymbol(symbolOop s) |
jrose@1862 | 40 | : ciObject(s), _sid(vmSymbols::NO_SID) |
jrose@1862 | 41 | { |
jrose@1862 | 42 | assert(sid_ok(), "must not be in vmSymbols"); |
duke@435 | 43 | } |
duke@435 | 44 | |
duke@435 | 45 | // ciSymbol |
duke@435 | 46 | // |
duke@435 | 47 | // This class represents a symbolOop in the HotSpot virtual |
duke@435 | 48 | // machine. |
duke@435 | 49 | |
duke@435 | 50 | // ------------------------------------------------------------------ |
duke@435 | 51 | // ciSymbol::as_utf8 |
duke@435 | 52 | // |
duke@435 | 53 | // The text of the symbol as a null-terminated C string. |
duke@435 | 54 | const char* ciSymbol::as_utf8() { |
duke@435 | 55 | VM_QUICK_ENTRY_MARK; |
duke@435 | 56 | symbolOop s = get_symbolOop(); |
duke@435 | 57 | return s->as_utf8(); |
duke@435 | 58 | } |
duke@435 | 59 | |
duke@435 | 60 | // ------------------------------------------------------------------ |
duke@435 | 61 | // ciSymbol::base |
duke@435 | 62 | jbyte* ciSymbol::base() { |
duke@435 | 63 | GUARDED_VM_ENTRY(return get_symbolOop()->base();) |
duke@435 | 64 | } |
duke@435 | 65 | |
duke@435 | 66 | // ------------------------------------------------------------------ |
duke@435 | 67 | // ciSymbol::byte_at |
duke@435 | 68 | int ciSymbol::byte_at(int i) { |
duke@435 | 69 | GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);) |
duke@435 | 70 | } |
duke@435 | 71 | |
duke@435 | 72 | // ------------------------------------------------------------------ |
twisti@1573 | 73 | // ciSymbol::starts_with |
twisti@1573 | 74 | // |
twisti@1573 | 75 | // Tests if the symbol starts with the given prefix. |
twisti@1573 | 76 | bool ciSymbol::starts_with(const char* prefix, int len) const { |
twisti@1573 | 77 | GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);) |
twisti@1573 | 78 | } |
twisti@1573 | 79 | |
twisti@1573 | 80 | // ------------------------------------------------------------------ |
twisti@1573 | 81 | // ciSymbol::index_of |
twisti@1573 | 82 | // |
twisti@1573 | 83 | // Determines where the symbol contains the given substring. |
twisti@1573 | 84 | int ciSymbol::index_of_at(int i, const char* str, int len) const { |
twisti@1573 | 85 | GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);) |
twisti@1573 | 86 | } |
twisti@1573 | 87 | |
twisti@1573 | 88 | // ------------------------------------------------------------------ |
duke@435 | 89 | // ciSymbol::utf8_length |
duke@435 | 90 | int ciSymbol::utf8_length() { |
duke@435 | 91 | GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();) |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | // ------------------------------------------------------------------ |
duke@435 | 95 | // ciSymbol::print_impl |
duke@435 | 96 | // |
duke@435 | 97 | // Implementation of the print method |
duke@435 | 98 | void ciSymbol::print_impl(outputStream* st) { |
duke@435 | 99 | st->print(" value="); |
duke@435 | 100 | print_symbol_on(st); |
duke@435 | 101 | } |
duke@435 | 102 | |
duke@435 | 103 | // ------------------------------------------------------------------ |
duke@435 | 104 | // ciSymbol::print_symbol_on |
duke@435 | 105 | // |
duke@435 | 106 | // Print the value of this symbol on an outputStream |
duke@435 | 107 | void ciSymbol::print_symbol_on(outputStream *st) { |
duke@435 | 108 | GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);) |
duke@435 | 109 | } |
duke@435 | 110 | |
duke@435 | 111 | // ------------------------------------------------------------------ |
duke@435 | 112 | // ciSymbol::make_impl |
duke@435 | 113 | // |
duke@435 | 114 | // Make a ciSymbol from a C string (implementation). |
duke@435 | 115 | ciSymbol* ciSymbol::make_impl(const char* s) { |
duke@435 | 116 | EXCEPTION_CONTEXT; |
duke@435 | 117 | // For some reason, oopFactory::new_symbol doesn't declare its |
duke@435 | 118 | // char* argument as const. |
duke@435 | 119 | symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD); |
duke@435 | 120 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 121 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 122 | CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
duke@435 | 123 | return ciEnv::_unloaded_cisymbol; |
duke@435 | 124 | } |
duke@435 | 125 | return CURRENT_THREAD_ENV->get_object(sym)->as_symbol(); |
duke@435 | 126 | } |
duke@435 | 127 | |
duke@435 | 128 | // ------------------------------------------------------------------ |
duke@435 | 129 | // ciSymbol::make |
duke@435 | 130 | // |
duke@435 | 131 | // Make a ciSymbol from a C string. |
duke@435 | 132 | ciSymbol* ciSymbol::make(const char* s) { |
duke@435 | 133 | GUARDED_VM_ENTRY(return make_impl(s);) |
duke@435 | 134 | } |