hotspot/src/share/vm/ci/ciSymbol.cpp
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 5420 586d3988e72b
child 7397 5b173b4ca846
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
     2
 * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_ciSymbol.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// ciSymbol::ciSymbol
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Preallocated handle variant.  Used with handles from vmSymboHandles.
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    32
ciSymbol::ciSymbol(symbolHandle h_s, vmSymbols::SID sid)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    33
  : ciObject(h_s), _sid(sid)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    34
{
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    35
  assert(sid_ok(), "must be in vmSymbols");
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    36
}
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    37
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    38
// Normal case for non-famous symbols.
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    39
ciSymbol::ciSymbol(symbolOop s)
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 4567
diff changeset
    40
  : ciObject(s), _sid(vmSymbols::NO_SID)
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
  assert(sid_ok(), "must not be in vmSymbols");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// ciSymbol
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// This class represents a symbolOop in the HotSpot virtual
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// ciSymbol::as_utf8
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// The text of the symbol as a null-terminated C string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
const char* ciSymbol::as_utf8() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  VM_QUICK_ENTRY_MARK;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  symbolOop s = get_symbolOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  return s->as_utf8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// ciSymbol::base
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
jbyte* ciSymbol::base() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  GUARDED_VM_ENTRY(return get_symbolOop()->base();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// ciSymbol::byte_at
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
int ciSymbol::byte_at(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// ------------------------------------------------------------------
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    73
// ciSymbol::starts_with
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    74
//
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    75
// Tests if the symbol starts with the given prefix.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    76
bool ciSymbol::starts_with(const char* prefix, int len) const {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    77
  GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);)
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    78
}
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    79
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    80
// ------------------------------------------------------------------
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    81
// ciSymbol::index_of
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    82
//
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    83
// Determines where the symbol contains the given substring.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    84
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
    85
  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
    86
}
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    87
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    88
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// ciSymbol::utf8_length
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
int ciSymbol::utf8_length() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// ciSymbol::print_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// Implementation of the print method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
void ciSymbol::print_impl(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  st->print(" value=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// ciSymbol::print_symbol_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// Print the value of this symbol on an outputStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
void ciSymbol::print_symbol_on(outputStream *st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// ciSymbol::make_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// Make a ciSymbol from a C string (implementation).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
ciSymbol* ciSymbol::make_impl(const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  EXCEPTION_CONTEXT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // For some reason, oopFactory::new_symbol doesn't declare its
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // char* argument as const.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  if (HAS_PENDING_EXCEPTION) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    CURRENT_THREAD_ENV->record_out_of_memory_failure();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    return ciEnv::_unloaded_cisymbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  return CURRENT_THREAD_ENV->get_object(sym)->as_symbol();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// ciSymbol::make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// Make a ciSymbol from a C string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
ciSymbol* ciSymbol::make(const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  GUARDED_VM_ENTRY(return make_impl(s);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}