author | zgu |
Thu, 07 Aug 2014 12:18:58 -0700 | |
changeset 25946 | 1572c9f03fb9 |
parent 24002 | 4e6a72032a99 |
child 38030 | 93f24e7b3c43 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
13391
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "ci/ciSymbol.hpp" |
|
27 |
#include "ci/ciUtilities.hpp" |
|
28 |
#include "memory/oopFactory.hpp" |
|
1 | 29 |
|
30 |
// ------------------------------------------------------------------ |
|
31 |
// ciSymbol::ciSymbol |
|
32 |
// |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
33 |
// Preallocated symbol variant. Used with symbols from vmSymbols. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
34 |
ciSymbol::ciSymbol(Symbol* s, vmSymbols::SID sid) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
35 |
: _symbol(s), _sid(sid) |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
36 |
{ |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
37 |
assert(_symbol != NULL, "adding null symbol"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
38 |
_symbol->increment_refcount(); // increment ref count |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
39 |
assert(sid_ok(), "must be in vmSymbols"); |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
40 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
41 |
|
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
42 |
// Normal case for non-famous symbols. |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
43 |
ciSymbol::ciSymbol(Symbol* s) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
44 |
: _symbol(s), _sid(vmSymbols::NO_SID) |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
45 |
{ |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
46 |
assert(_symbol != NULL, "adding null symbol"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
47 |
_symbol->increment_refcount(); // increment ref count |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4567
diff
changeset
|
48 |
assert(sid_ok(), "must not be in vmSymbols"); |
1 | 49 |
} |
50 |
||
51 |
// ciSymbol |
|
52 |
// |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
53 |
// This class represents a Symbol* in the HotSpot virtual |
1 | 54 |
// machine. |
55 |
||
56 |
// ------------------------------------------------------------------ |
|
57 |
// ciSymbol::as_utf8 |
|
58 |
// |
|
59 |
// The text of the symbol as a null-terminated C string. |
|
60 |
const char* ciSymbol::as_utf8() { |
|
61 |
VM_QUICK_ENTRY_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
62 |
Symbol* s = get_symbol(); |
1 | 63 |
return s->as_utf8(); |
64 |
} |
|
65 |
||
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13963
diff
changeset
|
66 |
// The text of the symbol as a null-terminated C string. |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13963
diff
changeset
|
67 |
const char* ciSymbol::as_quoted_ascii() { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13963
diff
changeset
|
68 |
GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();) |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13963
diff
changeset
|
69 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13963
diff
changeset
|
70 |
|
1 | 71 |
// ------------------------------------------------------------------ |
72 |
// ciSymbol::base |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
73 |
const jbyte* ciSymbol::base() { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
74 |
GUARDED_VM_ENTRY(return get_symbol()->base();) |
1 | 75 |
} |
76 |
||
77 |
// ------------------------------------------------------------------ |
|
78 |
// ciSymbol::byte_at |
|
79 |
int ciSymbol::byte_at(int i) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
80 |
GUARDED_VM_ENTRY(return get_symbol()->byte_at(i);) |
1 | 81 |
} |
82 |
||
83 |
// ------------------------------------------------------------------ |
|
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
84 |
// ciSymbol::starts_with |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
85 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
86 |
// Tests if the symbol starts with the given prefix. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
87 |
bool ciSymbol::starts_with(const char* prefix, int len) const { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
88 |
GUARDED_VM_ENTRY(return get_symbol()->starts_with(prefix, len);) |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
89 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
90 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
91 |
bool ciSymbol::is_signature_polymorphic_name() const { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
92 |
GUARDED_VM_ENTRY(return MethodHandles::is_signature_polymorphic_name(get_symbol());) |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
93 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
94 |
|
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
95 |
// ------------------------------------------------------------------ |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
96 |
// ciSymbol::index_of |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
97 |
// |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
98 |
// Determines where the symbol contains the given substring. |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
99 |
int ciSymbol::index_of_at(int i, const char* str, int len) const { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
100 |
GUARDED_VM_ENTRY(return get_symbol()->index_of_at(i, str, len);) |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
101 |
} |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
102 |
|
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1
diff
changeset
|
103 |
// ------------------------------------------------------------------ |
1 | 104 |
// ciSymbol::utf8_length |
105 |
int ciSymbol::utf8_length() { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
106 |
GUARDED_VM_ENTRY(return get_symbol()->utf8_length();) |
1 | 107 |
} |
108 |
||
109 |
// ------------------------------------------------------------------ |
|
110 |
// ciSymbol::print_impl |
|
111 |
// |
|
112 |
// Implementation of the print method |
|
113 |
void ciSymbol::print_impl(outputStream* st) { |
|
114 |
st->print(" value="); |
|
115 |
print_symbol_on(st); |
|
116 |
} |
|
117 |
||
118 |
// ------------------------------------------------------------------ |
|
119 |
// ciSymbol::print_symbol_on |
|
120 |
// |
|
121 |
// Print the value of this symbol on an outputStream |
|
122 |
void ciSymbol::print_symbol_on(outputStream *st) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
123 |
GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);) |
1 | 124 |
} |
125 |
||
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
14477
diff
changeset
|
126 |
const char* ciSymbol::as_klass_external_name() const { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
14477
diff
changeset
|
127 |
GUARDED_VM_ENTRY(return get_symbol()->as_klass_external_name();); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
14477
diff
changeset
|
128 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
14477
diff
changeset
|
129 |
|
1 | 130 |
// ------------------------------------------------------------------ |
131 |
// ciSymbol::make_impl |
|
132 |
// |
|
133 |
// Make a ciSymbol from a C string (implementation). |
|
134 |
ciSymbol* ciSymbol::make_impl(const char* s) { |
|
135 |
EXCEPTION_CONTEXT; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
136 |
TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD); |
1 | 137 |
if (HAS_PENDING_EXCEPTION) { |
138 |
CLEAR_PENDING_EXCEPTION; |
|
139 |
CURRENT_THREAD_ENV->record_out_of_memory_failure(); |
|
140 |
return ciEnv::_unloaded_cisymbol; |
|
141 |
} |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
142 |
return CURRENT_THREAD_ENV->get_symbol(sym); |
1 | 143 |
} |
144 |
||
145 |
// ------------------------------------------------------------------ |
|
146 |
// ciSymbol::make |
|
147 |
// |
|
148 |
// Make a ciSymbol from a C string. |
|
149 |
ciSymbol* ciSymbol::make(const char* s) { |
|
150 |
GUARDED_VM_ENTRY(return make_impl(s);) |
|
151 |
} |