hotspot/src/share/vm/code/compiledIC.hpp
author stefank
Tue, 01 Jul 2014 09:03:55 +0200
changeset 25486 be44827be5e7
parent 22234 da823d78ad65
child 25716 fc9bd7814b10
permissions -rw-r--r--
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator Reviewed-by: iveresov, mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 20072
diff changeset
     2
 * Copyright (c) 1997, 2013, 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
#ifndef SHARE_VM_CODE_COMPILEDIC_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CODE_COMPILEDIC_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/linkResolver.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    29
#include "oops/compiledICHolder.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#ifdef TARGET_ARCH_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
# include "nativeInst_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#ifdef TARGET_ARCH_sparc
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
# include "nativeInst_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#ifdef TARGET_ARCH_zero
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
# include "nativeInst_zero.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#endif
8107
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    39
#ifdef TARGET_ARCH_arm
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    40
# include "nativeInst_arm.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    41
#endif
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    42
#ifdef TARGET_ARCH_ppc
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    43
# include "nativeInst_ppc.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
    44
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// The CompiledIC represents a compiled inline cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// In order to make patching of the inline cache MT-safe, we only allow the following
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// transitions (when not at a safepoint):
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//         [1] --<--  Clean -->---  [1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//            /       (null)      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//           /                     \      /-<-\
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//          /          [2]          \    /     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//      Interpreted  ---------> Monomorphic     | [3]
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    58
//  (CompiledICHolder*)            (Klass*)     |
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//          \                        /   \     /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//       [4] \                      / [4] \->-/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
//            \->-  Megamorphic -<-/
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    62
//                  (Method*)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// The text in paranteses () refere to the value of the inline cache receiver (mov instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// The numbers in square brackets refere to the kind of transition:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// [1]: Initial fixup. Receiver it found from debug information
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// [2]: Compilation of a method
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    69
// [3]: Recompilation of a method (note: only entry is changed. The Klass* must stay the same)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// [4]: Inline cache miss. We go directly to megamorphic call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// transition is made to a stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
class CompiledIC;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    76
class ICStub;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    78
class CompiledICInfo : public StackObj {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  address _entry;              // entry point for call
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    81
  void*   _cached_value;         // Value of cached_value (either in stub or inline cache)
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    82
  bool    _is_icholder;          // Is the cached value a CompiledICHolder*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  bool    _is_optimized;       // it is an optimized virtual call (i.e., can be statically bound)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool    _to_interpreter;     // Call it to interpreter
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    85
  bool    _release_icholder;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  address entry() const        { return _entry; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    88
  Metadata*    cached_metadata() const         { assert(!_is_icholder, ""); return (Metadata*)_cached_value; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    89
  CompiledICHolder*    claim_cached_icholder() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    90
    assert(_is_icholder, "");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    91
    assert(_cached_value != NULL, "must be non-NULL");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    92
    _release_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    93
    CompiledICHolder* icholder = (CompiledICHolder*)_cached_value;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    94
    icholder->claim();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    95
    return icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    96
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  bool    is_optimized() const { return _is_optimized; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    98
  bool         to_interpreter() const  { return _to_interpreter; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    99
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   100
  void set_compiled_entry(address entry, Klass* klass, bool is_optimized) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   101
    _entry      = entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   102
    _cached_value = (void*)klass;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   103
    _to_interpreter = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   104
    _is_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   105
    _is_optimized = is_optimized;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   106
    _release_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   107
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   108
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   109
  void set_interpreter_entry(address entry, Method* method) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   110
    _entry      = entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   111
    _cached_value = (void*)method;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   112
    _to_interpreter = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   113
    _is_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   114
    _is_optimized = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   115
    _release_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   116
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   117
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   118
  void set_icholder_entry(address entry, CompiledICHolder* icholder) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   119
    _entry      = entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   120
    _cached_value = (void*)icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   121
    _to_interpreter = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   122
    _is_icholder = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   123
    _is_optimized = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   124
    _release_icholder = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   125
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   126
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   127
  CompiledICInfo(): _entry(NULL), _cached_value(NULL), _is_icholder(false),
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   128
                    _to_interpreter(false), _is_optimized(false), _release_icholder(false) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   129
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   130
  ~CompiledICInfo() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   131
    // In rare cases the info is computed but not used, so release any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   132
    // CompiledICHolder* that was created
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   133
    if (_release_icholder) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   134
      assert(_is_icholder, "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   135
      CompiledICHolder* icholder = (CompiledICHolder*)_cached_value;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   136
      icholder->claim();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   137
      delete icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   138
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   139
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
class CompiledIC: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  friend class InlineCacheBuffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  friend class ICStub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  NativeCall*   _ic_call;       // the call instruction
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   149
  NativeMovConstReg* _value;    // patchable value cell for this IC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  bool          _is_optimized;  // an optimized virtual call (i.e., no compiled IC)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   152
  CompiledIC(nmethod* nm, NativeCall* ic_call);
25486
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   153
  CompiledIC(RelocIterator* iter);
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   154
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   155
  void initialize_from_iter(RelocIterator* iter);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   156
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   157
  static bool is_icholder_entry(address entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // low-level inline-cache manipulation. Cannot be accessed directly, since it might not be MT-safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // to change an inline-cache. These changes the underlying inline-cache directly. They *newer* make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // changes to a transition stub.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   162
  void internal_set_ic_destination(address entry_point, bool is_icstub, void* cache, bool is_icholder);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   163
  void set_ic_destination(ICStub* stub);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   164
  void set_ic_destination(address entry_point) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   165
    assert(_is_optimized, "use set_ic_destination_and_value instead");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   166
    internal_set_ic_destination(entry_point, false, NULL, false);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   167
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   168
  // This only for use by ICStubs where the type of the value isn't known
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   169
  void set_ic_destination_and_value(address entry_point, void* value) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   170
    internal_set_ic_destination(entry_point, false, value, is_icholder_entry(entry_point));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   171
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   172
  void set_ic_destination_and_value(address entry_point, Metadata* value) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   173
    internal_set_ic_destination(entry_point, false, value, false);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   174
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   175
  void set_ic_destination_and_value(address entry_point, CompiledICHolder* value) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   176
    internal_set_ic_destination(entry_point, false, value, true);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   177
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Reads the location of the transition stub. This will fail with an assertion, if no transition stub is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // associated with the inline cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  address stub_address() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  bool is_in_transition_state() const;  // Use InlineCacheBuffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // conversion (machine PC to CompiledIC*)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   186
  friend CompiledIC* CompiledIC_before(nmethod* nm, address return_addr);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   187
  friend CompiledIC* CompiledIC_at(nmethod* nm, address call_site);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  friend CompiledIC* CompiledIC_at(Relocation* call_site);
25486
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   189
  friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   191
  // This is used to release CompiledICHolder*s from nmethods that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   192
  // are about to be freed.  The callsite might contain other stale
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   193
  // values of other kinds so it must be careful.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   194
  static void cleanup_call_site(virtual_call_Relocation* call_site);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   195
  static bool is_icholder_call_site(virtual_call_Relocation* call_site);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   196
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   197
  // Return the cached_metadata/destination associated with this inline cache. If the cache currently points
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // to a transition stub, it will read the values from the transition stub.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   199
  void* cached_value() const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   200
  CompiledICHolder* cached_icholder() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   201
    assert(is_icholder_call(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   202
    return (CompiledICHolder*) cached_value();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   203
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   204
  Metadata* cached_metadata() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   205
    assert(!is_icholder_call(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   206
    return (Metadata*) cached_value();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   207
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   208
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  address ic_destination() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  bool is_optimized() const   { return _is_optimized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // State
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  bool is_clean() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  bool is_megamorphic() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  bool is_call_to_compiled() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  bool is_call_to_interpreted() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   219
  bool is_icholder_call() const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   220
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  address end_of_call() { return  _ic_call->return_address(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // MT-safe patching of inline caches. Note: Only safe to call is_xxx when holding the CompiledIC_ock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // so you are guaranteed that no patching takes place. The same goes for verify.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // Note: We do not provide any direct access to the stub code, to prevent parts of the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // to manipulate the inline cache in MT-unsafe ways.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // They all takes a TRAP argument, since they can cause a GC if the inline-cache buffer is full.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  void set_to_clean();  // Can only be called during a safepoint operation
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   232
  void set_to_monomorphic(CompiledICInfo& info);
20072
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   233
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   234
  // Returns true if successful and false otherwise. The call can fail if memory
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   235
  // allocation in the code cache fails.
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   236
  bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  static void compute_monomorphic_entry(methodHandle method, KlassHandle receiver_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
                                        bool is_optimized, bool static_bound, CompiledICInfo& info, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Location
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  address instruction_address() const { return _ic_call->instruction_address(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Misc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  void print()             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  void print_compiled_ic() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  void verify()            PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   250
inline CompiledIC* CompiledIC_before(nmethod* nm, address return_addr) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   251
  CompiledIC* c_ic = new CompiledIC(nm, nativeCall_before(return_addr));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   256
inline CompiledIC* CompiledIC_at(nmethod* nm, address call_site) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   257
  CompiledIC* c_ic = new CompiledIC(nm, nativeCall_at(call_site));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
inline CompiledIC* CompiledIC_at(Relocation* call_site) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   263
  assert(call_site->type() == relocInfo::virtual_call_type ||
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   264
         call_site->type() == relocInfo::opt_virtual_call_type, "wrong reloc. info");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   265
  CompiledIC* c_ic = new CompiledIC(call_site->code(), nativeCall_at(call_site->addr()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
25486
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   270
inline CompiledIC* CompiledIC_at(RelocIterator* reloc_iter) {
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   271
  assert(reloc_iter->type() == relocInfo::virtual_call_type ||
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   272
      reloc_iter->type() == relocInfo::opt_virtual_call_type, "wrong reloc. info");
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   273
  CompiledIC* c_ic = new CompiledIC(reloc_iter);
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   274
  c_ic->verify();
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   275
  return c_ic;
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   276
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// The CompiledStaticCall represents a call to a static method in the compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
// Transition diagram of a static call site is somewhat simpler than for an inlined cache:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
//           -----<----- Clean ----->-----
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
//          /                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
//         /                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
//    compilled code <------------> interpreted code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
//  Clean:            Calls directly to runtime method for fixup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
//  Compiled code:    Calls directly to compiled code
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   291
//  Interpreted code: Calls to stub that set Method* reference
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
class CompiledStaticCall;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
class StaticCallInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  address      _entry;          // Entrypoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  methodHandle _callee;         // Callee (used when calling interpreter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  bool         _to_interpreter; // call to interpreted method (otherwise compiled)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  friend class CompiledStaticCall;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  address      entry() const    { return _entry;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  methodHandle callee() const   { return _callee; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
class CompiledStaticCall: public NativeCall {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  friend class CompiledIC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // Also used by CompiledIC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  void set_to_interpreted(methodHandle callee, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  bool is_optimized_virtual();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  friend CompiledStaticCall* compiledStaticCall_before(address return_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  friend CompiledStaticCall* compiledStaticCall_at(address native_call);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  friend CompiledStaticCall* compiledStaticCall_at(Relocation* call_site);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   321
  // Code
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   322
  static void emit_to_interp_stub(CodeBuffer &cbuf);
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   323
  static int to_interp_stub_size();
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   324
  static int reloc_to_interp_stub();
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   325
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // State
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  bool is_clean() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  bool is_call_to_compiled() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  bool is_call_to_interpreted() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  // Clean static call (will force resolving on next use)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  void set_to_clean();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // Set state. The entry must be the same, as computed by compute_entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // Computation and setting is split up, since the actions are separate during
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // a OptoRuntime::resolve_xxx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  void set(const StaticCallInfo& info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // Compute entry point given a method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  static void compute_entry(methodHandle m, StaticCallInfo& info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // Stub support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  address find_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  static void set_stub_to_clean(static_stub_Relocation* static_stub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  // Misc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  void print()  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  void verify() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
inline CompiledStaticCall* compiledStaticCall_before(address return_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  CompiledStaticCall* st = (CompiledStaticCall*)nativeCall_before(return_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  st->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  return st;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
inline CompiledStaticCall* compiledStaticCall_at(address native_call) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  CompiledStaticCall* st = (CompiledStaticCall*)native_call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  st->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  return st;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
inline CompiledStaticCall* compiledStaticCall_at(Relocation* call_site) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  return compiledStaticCall_at(call_site->addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   367
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   368
#endif // SHARE_VM_CODE_COMPILEDIC_HPP