src/hotspot/share/code/icBuffer.cpp
author eosterlund
Wed, 05 Dec 2018 15:57:26 +0100
changeset 52857 7e268f863ff0
parent 52384 d6dc479bcdd3
child 52896 98408c7c0b73
permissions -rw-r--r--
8214338: Move IC stub refilling out of IC cache transitions Reviewed-by: dlong, rbackman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
    26
#include "code/codeCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "code/compiledIC.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/icBuffer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "code/nmethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "code/scopeDesc.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29081
diff changeset
    31
#include "gc/shared/collectedHeap.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "interpreter/linkResolver.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "memory/resourceArea.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 47216
diff changeset
    35
#include "memory/universe.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    36
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "oops/oop.inline.hpp"
49393
93fe2fc5c093 8199472: Fix non-PCH build after JDK-8199319
simonis
parents: 49359
diff changeset
    38
#include "runtime/handles.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/stubRoutines.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
DEF_STUB_INTERFACE(ICStub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
StubQueue* InlineCacheBuffer::_buffer    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    46
CompiledICHolder* InlineCacheBuffer::_pending_released = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    47
int InlineCacheBuffer::_pending_count = 0;
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
    48
DEBUG_ONLY(volatile int InlineCacheBuffer::_needs_refill = 0;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
void ICStub::finalize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  if (!is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    ResourceMark rm;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33148
diff changeset
    53
    CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site());
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33148
diff changeset
    54
    assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    57
    ic->set_ic_destination_and_value(destination(), cached_value());
1
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
address ICStub::destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  return InlineCacheBuffer::ic_buffer_entry_point(code_begin());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    66
void* ICStub::cached_value() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    67
  return InlineCacheBuffer::ic_buffer_cached_value(code_begin());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    71
void ICStub::set_stub(CompiledIC *ic, void* cached_val, address dest_addr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // We cannot store a pointer to the 'ic' object, since it is resource allocated. Instead we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // store the location of the inline cache. Then we have enough information recreate the CompiledIC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // object when we need to remove the stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  _ic_site = ic->instruction_address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Assemble new stub
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    78
  InlineCacheBuffer::assemble_ic_buffer_code(code_begin(), cached_val, dest_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  assert(destination() == dest_addr,   "can recover destination");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    80
  assert(cached_value() == cached_val, "can recover destination");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
void ICStub::clear() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    85
  if (CompiledIC::is_icholder_entry(destination())) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    86
    InlineCacheBuffer::queue_for_release((CompiledICHolder*)cached_value());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    87
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  _ic_site = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// anybody calling to this stub will trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
void ICStub::verify() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
void ICStub::print() {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 30764
diff changeset
    99
  tty->print_cr("ICStub: site: " INTPTR_FORMAT, p2i(_ic_site));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
//-----------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// Implementation of InlineCacheBuffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
void InlineCacheBuffer::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  if (_buffer != NULL) return; // already initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  assert (_buffer != NULL, "cannot allocate InlineCacheBuffer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
ICStub* InlineCacheBuffer::new_ic_stub() {
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   115
  return (ICStub*)buffer()->request_committed(ic_stub_code_size());
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   116
}
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   117
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   118
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   119
void InlineCacheBuffer::refill_ic_stubs() {
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   120
  DEBUG_ONLY(Atomic::store(0, &_needs_refill));
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   121
  // we ran out of inline cache buffer space; must enter safepoint.
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   122
  // We do this by forcing a safepoint
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   123
  EXCEPTION_MARK;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   125
  VM_ICBufferFull ibf;
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   126
  VMThread::execute(&ibf);
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   127
  // We could potential get an async. exception at this point.
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   128
  // In that case we will rethrow it to ourselvs.
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   129
  if (HAS_PENDING_EXCEPTION) {
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   130
    oop exception = PENDING_EXCEPTION;
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   131
    CLEAR_PENDING_EXCEPTION;
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   132
    Thread::send_async_exception(JavaThread::current()->threadObj(), exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
void InlineCacheBuffer::update_inline_caches() {
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   138
  assert(_needs_refill == 0,
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   139
         "Forgot to handle a failed IC transition requiring IC stubs");
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   140
  if (buffer()->number_of_stubs() > 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    if (TraceICBuffer) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      tty->print_cr("[updating inline caches with %d stubs]", buffer()->number_of_stubs());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    buffer()->remove_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   146
  release_pending_icholders();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
bool InlineCacheBuffer::contains(address instruction_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  return buffer()->contains(instruction_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
bool InlineCacheBuffer::is_empty() {
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   156
  return buffer()->number_of_stubs() == 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
void InlineCacheBuffer_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  InlineCacheBuffer::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   165
bool InlineCacheBuffer::create_transition_stub(CompiledIC *ic, void* cached_value, address entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  assert(!SafepointSynchronize::is_at_safepoint(), "should not be called during a safepoint");
52384
d6dc479bcdd3 8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents: 49393
diff changeset
   167
  assert(CompiledICLocker::is_safe(ic->instruction_address()), "mt unsafe call");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   168
  if (TraceICBuffer) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   169
    tty->print_cr("  create transition stub for " INTPTR_FORMAT " destination " INTPTR_FORMAT " cached value " INTPTR_FORMAT,
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 30764
diff changeset
   170
                  p2i(ic->instruction_address()), p2i(entry), p2i(cached_value));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   171
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   173
  // allocate and initialize new "out-of-line" inline-cache
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   174
  ICStub* ic_stub = new_ic_stub();
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   175
  if (ic_stub == NULL) {
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   176
    DEBUG_ONLY(Atomic::inc(&_needs_refill));
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   177
    return false;
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   178
  }
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   179
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // If an transition stub is already associate with the inline cache, then we remove the association.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  if (ic->is_in_transition_state()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    ICStub* old_stub = ICStub_from_destination_address(ic->stub_address());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    old_stub->clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   186
  ic_stub->set_stub(ic, cached_value, entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  // Update inline cache in nmethod to point to new "out-of-line" allocated inline cache
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   189
  ic->set_ic_destination(ic_stub);
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   190
  return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
address InlineCacheBuffer::ic_destination_for(CompiledIC *ic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  ICStub* stub = ICStub_from_destination_address(ic->stub_address());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  return stub->destination();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   200
void* InlineCacheBuffer::cached_value_for(CompiledIC *ic) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  ICStub* stub = ICStub_from_destination_address(ic->stub_address());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   202
  return stub->cached_value();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   204
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   205
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   206
// Free CompiledICHolder*s that are no longer in use
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   207
void InlineCacheBuffer::release_pending_icholders() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   208
  assert(SafepointSynchronize::is_at_safepoint(), "should only be called during a safepoint");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   209
  CompiledICHolder* holder = _pending_released;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   210
  _pending_released = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   211
  while (holder != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   212
    CompiledICHolder* next = holder->next();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   213
    delete holder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   214
    holder = next;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   215
    _pending_count--;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   216
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   217
  assert(_pending_count == 0, "wrong count");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   218
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   219
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   220
// Enqueue this icholder for release during the next safepoint.  It's
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   221
// not safe to free them until them since they might be visible to
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   222
// another thread.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   223
void InlineCacheBuffer::queue_for_release(CompiledICHolder* icholder) {
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 52384
diff changeset
   224
  MutexLockerEx mex(InlineCacheBuffer_lock, Mutex::_no_safepoint_check_flag);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   225
  icholder->set_next(_pending_released);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   226
  _pending_released = icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   227
  _pending_count++;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   228
  if (TraceICBuffer) {
33148
68fa8b6c4340 8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 30764
diff changeset
   229
    tty->print_cr("enqueueing icholder " INTPTR_FORMAT " to be freed", p2i(icholder));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   230
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   231
}