Mercurial > hg > graal-compiler
annotate src/share/vm/ci/ciSymbol.cpp @ 1751:2528b5bd749c
6980262: Memory leak when exception is thrown in static initializer
Summary: Use resource memory instead of c-heap for the exception message
Reviewed-by: phh, jmasa
author | kamg |
---|---|
date | Fri, 27 Aug 2010 15:05:28 -0400 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
2 * Copyright (c) 1999, 2009, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1507
diff
changeset
|
21 * questions. |
0 | 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 } |