src/hotspot/share/code/compiledIC.hpp
author aph
Wed, 03 Jan 2018 17:29:20 +0000
changeset 48487 abf1d797e380
parent 47216 71c04702a3d5
child 48608 1dab70e20292
permissions -rw-r--r--
8193260: AArch64: JVMCI: Implement trampoline calls Reviewed-by: adinn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 42650
diff changeset
     2
 * Copyright (c) 1997, 2017, 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
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 22234
diff changeset
    28
#include "code/nativeInst.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/linkResolver.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    30
#include "oops/compiledICHolder.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// The CompiledIC represents a compiled inline cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// In order to make patching of the inline cache MT-safe, we only allow the following
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// transitions (when not at a safepoint):
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//         [1] --<--  Clean -->---  [1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//            /       (null)      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//           /                     \      /-<-\
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//          /          [2]          \    /     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//      Interpreted  ---------> Monomorphic     | [3]
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    44
//  (CompiledICHolder*)            (Klass*)     |
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//          \                        /   \     /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//       [4] \                      / [4] \->-/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//            \->-  Megamorphic -<-/
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    48
//                  (Method*)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// The text in paranteses () refere to the value of the inline cache receiver (mov instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// The numbers in square brackets refere to the kind of transition:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// [1]: Initial fixup. Receiver it found from debug information
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// [2]: Compilation of a method
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    55
// [3]: Recompilation of a method (note: only entry is changed. The Klass* must stay the same)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// [4]: Inline cache miss. We go directly to megamorphic call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// transition is made to a stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class CompiledIC;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    62
class ICStub;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    64
class CompiledICInfo : public StackObj {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  address _entry;              // entry point for call
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    67
  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
    68
  bool    _is_icholder;          // Is the cached value a CompiledICHolder*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  bool    _is_optimized;       // it is an optimized virtual call (i.e., can be statically bound)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  bool    _to_interpreter;     // Call it to interpreter
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
    71
  bool    _to_aot;             // Call it to aot code
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    72
  bool    _release_icholder;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  address entry() const        { return _entry; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    75
  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
    76
  CompiledICHolder*    claim_cached_icholder() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    77
    assert(_is_icholder, "");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    78
    assert(_cached_value != NULL, "must be non-NULL");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    79
    _release_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    80
    CompiledICHolder* icholder = (CompiledICHolder*)_cached_value;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    81
    icholder->claim();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    82
    return icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    83
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  bool    is_optimized() const { return _is_optimized; }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
    85
  bool  to_interpreter() const { return _to_interpreter; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
    86
  bool          to_aot() const { return _to_aot; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    87
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    88
  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
    89
    _entry      = entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    90
    _cached_value = (void*)klass;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    91
    _to_interpreter = false;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
    92
    _to_aot = false;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    93
    _is_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    94
    _is_optimized = is_optimized;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    95
    _release_icholder = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    96
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    97
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    98
  void set_interpreter_entry(address entry, Method* method) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    99
    _entry      = entry;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   100
    _cached_value = (void*)method;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   101
    _to_interpreter = true;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   102
    _to_aot = false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   103
    _is_icholder = false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   104
    _is_optimized = true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   105
    _release_icholder = false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   106
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   107
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   108
  void set_aot_entry(address entry, Method* method) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   109
    _entry      = entry;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   110
    _cached_value = (void*)method;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   111
    _to_interpreter = false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   112
    _to_aot = true;
13728
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;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   122
    _to_aot = false;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   123
    _is_icholder = true;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   124
    _is_optimized = false;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   125
    _release_icholder = true;
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
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   128
  CompiledICInfo(): _entry(NULL), _cached_value(NULL), _is_icholder(false),
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   129
                    _to_interpreter(false), _to_aot(false), _is_optimized(false), _release_icholder(false) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   130
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   131
  ~CompiledICInfo() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   132
    // 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
   133
    // CompiledICHolder* that was created
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   134
    if (_release_icholder) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   135
      assert(_is_icholder, "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   136
      CompiledICHolder* icholder = (CompiledICHolder*)_cached_value;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   137
      icholder->claim();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   138
      delete icholder;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   139
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   140
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   143
class NativeCallWrapper: public ResourceObj {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   144
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   145
  virtual address destination() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   146
  virtual address instruction_address() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   147
  virtual address next_instruction_address() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   148
  virtual address return_address() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   149
  virtual address get_resolve_call_stub(bool is_optimized) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   150
  virtual void set_destination_mt_safe(address dest) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   151
  virtual void set_to_interpreted(const methodHandle& method, CompiledICInfo& info) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   152
  virtual void verify() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   153
  virtual void verify_resolve_call(address dest) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   154
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   155
  virtual bool is_call_to_interpreted(address dest) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   156
  virtual bool is_safe_for_patching() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   157
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   158
  virtual NativeInstruction* get_load_instruction(virtual_call_Relocation* r) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   159
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   160
  virtual void *get_data(NativeInstruction* instruction) const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   161
  virtual void set_data(NativeInstruction* instruction, intptr_t data) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   162
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   163
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
class CompiledIC: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  friend class InlineCacheBuffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  friend class ICStub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
 private:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   169
  NativeCallWrapper* _call;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   170
  NativeInstruction* _value;    // patchable value cell for this IC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  bool          _is_optimized;  // an optimized virtual call (i.e., no compiled IC)
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   172
  CompiledMethod* _method;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33593
diff changeset
   174
  CompiledIC(CompiledMethod* cm, NativeCall* ic_call);
25486
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   175
  CompiledIC(RelocIterator* iter);
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   176
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   177
  void initialize_from_iter(RelocIterator* iter);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   178
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   179
  static bool is_icholder_entry(address entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // low-level inline-cache manipulation. Cannot be accessed directly, since it might not be MT-safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // to change an inline-cache. These changes the underlying inline-cache directly. They *newer* make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // changes to a transition stub.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   184
  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
   185
  void set_ic_destination(ICStub* stub);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   186
  void set_ic_destination(address entry_point) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   187
    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
   188
    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
   189
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   190
  // 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
   191
  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
   192
    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
   193
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   194
  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
   195
    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
   196
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   197
  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
   198
    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
   199
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // 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
   202
  // associated with the inline cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  address stub_address() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  bool is_in_transition_state() const;  // Use InlineCacheBuffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // conversion (machine PC to CompiledIC*)
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33593
diff changeset
   208
  friend CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33593
diff changeset
   209
  friend CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  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
   211
  friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   213
  // 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
   214
  // 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
   215
  // values of other kinds so it must be careful.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   216
  static void cleanup_call_site(virtual_call_Relocation* call_site, const CompiledMethod* cm);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   217
  static bool is_icholder_call_site(virtual_call_Relocation* call_site, const CompiledMethod* cm);
13728
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
  // Return the cached_metadata/destination associated with this inline cache. If the cache currently points
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // 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
   221
  void* cached_value() const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   222
  CompiledICHolder* cached_icholder() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   223
    assert(is_icholder_call(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   224
    return (CompiledICHolder*) cached_value();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   225
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   226
  Metadata* cached_metadata() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   227
    assert(!is_icholder_call(), "must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   228
    return (Metadata*) cached_value();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   229
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   230
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   231
  void* get_data() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   232
    return _call->get_data(_value);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   233
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   234
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   235
  void set_data(intptr_t data) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   236
    _call->set_data(_value, data);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   237
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   238
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  address ic_destination() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  bool is_optimized() const   { return _is_optimized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // State
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  bool is_clean() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  bool is_megamorphic() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  bool is_call_to_compiled() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  bool is_call_to_interpreted() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   249
  bool is_icholder_call() const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   250
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   251
  address end_of_call() { return  _call->return_address(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // 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
   254
  // so you are guaranteed that no patching takes place. The same goes for verify.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // 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
   257
  // to manipulate the inline cache in MT-unsafe ways.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // 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
   260
  //
32466
915d0c3d25aa 8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents: 32401
diff changeset
   261
  void set_to_clean(bool in_use = true);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   262
  void set_to_monomorphic(CompiledICInfo& info);
26912
19021f626ad2 8058737: CodeCache::find_blob fails with 'unsafe access to zombie method'
thartmann
parents: 25716
diff changeset
   263
  void clear_ic_stub();
20072
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   264
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   265
  // 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
   266
  // allocation in the code cache fails.
6da61000acff 7009641: Don't fail VM when CodeCache is full
anoll
parents: 17094
diff changeset
   267
  bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 42650
diff changeset
   269
  static void compute_monomorphic_entry(const methodHandle& method, Klass* receiver_klass,
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   270
                                        bool is_optimized, bool static_bound, bool caller_is_nmethod,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   271
                                        CompiledICInfo& info, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  // Location
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   274
  address instruction_address() const { return _call->instruction_address(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // Misc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  void print()             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  void print_compiled_ic() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  void verify()            PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33593
diff changeset
   282
inline CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   283
  CompiledIC* c_ic = new CompiledIC(nm, nativeCall_before(return_addr));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 33593
diff changeset
   288
inline CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   289
  CompiledIC* c_ic = new CompiledIC(nm, nativeCall_at(call_site));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
inline CompiledIC* CompiledIC_at(Relocation* call_site) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   295
  assert(call_site->type() == relocInfo::virtual_call_type ||
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   296
         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
   297
  CompiledIC* c_ic = new CompiledIC(call_site->code(), nativeCall_at(call_site->addr()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  c_ic->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  return c_ic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
25486
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   302
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
   303
  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
   304
      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
   305
  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
   306
  c_ic->verify();
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   307
  return c_ic;
be44827be5e7 8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents: 22234
diff changeset
   308
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
// The CompiledStaticCall represents a call to a static method in the compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// Transition diagram of a static call site is somewhat simpler than for an inlined cache:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
//           -----<----- Clean ----->-----
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
//          /                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
//         /                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
//    compilled code <------------> interpreted code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
//  Clean:            Calls directly to runtime method for fixup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
//  Compiled code:    Calls directly to compiled code
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   323
//  Interpreted code: Calls to stub that set Method* reference
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
class StaticCallInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  address      _entry;          // Entrypoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  methodHandle _callee;         // Callee (used when calling interpreter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  bool         _to_interpreter; // call to interpreted method (otherwise compiled)
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   332
  bool         _to_aot;         // call to aot method (otherwise compiled)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  friend class CompiledStaticCall;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   335
  friend class CompiledDirectStaticCall;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   336
  friend class CompiledPltStaticCall;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  address      entry() const    { return _entry;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  methodHandle callee() const   { return _callee; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   342
class CompiledStaticCall : public ResourceObj {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
 public:
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   344
  // Code
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32466
diff changeset
   345
  static address emit_to_interp_stub(CodeBuffer &cbuf, address mark = NULL);
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   346
  static int to_interp_stub_size();
48487
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47216
diff changeset
   347
  static int to_trampoline_stub_size();
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   348
  static int reloc_to_interp_stub();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   349
  static void emit_to_aot_stub(CodeBuffer &cbuf, address mark = NULL);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   350
  static int to_aot_stub_size();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   351
  static int reloc_to_aot_stub();
17094
29c4955396d2 8003853: specify offset of IC load in java_to_interp stub
dlong
parents: 13728
diff changeset
   352
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   353
  // Compute entry point given a method
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   354
  static void compute_entry(const methodHandle& m, bool caller_is_nmethod, StaticCallInfo& info);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   355
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   356
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   357
  // Clean static call (will force resolving on next use)
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   358
  virtual address destination() const = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  // Clean static call (will force resolving on next use)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  void set_to_clean();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  // Set state. The entry must be the same, as computed by compute_entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  // Computation and setting is split up, since the actions are separate during
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  // a OptoRuntime::resolve_xxx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  void set(const StaticCallInfo& info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   368
  // State
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   369
  bool is_clean() const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   370
  bool is_call_to_compiled() const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   371
  virtual bool is_call_to_interpreted() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   372
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   373
  virtual address instruction_address() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   374
protected:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   375
  virtual address resolve_call_stub() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   376
  virtual void set_destination_mt_safe(address dest) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   377
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   378
  virtual void set_to_far(const methodHandle& callee, address entry) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   379
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   380
  virtual void set_to_interpreted(const methodHandle& callee, address entry) = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   381
  virtual const char* name() const = 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   382
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   383
  void set_to_compiled(address entry);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   384
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   385
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   386
class CompiledDirectStaticCall : public CompiledStaticCall {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   387
private:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   388
  friend class CompiledIC;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   389
  friend class DirectNativeCallWrapper;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   390
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   391
  // Also used by CompiledIC
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   392
  void set_to_interpreted(const methodHandle& callee, address entry);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   393
#if INCLUDE_AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   394
  void set_to_far(const methodHandle& callee, address entry);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   395
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   396
  address instruction_address() const { return _call->instruction_address(); }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   397
  void set_destination_mt_safe(address dest) { _call->set_destination_mt_safe(dest); }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   398
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   399
  NativeCall* _call;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   400
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   401
  CompiledDirectStaticCall(NativeCall* call) : _call(call) {}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   402
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   403
 public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   404
  static inline CompiledDirectStaticCall* before(address return_addr) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   405
    CompiledDirectStaticCall* st = new CompiledDirectStaticCall(nativeCall_before(return_addr));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   406
    st->verify();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   407
    return st;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   408
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   409
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   410
  static inline CompiledDirectStaticCall* at(address native_call) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   411
    CompiledDirectStaticCall* st = new CompiledDirectStaticCall(nativeCall_at(native_call));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   412
    st->verify();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   413
    return st;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   414
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   415
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   416
  static inline CompiledDirectStaticCall* at(Relocation* call_site) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   417
    return at(call_site->addr());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   418
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   419
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   420
  // Delegation
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   421
  address destination() const { return _call->destination(); }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   422
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   423
  // State
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   424
  virtual bool is_call_to_interpreted() const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   425
  bool is_call_to_far() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // Stub support
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   428
  static address find_stub_for(address instruction, bool is_aot);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   429
  address find_stub(bool is_aot);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  static void set_stub_to_clean(static_stub_Relocation* static_stub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // Misc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  void print()  PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  void verify() PRODUCT_RETURN;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   435
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   436
 protected:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   437
  virtual address resolve_call_stub() const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38133
diff changeset
   438
  virtual const char* name() const { return "CompiledDirectStaticCall"; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   441
#endif // SHARE_VM_CODE_COMPILEDIC_HPP