author | dcubed |
Wed, 20 Jan 2010 11:32:41 -0700 | |
changeset 4733 | 27a7366e12da |
parent 4567 | 7fc02fbe5c7a |
child 5420 | 586d3988e72b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
2 |
* Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. |
1 | 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. |
|
32 |
ciSymbol::ciSymbol(symbolHandle h_s) : ciObject(h_s) { |
|
33 |
} |
|
34 |
||
35 |
// ciSymbol |
|
36 |
// |
|
37 |
// This class represents a symbolOop in the HotSpot virtual |
|
38 |
// machine. |
|
39 |
||
40 |
// ------------------------------------------------------------------ |
|
41 |
// ciSymbol::as_utf8 |
|
42 |
// |
|
43 |
// The text of the symbol as a null-terminated C string. |
|
44 |
const char* ciSymbol::as_utf8() { |
|
45 |
VM_QUICK_ENTRY_MARK; |
|
46 |
symbolOop s = get_symbolOop(); |
|
47 |
return s->as_utf8(); |
|
48 |
} |
|
49 |
||
50 |
// ------------------------------------------------------------------ |
|
51 |
// ciSymbol::base |
|
52 |
jbyte* ciSymbol::base() { |
|
53 |
GUARDED_VM_ENTRY(return get_symbolOop()->base();) |
|
54 |
} |
|
55 |
||
56 |
// ------------------------------------------------------------------ |
|
57 |
// ciSymbol::byte_at |
|
58 |
int ciSymbol::byte_at(int i) { |
|
59 |
GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);) |
|
60 |
} |
|
61 |
||
62 |
// ------------------------------------------------------------------ |
|
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
63 |
// ciSymbol::starts_with |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
64 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
65 |
// Tests if the symbol starts with the given prefix. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
66 |
bool ciSymbol::starts_with(const char* prefix, int len) const { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
67 |
GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
68 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
69 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
70 |
// ------------------------------------------------------------------ |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
71 |
// ciSymbol::index_of |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
72 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
73 |
// Determines where the symbol contains the given substring. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
74 |
int ciSymbol::index_of_at(int i, const char* str, int len) const { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
75 |
GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);) |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
76 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
77 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
78 |
// ------------------------------------------------------------------ |
1 | 79 |
// ciSymbol::utf8_length |
80 |
int ciSymbol::utf8_length() { |
|
81 |
GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();) |
|
82 |
} |
|
83 |
||
84 |
// ------------------------------------------------------------------ |
|
85 |
// ciSymbol::print_impl |
|
86 |
// |
|
87 |
// Implementation of the print method |
|
88 |
void ciSymbol::print_impl(outputStream* st) { |
|
89 |
st->print(" value="); |
|
90 |
print_symbol_on(st); |
|
91 |
} |
|
92 |
||
93 |
// ------------------------------------------------------------------ |
|
94 |
// ciSymbol::print_symbol_on |
|
95 |
// |
|
96 |
// Print the value of this symbol on an outputStream |
|
97 |
void ciSymbol::print_symbol_on(outputStream *st) { |
|
98 |
GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);) |
|
99 |
} |
|
100 |
||
101 |
// ------------------------------------------------------------------ |
|
102 |
// ciSymbol::make_impl |
|
103 |
// |
|
104 |
// Make a ciSymbol from a C string (implementation). |
|
105 |
ciSymbol* ciSymbol::make_impl(const char* s) { |
|
106 |
EXCEPTION_CONTEXT; |
|
107 |
// For some reason, oopFactory::new_symbol doesn't declare its |
|
108 |
// char* argument as const. |
|
109 |
symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD); |
|
110 |
if (HAS_PENDING_EXCEPTION) { |
|
111 |
CLEAR_PENDING_EXCEPTION; |
|
112 |
CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
|
113 |
return ciEnv::_unloaded_cisymbol; |
|
114 |
} |
|
115 |
return CURRENT_THREAD_ENV->get_object(sym)->as_symbol(); |
|
116 |
} |
|
117 |
||
118 |
// ------------------------------------------------------------------ |
|
119 |
// ciSymbol::make |
|
120 |
// |
|
121 |
// Make a ciSymbol from a C string. |
|
122 |
ciSymbol* ciSymbol::make(const char* s) { |
|
123 |
GUARDED_VM_ENTRY(return make_impl(s);) |
|
124 |
} |