src/hotspot/share/ci/ciSymbol.cpp
author redestad
Thu, 20 Dec 2018 19:44:08 +0100
changeset 53091 5bf5b773fc41
parent 51997 9ce37fa2e179
child 54786 ebf733a324d4
permissions -rw-r--r--
8215555: TieredCompilation C2 threads can excessively block handshakes Reviewed-by: kvn, neliasso, rehn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49449
diff changeset
     2
 * Copyright (c) 1999, 2018, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "ci/ciSymbol.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 47216
diff changeset
    27
#include "ci/ciUtilities.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/oopFactory.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// ciSymbol::ciSymbol
489c9b5090e2 Initial load
duke
parents:
diff changeset
    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
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// ciSymbol::as_utf8
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// The text of the symbol as a null-terminated C string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
const char* ciSymbol::as_utf8() {
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 24002
diff changeset
    61
  GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_utf8();)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
14477
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13963
diff changeset
    64
// 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
    65
const char* ciSymbol::as_quoted_ascii() {
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13963
diff changeset
    66
  GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();)
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13963
diff changeset
    67
}
95e66ea71f71 6830717: replay of compilations would help with debugging
minqi
parents: 13963
diff changeset
    68
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// ciSymbol::base
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49449
diff changeset
    71
const u1* ciSymbol::base() {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    72
  GUARDED_VM_ENTRY(return get_symbol()->base();)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// ------------------------------------------------------------------
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49449
diff changeset
    76
// ciSymbol::char_at
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49449
diff changeset
    77
char ciSymbol::char_at(int i) {
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 49449
diff changeset
    78
  GUARDED_VM_ENTRY(return get_symbol()->char_at(i);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// ------------------------------------------------------------------
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    82
// ciSymbol::starts_with
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    83
//
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    84
// Tests if the symbol starts with the given prefix.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    85
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
    86
  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
    87
}
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    88
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8921
diff changeset
    89
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
    90
  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
    91
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8921
diff changeset
    92
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    93
// ------------------------------------------------------------------
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    94
// ciSymbol::index_of
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
// Determines where the symbol contains the given substring.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
    97
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
    98
  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
    99
}
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
   100
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1
diff changeset
   101
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// ciSymbol::utf8_length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
int ciSymbol::utf8_length() {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   104
  GUARDED_VM_ENTRY(return get_symbol()->utf8_length();)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// ciSymbol::print_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// Implementation of the print method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
void ciSymbol::print_impl(outputStream* st) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  st->print(" value=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// ciSymbol::print_symbol_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// Print the value of this symbol on an outputStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
void ciSymbol::print_symbol_on(outputStream *st) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   121
  GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 14477
diff changeset
   124
const char* ciSymbol::as_klass_external_name() const {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 14477
diff changeset
   125
  GUARDED_VM_ENTRY(return get_symbol()->as_klass_external_name(););
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 14477
diff changeset
   126
}
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 14477
diff changeset
   127
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// ciSymbol::make_impl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// Make a ciSymbol from a C string (implementation).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
ciSymbol* ciSymbol::make_impl(const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  EXCEPTION_CONTEXT;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   134
  TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  if (HAS_PENDING_EXCEPTION) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    CLEAR_PENDING_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    CURRENT_THREAD_ENV->record_out_of_memory_failure();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    return ciEnv::_unloaded_cisymbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   140
  return CURRENT_THREAD_ENV->get_symbol(sym);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// ciSymbol::make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
// Make a ciSymbol from a C string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
ciSymbol* ciSymbol::make(const char* s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  GUARDED_VM_ENTRY(return make_impl(s);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
}