Mercurial > hg > truffle
annotate src/share/vm/ci/ciSymbol.cpp @ 1507:cd5dbf694d45
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
author | jrose |
---|---|
date | Sat, 01 May 2010 02:42:18 -0700 |
parents | dd57230ba8fe |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_ciSymbol.cpp.incl" | |
27 | |
28 // ------------------------------------------------------------------ | |
29 // ciSymbol::ciSymbol | |
30 // | |
31 // Preallocated handle variant. Used with handles from vmSymboHandles. | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
32 ciSymbol::ciSymbol(symbolHandle h_s, vmSymbols::SID sid) |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
33 : ciObject(h_s), _sid(sid) |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
34 { |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
35 assert(sid_ok(), "must be in vmSymbols"); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
36 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
37 |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
38 // Normal case for non-famous symbols. |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
39 ciSymbol::ciSymbol(symbolOop s) |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
40 : ciObject(s), _sid(vmSymbols::NO_SID) |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
41 { |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1138
diff
changeset
|
42 assert(sid_ok(), "must not be in vmSymbols"); |
0 | 43 } |
44 | |
45 // ciSymbol | |
46 // | |
47 // This class represents a symbolOop in the HotSpot virtual | |
48 // machine. | |
49 | |
50 // ------------------------------------------------------------------ | |
51 // ciSymbol::as_utf8 | |
52 // | |
53 // The text of the symbol as a null-terminated C string. | |
54 const char* ciSymbol::as_utf8() { | |
55 VM_QUICK_ENTRY_MARK; | |
56 symbolOop s = get_symbolOop(); | |
57 return s->as_utf8(); | |
58 } | |
59 | |
60 // ------------------------------------------------------------------ | |
61 // ciSymbol::base | |
62 jbyte* ciSymbol::base() { | |
63 GUARDED_VM_ENTRY(return get_symbolOop()->base();) | |
64 } | |
65 | |
66 // ------------------------------------------------------------------ | |
67 // ciSymbol::byte_at | |
68 int ciSymbol::byte_at(int i) { | |
69 GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);) | |
70 } | |
71 | |
72 // ------------------------------------------------------------------ | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
73 // ciSymbol::starts_with |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
74 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
75 // Tests if the symbol starts with the given prefix. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
76 bool ciSymbol::starts_with(const char* prefix, int len) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
77 GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
78 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
79 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
80 // ------------------------------------------------------------------ |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
81 // ciSymbol::index_of |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
82 // |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
83 // Determines where the symbol contains the given substring. |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
84 int ciSymbol::index_of_at(int i, const char* str, int len) const { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
85 GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);) |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
86 } |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
87 |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
0
diff
changeset
|
88 // ------------------------------------------------------------------ |
0 | 89 // ciSymbol::utf8_length |
90 int ciSymbol::utf8_length() { | |
91 GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();) | |
92 } | |
93 | |
94 // ------------------------------------------------------------------ | |
95 // ciSymbol::print_impl | |
96 // | |
97 // Implementation of the print method | |
98 void ciSymbol::print_impl(outputStream* st) { | |
99 st->print(" value="); | |
100 print_symbol_on(st); | |
101 } | |
102 | |
103 // ------------------------------------------------------------------ | |
104 // ciSymbol::print_symbol_on | |
105 // | |
106 // Print the value of this symbol on an outputStream | |
107 void ciSymbol::print_symbol_on(outputStream *st) { | |
108 GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);) | |
109 } | |
110 | |
111 // ------------------------------------------------------------------ | |
112 // ciSymbol::make_impl | |
113 // | |
114 // Make a ciSymbol from a C string (implementation). | |
115 ciSymbol* ciSymbol::make_impl(const char* s) { | |
116 EXCEPTION_CONTEXT; | |
117 // For some reason, oopFactory::new_symbol doesn't declare its | |
118 // char* argument as const. | |
119 symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD); | |
120 if (HAS_PENDING_EXCEPTION) { | |
121 CLEAR_PENDING_EXCEPTION; | |
122 CURRENT_THREAD_ENV->record_out_of_memory_failure(); | |
123 return ciEnv::_unloaded_cisymbol; | |
124 } | |
125 return CURRENT_THREAD_ENV->get_object(sym)->as_symbol(); | |
126 } | |
127 | |
128 // ------------------------------------------------------------------ | |
129 // ciSymbol::make | |
130 // | |
131 // Make a ciSymbol from a C string. | |
132 ciSymbol* ciSymbol::make(const char* s) { | |
133 GUARDED_VM_ENTRY(return make_impl(s);) | |
134 } |